| 27 | } |
| 28 | |
| 29 | void EngineDummy::HandleEvents() |
| 30 | { |
| 31 | // No window, so no resize / fullscreen / focus handling — but the SDL event |
| 32 | // queue still fills (harness `key` injection, --auto-key, real input under a |
| 33 | // hidden window). Drain it and route input to the same buffers GL33 uses. |
| 34 | SDL_Event event; |
| 35 | while (SDL_PollEvent(&event)) |
| 36 | { |
| 37 | switch (event.type) |
| 38 | { |
| 39 | case SDL_EVENT_QUIT: |
| 40 | case SDL_EVENT_WINDOW_CLOSE_REQUESTED: |
| 41 | if (GApp) |
| 42 | GApp->m_closeRequest = true; |
| 43 | break; |
| 44 | case SDL_EVENT_KEY_DOWN: |
| 45 | if (!event.key.repeat) |
| 46 | SDLInput_BufferKeyEvent(event.key.scancode, true, Foundation::GlobalTickCount()); |
| 47 | SDLInput_BufferUIKeyEvent(event.key.key, true); |
| 48 | break; |
| 49 | case SDL_EVENT_KEY_UP: |
| 50 | SDLInput_BufferKeyEvent(event.key.scancode, false, Foundation::GlobalTickCount()); |
| 51 | SDLInput_BufferUIKeyEvent(event.key.key, false); |
| 52 | break; |
| 53 | case SDL_EVENT_TEXT_INPUT: |
| 54 | SDLInput_BufferUICharEvent(event.text.text); |
| 55 | break; |
| 56 | case SDL_EVENT_MOUSE_BUTTON_DOWN: |
| 57 | case SDL_EVENT_MOUSE_BUTTON_UP: |
| 58 | { |
| 59 | int btn = event.button.button - 1; |
| 60 | if (btn == 1) |
| 61 | btn = 2; |
| 62 | else if (btn == 2) |
| 63 | btn = 1; |
| 64 | SDLInput_BufferMouseButton(btn, event.type == SDL_EVENT_MOUSE_BUTTON_DOWN); |
| 65 | break; |
| 66 | } |
| 67 | case SDL_EVENT_MOUSE_MOTION: |
| 68 | SDLInput_BufferMouseMotion(event.motion.xrel, event.motion.yrel); |
| 69 | break; |
| 70 | case SDL_EVENT_MOUSE_WHEEL: |
| 71 | SDLInput_BufferMouseWheel(event.wheel.y); |
| 72 | break; |
| 73 | default: |
| 74 | break; |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | EngineDummy::~EngineDummy() |
| 80 | { |
no test coverage detected