Changeset 184 for trunk/src/gl/gl_window.cc
- Timestamp:
- 08/01/13 01:36:03 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gl/gl_window.cc
r172 r184 132 132 } 133 133 134 static bool sdl_joy_button_event_to_io_event( const SDL_JoyButtonEvent& jb, io_event& jevent ) 135 { 136 jevent.type = EV_JOY_BUTTON; 137 jevent.jbutton.id = jb.which; 138 jevent.jbutton.button = jb.button; 139 jevent.jbutton.pressed = (jb.type == SDL_PRESSED); 140 return true; 141 } 142 143 static bool sdl_joy_axis_event_to_io_event( const SDL_JoyAxisEvent& ja, io_event& jevent ) 144 { 145 jevent.type = EV_JOY_AXIS; 146 jevent.jaxis.id = ja.which; 147 jevent.jaxis.axis = ja.axis; 148 jevent.jaxis.value = ja.value; 149 return true; 150 } 151 152 static bool sdl_joy_hat_event_to_io_event( const SDL_JoyHatEvent& jh, io_event& jevent ) 153 { 154 jevent.type = EV_JOY_HAT; 155 jevent.jhat.id = jh.which; 156 jevent.jhat.hat = jh.hat; 157 jevent.jhat.value = jh.value; 158 return true; 159 } 160 161 static bool sdl_joy_ball_event_to_io_event( const SDL_JoyBallEvent& jb, io_event& jevent ) 162 { 163 jevent.type = EV_JOY_HAT; 164 jevent.jball.id = jb.which; 165 jevent.jball.ball = jb.ball; 166 jevent.jball.rx = jb.xrel; 167 jevent.jball.ry = jb.yrel; 168 return true; 169 } 170 134 171 static bool sdl_event_to_io_event( const SDL_Event& e, io_event& ioevent ) 135 172 { … … 156 193 case SDL_SYSWMEVENT : ioevent.type = EV_SYSTEM; return true; 157 194 case SDL_QUIT : ioevent.type = EV_QUIT; return true; 158 case SDL_JOYAXISMOTION : return false;159 case SDL_JOYBALLMOTION : return false;160 case SDL_JOYHATMOTION : return false;161 case SDL_JOYBUTTONDOWN : return false;162 case SDL_JOYBUTTONUP : return false;195 case SDL_JOYAXISMOTION : return sdl_joy_axis_event_to_io_event( e.jaxis, ioevent ); 196 case SDL_JOYBALLMOTION : return sdl_joy_ball_event_to_io_event( e.jball, ioevent ); 197 case SDL_JOYHATMOTION : return sdl_joy_hat_event_to_io_event( e.jhat, ioevent ); 198 case SDL_JOYBUTTONDOWN : return sdl_joy_button_event_to_io_event( e.jbutton, ioevent ); 199 case SDL_JOYBUTTONUP : return sdl_joy_button_event_to_io_event( e.jbutton, ioevent ); 163 200 default : return false; 164 201 } … … 183 220 } 184 221 222 // NV_LOG( LOG_INFO, "Joystick count : " << SDL_NumJoysticks() ); 223 // SDL_Joystick* j = SDL_JoystickOpen(0); 224 // if (j) 225 // { 226 // NV_LOG( LOG_INFO, "Joystick Name: " << SDL_JoystickNameForIndex(0) ); 227 // NV_LOG( LOG_INFO, "Joystick Number of Axes: " << SDL_JoystickNumAxes(j)); 228 // NV_LOG( LOG_INFO, "Joystick Number of Buttons: " << SDL_JoystickNumButtons(j)); 229 // NV_LOG( LOG_INFO, "Joystick Number of Balls: " << SDL_JoystickNumBalls(j)); 230 // } 231 232 185 233 m_context = new gl_context( m_device, m_handle ); 186 234 m_context->set_viewport( nv::ivec4( 0, 0, m_width, m_height ) );
Note: See TracChangeset
for help on using the changeset viewer.