| 1505 | } |
| 1506 | |
| 1507 | ControlTypes GetInputTypeFromEvent(const SDL_Event &event) |
| 1508 | { |
| 1509 | if (IsAnyOf(event.type, SDL_KEYDOWN, SDL_KEYUP)) |
| 1510 | return ControlTypes::KeyboardAndMouse; |
| 1511 | #ifdef USE_SDL1 |
| 1512 | if (IsAnyOf(event.type, SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP, SDL_MOUSEMOTION)) |
| 1513 | return ControlTypes::KeyboardAndMouse; |
| 1514 | #else |
| 1515 | if (IsAnyOf(event.type, SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP)) |
| 1516 | return event.button.which == SDL_TOUCH_MOUSEID ? ControlTypes::VirtualGamepad : ControlTypes::KeyboardAndMouse; |
| 1517 | if (event.type == SDL_MOUSEMOTION) |
| 1518 | return event.motion.which == SDL_TOUCH_MOUSEID ? ControlTypes::VirtualGamepad : ControlTypes::KeyboardAndMouse; |
| 1519 | if (event.type == SDL_MOUSEWHEEL) |
| 1520 | return event.wheel.which == SDL_TOUCH_MOUSEID ? ControlTypes::VirtualGamepad : ControlTypes::KeyboardAndMouse; |
| 1521 | if (IsAnyOf(event.type, SDL_FINGERDOWN, SDL_FINGERUP, SDL_FINGERMOTION)) |
| 1522 | return ControlTypes::VirtualGamepad; |
| 1523 | if (event.type == SDL_CONTROLLERAXISMOTION |
| 1524 | && (event.caxis.axis == SDL_CONTROLLER_AXIS_TRIGGERLEFT || event.caxis.axis == SDL_CONTROLLER_AXIS_TRIGGERRIGHT |
| 1525 | || IsStickMovementSignificant())) |
| 1526 | return ControlTypes::Gamepad; |
| 1527 | if (event.type >= SDL_CONTROLLERBUTTONDOWN && event.type <= SDL_CONTROLLERDEVICEREMAPPED) |
| 1528 | return ControlTypes::Gamepad; |
| 1529 | if (IsAnyOf(event.type, SDL_JOYDEVICEADDED, SDL_JOYDEVICEREMOVED)) |
| 1530 | return ControlTypes::Gamepad; |
| 1531 | #endif |
| 1532 | if (event.type == SDL_JOYAXISMOTION && IsStickMovementSignificant()) |
| 1533 | return ControlTypes::Gamepad; |
| 1534 | if (event.type >= SDL_JOYBALLMOTION && event.type <= SDL_JOYBUTTONUP) |
| 1535 | return ControlTypes::Gamepad; |
| 1536 | |
| 1537 | return ControlTypes::None; |
| 1538 | } |
| 1539 | |
| 1540 | float rightStickLastMove = 0; |
| 1541 |
no test coverage detected