-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsdl2inputbackend.cpp
More file actions
764 lines (712 loc) · 23.1 KB
/
sdl2inputbackend.cpp
File metadata and controls
764 lines (712 loc) · 23.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
#include <fea/ui/sdl2inputbackend.hpp>
namespace fea
{
SDL2InputBackend::SDL2InputBackend():
mKeyRepeat(true)
{
//SDL_EnableKeyRepeat(500, 30);
}
std::queue<Event> SDL2InputBackend::fetchEvents()
{
SDL_Event event;
std::queue<Event> result;
while(SDL_PollEvent(&event))
{
if(event.type == SDL_QUIT)
{
result.push(closed());
}
else if(event.type == SDL_WINDOWEVENT)
{
if(event.window.event == SDL_WINDOWEVENT_RESIZED)
result.push(resized(event));
else if(event.window.event == SDL_WINDOWEVENT_FOCUS_LOST)
result.push(windowFocus(false));
else if(event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED)
result.push(windowFocus(true));
}
else if(event.type == SDL_KEYDOWN)
{
if(event.key.repeat == 1 && !mKeyRepeat)
continue;
result.push(keyPressed(event));
}
else if(event.type == SDL_KEYUP)
result.push(keyReleased(event));
else if(event.type == SDL_MOUSEBUTTONDOWN)
result.push(mouseButtonPressed(event));
else if(event.type == SDL_MOUSEWHEEL)
result.push(mouseWheel(event));
else if(event.type == SDL_MOUSEBUTTONUP)
result.push(mouseButtonReleased(event));
else if(event.type == SDL_MOUSEMOTION)
result.push(mouseMoved(event));
else if(event.type == SDL_JOYBUTTONDOWN)
result.push(gamepadButtonPressed(event));
else if(event.type == SDL_JOYBUTTONUP)
result.push(gamepadButtonReleased(event));
else if(event.type == SDL_JOYAXISMOTION)
result.push(gamepadMoved(event));
}
return result;
}
bool SDL2InputBackend::isKeyPressed(Keyboard::Code code)
{
const uint8_t* keymap = (uint8_t*)SDL_GetKeyboardState(NULL);
return keymap[feaKeyCodeToSdl(code)];
}
bool SDL2InputBackend::isMouseButtonPressed(Mouse::Button b)
{
return SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(feaMouseButtonToSdl(b));
}
Vec2I SDL2InputBackend::getMouseGlobalPosition()
{
//will be local only, not global
int x, y;
SDL_GetMouseState(&x, &y);
return Vec2I{0, 0};
}
Vec2I SDL2InputBackend::getMouseWindowPosition()
{
int x, y;
SDL_GetMouseState(&x, &y);
return Vec2I{x, y};
}
void SDL2InputBackend::setMouseGlobalPosition(int32_t x, int32_t y)
{
//works locally, not globlaly
//SDL_WarpMouse((uint16_t)x, (uint16_t)y);
}
void SDL2InputBackend::setMouseWindowPosition(int32_t x, int32_t y)
{
//SDL_WarpMouse((uint16_t)x, (uint16_t)y);
}
bool SDL2InputBackend::isGamepadConnected(uint32_t id)
{
(void)id;
//not sure
return true;
}
uint32_t SDL2InputBackend::getGamepadButtonCount(uint32_t id)
{
(void)id;
//not sure
return 0;
}
bool SDL2InputBackend::isGamepadButtonPressed(uint32_t id, uint32_t button)
{
(void)id;
(void)button;
//not sure
return false;
}
bool SDL2InputBackend::gamepadHasAxis(uint32_t id, Gamepad::Axis axis)
{
(void)id;
(void)axis;
//not sure
return false;
}
float SDL2InputBackend::getGamepadAxisPosition(uint32_t id, Gamepad::Axis axis)
{
(void)id;
(void)axis;
//not sure
return 0.0f;
}
void SDL2InputBackend::setGamepadThreshold(float threshold)
{
//TBI
//window.setJoystickThreshold(threshold);
(void) threshold;
}
void SDL2InputBackend::setKeyRepeatEnabled(bool enabled)
{
//TBI
//window.setKeyRepeatEnabled(enabled);
mKeyRepeat = enabled;
(void) enabled;
}
Event SDL2InputBackend::closed()
{
Event result;
result.type = Event::CLOSED;
return result;
}
Event SDL2InputBackend::resized(SDL_Event& event)
{
Event result;
result.type = Event::RESIZED;
result.size.width = (uint32_t)event.window.data1;
result.size.height = (uint32_t)event.window.data2;
return result;
}
Event SDL2InputBackend::windowFocus(bool focus)
{
Event result;
if(focus)
result.type = Event::GAINEDFOCUS;
else
result.type = Event::LOSTFOCUS;
return result;
}
Event SDL2InputBackend::keyPressed(SDL_Event& event)
{
Event result;
result.type = Event::KEYPRESSED;
result.key.code = sdlKeyCodeToFea(event.key.keysym.sym);
//these not fixed
//result.key.alt = event.key.alt;
//result.key.control = event.key.control;
//result.key.shift = event.key.shift;
//result.key.system = event.key.system;
return result;
}
Event SDL2InputBackend::keyReleased(SDL_Event& event)
{
Event result;
result.type = Event::KEYRELEASED;
result.key.code = sdlKeyCodeToFea(event.key.keysym.sym);
//these not fixed
//result.key.alt = event.key.alt;
//result.key.control = event.key.control;
//result.key.shift = event.key.shift;
//result.key.system = event.key.system;
return result;
}
Event SDL2InputBackend::mouseButtonPressed(SDL_Event& event)
{
Event result;
result.mouseButton.x = event.button.x;
result.mouseButton.y = event.button.y;
uint32_t button = event.button.button;
if(button == SDL_BUTTON_LEFT || button == SDL_BUTTON_MIDDLE || button == SDL_BUTTON_RIGHT || button == SDL_BUTTON_X1 || button == SDL_BUTTON_X2)
{
result.type = Event::MOUSEBUTTONPRESSED;
result.mouseButton.button = sdlMouseButtonToFea(button);
}else if(button == 6 || button == 7){
result.type = Event::MOUSEWHEELMOVED;
result.mouseWheel.delta = 0;
result.mouseWheel.y = 0;
result.mouseWheel.x = 0;
if(button == 6){
result.mouseWheel.x = -1;
}else if(button == 7){
result.mouseWheel.x = 1;
}
}
return result;
}
Event SDL2InputBackend::mouseWheel(SDL_Event& event){
Event result;
result.type = Event::MOUSEWHEELMOVED;
result.mouseWheel.delta = event.wheel.y;
result.mouseWheel.x = event.wheel.x;
result.mouseWheel.y = event.wheel.y;
return result;
}
Event SDL2InputBackend::mouseButtonReleased(SDL_Event& event)
{
Event result;
result.type = Event::MOUSEBUTTONRELEASED;
result.mouseButton.button = sdlMouseButtonToFea(event.button.button);
result.mouseButton.x = event.button.x;
result.mouseButton.y = event.button.y;
return result;
}
Event SDL2InputBackend::mouseMoved(SDL_Event& event)
{
Event result;
result.type = Event::MOUSEMOVED;
result.mouseMove.x = event.motion.x;
result.mouseMove.y = event.motion.y;
result.mouseMove.relx = event.motion.xrel;
result.mouseMove.rely = event.motion.yrel;
return result;
}
Event SDL2InputBackend::gamepadButtonPressed(SDL_Event& event)
{
//TBI
Event result;
result.type = Event::GAMEPADBUTTONPRESSED;
(void)event;
//result.gamepadButton.gamepadId = event.joystickButton.joystickId;
//result.gamepadButton.button = event.joystickButton.button;
return result;
}
Event SDL2InputBackend::gamepadButtonReleased(SDL_Event& event)
{
//TBI
Event result;
result.type = Event::GAMEPADBUTTONRELEASED;
(void)event;
//result.gamepadButton.gamepadId = event.joystickButton.joystickId;
//result.gamepadButton.button = event.joystickButton.button;
return result;
}
Event SDL2InputBackend::gamepadMoved(SDL_Event& event)
{
//TBI
Event result;
result.type = Event::GAMEPADMOVED;
(void)event;
//result.gamepadMove.axis = (Gamepad::Axis) event.joystickMove.axis;
//result.gamepadMove.gamepadId = (Gamepad::Axis) event.joystickMove.joystickId;
//result.gamepadMove.position = event.joystickMove.position;
return result;
}
Keyboard::Code SDL2InputBackend::sdlKeyCodeToFea(SDL_Keycode sdlCode) const
{
switch(sdlCode)
{
case SDLK_a:
return Keyboard::A;
case SDLK_b:
return Keyboard::B;
case SDLK_c:
return Keyboard::C;
case SDLK_d:
return Keyboard::D;
case SDLK_e:
return Keyboard::E;
case SDLK_f:
return Keyboard::F;
case SDLK_g:
return Keyboard::G;
case SDLK_h:
return Keyboard::H;
case SDLK_i:
return Keyboard::I;
case SDLK_j:
return Keyboard::J;
case SDLK_k:
return Keyboard::K;
case SDLK_l:
return Keyboard::L;
case SDLK_m:
return Keyboard::M;
case SDLK_n:
return Keyboard::N;
case SDLK_o:
return Keyboard::O;
case SDLK_p:
return Keyboard::P;
case SDLK_q:
return Keyboard::Q;
case SDLK_r:
return Keyboard::R;
case SDLK_s:
return Keyboard::S;
case SDLK_t:
return Keyboard::T;
case SDLK_u:
return Keyboard::U;
case SDLK_v:
return Keyboard::V;
case SDLK_w:
return Keyboard::W;
case SDLK_x:
return Keyboard::X;
case SDLK_y:
return Keyboard::Y;
case SDLK_z:
return Keyboard::Z;
case SDLK_0:
return Keyboard::NUM0;
case SDLK_1:
return Keyboard::NUM1;
case SDLK_2:
return Keyboard::NUM2;
case SDLK_3:
return Keyboard::NUM3;
case SDLK_4:
return Keyboard::NUM4;
case SDLK_5:
return Keyboard::NUM5;
case SDLK_6:
return Keyboard::NUM6;
case SDLK_7:
return Keyboard::NUM7;
case SDLK_8:
return Keyboard::NUM8;
case SDLK_9:
return Keyboard::NUM9;
case SDLK_ESCAPE:
return Keyboard::ESCAPE;
case SDLK_LCTRL:
return Keyboard::LCONTROL;
case SDLK_LSHIFT:
return Keyboard::LSHIFT;
case SDLK_LALT:
return Keyboard::LALT;
case SDLK_LGUI:
return Keyboard::LSYSTEM;
case SDLK_RCTRL:
return Keyboard::RCONTROL;
case SDLK_RSHIFT:
return Keyboard::RSHIFT;
case SDLK_RALT:
return Keyboard::RALT;
case SDLK_RGUI:
return Keyboard::RSYSTEM;
case SDLK_MENU:
return Keyboard::MENU;
case SDLK_LEFTBRACKET:
return Keyboard::LBRACKET;
case SDLK_RIGHTBRACKET:
return Keyboard::RBRACKET;
case SDLK_SEMICOLON:
return Keyboard::SEMICOLON;
case SDLK_COMMA:
return Keyboard::COMMA;
case SDLK_PERIOD:
return Keyboard::PERIOD;
case SDLK_QUOTE:
return Keyboard::QUOTE;
case SDLK_SLASH:
return Keyboard::SLASH;
case SDLK_BACKSLASH:
return Keyboard::BACKSLASH;
case SDLK_BACKQUOTE:
return Keyboard::TILDE;
case SDLK_EQUALS:
return Keyboard::EQUAL;
case SDLK_MINUS:
return Keyboard::DASH;
case SDLK_SPACE:
return Keyboard::SPACE;
case SDLK_RETURN:
return Keyboard::RETURN;
case SDLK_BACKSPACE:
return Keyboard::BACKSPACE;
case SDLK_TAB:
return Keyboard::TAB;
case SDLK_PAGEUP:
return Keyboard::PAGEUP;
case SDLK_PAGEDOWN:
return Keyboard::PAGEDOWN;
case SDLK_END:
return Keyboard::END;
case SDLK_HOME:
return Keyboard::HOME;
case SDLK_INSERT:
return Keyboard::INSERT;
case SDLK_DELETE:
return Keyboard::DELETE;
case SDLK_KP_PLUS:
return Keyboard::ADD;
case SDLK_KP_MINUS:
return Keyboard::SUBTRACT;
case SDLK_KP_MULTIPLY:
return Keyboard::MULTIPLY;
case SDLK_KP_DIVIDE:
return Keyboard::DIVIDE;
case SDLK_LEFT:
return Keyboard::LEFT;
case SDLK_RIGHT:
return Keyboard::RIGHT;
case SDLK_UP:
return Keyboard::UP;
case SDLK_DOWN:
return Keyboard::DOWN;
case SDLK_KP_0:
return Keyboard::NUMPAD0;
case SDLK_KP_1:
return Keyboard::NUMPAD1;
case SDLK_KP_2:
return Keyboard::NUMPAD2;
case SDLK_KP_3:
return Keyboard::NUMPAD3;
case SDLK_KP_4:
return Keyboard::NUMPAD4;
case SDLK_KP_5:
return Keyboard::NUMPAD5;
case SDLK_KP_6:
return Keyboard::NUMPAD6;
case SDLK_KP_7:
return Keyboard::NUMPAD7;
case SDLK_KP_8:
return Keyboard::NUMPAD8;
case SDLK_KP_9:
return Keyboard::NUMPAD9;
case SDLK_F1:
return Keyboard::F1;
case SDLK_F2:
return Keyboard::F2;
case SDLK_F3:
return Keyboard::F3;
case SDLK_F4:
return Keyboard::F4;
case SDLK_F5:
return Keyboard::F5;
case SDLK_F6:
return Keyboard::F6;
case SDLK_F7:
return Keyboard::F7;
case SDLK_F8:
return Keyboard::F8;
case SDLK_F9:
return Keyboard::F9;
case SDLK_F10:
return Keyboard::F10;
case SDLK_F11:
return Keyboard::F11;
case SDLK_F12:
return Keyboard::F12;
case SDLK_F13:
return Keyboard::F13;
case SDLK_F14:
return Keyboard::F14;
case SDLK_F15:
return Keyboard::F15;
case SDLK_PAUSE:
return Keyboard::PAUSE;
default:
return Keyboard::UNKNOWN;
}
}
SDL_Keycode SDL2InputBackend::feaKeyCodeToSdl(Keyboard::Code feaCode) const
{
switch(feaCode)
{
case Keyboard::UNKNOWN:
return (SDL_Keycode)-1;
case Keyboard::A:
return SDLK_a;
case Keyboard::B:
return SDLK_b;
case Keyboard::C:
return SDLK_c;
case Keyboard::D:
return SDLK_d;
case Keyboard::E:
return SDLK_e;
case Keyboard::F:
return SDLK_f;
case Keyboard::G:
return SDLK_g;
case Keyboard::H:
return SDLK_h;
case Keyboard::I:
return SDLK_i;
case Keyboard::J:
return SDLK_j;
case Keyboard::K:
return SDLK_k;
case Keyboard::L:
return SDLK_l;
case Keyboard::M:
return SDLK_m;
case Keyboard::N:
return SDLK_n;
case Keyboard::O:
return SDLK_o;
case Keyboard::P:
return SDLK_p;
case Keyboard::Q:
return SDLK_q;
case Keyboard::R:
return SDLK_r;
case Keyboard::S:
return SDLK_s;
case Keyboard::T:
return SDLK_t;
case Keyboard::U:
return SDLK_u;
case Keyboard::V:
return SDLK_v;
case Keyboard::W:
return SDLK_w;
case Keyboard::X:
return SDLK_x;
case Keyboard::Y:
return SDLK_y;
case Keyboard::Z:
return SDLK_z;
case Keyboard::NUM0:
return SDLK_0;
case Keyboard::NUM1:
return SDLK_1;
case Keyboard::NUM2:
return SDLK_2;
case Keyboard::NUM3:
return SDLK_3;
case Keyboard::NUM4:
return SDLK_4;
case Keyboard::NUM5:
return SDLK_5;
case Keyboard::NUM6:
return SDLK_6;
case Keyboard::NUM7:
return SDLK_7;
case Keyboard::NUM8:
return SDLK_8;
case Keyboard::NUM9:
return SDLK_9;
case Keyboard::ESCAPE:
return SDLK_ESCAPE;
case Keyboard::LCONTROL:
return SDLK_LCTRL;
case Keyboard::LSHIFT:
return SDLK_LSHIFT;
case Keyboard::LALT:
return SDLK_LALT;
case Keyboard::LSYSTEM:
return SDLK_LGUI;
case Keyboard::RCONTROL:
return SDLK_RCTRL;
case Keyboard::RSHIFT:
return SDLK_RSHIFT;
case Keyboard::RALT:
return SDLK_RALT;
case Keyboard::RSYSTEM:
return SDLK_RGUI;
case Keyboard::MENU:
return SDLK_MENU;
case Keyboard::LBRACKET:
return SDLK_LEFTBRACKET;
case Keyboard::RBRACKET:
return SDLK_RIGHTBRACKET;
case Keyboard::SEMICOLON:
return SDLK_SEMICOLON;
case Keyboard::COMMA:
return SDLK_COMMA;
case Keyboard::PERIOD:
return SDLK_PERIOD;
case Keyboard::QUOTE:
return SDLK_QUOTE;
case Keyboard::SLASH:
return SDLK_SLASH;
case Keyboard::BACKSLASH:
return SDLK_BACKSLASH;
case Keyboard::TILDE:
return SDLK_BACKQUOTE;
case Keyboard::EQUAL:
return SDLK_EQUALS;
case Keyboard::DASH:
return SDLK_MINUS;
case Keyboard::SPACE:
return SDLK_SPACE;
case Keyboard::RETURN:
return SDLK_RETURN;
case Keyboard::BACKSPACE:
return SDLK_BACKSPACE;
case Keyboard::TAB:
return SDLK_TAB;
case Keyboard::PAGEUP:
return SDLK_PAGEUP;
case Keyboard::PAGEDOWN:
return SDLK_PAGEDOWN;
case Keyboard::END:
return SDLK_END;
case Keyboard::HOME:
return SDLK_HOME;
case Keyboard::INSERT:
return SDLK_INSERT;
case Keyboard::DELETE:
return SDLK_DELETE;
case Keyboard::ADD:
return SDLK_KP_PLUS;
case Keyboard::SUBTRACT:
return SDLK_KP_MINUS;
case Keyboard::MULTIPLY:
return SDLK_KP_MULTIPLY;
case Keyboard::DIVIDE:
return SDLK_KP_DIVIDE;
case Keyboard::LEFT:
return SDLK_LEFT;
case Keyboard::RIGHT:
return SDLK_RIGHT;
case Keyboard::UP:
return SDLK_UP;
case Keyboard::DOWN:
return SDLK_DOWN;
case Keyboard::NUMPAD0:
return SDLK_KP_0;
case Keyboard::NUMPAD1:
return SDLK_KP_1;
case Keyboard::NUMPAD2:
return SDLK_KP_2;
case Keyboard::NUMPAD3:
return SDLK_KP_3;
case Keyboard::NUMPAD4:
return SDLK_KP_4;
case Keyboard::NUMPAD5:
return SDLK_KP_5;
case Keyboard::NUMPAD6:
return SDLK_KP_6;
case Keyboard::NUMPAD7:
return SDLK_KP_7;
case Keyboard::NUMPAD8:
return SDLK_KP_8;
case Keyboard::NUMPAD9:
return SDLK_KP_9;
case Keyboard::F1:
return SDLK_F1;
case Keyboard::F2:
return SDLK_F2;
case Keyboard::F3:
return SDLK_F3;
case Keyboard::F4:
return SDLK_F4;
case Keyboard::F5:
return SDLK_F5;
case Keyboard::F6:
return SDLK_F6;
case Keyboard::F7:
return SDLK_F7;
case Keyboard::F8:
return SDLK_F8;
case Keyboard::F9:
return SDLK_F9;
case Keyboard::F10:
return SDLK_F10;
case Keyboard::F11:
return SDLK_F11;
case Keyboard::F12:
return SDLK_F12;
case Keyboard::F13:
return SDLK_F13;
case Keyboard::F14:
return SDLK_F14;
case Keyboard::F15:
return SDLK_F15;
case Keyboard::PAUSE:
return SDLK_PAUSE;
}
}
uint8_t SDL2InputBackend::feaMouseButtonToSdl(Mouse::Button feaMouseButton) const
{
switch(feaMouseButton)
{
case Mouse::LEFT:
return SDL_BUTTON_LEFT;
case Mouse::RIGHT:
return SDL_BUTTON_RIGHT;
case Mouse::MIDDLE:
return SDL_BUTTON_MIDDLE;
case Mouse::XBUTTON1:
return SDL_BUTTON_X1;
case Mouse::XBUTTON2:
return SDL_BUTTON_X2;
}
}
Mouse::Button SDL2InputBackend::sdlMouseButtonToFea(uint32_t sdlMouseButton) const
{
switch(sdlMouseButton)
{
case SDL_BUTTON_LEFT:
return Mouse::LEFT;
case SDL_BUTTON_RIGHT:
return Mouse::RIGHT;
case SDL_BUTTON_MIDDLE:
return Mouse::MIDDLE;
case SDL_BUTTON_X1:
return Mouse::XBUTTON1;
case SDL_BUTTON_X2:
return Mouse::XBUTTON2;
default:
return Mouse::LEFT;
}
}
}