Changeset 1709 for trunk/src/platform/sdl/sdlinput.cpp
- Timestamp:
- Aug 9, 2012, 11:44:52 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/platform/sdl/sdlinput.cpp
r1692 r1709 24 24 #include "sdlinput.h" 25 25 26 /* We force joystick polling because no events are received when 27 * there is no SDL display (eg. on the Raspberry Pi). */ 28 #define SDL_FORCE_POLL_JOYSTICK 1 29 26 30 namespace lol 27 31 { … … 54 58 SDL_Init(SDL_INIT_TIMER | SDL_INIT_JOYSTICK); 55 59 60 # if SDL_FORCE_POLL_JOYSTICK 61 SDL_JoystickEventState(SDL_QUERY); 62 # else 63 SDL_JoystickEventState(SDL_ENABLE); 64 # endif 65 56 66 /* Register all the joysticks we can find, and let the input 57 67 * system decide what it wants to track. */ 58 SDL_JoystickEventState(SDL_ENABLE);59 68 for (int i = 0; i < SDL_NumJoysticks(); i++) 60 69 { … … 126 135 ivec2 mouse = SdlInputData::GetMousePos();; 127 136 Input::SetMousePos(mouse); 137 138 # if SDL_FORCE_POLL_JOYSTICK 139 /* Pump all joystick events because no event is coming to us. */ 140 SDL_JoystickUpdate(); 141 for (int j = 0; j < m_joysticks.Count(); j++) 142 { 143 for (int i = 0; i < SDL_JoystickNumButtons(m_joysticks[j].m1); i++) 144 m_joysticks[j].m2->SetButton(i, SDL_JoystickGetButton(m_joysticks[j].m1, i)); 145 for (int i = 0; i < SDL_JoystickNumAxes(m_joysticks[j].m1); i++) 146 m_joysticks[j].m2->SetAxis(i, (float)SDL_JoystickGetAxis(m_joysticks[j].m1, i) / 32768.f); 147 } 148 # endif 128 149 129 150 /* Handle keyboard and WM events */ … … 154 175 } 155 176 177 # if !SDL_FORCE_POLL_JOYSTICK 156 178 case SDL_JOYAXISMOTION: 157 179 m_joysticks[event.jaxis.which].m2->SetAxis(event.jaxis.axis, (float)event.jaxis.value / 32768.f); … … 162 184 m_joysticks[event.jbutton.which].m2->SetButton(event.jbutton.button, event.jbutton.state); 163 185 break; 186 # endif 164 187 } 165 188 }
Note: See TracChangeset
for help on using the changeset viewer.