rolmodl
C++ API for the Simple Directmedia Library 2 (SDL2)
Kb.hpp
1 #pragma once
2 
3 #include "forwarddecl/Kb.hpp"
4 
5 namespace rolmodl::kb {
6  class State {
7  public:
8  State(const State& that) = delete;
9  State(State&& that) = delete;
10 
11  State& operator=(const State& that) = delete;
12  State& operator=(State&& that) = delete;
13 
14  // fixme: SDL_PumpEvents required before calls
15  static bool down(const Scancode s);
16  static bool up(const Scancode s);
17 
18  static bool down(const Key k);
19  static bool up(const Key k);
20 
21  static State& instance() noexcept;
22 
23  static const uint8_t* unsafeRaw() noexcept;
24  static unsigned int unsafeRawL() noexcept;
25 
26  private:
27  State() noexcept;
28 
29  const uint8_t* data_;
30  unsigned int l_;
31  };
32 
33  namespace key {
34  struct Name {
35  public:
36  Name(const Name& that) = delete;
37  Name(Name&& that) = delete;
38 
39  Name& operator=(const Name& that) = delete;
40  Name& operator=(Name&& that) = delete;
41 
42  static void query(const Key k) noexcept;
43  static const char* lastQueryRes() noexcept;
44 
45  static Name& instance() noexcept;
46 
47  private:
48  Name();
49 
50  const char* data_;
51  };
52 
53  constexpr Scancode scancode(const Key k) noexcept {
54  return scancode::unsafe::fromSDLEnum(SDL_GetScancodeFromKey(key::unsafe::toSDLEnum(k)));
55  }
56  constexpr Key fromScancode(const Scancode s) noexcept {
57  return key::unsafe::fromSDLEnum(SDL_GetKeyFromScancode(scancode::unsafe::toSDLEnum(s)));
58  }
59  }
60  namespace scancode {
61  constexpr Key key(const Scancode s) noexcept {
62  return key::fromScancode(s);
63  }
64  constexpr Scancode fromKey(const Key k) noexcept {
65  return key::scancode(k);
66  }
67  }
68 
69  enum class Key {
70  unknown,
71 
72  // row 0
73  escape,
74 
75  f1,
76  f2,
77  f3,
78  f4,
79  f5,
80  f6,
81  f7,
82  f8,
83  f9,
84  f10,
85  f11,
86  f12,
87 
88  printscreen,
89  scrolllock,
90  pause,
91 
92  // row 1
93  backquote,
94 
95  num_1,
96  num_2,
97  num_3,
98  num_4,
99  num_5,
100  num_6,
101  num_7,
102  num_8,
103  num_9,
104  num_0,
105 
106  exclamationPoint,
107  at,
108  hash,
109  dollar,
110  percent,
111  caret,
112  ampersand,
113  asterisk,
114  leftParen,
115  rightParen,
116  minus,
117  underscore,
118  eq,
119  plus,
120  backspace,
121 
122  insert,
123  home,
124  pageup,
125 
126  numlock,
127  kp_divide,
128  kp_multiply,
129  kp_minus,
130 
131  // row2
132  tab,
133  q, w, e, r, t, y, u, i, o, p,
134  leftBracket,
135  // leftBrace, // todo: not in sdl
136  rightBracket,
137  // rightBrace, // todo: not in sdl
138  backslash,
139  // vbar, // todo: not is sdl
140 
141  del,
142  end,
143  pagedown,
144 
145  kp_7, kp_8, kp_9,
146 
147  // row 3
148  capslock,
149  a, s, d, f, g, h, j, k, l,
150  semicolon,
151  colon,
152  apostrophe,
153  quote,
154  enter,
155  enter2,
156 
157  kp_4, kp_5, kp_6,
158  kp_plus,
159 
160  //row 4
161  lshift,
162  z, x, c, v, b, n, m,
163  comma,
164  less,
165  period,
166  greater,
167  slash,
168  questionMark,
169  rshift,
170 
171  kp_1, kp_2, kp_3,
172 
173  //row 5
174  lctrl,
175  lgui, // todo: better name?
176  lalt,
177  space,
178  ralt,
179  rgui,
180  app,
181  rctrl,
182 
183  left,
184  up,
185  right,
186  down,
187 
188  kp_0,
189  kp_period,
190  kp_enter,
191 
192  // etc.
193 
194  f13,
195  f14,
196  f15,
197  f16,
198  f17,
199  f18,
200  f19,
201  f20,
202  f21,
203  f22,
204  f23,
205  f24,
206 
207  mute,
208  volumeUp,
209  volumeDown,
210 
211  cut,
212  copy,
213  paste,
214 
215  brightnessDown,
216  brightnessUp,
217  displaySwitch,
218 
219  kb_illum_toggle,
220  kb_illum_down,
221  kb_illum_up,
222 
223  thousandsSeparator,
224  decimalSeparator,
225 
226  currency_unit,
227  currency_subunit,
228 
229  kp_comma,
230  kp_eq,
231  kp_eqas400,
232  kp_00,
233  kp_000,
234  kp_leftParen,
235  kp_rightParen,
236  kp_leftBrace,
237  kp_rightBrace,
238  kp_tab,
239  kp_backspace,
240  kp_a,
241  kp_b,
242  kp_c,
243  kp_d,
244  kp_e,
245  kp_f,
246  kp_xor,
247  kp_power,
248  kp_percent,
249  kp_less,
250  kp_greater,
251  kp_ampersand,
252  kp_doubleAmpersand,
253  kp_vbar,
254  kp_doubleVbar,
255  kp_colon,
256  kp_hash,
257  kp_space,
258  kp_at,
259  kp_exclamationPoint,
260  kp_mem_store,
261  kp_mem_recall,
262  kp_mem_clear,
263  kp_mem_add,
264  kp_mem_subtract,
265  kp_mem_multiply,
266  kp_mem_divide,
267  kp_plusMinus,
268  kp_clear,
269  kp_clearEntry,
270  kp_bin,
271  kp_octal,
272  kp_decimal,
273  kp_hex,
274 
275  audio_next,
276  audio_prev,
277  audio_stop,
278  audio_play,
279  audio_mute,
280  audio_rewind,
281  audio_fastforward,
282  mediaSelect,
283 
284  sleep,
285  power,
286  eject,
287  exec,
288  help,
289  menu,
290  select,
291  stop,
292  redo,
293  undo,
294  find,
295 
296  www,
297  mail,
298  calculator,
299  computer,
300  ac_search,
301  ac_home,
302  ac_back,
303  ac_fwd,
304  ac_stop,
305  ac_refresh,
306  ac_bookmarks,
307 
308  altErase,
309  mode,
310  sysrq,
311  cancel,
312  clear,
313  prior,
314  separator,
315  out,
316  oper,
317  clearAgain,
318  crsel,
319  exsel,
320 
321  app1,
322  app2
323  };
324  namespace key::unsafe {
325  constexpr Key fromSDLEnum(const SDL_Keycode k) noexcept;
326  constexpr SDL_Keycode toSDLEnum(const Key k) noexcept;
327  }
328 
329  enum class Scancode {
330  unknown,
331 
332  // row 0
333  escape,
334 
335  f1,
336  f2,
337  f3,
338  f4,
339  f5,
340  f6,
341  f7,
342  f8,
343  f9,
344  f10,
345  f11,
346  f12,
347 
348  printscreen,
349  scrolllock,
350  pause,
351 
352  // row 1
353  backquote,
354 
355  num_1,
356  num_2,
357  num_3,
358  num_4,
359  num_5,
360  num_6,
361  num_7,
362  num_8,
363  num_9,
364  num_0,
365 
366  exclamationPoint,
367  at,
368  hash,
369  dollar,
370  percent,
371  caret,
372  ampersand,
373  asterisk,
374  leftParen,
375  rightParen,
376  minus,
377  underscore,
378  eq,
379  plus,
380  backspace,
381 
382  insert,
383  home,
384  pageup,
385 
386  numlock,
387  kp_divide,
388  kp_multiply,
389  kp_minus,
390 
391  // row2
392  tab,
393  q, w, e, r, t, y, u, i, o, p,
394  leftBracket,
395  // leftBrace, // todo: not in sdl
396  rightBracket,
397  // rightBrace, // todo: not in sdl
398  backslash,
399  // vbar, // todo: not is sdl
400 
401  del,
402  end,
403  pagedown,
404 
405  kp_7, kp_8, kp_9,
406 
407  // row 3
408  capslock,
409  a, s, d, f, g, h, j, k, l,
410  semicolon,
411  colon,
412  apostrophe,
413  quote,
414  enter,
415  enter2,
416 
417  kp_4, kp_5, kp_6,
418  kp_plus,
419 
420  //row 4
421  lshift,
422  z, x, c, v, b, n, m,
423  comma,
424  less,
425  period,
426  greater,
427  slash,
428  questionMark,
429  rshift,
430 
431  kp_1, kp_2, kp_3,
432 
433  //row 5
434  lctrl,
435  lgui, // todo: better name?
436  lalt,
437  space,
438  ralt,
439  rgui,
440  app,
441  rctrl,
442 
443  left,
444  up,
445  right,
446  down,
447 
448  kp_0,
449  kp_period,
450  kp_enter,
451 
452  // etc.
453 
454  f13,
455  f14,
456  f15,
457  f16,
458  f17,
459  f18,
460  f19,
461  f20,
462  f21,
463  f22,
464  f23,
465  f24,
466 
467  mute,
468  volumeUp,
469  volumeDown,
470 
471  cut,
472  copy,
473  paste,
474 
475  brightnessDown,
476  brightnessUp,
477  displaySwitch,
478 
479  kb_illum_toggle,
480  kb_illum_down,
481  kb_illum_up,
482 
483  thousandsSeparator,
484  decimalSeparator,
485 
486  currency_unit,
487  currency_subunit,
488 
489  kp_comma,
490  kp_eq,
491  kp_eqas400,
492  kp_00,
493  kp_000,
494  kp_leftParen,
495  kp_rightParen,
496  kp_leftBrace,
497  kp_rightBrace,
498  kp_tab,
499  kp_backspace,
500  kp_a,
501  kp_b,
502  kp_c,
503  kp_d,
504  kp_e,
505  kp_f,
506  kp_xor,
507  kp_power,
508  kp_percent,
509  kp_less,
510  kp_greater,
511  kp_ampersand,
512  kp_doubleAmpersand,
513  kp_vbar,
514  kp_doubleVbar,
515  kp_colon,
516  kp_hash,
517  kp_space,
518  kp_at,
519  kp_exclamationPoint,
520  kp_mem_store,
521  kp_mem_recall,
522  kp_mem_clear,
523  kp_mem_add,
524  kp_mem_subtract,
525  kp_mem_multiply,
526  kp_mem_divide,
527  kp_plusMinus,
528  kp_clear,
529  kp_clearEntry,
530  kp_bin,
531  kp_octal,
532  kp_decimal,
533  kp_hex,
534 
535  audio_next,
536  audio_prev,
537  audio_stop,
538  audio_play,
539  audio_mute,
540  audio_rewind,
541  audio_fastforward,
542  mediaSelect,
543 
544  sleep,
545  power,
546  eject,
547  exec,
548  help,
549  menu,
550  select,
551  stop,
552  redo,
553  undo,
554  find,
555 
556  www,
557  mail,
558  calculator,
559  computer,
560  ac_search,
561  ac_home,
562  ac_back,
563  ac_fwd,
564  ac_stop,
565  ac_refresh,
566  ac_bookmarks,
567 
568  altErase,
569  mode,
570  sysrq,
571  cancel,
572  clear,
573  prior,
574  separator,
575  out,
576  oper,
577  clearAgain,
578  crsel,
579  exsel,
580 
581  app1,
582  app2,
583 
584  nonUsHash,
585  nonUsBackslash,
586 
587  internat_1,
588  internat_2,
589  internat_3,
590  internat_4,
591  internat_5,
592  internat_6,
593  internat_7,
594  internat_8,
595  internat_9,
596 
597  lang_1,
598  lang_2,
599  lang_3,
600  lang_4,
601  lang_5,
602  lang_6,
603  lang_7,
604  lang_8,
605  lang_9
606  };
607  namespace scancode::unsafe {
608  constexpr Scancode fromSDLEnum(const SDL_Scancode k) noexcept;
609  constexpr SDL_Scancode toSDLEnum(const Scancode k) noexcept;
610  }
611 
612  namespace key::unsafe {
613  constexpr Key fromSDLEnum(const SDL_Keycode k) noexcept {
614  if (k == SDLK_UNKNOWN)
615  return Key::unknown;
616 
617  if (k == SDLK_RETURN)
618  return Key::enter;
619  if (k == SDLK_ESCAPE)
620  return Key::escape;
621  if (k == SDLK_BACKSPACE)
622  return Key::backspace;
623  if (k == SDLK_TAB)
624  return Key::tab;
625  if (k == SDLK_SPACE)
626  return Key::space;
627  if (k == SDLK_EXCLAIM)
628  return Key::exclamationPoint;
629  if (k == SDLK_QUOTEDBL)
630  return Key::quote;
631  if (k == SDLK_HASH)
632  return Key::hash;
633  if (k == SDLK_PERCENT)
634  return Key::percent;
635  if (k == SDLK_DOLLAR)
636  return Key::dollar;
637  if (k == SDLK_AMPERSAND)
638  return Key::ampersand;
639  if (k == SDLK_QUOTE)
640  return Key::apostrophe;
641  if (k == SDLK_LEFTPAREN)
642  return Key::leftParen;
643  if (k == SDLK_RIGHTPAREN)
644  return Key::rightParen;
645  if (k == SDLK_ASTERISK)
646  return Key::asterisk;
647  if (k == SDLK_PLUS)
648  return Key::plus;
649  if (k == SDLK_COMMA)
650  return Key::comma;
651  if (k == SDLK_MINUS)
652  return Key::minus;
653  if (k == SDLK_PERIOD)
654  return Key::period;
655  if (k == SDLK_SLASH)
656  return Key::slash;
657  if (k == SDLK_0)
658  return Key::num_0;
659  if (k == SDLK_1)
660  return Key::num_1;
661  if (k == SDLK_2)
662  return Key::num_2;
663  if (k == SDLK_3)
664  return Key::num_3;
665  if (k == SDLK_4)
666  return Key::num_4;
667  if (k == SDLK_5)
668  return Key::num_5;
669  if (k == SDLK_6)
670  return Key::num_6;
671  if (k == SDLK_7)
672  return Key::num_7;
673  if (k == SDLK_8)
674  return Key::num_8;
675  if (k == SDLK_9)
676  return Key::num_9;
677  if (k == SDLK_COLON)
678  return Key::colon;
679  if (k == SDLK_SEMICOLON)
680  return Key::semicolon;
681  if (k == SDLK_LESS)
682  return Key::less;
683  if (k == SDLK_EQUALS)
684  return Key::eq;
685  if (k == SDLK_GREATER)
686  return Key::greater;
687  if (k == SDLK_QUESTION)
688  return Key::questionMark;
689  if (k == SDLK_AT)
690  return Key::at;
691 
692  if (k == SDLK_LEFTBRACKET)
693  return Key::leftBracket;
694  if (k == SDLK_BACKSLASH)
695  return Key::backslash;
696  if (k == SDLK_RIGHTBRACKET)
697  return Key::rightBracket;
698  if (k == SDLK_CARET)
699  return Key::caret;
700  if (k == SDLK_UNDERSCORE)
701  return Key::underscore;
702  if (k == SDLK_BACKQUOTE)
703  return Key::backquote;
704  if (k == SDLK_a)
705  return Key::a;
706  if (k == SDLK_b)
707  return Key::b;
708  if (k == SDLK_c)
709  return Key::c;
710  if (k == SDLK_d)
711  return Key::d;
712  if (k == SDLK_e)
713  return Key::e;
714  if (k == SDLK_f)
715  return Key::f;
716  if (k == SDLK_g)
717  return Key::g;
718  if (k == SDLK_h)
719  return Key::h;
720  if (k == SDLK_i)
721  return Key::i;
722  if (k == SDLK_j)
723  return Key::j;
724  if (k == SDLK_k)
725  return Key::k;
726  if (k == SDLK_l)
727  return Key::l;
728  if (k == SDLK_m)
729  return Key::m;
730  if (k == SDLK_n)
731  return Key::n;
732  if (k == SDLK_o)
733  return Key::o;
734  if (k == SDLK_p)
735  return Key::p;
736  if (k == SDLK_q)
737  return Key::q;
738  if (k == SDLK_r)
739  return Key::r;
740  if (k == SDLK_s)
741  return Key::s;
742  if (k == SDLK_t)
743  return Key::t;
744  if (k == SDLK_u)
745  return Key::u;
746  if (k == SDLK_v)
747  return Key::v;
748  if (k == SDLK_w)
749  return Key::w;
750  if (k == SDLK_x)
751  return Key::x;
752  if (k == SDLK_y)
753  return Key::y;
754  if (k == SDLK_z)
755  return Key::z;
756 
757  if (k == SDLK_CAPSLOCK)
758  return Key::capslock;
759 
760  if (k == SDLK_F1)
761  return Key::f1;
762  if (k == SDLK_F2)
763  return Key::f2;
764  if (k == SDLK_F3)
765  return Key::f3;
766  if (k == SDLK_F4)
767  return Key::f4;
768  if (k == SDLK_F5)
769  return Key::f5;
770  if (k == SDLK_F6)
771  return Key::f6;
772  if (k == SDLK_F7)
773  return Key::f7;
774  if (k == SDLK_F8)
775  return Key::f8;
776  if (k == SDLK_F9)
777  return Key::f9;
778  if (k == SDLK_F10)
779  return Key::f10;
780  if (k == SDLK_F11)
781  return Key::f11;
782  if (k == SDLK_F12)
783  return Key::f12;
784 
785  if (k == SDLK_PRINTSCREEN)
786  return Key::printscreen;
787  if (k == SDLK_SCROLLLOCK)
788  return Key::scrolllock;
789  if (k == SDLK_PAUSE)
790  return Key::pause;
791  if (k == SDLK_INSERT)
792  return Key::insert;
793  if (k == SDLK_HOME)
794  return Key::home;
795  if (k == SDLK_PAGEUP)
796  return Key::pageup;
797  if (k == SDLK_DELETE)
798  return Key::del;
799  if (k == SDLK_END)
800  return Key::end;
801  if (k == SDLK_PAGEDOWN)
802  return Key::pagedown;
803  if (k == SDLK_RIGHT)
804  return Key::right;
805  if (k == SDLK_LEFT)
806  return Key::left;
807  if (k == SDLK_DOWN)
808  return Key::down;
809  if (k == SDLK_UP)
810  return Key::up;
811 
812  if (k == SDLK_NUMLOCKCLEAR)
813  return Key::numlock;
814  if (k == SDLK_KP_DIVIDE)
815  return Key::kp_divide;
816  if (k == SDLK_KP_MULTIPLY)
817  return Key::kp_multiply;
818  if (k == SDLK_KP_MINUS)
819  return Key::kp_minus;
820  if (k == SDLK_KP_PLUS)
821  return Key::kp_plus;
822  if (k == SDLK_KP_ENTER)
823  return Key::kp_enter;
824  if (k == SDLK_KP_1)
825  return Key::kp_1;
826  if (k == SDLK_KP_2)
827  return Key::kp_2;
828  if (k == SDLK_KP_3)
829  return Key::kp_3;
830  if (k == SDLK_KP_4)
831  return Key::kp_4;
832  if (k == SDLK_KP_5)
833  return Key::kp_5;
834  if (k == SDLK_KP_6)
835  return Key::kp_6;
836  if (k == SDLK_KP_7)
837  return Key::kp_7;
838  if (k == SDLK_KP_8)
839  return Key::kp_8;
840  if (k == SDLK_KP_9)
841  return Key::kp_9;
842  if (k == SDLK_KP_0)
843  return Key::kp_0;
844  if (k == SDLK_KP_PERIOD)
845  return Key::kp_period;
846 
847  if (k == SDLK_APPLICATION)
848  return Key::app;
849  if (k == SDLK_POWER)
850  return Key::power;
851  if (k == SDLK_KP_EQUALS)
852  return Key::kp_eq;
853  if (k == SDLK_F13)
854  return Key::f13;
855  if (k == SDLK_F14)
856  return Key::f14;
857  if (k == SDLK_F15)
858  return Key::f15;
859  if (k == SDLK_F16)
860  return Key::f16;
861  if (k == SDLK_F17)
862  return Key::f17;
863  if (k == SDLK_F18)
864  return Key::f18;
865  if (k == SDLK_F19)
866  return Key::f19;
867  if (k == SDLK_F20)
868  return Key::f20;
869  if (k == SDLK_F21)
870  return Key::f21;
871  if (k == SDLK_F22)
872  return Key::f22;
873  if (k == SDLK_F23)
874  return Key::f23;
875  if (k == SDLK_F24)
876  return Key::f24;
877  if (k == SDLK_EXECUTE)
878  return Key::exec;
879  if (k == SDLK_HELP)
880  return Key::help;
881  if (k == SDLK_MENU)
882  return Key::menu;
883  if (k == SDLK_SELECT)
884  return Key::select;
885  if (k == SDLK_STOP)
886  return Key::stop;
887  if (k == SDLK_AGAIN)
888  return Key::redo;
889  if (k == SDLK_UNDO)
890  return Key::undo;
891  if (k == SDLK_CUT)
892  return Key::cut;
893  if (k == SDLK_COPY)
894  return Key::copy;
895  if (k == SDLK_PASTE)
896  return Key::paste;
897  if (k == SDLK_FIND)
898  return Key::find;
899  if (k == SDLK_MUTE)
900  return Key::mute;
901  if (k == SDLK_VOLUMEUP)
902  return Key::volumeUp;
903  if (k == SDLK_VOLUMEDOWN)
904  return Key::volumeDown;
905  if (k == SDLK_KP_COMMA)
906  return Key::kp_comma;
907  if (k == SDLK_KP_EQUALSAS400)
908  return Key::kp_eqas400;
909 
910  if (k == SDLK_ALTERASE)
911  return Key::altErase;
912  if (k == SDLK_SYSREQ)
913  return Key::sysrq;
914  if (k == SDLK_CANCEL)
915  return Key::cancel;
916  if (k == SDLK_CLEAR)
917  return Key::clear;
918  if (k == SDLK_PRIOR)
919  return Key::prior;
920  if (k == SDLK_RETURN2)
921  return Key::enter2;
922  if (k == SDLK_SEPARATOR)
923  return Key::separator;
924  if (k == SDLK_OUT)
925  return Key::out;
926  if (k == SDLK_OPER)
927  return Key::oper;
928  if (k == SDLK_CLEARAGAIN)
929  return Key::clearAgain;
930  if (k == SDLK_CRSEL)
931  return Key::crsel;
932  if (k == SDLK_EXSEL)
933  return Key::exsel;
934 
935  if (k == SDLK_KP_00)
936  return Key::kp_00;
937  if (k == SDLK_KP_000)
938  return Key::kp_000;
939  if (k == SDLK_THOUSANDSSEPARATOR)
940  return Key::thousandsSeparator;
941  if (k == SDLK_DECIMALSEPARATOR)
942  return Key::decimalSeparator;
943  if (k == SDLK_CURRENCYUNIT)
944  return Key::currency_unit;
945  if (k == SDLK_CURRENCYSUBUNIT)
946  return Key::currency_subunit;
947  if (k == SDLK_KP_LEFTPAREN)
948  return Key::kp_leftParen;
949  if (k == SDLK_KP_RIGHTPAREN)
950  return Key::kp_rightParen;
951  if (k == SDLK_KP_LEFTBRACE)
952  return Key::kp_leftBrace;
953  if (k == SDLK_KP_RIGHTBRACE)
954  return Key::kp_rightBrace;
955  if (k == SDLK_KP_TAB)
956  return Key::kp_tab;
957  if (k == SDLK_KP_BACKSPACE)
958  return Key::kp_backspace;
959  if (k == SDLK_KP_A)
960  return Key::kp_a;
961  if (k == SDLK_KP_B)
962  return Key::kp_b;
963  if (k == SDLK_KP_C)
964  return Key::kp_c;
965  if (k == SDLK_KP_D)
966  return Key::kp_d;
967  if (k == SDLK_KP_E)
968  return Key::kp_e;
969  if (k == SDLK_KP_F)
970  return Key::kp_f;
971  if (k == SDLK_KP_XOR)
972  return Key::kp_xor;
973  if (k == SDLK_KP_POWER)
974  return Key::kp_power;
975  if (k == SDLK_KP_PERCENT)
976  return Key::kp_percent;
977  if (k == SDLK_KP_LESS)
978  return Key::kp_less;
979  if (k == SDLK_KP_GREATER)
980  return Key::kp_greater;
981  if (k == SDLK_KP_AMPERSAND)
982  return Key::kp_ampersand;
983  if (k == SDLK_KP_DBLAMPERSAND)
984  return Key::kp_doubleAmpersand;
985  if (k == SDLK_KP_VERTICALBAR)
986  return Key::kp_vbar;
987  if (k == SDLK_KP_DBLVERTICALBAR)
988  return Key::kp_doubleVbar;
989  if (k == SDLK_KP_COLON)
990  return Key::kp_colon;
991  if (k == SDLK_KP_HASH)
992  return Key::kp_hash;
993  if (k == SDLK_KP_SPACE)
994  return Key::kp_space;
995  if (k == SDLK_KP_AT)
996  return Key::kp_at;
997  if (k == SDLK_KP_EXCLAM)
998  return Key::kp_exclamationPoint;
999  if (k == SDLK_KP_MEMSTORE)
1000  return Key::kp_mem_store;
1001  if (k == SDLK_KP_MEMRECALL)
1002  return Key::kp_mem_recall;
1003  if (k == SDLK_KP_MEMCLEAR)
1004  return Key::kp_mem_clear;
1005  if (k == SDLK_KP_MEMADD)
1006  return Key::kp_mem_add;
1007  if (k == SDLK_KP_MEMSUBTRACT)
1008  return Key::kp_mem_subtract;
1009  if (k == SDLK_KP_MEMMULTIPLY)
1010  return Key::kp_mem_multiply;
1011  if (k == SDLK_KP_MEMDIVIDE)
1012  return Key::kp_mem_divide;
1013  if (k == SDLK_KP_PLUSMINUS)
1014  return Key::kp_plusMinus;
1015  if (k == SDLK_KP_CLEAR)
1016  return Key::kp_clear;
1017  if (k == SDLK_KP_CLEARENTRY)
1018  return Key::kp_clearEntry;
1019  if (k == SDLK_KP_BINARY)
1020  return Key::kp_bin;
1021  if (k == SDLK_KP_OCTAL)
1022  return Key::kp_octal;
1023  if (k == SDLK_KP_DECIMAL)
1024  return Key::kp_decimal;
1025  if (k == SDLK_KP_HEXADECIMAL)
1026  return Key::kp_hex;
1027 
1028  if (k == SDLK_LCTRL)
1029  return Key::lctrl;
1030  if (k == SDLK_LSHIFT)
1031  return Key::lshift;
1032  if (k == SDLK_LALT)
1033  return Key::lalt;
1034  if (k == SDLK_LGUI)
1035  return Key::lgui;
1036  if (k == SDLK_RCTRL)
1037  return Key::rctrl;
1038  if (k == SDLK_RSHIFT)
1039  return Key::rshift;
1040  if (k == SDLK_RALT)
1041  return Key::ralt;
1042  if (k == SDLK_RGUI)
1043  return Key::rgui;
1044 
1045  if (k == SDLK_MODE)
1046  return Key::mode;
1047 
1048  if (k == SDLK_AUDIONEXT)
1049  return Key::audio_next;
1050  if (k == SDLK_AUDIOPREV)
1051  return Key::audio_prev;
1052  if (k == SDLK_AUDIOSTOP)
1053  return Key::audio_stop;
1054  if (k == SDLK_AUDIOPLAY)
1055  return Key::audio_play;
1056  if (k == SDLK_AUDIOMUTE)
1057  return Key::audio_mute;
1058  if (k == SDLK_MEDIASELECT)
1059  return Key::mediaSelect;
1060  if (k == SDLK_WWW)
1061  return Key::www;
1062  if (k == SDLK_MAIL)
1063  return Key::mail;
1064  if (k == SDLK_CALCULATOR)
1065  return Key::calculator;
1066  if (k == SDLK_COMPUTER)
1067  return Key::computer;
1068  if (k == SDLK_AC_SEARCH)
1069  return Key::ac_search;
1070  if (k == SDLK_AC_HOME)
1071  return Key::ac_home;
1072  if (k == SDLK_AC_BACK)
1073  return Key::ac_back;
1074  if (k == SDLK_AC_FORWARD)
1075  return Key::ac_fwd;
1076  if (k == SDLK_AC_STOP)
1077  return Key::ac_stop;
1078  if (k == SDLK_AC_REFRESH)
1079  return Key::ac_refresh;
1080  if (k == SDLK_AC_BOOKMARKS)
1081  return Key::ac_bookmarks;
1082 
1083  if (k == SDLK_BRIGHTNESSDOWN)
1084  return Key::brightnessDown;
1085  if (k == SDLK_BRIGHTNESSUP)
1086  return Key::brightnessUp;
1087  if (k == SDLK_DISPLAYSWITCH)
1088  return Key::displaySwitch;
1089  if (k == SDLK_KBDILLUMTOGGLE)
1090  return Key::kb_illum_toggle;
1091  if (k == SDLK_KBDILLUMDOWN)
1092  return Key::kb_illum_down;
1093  if (k == SDLK_KBDILLUMUP)
1094  return Key::kb_illum_up;
1095  if (k == SDLK_EJECT)
1096  return Key::eject;
1097  if (k == SDLK_SLEEP)
1098  return Key::sleep;
1099  if (k == SDLK_APP1)
1100  return Key::app1;
1101  if (k == SDLK_APP2)
1102  return Key::app2;
1103 
1104  if (k == SDLK_AUDIOREWIND)
1105  return Key::audio_rewind;
1106  if (k == SDLK_AUDIOFASTFORWARD)
1107  return Key::audio_fastforward;
1108 
1109  return Key::unknown;
1110  }
1111 
1112  constexpr SDL_Keycode toSDLEnum(const Key k) noexcept {
1113  if (k == Key::unknown)
1114  return SDLK_UNKNOWN;
1115 
1116  if (k == Key::enter)
1117  return SDLK_RETURN;
1118  if (k == Key::escape)
1119  return SDLK_ESCAPE;
1120  if (k == Key::backspace)
1121  return SDLK_BACKSPACE;
1122  if (k == Key::tab)
1123  return SDLK_TAB;
1124  if (k == Key::space)
1125  return SDLK_SPACE;
1126  if (k == Key::exclamationPoint)
1127  return SDLK_EXCLAIM;
1128  if (k == Key::quote)
1129  return SDLK_QUOTEDBL;
1130  if (k == Key::hash)
1131  return SDLK_HASH;
1132  if (k == Key::percent)
1133  return SDLK_PERCENT;
1134  if (k == Key::dollar)
1135  return SDLK_DOLLAR;
1136  if (k == Key::ampersand)
1137  return SDLK_AMPERSAND;
1138  if (k == Key::apostrophe)
1139  return SDLK_QUOTE;
1140  if (k == Key::leftParen)
1141  return SDLK_LEFTPAREN;
1142  if (k == Key::rightParen)
1143  return SDLK_RIGHTPAREN;
1144  if (k == Key::asterisk)
1145  return SDLK_ASTERISK;
1146  if (k == Key::plus)
1147  return SDLK_PLUS;
1148  if (k == Key::comma)
1149  return SDLK_COMMA;
1150  if (k == Key::minus)
1151  return SDLK_MINUS;
1152  if (k == Key::period)
1153  return SDLK_PERIOD;
1154  if (k == Key::slash)
1155  return SDLK_SLASH;
1156  if (k == Key::num_0)
1157  return SDLK_0;
1158  if (k == Key::num_1)
1159  return SDLK_1;
1160  if (k == Key::num_2)
1161  return SDLK_2;
1162  if (k == Key::num_3)
1163  return SDLK_3;
1164  if (k == Key::num_4)
1165  return SDLK_4;
1166  if (k == Key::num_5)
1167  return SDLK_5;
1168  if (k == Key::num_6)
1169  return SDLK_6;
1170  if (k == Key::num_7)
1171  return SDLK_7;
1172  if (k == Key::num_8)
1173  return SDLK_8;
1174  if (k == Key::num_9)
1175  return SDLK_9;
1176  if (k == Key::colon)
1177  return SDLK_COLON;
1178  if (k == Key::semicolon)
1179  return SDLK_SEMICOLON;
1180  if (k == Key::less)
1181  return SDLK_LESS;
1182  if (k == Key::eq)
1183  return SDLK_EQUALS;
1184  if (k == Key::greater)
1185  return SDLK_GREATER;
1186  if (k == Key::questionMark)
1187  return SDLK_QUESTION;
1188  if (k == Key::at)
1189  return SDLK_AT;
1190 
1191  if (k == Key::leftBracket)
1192  return SDLK_LEFTBRACKET;
1193  if (k == Key::backslash)
1194  return SDLK_BACKSLASH;
1195  if (k == Key::rightBracket)
1196  return SDLK_RIGHTBRACKET;
1197  if (k == Key::caret)
1198  return SDLK_CARET;
1199  if (k == Key::underscore)
1200  return SDLK_UNDERSCORE;
1201  if (k == Key::backquote)
1202  return SDLK_BACKQUOTE;
1203  if (k == Key::a)
1204  return SDLK_a;
1205  if (k == Key::b)
1206  return SDLK_b;
1207  if (k == Key::c)
1208  return SDLK_c;
1209  if (k == Key::d)
1210  return SDLK_d;
1211  if (k == Key::e)
1212  return SDLK_e;
1213  if (k == Key::f)
1214  return SDLK_f;
1215  if (k == Key::g)
1216  return SDLK_g;
1217  if (k == Key::h)
1218  return SDLK_h;
1219  if (k == Key::i)
1220  return SDLK_i;
1221  if (k == Key::j)
1222  return SDLK_j;
1223  if (k == Key::k)
1224  return SDLK_k;
1225  if (k == Key::l)
1226  return SDLK_l;
1227  if (k == Key::m)
1228  return SDLK_m;
1229  if (k == Key::n)
1230  return SDLK_n;
1231  if (k == Key::o)
1232  return SDLK_o;
1233  if (k == Key::p)
1234  return SDLK_p;
1235  if (k == Key::q)
1236  return SDLK_q;
1237  if (k == Key::r)
1238  return SDLK_r;
1239  if (k == Key::s)
1240  return SDLK_s;
1241  if (k == Key::t)
1242  return SDLK_t;
1243  if (k == Key::u)
1244  return SDLK_u;
1245  if (k == Key::v)
1246  return SDLK_v;
1247  if (k == Key::w)
1248  return SDLK_w;
1249  if (k == Key::x)
1250  return SDLK_x;
1251  if (k == Key::y)
1252  return SDLK_y;
1253  if (k == Key::z)
1254  return SDLK_z;
1255 
1256  if (k == Key::capslock)
1257  return SDLK_CAPSLOCK;
1258 
1259  if (k == Key::f1)
1260  return SDLK_F1;
1261  if (k == Key::f2)
1262  return SDLK_F2;
1263  if (k == Key::f3)
1264  return SDLK_F3;
1265  if (k == Key::f4)
1266  return SDLK_F4;
1267  if (k == Key::f5)
1268  return SDLK_F5;
1269  if (k == Key::f6)
1270  return SDLK_F6;
1271  if (k == Key::f7)
1272  return SDLK_F7;
1273  if (k == Key::f8)
1274  return SDLK_F8;
1275  if (k == Key::f9)
1276  return SDLK_F9;
1277  if (k == Key::f10)
1278  return SDLK_F10;
1279  if (k == Key::f11)
1280  return SDLK_F11;
1281  if (k == Key::f12)
1282  return SDLK_F12;
1283 
1284  if (k == Key::printscreen)
1285  return SDLK_PRINTSCREEN;
1286  if (k == Key::scrolllock)
1287  return SDLK_SCROLLLOCK;
1288  if (k == Key::pause)
1289  return SDLK_PAUSE;
1290  if (k == Key::insert)
1291  return SDLK_INSERT;
1292  if (k == Key::home)
1293  return SDLK_HOME;
1294  if (k == Key::pageup)
1295  return SDLK_PAGEUP;
1296  if (k == Key::del)
1297  return SDLK_DELETE;
1298  if (k == Key::end)
1299  return SDLK_END;
1300  if (k == Key::pagedown)
1301  return SDLK_PAGEDOWN;
1302  if (k == Key::right)
1303  return SDLK_RIGHT;
1304  if (k == Key::left)
1305  return SDLK_LEFT;
1306  if (k == Key::down)
1307  return SDLK_DOWN;
1308  if (k == Key::up)
1309  return SDLK_UP;
1310 
1311  if (k == Key::numlock)
1312  return SDLK_NUMLOCKCLEAR;
1313  if (k == Key::kp_divide)
1314  return SDLK_KP_DIVIDE;
1315  if (k == Key::kp_multiply)
1316  return SDLK_KP_MULTIPLY;
1317  if (k == Key::kp_minus)
1318  return SDLK_KP_MINUS;
1319  if (k == Key::kp_plus)
1320  return SDLK_KP_PLUS;
1321  if (k == Key::kp_enter)
1322  return SDLK_KP_ENTER;
1323  if (k == Key::kp_1)
1324  return SDLK_KP_1;
1325  if (k == Key::kp_2)
1326  return SDLK_KP_2;
1327  if (k == Key::kp_3)
1328  return SDLK_KP_3;
1329  if (k == Key::kp_4)
1330  return SDLK_KP_4;
1331  if (k == Key::kp_5)
1332  return SDLK_KP_5;
1333  if (k == Key::kp_6)
1334  return SDLK_KP_6;
1335  if (k == Key::kp_7)
1336  return SDLK_KP_7;
1337  if (k == Key::kp_8)
1338  return SDLK_KP_8;
1339  if (k == Key::kp_9)
1340  return SDLK_KP_9;
1341  if (k == Key::kp_0)
1342  return SDLK_KP_0;
1343  if (k == Key::kp_period)
1344  return SDLK_KP_PERIOD;
1345 
1346  if (k == Key::app)
1347  return SDLK_APPLICATION;
1348  if (k == Key::power)
1349  return SDLK_POWER;
1350  if (k == Key::kp_eq)
1351  return SDLK_KP_EQUALS;
1352  if (k == Key::f13)
1353  return SDLK_F13;
1354  if (k == Key::f14)
1355  return SDLK_F14;
1356  if (k == Key::f15)
1357  return SDLK_F15;
1358  if (k == Key::f16)
1359  return SDLK_F16;
1360  if (k == Key::f17)
1361  return SDLK_F17;
1362  if (k == Key::f18)
1363  return SDLK_F18;
1364  if (k == Key::f19)
1365  return SDLK_F19;
1366  if (k == Key::f20)
1367  return SDLK_F20;
1368  if (k == Key::f21)
1369  return SDLK_F21;
1370  if (k == Key::f22)
1371  return SDLK_F22;
1372  if (k == Key::f23)
1373  return SDLK_F23;
1374  if (k == Key::f24)
1375  return SDLK_F24;
1376  if (k == Key::exec)
1377  return SDLK_EXECUTE;
1378  if (k == Key::help)
1379  return SDLK_HELP;
1380  if (k == Key::menu)
1381  return SDLK_MENU;
1382  if (k == Key::select)
1383  return SDLK_SELECT;
1384  if (k == Key::stop)
1385  return SDLK_STOP;
1386  if (k == Key::redo)
1387  return SDLK_AGAIN;
1388  if (k == Key::undo)
1389  return SDLK_UNDO;
1390  if (k == Key::cut)
1391  return SDLK_CUT;
1392  if (k == Key::copy)
1393  return SDLK_COPY;
1394  if (k == Key::paste)
1395  return SDLK_PASTE;
1396  if (k == Key::find)
1397  return SDLK_FIND;
1398  if (k == Key::mute)
1399  return SDLK_MUTE;
1400  if (k == Key::volumeUp)
1401  return SDLK_VOLUMEUP;
1402  if (k == Key::volumeDown)
1403  return SDLK_VOLUMEDOWN;
1404  if (k == Key::kp_comma)
1405  return SDLK_KP_COMMA;
1406  if (k == Key::kp_eqas400)
1407  return SDLK_KP_EQUALSAS400;
1408 
1409  if (k == Key::altErase)
1410  return SDLK_ALTERASE;
1411  if (k == Key::sysrq)
1412  return SDLK_SYSREQ;
1413  if (k == Key::cancel)
1414  return SDLK_CANCEL;
1415  if (k == Key::clear)
1416  return SDLK_CLEAR;
1417  if (k == Key::prior)
1418  return SDLK_PRIOR;
1419  if (k == Key::enter2)
1420  return SDLK_RETURN2;
1421  if (k == Key::separator)
1422  return SDLK_SEPARATOR;
1423  if (k == Key::out)
1424  return SDLK_OUT;
1425  if (k == Key::oper)
1426  return SDLK_OPER;
1427  if (k == Key::clearAgain)
1428  return SDLK_CLEARAGAIN;
1429  if (k == Key::crsel)
1430  return SDLK_CRSEL;
1431  if (k == Key::exsel)
1432  return SDLK_EXSEL;
1433 
1434  if (k == Key::kp_00)
1435  return SDLK_KP_00;
1436  if (k == Key::kp_000)
1437  return SDLK_KP_000;
1438  if (k == Key::thousandsSeparator)
1439  return SDLK_THOUSANDSSEPARATOR;
1440  if (k == Key::decimalSeparator)
1441  return SDLK_DECIMALSEPARATOR;
1442  if (k == Key::currency_unit)
1443  return SDLK_CURRENCYUNIT;
1444  if (k == Key::currency_subunit)
1445  return SDLK_CURRENCYSUBUNIT;
1446  if (k == Key::kp_leftParen)
1447  return SDLK_KP_LEFTPAREN;
1448  if (k == Key::kp_rightParen)
1449  return SDLK_KP_RIGHTPAREN;
1450  if (k == Key::kp_leftBrace)
1451  return SDLK_KP_LEFTBRACE;
1452  if (k == Key::kp_rightBrace)
1453  return SDLK_KP_RIGHTBRACE;
1454  if (k == Key::kp_tab)
1455  return SDLK_KP_TAB;
1456  if (k == Key::kp_backspace)
1457  return SDLK_KP_BACKSPACE;
1458  if (k == Key::kp_a)
1459  return SDLK_KP_A;
1460  if (k == Key::kp_b)
1461  return SDLK_KP_B;
1462  if (k == Key::kp_c)
1463  return SDLK_KP_C;
1464  if (k == Key::kp_d)
1465  return SDLK_KP_D;
1466  if (k == Key::kp_e)
1467  return SDLK_KP_E;
1468  if (k == Key::kp_f)
1469  return SDLK_KP_F;
1470  if (k == Key::kp_xor)
1471  return SDLK_KP_XOR;
1472  if (k == Key::kp_power)
1473  return SDLK_KP_POWER;
1474  if (k == Key::kp_percent)
1475  return SDLK_KP_PERCENT;
1476  if (k == Key::kp_less)
1477  return SDLK_KP_LESS;
1478  if (k == Key::kp_greater)
1479  return SDLK_KP_GREATER;
1480  if (k == Key::kp_ampersand)
1481  return SDLK_KP_AMPERSAND;
1482  if (k == Key::kp_doubleAmpersand)
1483  return SDLK_KP_DBLAMPERSAND;
1484  if (k == Key::kp_vbar)
1485  return SDLK_KP_VERTICALBAR;
1486  if (k == Key::kp_doubleVbar)
1487  return SDLK_KP_DBLVERTICALBAR;
1488  if (k == Key::kp_colon)
1489  return SDLK_KP_COLON;
1490  if (k == Key::kp_hash)
1491  return SDLK_KP_HASH;
1492  if (k == Key::kp_space)
1493  return SDLK_KP_SPACE;
1494  if (k == Key::kp_at)
1495  return SDLK_KP_AT;
1496  if (k == Key::kp_exclamationPoint)
1497  return SDLK_KP_EXCLAM;
1498  if (k == Key::kp_mem_store)
1499  return SDLK_KP_MEMSTORE;
1500  if (k == Key::kp_mem_recall)
1501  return SDLK_KP_MEMRECALL;
1502  if (k == Key::kp_mem_clear)
1503  return SDLK_KP_MEMCLEAR;
1504  if (k == Key::kp_mem_add)
1505  return SDLK_KP_MEMADD;
1506  if (k == Key::kp_mem_subtract)
1507  return SDLK_KP_MEMSUBTRACT;
1508  if (k == Key::kp_mem_multiply)
1509  return SDLK_KP_MEMMULTIPLY;
1510  if (k == Key::kp_mem_divide)
1511  return SDLK_KP_MEMDIVIDE;
1512  if (k == Key::kp_plusMinus)
1513  return SDLK_KP_PLUSMINUS;
1514  if (k == Key::kp_clear)
1515  return SDLK_KP_CLEAR;
1516  if (k == Key::kp_clearEntry)
1517  return SDLK_KP_CLEARENTRY;
1518  if (k == Key::kp_bin)
1519  return SDLK_KP_BINARY;
1520  if (k == Key::kp_octal)
1521  return SDLK_KP_OCTAL;
1522  if (k == Key::kp_decimal)
1523  return SDLK_KP_DECIMAL;
1524  if (k == Key::kp_hex)
1525  return SDLK_KP_HEXADECIMAL;
1526 
1527  if (k == Key::lctrl)
1528  return SDLK_LCTRL;
1529  if (k == Key::lshift)
1530  return SDLK_LSHIFT;
1531  if (k == Key::lalt)
1532  return SDLK_LALT;
1533  if (k == Key::lgui)
1534  return SDLK_LGUI;
1535  if (k == Key::rctrl)
1536  return SDLK_RCTRL;
1537  if (k == Key::rshift)
1538  return SDLK_RSHIFT;
1539  if (k == Key::ralt)
1540  return SDLK_RALT;
1541  if (k == Key::rgui)
1542  return SDLK_RGUI;
1543 
1544  if (k == Key::mode)
1545  return SDLK_MODE;
1546 
1547  if (k == Key::audio_next)
1548  return SDLK_AUDIONEXT;
1549  if (k == Key::audio_prev)
1550  return SDLK_AUDIOPREV;
1551  if (k == Key::audio_stop)
1552  return SDLK_AUDIOSTOP;
1553  if (k == Key::audio_play)
1554  return SDLK_AUDIOPLAY;
1555  if (k == Key::audio_mute)
1556  return SDLK_AUDIOMUTE;
1557  if (k == Key::mediaSelect)
1558  return SDLK_MEDIASELECT;
1559  if (k == Key::www)
1560  return SDLK_WWW;
1561  if (k == Key::mail)
1562  return SDLK_MAIL;
1563  if (k == Key::calculator)
1564  return SDLK_CALCULATOR;
1565  if (k == Key::computer)
1566  return SDLK_COMPUTER;
1567  if (k == Key::ac_search)
1568  return SDLK_AC_SEARCH;
1569  if (k == Key::ac_home)
1570  return SDLK_AC_HOME;
1571  if (k == Key::ac_back)
1572  return SDLK_AC_BACK;
1573  if (k == Key::ac_fwd)
1574  return SDLK_AC_FORWARD;
1575  if (k == Key::ac_stop)
1576  return SDLK_AC_STOP;
1577  if (k == Key::ac_refresh)
1578  return SDLK_AC_REFRESH;
1579  if (k == Key::ac_bookmarks)
1580  return SDLK_AC_BOOKMARKS;
1581 
1582  if (k == Key::brightnessDown)
1583  return SDLK_BRIGHTNESSDOWN;
1584  if (k == Key::brightnessUp)
1585  return SDLK_BRIGHTNESSUP;
1586  if (k == Key::displaySwitch)
1587  return SDLK_DISPLAYSWITCH;
1588  if (k == Key::kb_illum_toggle)
1589  return SDLK_KBDILLUMTOGGLE;
1590  if (k == Key::kb_illum_down)
1591  return SDLK_KBDILLUMDOWN;
1592  if (k == Key::kb_illum_up)
1593  return SDLK_KBDILLUMUP;
1594  if (k == Key::eject)
1595  return SDLK_EJECT;
1596  if (k == Key::sleep)
1597  return SDLK_SLEEP;
1598  if (k == Key::app1)
1599  return SDLK_APP1;
1600  if (k == Key::app2)
1601  return SDLK_APP2;
1602 
1603  if (k == Key::audio_rewind)
1604  return SDLK_AUDIOREWIND;
1605  if (k == Key::audio_fastforward)
1606  return SDLK_AUDIOFASTFORWARD;
1607 
1608  return SDLK_UNKNOWN;
1609  }
1610  }
1611 
1612  namespace scancode::unsafe {
1613  constexpr Scancode fromSDLEnum(const SDL_Scancode k) noexcept {
1614  if (k == SDL_SCANCODE_UNKNOWN)
1615  return Scancode::unknown;
1616 
1617  if (k == SDL_SCANCODE_A)
1618  return Scancode::a;
1619  if (k == SDL_SCANCODE_B)
1620  return Scancode::b;
1621  if (k == SDL_SCANCODE_C)
1622  return Scancode::c;
1623  if (k == SDL_SCANCODE_D)
1624  return Scancode::d;
1625  if (k == SDL_SCANCODE_E)
1626  return Scancode::e;
1627  if (k == SDL_SCANCODE_F)
1628  return Scancode::f;
1629  if (k == SDL_SCANCODE_G)
1630  return Scancode::g;
1631  if (k == SDL_SCANCODE_H)
1632  return Scancode::h;
1633  if (k == SDL_SCANCODE_I)
1634  return Scancode::i;
1635  if (k == SDL_SCANCODE_J)
1636  return Scancode::j;
1637  if (k == SDL_SCANCODE_K)
1638  return Scancode::k;
1639  if (k == SDL_SCANCODE_L)
1640  return Scancode::l;
1641  if (k == SDL_SCANCODE_M)
1642  return Scancode::m;
1643  if (k == SDL_SCANCODE_N)
1644  return Scancode::n;
1645  if (k == SDL_SCANCODE_O)
1646  return Scancode::o;
1647  if (k == SDL_SCANCODE_P)
1648  return Scancode::p;
1649  if (k == SDL_SCANCODE_Q)
1650  return Scancode::q;
1651  if (k == SDL_SCANCODE_R)
1652  return Scancode::r;
1653  if (k == SDL_SCANCODE_S)
1654  return Scancode::s;
1655  if (k == SDL_SCANCODE_T)
1656  return Scancode::t;
1657  if (k == SDL_SCANCODE_U)
1658  return Scancode::u;
1659  if (k == SDL_SCANCODE_V)
1660  return Scancode::v;
1661  if (k == SDL_SCANCODE_W)
1662  return Scancode::w;
1663  if (k == SDL_SCANCODE_X)
1664  return Scancode::x;
1665  if (k == SDL_SCANCODE_Y)
1666  return Scancode::y;
1667  if (k == SDL_SCANCODE_Z)
1668  return Scancode::z;
1669 
1670  if (k == SDL_SCANCODE_1)
1671  return Scancode::num_1;
1672  if (k == SDL_SCANCODE_2)
1673  return Scancode::num_2;
1674  if (k == SDL_SCANCODE_3)
1675  return Scancode::num_3;
1676  if (k == SDL_SCANCODE_4)
1677  return Scancode::num_4;
1678  if (k == SDL_SCANCODE_5)
1679  return Scancode::num_5;
1680  if (k == SDL_SCANCODE_6)
1681  return Scancode::num_6;
1682  if (k == SDL_SCANCODE_7)
1683  return Scancode::num_7;
1684  if (k == SDL_SCANCODE_8)
1685  return Scancode::num_8;
1686  if (k == SDL_SCANCODE_9)
1687  return Scancode::num_9;
1688  if (k == SDL_SCANCODE_0)
1689  return Scancode::num_0;
1690 
1691  if (k == SDL_SCANCODE_RETURN)
1692  return Scancode::enter;
1693  if (k == SDL_SCANCODE_ESCAPE)
1694  return Scancode::escape;
1695  if (k == SDL_SCANCODE_BACKSPACE)
1696  return Scancode::backspace;
1697  if (k == SDL_SCANCODE_TAB)
1698  return Scancode::tab;
1699  if (k == SDL_SCANCODE_SPACE)
1700  return Scancode::space;
1701 
1702  if (k == SDL_SCANCODE_MINUS)
1703  return Scancode::minus;
1704  if (k == SDL_SCANCODE_EQUALS)
1705  return Scancode::eq;
1706  if (k == SDL_SCANCODE_LEFTBRACKET)
1707  return Scancode::leftBracket;
1708  if (k == SDL_SCANCODE_RIGHTBRACKET)
1709  return Scancode::rightBracket;
1710  if (k == SDL_SCANCODE_BACKSLASH)
1711  return Scancode::backslash;
1712  if (k == SDL_SCANCODE_NONUSHASH)
1713  return Scancode::nonUsHash;
1714  if (k == SDL_SCANCODE_SEMICOLON)
1715  return Scancode::semicolon;
1716  if (k == SDL_SCANCODE_APOSTROPHE)
1717  return Scancode::apostrophe;
1718  if (k == SDL_SCANCODE_GRAVE)
1719  return Scancode::backquote;
1720  if (k == SDL_SCANCODE_COMMA)
1721  return Scancode::comma;
1722  if (k == SDL_SCANCODE_PERIOD)
1723  return Scancode::period;
1724  if (k == SDL_SCANCODE_SLASH)
1725  return Scancode::slash;
1726 
1727  if (k == SDL_SCANCODE_CAPSLOCK)
1728  return Scancode::capslock;
1729 
1730  if (k == SDL_SCANCODE_F1)
1731  return Scancode::f1;
1732  if (k == SDL_SCANCODE_F2)
1733  return Scancode::f2;
1734  if (k == SDL_SCANCODE_F3)
1735  return Scancode::f3;
1736  if (k == SDL_SCANCODE_F4)
1737  return Scancode::f4;
1738  if (k == SDL_SCANCODE_F5)
1739  return Scancode::f5;
1740  if (k == SDL_SCANCODE_F6)
1741  return Scancode::f6;
1742  if (k == SDL_SCANCODE_F7)
1743  return Scancode::f7;
1744  if (k == SDL_SCANCODE_F8)
1745  return Scancode::f8;
1746  if (k == SDL_SCANCODE_F9)
1747  return Scancode::f9;
1748  if (k == SDL_SCANCODE_F10)
1749  return Scancode::f10;
1750  if (k == SDL_SCANCODE_F11)
1751  return Scancode::f11;
1752  if (k == SDL_SCANCODE_F12)
1753  return Scancode::f12;
1754 
1755  if (k == SDL_SCANCODE_PRINTSCREEN)
1756  return Scancode::printscreen;
1757  if (k == SDL_SCANCODE_SCROLLLOCK)
1758  return Scancode::scrolllock;
1759  if (k == SDL_SCANCODE_PAUSE)
1760  return Scancode::pause;
1761  if (k == SDL_SCANCODE_INSERT)
1762  return Scancode::insert;
1763  if (k == SDL_SCANCODE_HOME)
1764  return Scancode::home;
1765  if (k == SDL_SCANCODE_PAGEUP)
1766  return Scancode::pageup;
1767  if (k == SDL_SCANCODE_DELETE)
1768  return Scancode::del;
1769  if (k == SDL_SCANCODE_END)
1770  return Scancode::end;
1771  if (k == SDL_SCANCODE_PAGEDOWN)
1772  return Scancode::pagedown;
1773  if (k == SDL_SCANCODE_RIGHT)
1774  return Scancode::right;
1775  if (k == SDL_SCANCODE_LEFT)
1776  return Scancode::left;
1777  if (k == SDL_SCANCODE_DOWN)
1778  return Scancode::down;
1779  if (k == SDL_SCANCODE_UP)
1780  return Scancode::up;
1781 
1782  if (k == SDL_SCANCODE_NUMLOCKCLEAR)
1783  return Scancode::numlock;
1784  if (k == SDL_SCANCODE_KP_DIVIDE)
1785  return Scancode::kp_divide;
1786  if (k == SDL_SCANCODE_KP_MULTIPLY)
1787  return Scancode::kp_multiply;
1788  if (k == SDL_SCANCODE_KP_MINUS)
1789  return Scancode::kp_minus;
1790  if (k == SDL_SCANCODE_KP_PLUS)
1791  return Scancode::kp_plus;
1792  if (k == SDL_SCANCODE_KP_ENTER)
1793  return Scancode::kp_enter;
1794  if (k == SDL_SCANCODE_KP_1)
1795  return Scancode::kp_1;
1796  if (k == SDL_SCANCODE_KP_2)
1797  return Scancode::kp_2;
1798  if (k == SDL_SCANCODE_KP_3)
1799  return Scancode::kp_3;
1800  if (k == SDL_SCANCODE_KP_4)
1801  return Scancode::kp_4;
1802  if (k == SDL_SCANCODE_KP_5)
1803  return Scancode::kp_5;
1804  if (k == SDL_SCANCODE_KP_6)
1805  return Scancode::kp_6;
1806  if (k == SDL_SCANCODE_KP_7)
1807  return Scancode::kp_7;
1808  if (k == SDL_SCANCODE_KP_8)
1809  return Scancode::kp_8;
1810  if (k == SDL_SCANCODE_KP_9)
1811  return Scancode::kp_9;
1812  if (k == SDL_SCANCODE_KP_0)
1813  return Scancode::kp_0;
1814  if (k == SDL_SCANCODE_KP_PERIOD)
1815  return Scancode::kp_period;
1816 
1817  if (k == SDL_SCANCODE_NONUSBACKSLASH)
1818  return Scancode::nonUsBackslash;
1819  if (k == SDL_SCANCODE_APPLICATION)
1820  return Scancode::app;
1821  if (k == SDL_SCANCODE_POWER)
1822  return Scancode::power;
1823  if (k == SDL_SCANCODE_KP_EQUALS)
1824  return Scancode::kp_eq;
1825  if (k == SDL_SCANCODE_F13)
1826  return Scancode::f13;
1827  if (k == SDL_SCANCODE_F14)
1828  return Scancode::f14;
1829  if (k == SDL_SCANCODE_F15)
1830  return Scancode::f15;
1831  if (k == SDL_SCANCODE_F16)
1832  return Scancode::f16;
1833  if (k == SDL_SCANCODE_F17)
1834  return Scancode::f17;
1835  if (k == SDL_SCANCODE_F18)
1836  return Scancode::f18;
1837  if (k == SDL_SCANCODE_F19)
1838  return Scancode::f19;
1839  if (k == SDL_SCANCODE_F20)
1840  return Scancode::f20;
1841  if (k == SDL_SCANCODE_F21)
1842  return Scancode::f21;
1843  if (k == SDL_SCANCODE_F22)
1844  return Scancode::f22;
1845  if (k == SDL_SCANCODE_F23)
1846  return Scancode::f23;
1847  if (k == SDL_SCANCODE_F24)
1848  return Scancode::f24;
1849  if (k == SDL_SCANCODE_EXECUTE)
1850  return Scancode::exec;
1851  if (k == SDL_SCANCODE_HELP)
1852  return Scancode::help;
1853  if (k == SDL_SCANCODE_MENU)
1854  return Scancode::menu;
1855  if (k == SDL_SCANCODE_SELECT)
1856  return Scancode::select;
1857  if (k == SDL_SCANCODE_STOP)
1858  return Scancode::stop;
1859  if (k == SDL_SCANCODE_AGAIN)
1860  return Scancode::redo;
1861  if (k == SDL_SCANCODE_UNDO)
1862  return Scancode::undo;
1863  if (k == SDL_SCANCODE_CUT)
1864  return Scancode::cut;
1865  if (k == SDL_SCANCODE_COPY)
1866  return Scancode::copy;
1867  if (k == SDL_SCANCODE_PASTE)
1868  return Scancode::paste;
1869  if (k == SDL_SCANCODE_FIND)
1870  return Scancode::find;
1871  if (k == SDL_SCANCODE_MUTE)
1872  return Scancode::mute;
1873  if (k == SDL_SCANCODE_VOLUMEUP)
1874  return Scancode::volumeUp;
1875  if (k == SDL_SCANCODE_VOLUMEDOWN)
1876  return Scancode::volumeDown;
1877  if (k == SDL_SCANCODE_KP_COMMA)
1878  return Scancode::kp_comma;
1879  if (k == SDL_SCANCODE_KP_EQUALSAS400)
1880  return Scancode::kp_eqas400;
1881 
1882  if (k == SDL_SCANCODE_INTERNATIONAL1)
1883  return Scancode::internat_1;
1884  if (k == SDL_SCANCODE_INTERNATIONAL2)
1885  return Scancode::internat_2;
1886  if (k == SDL_SCANCODE_INTERNATIONAL3)
1887  return Scancode::internat_3;
1888  if (k == SDL_SCANCODE_INTERNATIONAL4)
1889  return Scancode::internat_4;
1890  if (k == SDL_SCANCODE_INTERNATIONAL5)
1891  return Scancode::internat_5;
1892  if (k == SDL_SCANCODE_INTERNATIONAL6)
1893  return Scancode::internat_6;
1894  if (k == SDL_SCANCODE_INTERNATIONAL7)
1895  return Scancode::internat_7;
1896  if (k == SDL_SCANCODE_INTERNATIONAL8)
1897  return Scancode::internat_8;
1898  if (k == SDL_SCANCODE_INTERNATIONAL9)
1899  return Scancode::internat_9;
1900  if (k == SDL_SCANCODE_LANG1)
1901  return Scancode::lang_1;
1902  if (k == SDL_SCANCODE_LANG2)
1903  return Scancode::lang_2;
1904  if (k == SDL_SCANCODE_LANG3)
1905  return Scancode::lang_3;
1906  if (k == SDL_SCANCODE_LANG4)
1907  return Scancode::lang_4;
1908  if (k == SDL_SCANCODE_LANG5)
1909  return Scancode::lang_5;
1910  if (k == SDL_SCANCODE_LANG6)
1911  return Scancode::lang_6;
1912  if (k == SDL_SCANCODE_LANG7)
1913  return Scancode::lang_7;
1914  if (k == SDL_SCANCODE_LANG8)
1915  return Scancode::lang_8;
1916  if (k == SDL_SCANCODE_LANG9)
1917  return Scancode::lang_9;
1918 
1919  if (k == SDL_SCANCODE_ALTERASE)
1920  return Scancode::altErase;
1921  if (k == SDL_SCANCODE_SYSREQ)
1922  return Scancode::sysrq;
1923  if (k == SDL_SCANCODE_CANCEL)
1924  return Scancode::cancel;
1925  if (k == SDL_SCANCODE_CLEAR)
1926  return Scancode::clear;
1927  if (k == SDL_SCANCODE_PRIOR)
1928  return Scancode::prior;
1929  if (k == SDL_SCANCODE_RETURN2)
1930  return Scancode::enter2;
1931  if (k == SDL_SCANCODE_SEPARATOR)
1932  return Scancode::separator;
1933  if (k == SDL_SCANCODE_OUT)
1934  return Scancode::out;
1935  if (k == SDL_SCANCODE_OPER)
1936  return Scancode::oper;
1937  if (k == SDL_SCANCODE_CLEARAGAIN)
1938  return Scancode::clearAgain;
1939  if (k == SDL_SCANCODE_CRSEL)
1940  return Scancode::crsel;
1941  if (k == SDL_SCANCODE_EXSEL)
1942  return Scancode::exsel;
1943 
1944  if (k == SDL_SCANCODE_KP_00)
1945  return Scancode::kp_00;
1946  if (k == SDL_SCANCODE_KP_000)
1947  return Scancode::kp_000;
1948  if (k == SDL_SCANCODE_THOUSANDSSEPARATOR)
1949  return Scancode::thousandsSeparator;
1950  if (k == SDL_SCANCODE_DECIMALSEPARATOR)
1951  return Scancode::decimalSeparator;
1952  if (k == SDL_SCANCODE_CURRENCYUNIT)
1953  return Scancode::currency_unit;
1954  if (k == SDL_SCANCODE_CURRENCYSUBUNIT)
1955  return Scancode::currency_subunit;
1956  if (k == SDL_SCANCODE_KP_LEFTPAREN)
1957  return Scancode::kp_leftParen;
1958  if (k == SDL_SCANCODE_KP_RIGHTPAREN)
1959  return Scancode::kp_rightParen;
1960  if (k == SDL_SCANCODE_KP_LEFTBRACE)
1961  return Scancode::kp_leftBrace;
1962  if (k == SDL_SCANCODE_KP_RIGHTBRACE)
1963  return Scancode::kp_rightBrace;
1964  if (k == SDL_SCANCODE_KP_TAB)
1965  return Scancode::kp_tab;
1966  if (k == SDL_SCANCODE_KP_BACKSPACE)
1967  return Scancode::kp_backspace;
1968  if (k == SDL_SCANCODE_KP_A)
1969  return Scancode::kp_a;
1970  if (k == SDL_SCANCODE_KP_B)
1971  return Scancode::kp_b;
1972  if (k == SDL_SCANCODE_KP_C)
1973  return Scancode::kp_c;
1974  if (k == SDL_SCANCODE_KP_D)
1975  return Scancode::kp_d;
1976  if (k == SDL_SCANCODE_KP_E)
1977  return Scancode::kp_e;
1978  if (k == SDL_SCANCODE_KP_F)
1979  return Scancode::kp_f;
1980  if (k == SDL_SCANCODE_KP_XOR)
1981  return Scancode::kp_xor;
1982  if (k == SDL_SCANCODE_KP_POWER)
1983  return Scancode::kp_power;
1984  if (k == SDL_SCANCODE_KP_PERCENT)
1985  return Scancode::kp_percent;
1986  if (k == SDL_SCANCODE_KP_LESS)
1987  return Scancode::kp_less;
1988  if (k == SDL_SCANCODE_KP_GREATER)
1989  return Scancode::kp_greater;
1990  if (k == SDL_SCANCODE_KP_AMPERSAND)
1991  return Scancode::kp_ampersand;
1992  if (k == SDL_SCANCODE_KP_DBLAMPERSAND)
1993  return Scancode::kp_doubleAmpersand;
1994  if (k == SDL_SCANCODE_KP_VERTICALBAR)
1995  return Scancode::kp_vbar;
1996  if (k == SDL_SCANCODE_KP_DBLVERTICALBAR)
1997  return Scancode::kp_doubleVbar;
1998  if (k == SDL_SCANCODE_KP_COLON)
1999  return Scancode::kp_colon;
2000  if (k == SDL_SCANCODE_KP_HASH)
2001  return Scancode::kp_hash;
2002  if (k == SDL_SCANCODE_KP_SPACE)
2003  return Scancode::kp_space;
2004  if (k == SDL_SCANCODE_KP_AT)
2005  return Scancode::kp_at;
2006  if (k == SDL_SCANCODE_KP_EXCLAM)
2007  return Scancode::kp_exclamationPoint;
2008  if (k == SDL_SCANCODE_KP_MEMSTORE)
2009  return Scancode::kp_mem_store;
2010  if (k == SDL_SCANCODE_KP_MEMRECALL)
2011  return Scancode::kp_mem_recall;
2012  if (k == SDL_SCANCODE_KP_MEMCLEAR)
2013  return Scancode::kp_mem_clear;
2014  if (k == SDL_SCANCODE_KP_MEMADD)
2015  return Scancode::kp_mem_add;
2016  if (k == SDL_SCANCODE_KP_MEMSUBTRACT)
2017  return Scancode::kp_mem_subtract;
2018  if (k == SDL_SCANCODE_KP_MEMMULTIPLY)
2019  return Scancode::kp_mem_multiply;
2020  if (k == SDL_SCANCODE_KP_MEMDIVIDE)
2021  return Scancode::kp_mem_divide;
2022  if (k == SDL_SCANCODE_KP_PLUSMINUS)
2023  return Scancode::kp_plusMinus;
2024  if (k == SDL_SCANCODE_KP_CLEAR)
2025  return Scancode::kp_mem_clear;
2026  if (k == SDL_SCANCODE_KP_CLEARENTRY)
2027  return Scancode::kp_clearEntry;
2028  if (k == SDL_SCANCODE_KP_BINARY)
2029  return Scancode::kp_bin;
2030  if (k == SDL_SCANCODE_KP_OCTAL)
2031  return Scancode::kp_octal;
2032  if (k == SDL_SCANCODE_KP_DECIMAL)
2033  return Scancode::kp_decimal;
2034  if (k == SDL_SCANCODE_KP_HEXADECIMAL)
2035  return Scancode::kp_hex;
2036 
2037  if (k == SDL_SCANCODE_LCTRL)
2038  return Scancode::lctrl;
2039  if (k == SDL_SCANCODE_LSHIFT)
2040  return Scancode::lshift;
2041  if (k == SDL_SCANCODE_LALT)
2042  return Scancode::lalt;
2043  if (k == SDL_SCANCODE_LGUI)
2044  return Scancode::lgui;
2045  if (k == SDL_SCANCODE_RCTRL)
2046  return Scancode::rctrl;
2047  if (k == SDL_SCANCODE_RSHIFT)
2048  return Scancode::rshift;
2049  if (k == SDL_SCANCODE_RALT)
2050  return Scancode::ralt;
2051  if (k == SDL_SCANCODE_RGUI)
2052  return Scancode::rgui;
2053 
2054  if (k == SDL_SCANCODE_MODE)
2055  return Scancode::mode;
2056 
2057  if (k == SDL_SCANCODE_AUDIONEXT)
2058  return Scancode::audio_next;
2059  if (k == SDL_SCANCODE_AUDIOPREV)
2060  return Scancode::audio_prev;
2061  if (k == SDL_SCANCODE_AUDIOSTOP)
2062  return Scancode::audio_stop;
2063  if (k == SDL_SCANCODE_AUDIOPLAY)
2064  return Scancode::audio_play;
2065  if (k == SDL_SCANCODE_AUDIOMUTE)
2066  return Scancode::audio_mute;
2067  if (k == SDL_SCANCODE_MEDIASELECT)
2068  return Scancode::mediaSelect;
2069  if (k == SDL_SCANCODE_WWW)
2070  return Scancode::www;
2071  if (k == SDL_SCANCODE_MAIL)
2072  return Scancode::mail;
2073  if (k == SDL_SCANCODE_CALCULATOR)
2074  return Scancode::calculator;
2075  if (k == SDL_SCANCODE_COMPUTER)
2076  return Scancode::computer;
2077  if (k == SDL_SCANCODE_AC_SEARCH)
2078  return Scancode::ac_search;
2079  if (k == SDL_SCANCODE_AC_HOME)
2080  return Scancode::ac_home;
2081  if (k == SDL_SCANCODE_AC_BACK)
2082  return Scancode::ac_back;
2083  if (k == SDL_SCANCODE_AC_FORWARD)
2084  return Scancode::ac_fwd;
2085  if (k == SDL_SCANCODE_AC_STOP)
2086  return Scancode::ac_stop;
2087  if (k == SDL_SCANCODE_AC_REFRESH)
2088  return Scancode::ac_refresh;
2089  if (k == SDL_SCANCODE_AC_BOOKMARKS)
2090  return Scancode::ac_bookmarks;
2091 
2092  if (k == SDL_SCANCODE_BRIGHTNESSDOWN)
2093  return Scancode::brightnessDown;
2094  if (k == SDL_SCANCODE_BRIGHTNESSUP)
2095  return Scancode::brightnessUp;
2096  if (k == SDL_SCANCODE_DISPLAYSWITCH)
2097  return Scancode::displaySwitch;
2098  if (k == SDL_SCANCODE_KBDILLUMTOGGLE)
2099  return Scancode::kb_illum_toggle;
2100  if (k == SDL_SCANCODE_KBDILLUMDOWN)
2101  return Scancode::kb_illum_down;
2102  if (k == SDL_SCANCODE_KBDILLUMUP)
2103  return Scancode::kb_illum_up;
2104  if (k == SDL_SCANCODE_EJECT)
2105  return Scancode::eject;
2106  if (k == SDL_SCANCODE_SLEEP)
2107  return Scancode::sleep;
2108 
2109  if (k == SDL_SCANCODE_APP1)
2110  return Scancode::app1;
2111  if (k == SDL_SCANCODE_APP2)
2112  return Scancode::app2;
2113 
2114  if (k == SDL_SCANCODE_AUDIOREWIND)
2115  return Scancode::audio_rewind;
2116  if (k == SDL_SCANCODE_AUDIOFASTFORWARD)
2117  return Scancode::audio_fastforward;
2118 
2119  return Scancode::unknown;
2120  }
2121  constexpr SDL_Scancode toSDLEnum(const Scancode k) noexcept {
2122  if (k == Scancode::unknown)
2123  return SDL_SCANCODE_UNKNOWN;
2124 
2125  if (k == Scancode::a)
2126  return SDL_SCANCODE_A;
2127  if (k == Scancode::b)
2128  return SDL_SCANCODE_B;
2129  if (k == Scancode::c)
2130  return SDL_SCANCODE_C;
2131  if (k == Scancode::d)
2132  return SDL_SCANCODE_D;
2133  if (k == Scancode::e)
2134  return SDL_SCANCODE_E;
2135  if (k == Scancode::f)
2136  return SDL_SCANCODE_F;
2137  if (k == Scancode::g)
2138  return SDL_SCANCODE_G;
2139  if (k == Scancode::h)
2140  return SDL_SCANCODE_H;
2141  if (k == Scancode::i)
2142  return SDL_SCANCODE_I;
2143  if (k == Scancode::j)
2144  return SDL_SCANCODE_J;
2145  if (k == Scancode::k)
2146  return SDL_SCANCODE_K;
2147  if (k == Scancode::l)
2148  return SDL_SCANCODE_L;
2149  if (k == Scancode::m)
2150  return SDL_SCANCODE_M;
2151  if (k == Scancode::n)
2152  return SDL_SCANCODE_N;
2153  if (k == Scancode::o)
2154  return SDL_SCANCODE_O;
2155  if (k == Scancode::p)
2156  return SDL_SCANCODE_P;
2157  if (k == Scancode::q)
2158  return SDL_SCANCODE_Q;
2159  if (k == Scancode::r)
2160  return SDL_SCANCODE_R;
2161  if (k == Scancode::s)
2162  return SDL_SCANCODE_S;
2163  if (k == Scancode::t)
2164  return SDL_SCANCODE_T;
2165  if (k == Scancode::u)
2166  return SDL_SCANCODE_U;
2167  if (k == Scancode::v)
2168  return SDL_SCANCODE_V;
2169  if (k == Scancode::w)
2170  return SDL_SCANCODE_W;
2171  if (k == Scancode::x)
2172  return SDL_SCANCODE_X;
2173  if (k == Scancode::y)
2174  return SDL_SCANCODE_Y;
2175  if (k == Scancode::z)
2176  return SDL_SCANCODE_Z;
2177 
2178  if (k == Scancode::num_1)
2179  return SDL_SCANCODE_1;
2180  if (k == Scancode::num_2)
2181  return SDL_SCANCODE_2;
2182  if (k == Scancode::num_3)
2183  return SDL_SCANCODE_3;
2184  if (k == Scancode::num_4)
2185  return SDL_SCANCODE_4;
2186  if (k == Scancode::num_5)
2187  return SDL_SCANCODE_5;
2188  if (k == Scancode::num_6)
2189  return SDL_SCANCODE_6;
2190  if (k == Scancode::num_7)
2191  return SDL_SCANCODE_7;
2192  if (k == Scancode::num_8)
2193  return SDL_SCANCODE_8;
2194  if (k == Scancode::num_9)
2195  return SDL_SCANCODE_9;
2196  if (k == Scancode::num_0)
2197  return SDL_SCANCODE_0;
2198 
2199  if (k == Scancode::enter)
2200  return SDL_SCANCODE_RETURN;
2201  if (k == Scancode::escape)
2202  return SDL_SCANCODE_ESCAPE;
2203  if (k == Scancode::backspace)
2204  return SDL_SCANCODE_BACKSPACE;
2205  if (k == Scancode::tab)
2206  return SDL_SCANCODE_TAB;
2207  if (k == Scancode::space)
2208  return SDL_SCANCODE_SPACE;
2209 
2210  if (k == Scancode::minus)
2211  return SDL_SCANCODE_MINUS;
2212  if (k == Scancode::eq)
2213  return SDL_SCANCODE_EQUALS;
2214  if (k == Scancode::leftBracket)
2215  return SDL_SCANCODE_LEFTBRACKET;
2216  if (k == Scancode::rightBracket)
2217  return SDL_SCANCODE_RIGHTBRACKET;
2218  if (k == Scancode::backslash)
2219  return SDL_SCANCODE_BACKSLASH;
2220  if (k == Scancode::nonUsHash)
2221  return SDL_SCANCODE_NONUSHASH;
2222  if (k == Scancode::semicolon)
2223  return SDL_SCANCODE_SEMICOLON;
2224  if (k == Scancode::apostrophe)
2225  return SDL_SCANCODE_APOSTROPHE;
2226  if (k == Scancode::backquote)
2227  return SDL_SCANCODE_GRAVE;
2228  if (k == Scancode::comma)
2229  return SDL_SCANCODE_COMMA;
2230  if (k == Scancode::period)
2231  return SDL_SCANCODE_PERIOD;
2232  if (k == Scancode::slash)
2233  return SDL_SCANCODE_SLASH;
2234 
2235  if (k == Scancode::capslock)
2236  return SDL_SCANCODE_CAPSLOCK;
2237 
2238  if (k == Scancode::f1)
2239  return SDL_SCANCODE_F1;
2240  if (k == Scancode::f2)
2241  return SDL_SCANCODE_F2;
2242  if (k == Scancode::f3)
2243  return SDL_SCANCODE_F3;
2244  if (k == Scancode::f4)
2245  return SDL_SCANCODE_F4;
2246  if (k == Scancode::f5)
2247  return SDL_SCANCODE_F5;
2248  if (k == Scancode::f6)
2249  return SDL_SCANCODE_F6;
2250  if (k == Scancode::f7)
2251  return SDL_SCANCODE_F7;
2252  if (k == Scancode::f8)
2253  return SDL_SCANCODE_F8;
2254  if (k == Scancode::f9)
2255  return SDL_SCANCODE_F9;
2256  if (k == Scancode::f10)
2257  return SDL_SCANCODE_F10;
2258  if (k == Scancode::f11)
2259  return SDL_SCANCODE_F11;
2260  if (k == Scancode::f12)
2261  return SDL_SCANCODE_F12;
2262 
2263  if (k == Scancode::printscreen)
2264  return SDL_SCANCODE_PRINTSCREEN;
2265  if (k == Scancode::scrolllock)
2266  return SDL_SCANCODE_SCROLLLOCK;
2267  if (k == Scancode::pause)
2268  return SDL_SCANCODE_PAUSE;
2269  if (k == Scancode::insert)
2270  return SDL_SCANCODE_INSERT;
2271  if (k == Scancode::home)
2272  return SDL_SCANCODE_HOME;
2273  if (k == Scancode::pageup)
2274  return SDL_SCANCODE_PAGEUP;
2275  if (k == Scancode::del)
2276  return SDL_SCANCODE_DELETE;
2277  if (k == Scancode::end)
2278  return SDL_SCANCODE_END;
2279  if (k == Scancode::pagedown)
2280  return SDL_SCANCODE_PAGEDOWN;
2281  if (k == Scancode::right)
2282  return SDL_SCANCODE_RIGHT;
2283  if (k == Scancode::left)
2284  return SDL_SCANCODE_LEFT;
2285  if (k == Scancode::down)
2286  return SDL_SCANCODE_DOWN;
2287  if (k == Scancode::up)
2288  return SDL_SCANCODE_UP;
2289 
2290  if (k == Scancode::numlock)
2291  return SDL_SCANCODE_NUMLOCKCLEAR;
2292  if (k == Scancode::kp_divide)
2293  return SDL_SCANCODE_KP_DIVIDE;
2294  if (k == Scancode::kp_multiply)
2295  return SDL_SCANCODE_KP_MULTIPLY;
2296  if (k == Scancode::kp_minus)
2297  return SDL_SCANCODE_KP_MINUS;
2298  if (k == Scancode::kp_plus)
2299  return SDL_SCANCODE_KP_PLUS;
2300  if (k == Scancode::kp_enter)
2301  return SDL_SCANCODE_KP_ENTER;
2302  if (k == Scancode::kp_1)
2303  return SDL_SCANCODE_KP_1;
2304  if (k == Scancode::kp_2)
2305  return SDL_SCANCODE_KP_2;
2306  if (k == Scancode::kp_3)
2307  return SDL_SCANCODE_KP_3;
2308  if (k == Scancode::kp_4)
2309  return SDL_SCANCODE_KP_4;
2310  if (k == Scancode::kp_5)
2311  return SDL_SCANCODE_KP_5;
2312  if (k == Scancode::kp_6)
2313  return SDL_SCANCODE_KP_6;
2314  if (k == Scancode::kp_7)
2315  return SDL_SCANCODE_KP_7;
2316  if (k == Scancode::kp_8)
2317  return SDL_SCANCODE_KP_8;
2318  if (k == Scancode::kp_9)
2319  return SDL_SCANCODE_KP_9;
2320  if (k == Scancode::kp_0)
2321  return SDL_SCANCODE_KP_0;
2322  if (k == Scancode::kp_period)
2323  return SDL_SCANCODE_KP_PERIOD;
2324 
2325  if (k == Scancode::nonUsBackslash)
2326  return SDL_SCANCODE_NONUSBACKSLASH;
2327  if (k == Scancode::app)
2328  return SDL_SCANCODE_APPLICATION;
2329  if (k == Scancode::power)
2330  return SDL_SCANCODE_POWER;
2331  if (k == Scancode::kp_eq)
2332  return SDL_SCANCODE_KP_EQUALS;
2333  if (k == Scancode::f13)
2334  return SDL_SCANCODE_F13;
2335  if (k == Scancode::f14)
2336  return SDL_SCANCODE_F14;
2337  if (k == Scancode::f15)
2338  return SDL_SCANCODE_F15;
2339  if (k == Scancode::f16)
2340  return SDL_SCANCODE_F16;
2341  if (k == Scancode::f17)
2342  return SDL_SCANCODE_F17;
2343  if (k == Scancode::f18)
2344  return SDL_SCANCODE_F18;
2345  if (k == Scancode::f19)
2346  return SDL_SCANCODE_F19;
2347  if (k == Scancode::f20)
2348  return SDL_SCANCODE_F20;
2349  if (k == Scancode::f21)
2350  return SDL_SCANCODE_F21;
2351  if (k == Scancode::f22)
2352  return SDL_SCANCODE_F22;
2353  if (k == Scancode::f23)
2354  return SDL_SCANCODE_F23;
2355  if (k == Scancode::f24)
2356  return SDL_SCANCODE_F24;
2357  if (k == Scancode::exec)
2358  return SDL_SCANCODE_EXECUTE;
2359  if (k == Scancode::help)
2360  return SDL_SCANCODE_HELP;
2361  if (k == Scancode::menu)
2362  return SDL_SCANCODE_MENU;
2363  if (k == Scancode::select)
2364  return SDL_SCANCODE_SELECT;
2365  if (k == Scancode::stop)
2366  return SDL_SCANCODE_STOP;
2367  if (k == Scancode::redo)
2368  return SDL_SCANCODE_AGAIN;
2369  if (k == Scancode::undo)
2370  return SDL_SCANCODE_UNDO;
2371  if (k == Scancode::cut)
2372  return SDL_SCANCODE_CUT;
2373  if (k == Scancode::copy)
2374  return SDL_SCANCODE_COPY;
2375  if (k == Scancode::paste)
2376  return SDL_SCANCODE_PASTE;
2377  if (k == Scancode::find)
2378  return SDL_SCANCODE_FIND;
2379  if (k == Scancode::mute)
2380  return SDL_SCANCODE_MUTE;
2381  if (k == Scancode::volumeUp)
2382  return SDL_SCANCODE_VOLUMEUP;
2383  if (k == Scancode::volumeDown)
2384  return SDL_SCANCODE_VOLUMEDOWN;
2385  if (k == Scancode::kp_comma)
2386  return SDL_SCANCODE_KP_COMMA;
2387  if (k == Scancode::kp_eqas400)
2388  return SDL_SCANCODE_KP_EQUALSAS400;
2389 
2390  if (k == Scancode::internat_1)
2391  return SDL_SCANCODE_INTERNATIONAL1;
2392  if (k == Scancode::internat_2)
2393  return SDL_SCANCODE_INTERNATIONAL2;
2394  if (k == Scancode::internat_3)
2395  return SDL_SCANCODE_INTERNATIONAL3;
2396  if (k == Scancode::internat_4)
2397  return SDL_SCANCODE_INTERNATIONAL4;
2398  if (k == Scancode::internat_5)
2399  return SDL_SCANCODE_INTERNATIONAL5;
2400  if (k == Scancode::internat_6)
2401  return SDL_SCANCODE_INTERNATIONAL6;
2402  if (k == Scancode::internat_7)
2403  return SDL_SCANCODE_INTERNATIONAL7;
2404  if (k == Scancode::internat_8)
2405  return SDL_SCANCODE_INTERNATIONAL8;
2406  if (k == Scancode::internat_9)
2407  return SDL_SCANCODE_INTERNATIONAL9;
2408  if (k == Scancode::lang_1)
2409  return SDL_SCANCODE_LANG1;
2410  if (k == Scancode::lang_2)
2411  return SDL_SCANCODE_LANG2;
2412  if (k == Scancode::lang_3)
2413  return SDL_SCANCODE_LANG3;
2414  if (k == Scancode::lang_4)
2415  return SDL_SCANCODE_LANG4;
2416  if (k == Scancode::lang_5)
2417  return SDL_SCANCODE_LANG5;
2418  if (k == Scancode::lang_6)
2419  return SDL_SCANCODE_LANG6;
2420  if (k == Scancode::lang_7)
2421  return SDL_SCANCODE_LANG7;
2422  if (k == Scancode::lang_8)
2423  return SDL_SCANCODE_LANG8;
2424  if (k == Scancode::lang_9)
2425  return SDL_SCANCODE_LANG9;
2426 
2427  if (k == Scancode::altErase)
2428  return SDL_SCANCODE_ALTERASE;
2429  if (k == Scancode::sysrq)
2430  return SDL_SCANCODE_SYSREQ;
2431  if (k == Scancode::cancel)
2432  return SDL_SCANCODE_CANCEL;
2433  if (k == Scancode::clear)
2434  return SDL_SCANCODE_CLEAR;
2435  if (k == Scancode::prior)
2436  return SDL_SCANCODE_PRIOR;
2437  if (k == Scancode::enter2)
2438  return SDL_SCANCODE_RETURN2;
2439  if (k == Scancode::separator)
2440  return SDL_SCANCODE_SEPARATOR;
2441  if (k == Scancode::out)
2442  return SDL_SCANCODE_OUT;
2443  if (k == Scancode::oper)
2444  return SDL_SCANCODE_OPER;
2445  if (k == Scancode::clearAgain)
2446  return SDL_SCANCODE_CLEARAGAIN;
2447  if (k == Scancode::crsel)
2448  return SDL_SCANCODE_CRSEL;
2449  if (k == Scancode::exsel)
2450  return SDL_SCANCODE_EXSEL;
2451 
2452  if (k == Scancode::kp_00)
2453  return SDL_SCANCODE_KP_00;
2454  if (k == Scancode::kp_000)
2455  return SDL_SCANCODE_KP_000;
2456  if (k == Scancode::thousandsSeparator)
2457  return SDL_SCANCODE_THOUSANDSSEPARATOR;
2458  if (k == Scancode::decimalSeparator)
2459  return SDL_SCANCODE_DECIMALSEPARATOR;
2460  if (k == Scancode::currency_unit)
2461  return SDL_SCANCODE_CURRENCYUNIT;
2462  if (k == Scancode::currency_subunit)
2463  return SDL_SCANCODE_CURRENCYSUBUNIT;
2464  if (k == Scancode::kp_leftParen)
2465  return SDL_SCANCODE_KP_LEFTPAREN;
2466  if (k == Scancode::kp_rightParen)
2467  return SDL_SCANCODE_KP_RIGHTPAREN;
2468  if (k == Scancode::kp_leftBrace)
2469  return SDL_SCANCODE_KP_LEFTBRACE;
2470  if (k == Scancode::kp_rightBrace)
2471  return SDL_SCANCODE_KP_RIGHTBRACE;
2472  if (k == Scancode::kp_tab)
2473  return SDL_SCANCODE_KP_TAB;
2474  if (k == Scancode::kp_backspace)
2475  return SDL_SCANCODE_KP_BACKSPACE;
2476  if (k == Scancode::kp_a)
2477  return SDL_SCANCODE_KP_A;
2478  if (k == Scancode::kp_b)
2479  return SDL_SCANCODE_KP_B;
2480  if (k == Scancode::kp_c)
2481  return SDL_SCANCODE_KP_C;
2482  if (k == Scancode::kp_d)
2483  return SDL_SCANCODE_KP_D;
2484  if (k == Scancode::kp_e)
2485  return SDL_SCANCODE_KP_E;
2486  if (k == Scancode::kp_f)
2487  return SDL_SCANCODE_KP_F;
2488  if (k == Scancode::kp_xor)
2489  return SDL_SCANCODE_KP_XOR;
2490  if (k == Scancode::kp_power)
2491  return SDL_SCANCODE_KP_POWER;
2492  if (k == Scancode::kp_percent)
2493  return SDL_SCANCODE_KP_PERCENT;
2494  if (k == Scancode::kp_less)
2495  return SDL_SCANCODE_KP_LESS;
2496  if (k == Scancode::kp_greater)
2497  return SDL_SCANCODE_KP_GREATER;
2498  if (k == Scancode::kp_ampersand)
2499  return SDL_SCANCODE_KP_AMPERSAND;
2500  if (k == Scancode::kp_doubleAmpersand)
2501  return SDL_SCANCODE_KP_DBLAMPERSAND;
2502  if (k == Scancode::kp_vbar)
2503  return SDL_SCANCODE_KP_VERTICALBAR;
2504  if (k == Scancode::kp_doubleVbar)
2505  return SDL_SCANCODE_KP_DBLVERTICALBAR;
2506  if (k == Scancode::kp_colon)
2507  return SDL_SCANCODE_KP_COLON;
2508  if (k == Scancode::kp_hash)
2509  return SDL_SCANCODE_KP_HASH;
2510  if (k == Scancode::kp_space)
2511  return SDL_SCANCODE_KP_SPACE;
2512  if (k == Scancode::kp_at)
2513  return SDL_SCANCODE_KP_AT;
2514  if (k == Scancode::kp_exclamationPoint)
2515  return SDL_SCANCODE_KP_EXCLAM;
2516  if (k == Scancode::kp_mem_store)
2517  return SDL_SCANCODE_KP_MEMSTORE;
2518  if (k == Scancode::kp_mem_recall)
2519  return SDL_SCANCODE_KP_MEMRECALL;
2520  if (k == Scancode::kp_mem_clear)
2521  return SDL_SCANCODE_KP_MEMCLEAR;
2522  if (k == Scancode::kp_mem_add)
2523  return SDL_SCANCODE_KP_MEMADD;
2524  if (k == Scancode::kp_mem_subtract)
2525  return SDL_SCANCODE_KP_MEMSUBTRACT;
2526  if (k == Scancode::kp_mem_multiply)
2527  return SDL_SCANCODE_KP_MEMMULTIPLY;
2528  if (k == Scancode::kp_mem_divide)
2529  return SDL_SCANCODE_KP_MEMDIVIDE;
2530  if (k == Scancode::kp_plusMinus)
2531  return SDL_SCANCODE_KP_PLUSMINUS;
2532  if (k == Scancode::kp_mem_clear)
2533  return SDL_SCANCODE_KP_CLEAR;
2534  if (k == Scancode::kp_clearEntry)
2535  return SDL_SCANCODE_KP_CLEARENTRY;
2536  if (k == Scancode::kp_bin)
2537  return SDL_SCANCODE_KP_BINARY;
2538  if (k == Scancode::kp_octal)
2539  return SDL_SCANCODE_KP_OCTAL;
2540  if (k == Scancode::kp_decimal)
2541  return SDL_SCANCODE_KP_DECIMAL;
2542  if (k == Scancode::kp_hex)
2543  return SDL_SCANCODE_KP_HEXADECIMAL;
2544 
2545  if (k == Scancode::lctrl)
2546  return SDL_SCANCODE_LCTRL;
2547  if (k == Scancode::lshift)
2548  return SDL_SCANCODE_LSHIFT;
2549  if (k == Scancode::lalt)
2550  return SDL_SCANCODE_LALT;
2551  if (k == Scancode::lgui)
2552  return SDL_SCANCODE_LGUI;
2553  if (k == Scancode::rctrl)
2554  return SDL_SCANCODE_RCTRL;
2555  if (k == Scancode::rshift)
2556  return SDL_SCANCODE_RSHIFT;
2557  if (k == Scancode::ralt)
2558  return SDL_SCANCODE_RALT;
2559  if (k == Scancode::rgui)
2560  return SDL_SCANCODE_RGUI;
2561 
2562  if (k == Scancode::mode)
2563  return SDL_SCANCODE_MODE;
2564 
2565  if (k == Scancode::audio_next)
2566  return SDL_SCANCODE_AUDIONEXT;
2567  if (k == Scancode::audio_prev)
2568  return SDL_SCANCODE_AUDIOPREV;
2569  if (k == Scancode::audio_stop)
2570  return SDL_SCANCODE_AUDIOSTOP;
2571  if (k == Scancode::audio_play)
2572  return SDL_SCANCODE_AUDIOPLAY;
2573  if (k == Scancode::audio_mute)
2574  return SDL_SCANCODE_AUDIOMUTE;
2575  if (k == Scancode::mediaSelect)
2576  return SDL_SCANCODE_MEDIASELECT;
2577  if (k == Scancode::www)
2578  return SDL_SCANCODE_WWW;
2579  if (k == Scancode::mail)
2580  return SDL_SCANCODE_MAIL;
2581  if (k == Scancode::calculator)
2582  return SDL_SCANCODE_CALCULATOR;
2583  if (k == Scancode::computer)
2584  return SDL_SCANCODE_COMPUTER;
2585  if (k == Scancode::ac_search)
2586  return SDL_SCANCODE_AC_SEARCH;
2587  if (k == Scancode::ac_home)
2588  return SDL_SCANCODE_AC_HOME;
2589  if (k == Scancode::ac_back)
2590  return SDL_SCANCODE_AC_BACK;
2591  if (k == Scancode::ac_fwd)
2592  return SDL_SCANCODE_AC_FORWARD;
2593  if (k == Scancode::ac_stop)
2594  return SDL_SCANCODE_AC_STOP;
2595  if (k == Scancode::ac_refresh)
2596  return SDL_SCANCODE_AC_REFRESH;
2597  if (k == Scancode::ac_bookmarks)
2598  return SDL_SCANCODE_AC_BOOKMARKS;
2599 
2600  if (k == Scancode::brightnessDown)
2601  return SDL_SCANCODE_BRIGHTNESSDOWN;
2602  if (k == Scancode::brightnessUp)
2603  return SDL_SCANCODE_BRIGHTNESSUP;
2604  if (k == Scancode::displaySwitch)
2605  return SDL_SCANCODE_DISPLAYSWITCH;
2606  if (k == Scancode::kb_illum_toggle)
2607  return SDL_SCANCODE_KBDILLUMTOGGLE;
2608  if (k == Scancode::kb_illum_down)
2609  return SDL_SCANCODE_KBDILLUMDOWN;
2610  if (k == Scancode::kb_illum_up)
2611  return SDL_SCANCODE_KBDILLUMUP;
2612  if (k == Scancode::eject)
2613  return SDL_SCANCODE_EJECT;
2614  if (k == Scancode::sleep)
2615  return SDL_SCANCODE_SLEEP;
2616 
2617  if (k == Scancode::app1)
2618  return SDL_SCANCODE_APP1;
2619  if (k == Scancode::app2)
2620  return SDL_SCANCODE_APP2;
2621 
2622  if (k == Scancode::audio_rewind)
2623  return SDL_SCANCODE_AUDIOREWIND;
2624  if (k == Scancode::audio_fastforward)
2625  return SDL_SCANCODE_AUDIOFASTFORWARD;
2626 
2627  return SDL_SCANCODE_UNKNOWN;
2628  }
2629  }
2630 }
std::find
T find(T... args)
std::copy
T copy(T... args)
std::experimental::filesystem::space
T space(T... args)
std::left
T left(T... args)
rolmodl::kb::key::Name
Definition: Kb.hpp:34
rolmodl::kb::State
Definition: Kb.hpp:6
std::end
T end(T... args)