Changeset 486 for trunk/src/sdl


Ignore:
Timestamp:
02/24/16 18:47:54 (9 years ago)
Author:
epyon
Message:
  • mass update once again...
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sdl/sdl_window.cc

    r440 r486  
    4545        }
    4646
    47         //      NV_LOG( LOG_INFO, "Joystick count : " << SDL_NumJoysticks() );
    48         //      SDL_Joystick* j = SDL_JoystickOpen(0);
    49         //      if (j)
    50         //      {
    51         //              NV_LOG( LOG_INFO, "Joystick Name: " << SDL_JoystickNameForIndex(0) );
    52         //              NV_LOG( LOG_INFO, "Joystick Number of Axes: " << SDL_JoystickNumAxes(j));
    53         //              NV_LOG( LOG_INFO, "Joystick Number of Buttons: " << SDL_JoystickNumButtons(j));
    54         //              NV_LOG( LOG_INFO, "Joystick Number of Balls: " << SDL_JoystickNumBalls(j));
    55         //      }
     47//      NV_LOG_INFO( "Joystick count : ", SDL_NumJoysticks() );
     48//      SDL_Joystick* j = SDL_JoystickOpen(0);
     49//      if ( j )
     50//      {
     51//              NV_LOG_INFO( "Joystick Name: ", SDL_JoystickNameForIndex( 0 ) );
     52//              NV_LOG_INFO( "Joystick Number of Axes: ", SDL_JoystickNumAxes( j ) );
     53//              NV_LOG_INFO( "Joystick Number of Buttons: ", SDL_JoystickNumButtons( j ) );
     54//              NV_LOG_INFO( "Joystick Number of Balls: ", SDL_JoystickNumBalls( j ) );
     55//      }
     56
     57        NV_LOG_INFO( "Joystick count : ", SDL_NumJoysticks() );
     58        SDL_GameController *controller = NULL;
     59        int controller_index = 0;
     60        for ( int i = 0; i < SDL_NumJoysticks(); ++i )
     61        {
     62                if ( SDL_IsGameController( i ) )
     63                {
     64                        controller = SDL_GameControllerOpen( i );
     65                        controller_index = i;
     66                        if ( controller ) break;
     67                        NV_LOG_ERROR( "Could not open gamecontroller ", i, ": ", SDL_GetError() );
     68                }
     69        }
     70
     71        if ( controller )
     72        {
     73                SDL_Joystick* j = SDL_GameControllerGetJoystick( controller );
     74                NV_LOG_INFO( "Controller Name: ", SDL_GameControllerNameForIndex( controller_index ) );
     75                NV_LOG_INFO( "Controller Number of Axes: ", SDL_JoystickNumAxes( j ) );
     76                NV_LOG_INFO( "Controller Number of Buttons: ", SDL_JoystickNumButtons( j ) );
     77                NV_LOG_INFO( "Controller Number of Balls: ", SDL_JoystickNumBalls( j ) );
     78        }
     79
     80
    5681
    5782        void* ctx_handle = SDL_GL_CreateContext( static_cast<SDL_Window*>( m_handle ) );
Note: See TracChangeset for help on using the changeset viewer.