89 auto getJoyDeadZone = [](
JoystickId ) {
return 25; };
90 auto check = [&](
const Event& event, std::string_view expected) {
92 if (expected.empty()) {
101 SECTION(
"keyboard") {
103 check(KeyUpEvent ::create(SDLK_h),
"");
106 sdl.button = SDL_MouseButtonEvent{};
107 sdl.button.type = SDL_MOUSEBUTTONDOWN;
108 sdl.button.button = 2;
110 sdl.button.type = SDL_MOUSEBUTTONUP;
113 sdl.motion = SDL_MouseMotionEvent{};
114 sdl.motion.type = SDL_MOUSEMOTION;
115 sdl.motion.xrel = 10;
116 sdl.motion.yrel = 20;
121 sdl.wheel = SDL_MouseWheelEvent{};
122 sdl.wheel.type = SDL_MOUSEWHEEL;
127 SECTION(
"joystick") {
128 sdl.jbutton = SDL_JoyButtonEvent{};
129 sdl.jbutton.type = SDL_JOYBUTTONDOWN;
130 sdl.jbutton.which = 0;
131 sdl.jbutton.button = 3;
133 sdl.jbutton.type = SDL_JOYBUTTONUP;
136 sdl.jhat = SDL_JoyHatEvent{};
137 sdl.jhat.type = SDL_JOYHATMOTION;
140 sdl.jhat.value = SDL_HAT_LEFT;
142 sdl.jhat.value = SDL_HAT_CENTERED;
144 sdl.jhat.value = SDL_HAT_LEFTDOWN;
147 sdl.jaxis = SDL_JoyAxisEvent{};
148 sdl.jaxis.type = SDL_JOYAXISMOTION;
151 sdl.jaxis.value = 32000;
153 sdl.jaxis.value = -32000;
155 sdl.jaxis.value = 2000;
158 SECTION(
"other SDL") {
159 sdl.window = SDL_WindowEvent{};
160 sdl.window.type = SDL_WINDOWEVENT;
178 sdl.button = SDL_MouseButtonEvent{};
179 sdl.button.type = SDL_MOUSEBUTTONDOWN;
180 sdl.button.button = 1;
182 sdl.button.button = 2;
185 sdl.button.type = SDL_MOUSEBUTTONUP;
186 sdl.button.button = 1;
188 sdl.button.button = 2;
191 sdl.wheel = SDL_MouseWheelEvent{};
192 sdl.wheel.type = SDL_MOUSEWHEEL;
197 sdl.jbutton = SDL_JoyButtonEvent{};
198 sdl.jbutton.type = SDL_JOYBUTTONDOWN;
199 sdl.jbutton.which = 0;
200 sdl.jbutton.button = 2;
202 sdl.jbutton.type = SDL_JOYBUTTONUP;
205 sdl.jbutton.type = SDL_JOYBUTTONDOWN;
206 sdl.jbutton.which = 0;
207 sdl.jbutton.button = 3;
209 sdl.jbutton.type = SDL_JOYBUTTONUP;
212 sdl.jbutton.type = SDL_JOYBUTTONDOWN;
213 sdl.jbutton.which = 1;
214 sdl.jbutton.button = 2;
216 sdl.type = SDL_JOYBUTTONUP;
219 sdl.jhat = SDL_JoyHatEvent{};
220 sdl.jhat.type = SDL_JOYHATMOTION;
223 sdl.jhat.value = SDL_HAT_LEFT;
225 sdl.jhat.value = SDL_HAT_LEFTDOWN;
227 sdl.jhat.value = SDL_HAT_DOWN;
230 sdl.jhat.type = SDL_JOYHATMOTION;
233 sdl.jhat.value = SDL_HAT_LEFT;
235 sdl.jhat.value = SDL_HAT_LEFTDOWN;
237 sdl.jhat.value = SDL_HAT_DOWN;
240 sdl.jhat.type = SDL_JOYHATMOTION;
243 sdl.jhat.value = SDL_HAT_LEFT;
245 sdl.jhat.value = SDL_HAT_LEFTDOWN;
247 sdl.jhat.value = SDL_HAT_DOWN;
250 sdl.jaxis = SDL_JoyAxisEvent{};
251 sdl.jaxis.type = SDL_JOYAXISMOTION;
254 sdl.jaxis.value = 32000;
256 sdl.jaxis.value = 123;
258 sdl.jaxis.value = -27000;
261 sdl.jaxis.type = SDL_JOYAXISMOTION;
264 sdl.jaxis.value = 32000;
266 sdl.jaxis.value = 123;
268 sdl.jaxis.value = -27000;
271 sdl.jaxis.type = SDL_JOYAXISMOTION;
274 sdl.jaxis.value = 32000;
276 sdl.jaxis.value = 123;
278 sdl.jaxis.value = -27000;
282 auto getJoyDeadZone = [](
JoystickId ) {
return 25; };
283 auto check = [&](
const std::optional<BooleanInput>& binding,
const Event& event, std::optional<bool> expected) {
285 CHECK(
match(*binding, event, getJoyDeadZone) == expected);
289 check(bKeyA, keyDownA,
true);
290 check(bKeyA, keyUpA,
false);
291 check(bKeyA, keyDownB, {});
292 check(bKeyA, keyUpB, {});
293 check(bKeyA, joy1button2Down, {});
294 check(bKeyA, mouseWheel, {});
297 check(bMouseButton1, mouseDown1,
true);
298 check(bMouseButton1, mouseUp1,
false);
299 check(bMouseButton1, mouseDown2, {});
300 check(bMouseButton1, mouseUp2, {});
301 check(bMouseButton1, keyDownA, {});
302 check(bMouseButton1, mouseWheel, {});
305 check(bJoy1Button2, joy1button2Down,
true);
306 check(bJoy1Button2, joy1button2Up,
false);
307 check(bJoy1Button2, joy1button3Down, {});
308 check(bJoy1Button2, joy1button3Up, {});
309 check(bJoy1Button2, joy2button2Down, {});
310 check(bJoy1Button2, joy2button2Up, {});
311 check(bJoy1Button2, mouseUp2, {});
312 check(bJoy1Button2, mouseWheel, {});
315 check(bJoy1Hat1Left, joy1hat1left,
true);
316 check(bJoy1Hat1Left, joy1hat1leftDown,
true);
317 check(bJoy1Hat1Left, joy1hat1down,
false);
318 check(bJoy1Hat1Left, joy1hat2left, {});
319 check(bJoy1Hat1Left, joy1hat2leftDown, {});
320 check(bJoy1Hat1Left, joy1hat2down, {});
321 check(bJoy1Hat1Left, joy2hat1left, {});
322 check(bJoy1Hat1Left, joy2hat1leftDown, {});
323 check(bJoy1Hat1Left, joy2hat1down, {});
324 check(bJoy1Hat1Left, joy1button2Down, {});
325 check(bJoy1Hat1Left, mouseWheel, {});
328 check(bJoy1Axis1P, joy1axis1P32000,
true);
329 check(bJoy1Axis1P, joy1axis1P123,
false);
330 check(bJoy1Axis1P, joy1axis1M27000,
false);
331 check(bJoy1Axis1P, joy1axis2P32000, {});
332 check(bJoy1Axis1P, joy1axis2P123, {});
333 check(bJoy1Axis1P, joy1axis2M27000, {});
334 check(bJoy1Axis1P, joy2axis1P32000, {});
335 check(bJoy1Axis1P, joy2axis1P123, {});
336 check(bJoy1Axis1P, joy2axis1M27000, {});
337 check(bJoy1Axis1P, joy1hat1left, {});
338 check(bJoy1Axis1P, mouseWheel, {});
std::variant< KeyUpEvent, KeyDownEvent, MouseMotionEvent, MouseButtonUpEvent, MouseButtonDownEvent, MouseWheelEvent, JoystickAxisMotionEvent, JoystickHatEvent, JoystickButtonUpEvent, JoystickButtonDownEvent, OsdControlReleaseEvent, OsdControlPressEvent, WindowEvent, TextEvent, FileDropEvent, QuitEvent, FinishFrameEvent, CliCommandEvent, GroupEvent, BootEvent, FrameDrawnEvent, BreakEvent, SwitchRendererEvent, TakeReverseSnapshotEvent, AfterTimedEvent, MachineLoadedEvent, MachineActivatedEvent, MachineDeactivatedEvent, MidiInReaderEvent, MidiInWindowsEvent, MidiInCoreMidiEvent, MidiInCoreMidiVirtualEvent, MidiInALSAEvent, Rs232TesterEvent, Rs232NetEvent, ImGuiDelayedActionEvent, ImGuiActiveEvent > Event