Changeset 184
- Timestamp:
- 08/01/13 01:36:03 (12 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/detail/io_event_list.inc
r93 r184 2 2 NV_IO_EVENT( EV_MOUSE_BUTTON ) 3 3 NV_IO_EVENT( EV_MOUSE_MOVE ) 4 NV_IO_EVENT( EV_JOY_BUTTON ) 5 NV_IO_EVENT( EV_JOY_AXIS ) 6 NV_IO_EVENT( EV_JOY_HAT ) 7 NV_IO_EVENT( EV_JOY_BALL ) 4 8 NV_IO_EVENT( EV_ACTIVE ) 5 9 NV_IO_EVENT( EV_RESIZE ) -
trunk/nv/io_event.hh
r132 r184 95 95 }; 96 96 97 struct joy_button_event 98 { 99 /// Joystick ID 100 sint32 id; 101 /// Button that is affected 102 uint8 button; 103 /// True if pressed 104 bool pressed; 105 }; 106 107 struct joy_axis_event 108 { 109 /// Joystick ID 110 sint32 id; 111 /// Axis ID 112 uint8 axis; 113 /// Value 114 sint16 value; 115 }; 116 117 struct joy_hat_event 118 { 119 /// Joystick ID 120 sint32 id; 121 /// Hat ID 122 uint8 hat; 123 /// Value 124 sint16 value; 125 }; 126 127 struct joy_ball_event 128 { 129 /// Joystick ID 130 sint32 id; 131 /// Ball ID 132 uint8 ball; 133 /// Relative X 134 sint16 rx; 135 /// Relative Y 136 sint16 ry; 137 }; 138 97 139 struct resize_event 98 140 { … … 124 166 mouse_button_event mbutton; 125 167 mouse_move_event mmove; 168 joy_button_event jbutton; 169 joy_axis_event jaxis; 170 joy_hat_event jhat; 171 joy_ball_event jball; 126 172 resize_event resize; 127 173 active_event active; -
trunk/src/gl/gl_device.cc
r171 r184 25 25 m_info = NULL; 26 26 27 if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )27 if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_JOYSTICK ) < 0 ) 28 28 { 29 29 NV_LOG( LOG_CRITICAL, "Video initialization failed: " << SDL_GetError( ) ); -
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 ) ); -
trunk/src/io_event.cc
r121 r184 94 94 db->create_type<mouse_move_event>("mouse_move_event").fields( mouse_move_fields ); 95 95 96 type_field joy_button_fields[] = { 97 type_field( "id", &joy_button_event::id ), 98 type_field( "button", &joy_button_event::button ), 99 type_field( "pressed", &joy_button_event::pressed ), 100 }; 101 db->create_type<joy_button_event>("joy_button_event").fields( joy_button_fields ); 102 103 type_field joy_axis_fields[] = { 104 type_field( "id", &joy_axis_event::id ), 105 type_field( "axis", &joy_axis_event::axis ), 106 type_field( "value", &joy_axis_event::value ), 107 }; 108 db->create_type<joy_axis_event>("joy_axis_event").fields( joy_axis_fields ); 109 110 type_field joy_hat_fields[] = { 111 type_field( "id", &joy_hat_event::id ), 112 type_field( "hat", &joy_hat_event::hat ), 113 type_field( "value", &joy_hat_event::value ), 114 }; 115 db->create_type<joy_hat_event>("joy_hat_event").fields( joy_hat_fields ); 116 117 type_field joy_ball_fields[] = { 118 type_field( "id", &joy_ball_event::id ), 119 type_field( "ball", &joy_ball_event::ball ), 120 type_field( "rx", &joy_ball_event::rx ), 121 type_field( "ry", &joy_ball_event::ry ), 122 }; 123 db->create_type<joy_ball_event>("joy_ball_event").fields( joy_ball_fields ); 124 96 125 type_field system_fields[] = { 97 126 type_field( "sys_type", &system_event::sys_type ),
Note: See TracChangeset
for help on using the changeset viewer.