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
//! Actual scan codes corresponded to virtual key codes.

#![allow(missing_docs)]

use crate::bind;

use super::key_code::KeyCode;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum ScanCode {
    Unknown,
    A,
    B,
    C,
    D,
    E,
    F,
    G,
    H,
    I,
    J,
    K,
    L,
    M,
    N,
    O,
    P,
    Q,
    R,
    S,
    T,
    U,
    V,
    W,
    X,
    Y,
    Z,
    Num1,
    Num2,
    Num3,
    Num4,
    Num5,
    Num6,
    Num7,
    Num8,
    Num9,
    Num0,
    Return,
    Escape,
    Backspace,
    Tab,
    Space,
    Minus,
    Equals,
    LeftBracket,
    RightBracket,
    Backslash,
    NonUsHash,
    Semicolon,
    Apostrophe,
    Grave,
    Comma,
    Period,
    Slash,
    CapsLock,
    F1,
    F2,
    F3,
    F4,
    F5,
    F6,
    F7,
    F8,
    F9,
    F10,
    F11,
    F12,
    PrintScreen,
    ScrollLock,
    Pause,
    Insert,
    Home,
    PageUp,
    Delete,
    End,
    PageDown,
    Right,
    Left,
    Down,
    Up,
    NumLockClear,
    KeypadDivide,
    KeypadMultiply,
    KeypadMinus,
    KeypadPlus,
    KeypadEnter,
    Keypad1,
    Keypad2,
    Keypad3,
    Keypad4,
    Keypad5,
    Keypad6,
    Keypad7,
    Keypad8,
    Keypad9,
    Keypad0,
    KeypadPeriod,
    NonUsBackslash,
    Application,
    Power,
    KeypadEquals,
    F13,
    F14,
    F15,
    F16,
    F17,
    F18,
    F19,
    F20,
    F21,
    F22,
    F23,
    F24,
    Execute,
    Help,
    Menu,
    Select,
    Stop,
    Again,
    Undo,
    Cut,
    Copy,
    Paste,
    Find,
    Mute,
    VolumeUp,
    VolumeDown,
    KeypadComma,
    KeypadEqualsAs400,
    International1,
    International2,
    International3,
    International4,
    International5,
    International6,
    International7,
    International8,
    International9,
    Lang1,
    Lang2,
    Lang3,
    Lang4,
    Lang5,
    Lang6,
    Lang7,
    Lang8,
    Lang9,
    AltErase,
    SysReq,
    Cancel,
    Clear,
    Prior,
    Return2,
    Separator,
    Out,
    Oper,
    ClearAgain,
    CrSel,
    ExSel,
    Keypad00,
    Keypad000,
    ThousandsSeparator,
    DecimalSeparator,
    CurrencyUnit,
    CurrencySubunit,
    KeypadLeftParen,
    KeypadRightParen,
    KeypadLeftBrace,
    KeypadRightBrace,
    KeypadTab,
    KeypadBackspace,
    KeypadA,
    KeypadB,
    KeypadC,
    KeypadD,
    KeypadE,
    KeypadF,
    KeypadXor,
    KeypadPower,
    KeypadPercent,
    KeypadLess,
    KeypadGreater,
    KeypadAmpersand,
    KeypadDblAmpersand,
    KeypadVerticalBar,
    KeypadDblVerticalBar,
    KeypadColon,
    KeypadHash,
    KeypadSpace,
    KeypadAt,
    KeypadExclam,
    KeypadMemStore,
    KeypadMemRecall,
    KeypadMemClear,
    KeypadMemAdd,
    KeypadMemSubtract,
    KeypadMemMultiply,
    KeypadMemDivide,
    KeypadPlusMinus,
    KeypadClear,
    KeypadClearEntry,
    KeypadBinary,
    KeypadOctal,
    KeypadDecimal,
    KeypadHexadecimal,
    LCtrl,
    LShift,
    LAlt,
    LGui,
    RCtrl,
    RShift,
    RAlt,
    RGui,
    Mode,
    AudioNext,
    AudioPrev,
    AudioStop,
    AudioPlay,
    AudioMute,
    MediaSelect,
    Www,
    Mail,
    Calculator,
    Computer,
    ApplicationSearch,
    ApplicationHome,
    ApplicationBack,
    ApplicationForward,
    ApplicationStop,
    ApplicationRefresh,
    ApplicationBookmarks,
    BrightnessDown,
    BrightnessUp,
    DisplaySwitch,
    KeyboardIllumToggle,
    KeyboardIllumDown,
    KeyboardIllumUp,
    Eject,
    Sleep,
    App1,
    App2,
    AudioRewind,
    AudioFastForward,
}

pub const NUM_SCANCODES: u16 = 512;

impl ScanCode {
    pub(crate) fn as_raw(self) -> bind::SDL_Scancode {
        match self {
            ScanCode::Unknown => bind::SDL_SCANCODE_UNKNOWN,
            ScanCode::A => bind::SDL_SCANCODE_A,
            ScanCode::B => bind::SDL_SCANCODE_B,
            ScanCode::C => bind::SDL_SCANCODE_C,
            ScanCode::D => bind::SDL_SCANCODE_D,
            ScanCode::E => bind::SDL_SCANCODE_E,
            ScanCode::F => bind::SDL_SCANCODE_F,
            ScanCode::G => bind::SDL_SCANCODE_G,
            ScanCode::H => bind::SDL_SCANCODE_H,
            ScanCode::I => bind::SDL_SCANCODE_I,
            ScanCode::J => bind::SDL_SCANCODE_J,
            ScanCode::K => bind::SDL_SCANCODE_K,
            ScanCode::L => bind::SDL_SCANCODE_L,
            ScanCode::M => bind::SDL_SCANCODE_M,
            ScanCode::N => bind::SDL_SCANCODE_N,
            ScanCode::O => bind::SDL_SCANCODE_O,
            ScanCode::P => bind::SDL_SCANCODE_P,
            ScanCode::Q => bind::SDL_SCANCODE_Q,
            ScanCode::R => bind::SDL_SCANCODE_R,
            ScanCode::S => bind::SDL_SCANCODE_S,
            ScanCode::T => bind::SDL_SCANCODE_T,
            ScanCode::U => bind::SDL_SCANCODE_U,
            ScanCode::V => bind::SDL_SCANCODE_V,
            ScanCode::W => bind::SDL_SCANCODE_W,
            ScanCode::X => bind::SDL_SCANCODE_X,
            ScanCode::Y => bind::SDL_SCANCODE_Y,
            ScanCode::Z => bind::SDL_SCANCODE_Z,
            ScanCode::Num1 => bind::SDL_SCANCODE_1,
            ScanCode::Num2 => bind::SDL_SCANCODE_2,
            ScanCode::Num3 => bind::SDL_SCANCODE_3,
            ScanCode::Num4 => bind::SDL_SCANCODE_4,
            ScanCode::Num5 => bind::SDL_SCANCODE_5,
            ScanCode::Num6 => bind::SDL_SCANCODE_6,
            ScanCode::Num7 => bind::SDL_SCANCODE_7,
            ScanCode::Num8 => bind::SDL_SCANCODE_8,
            ScanCode::Num9 => bind::SDL_SCANCODE_9,
            ScanCode::Num0 => bind::SDL_SCANCODE_0,
            ScanCode::Return => bind::SDL_SCANCODE_RETURN,
            ScanCode::Escape => bind::SDL_SCANCODE_ESCAPE,
            ScanCode::Backspace => bind::SDL_SCANCODE_BACKSPACE,
            ScanCode::Tab => bind::SDL_SCANCODE_TAB,
            ScanCode::Space => bind::SDL_SCANCODE_SPACE,
            ScanCode::Minus => bind::SDL_SCANCODE_MINUS,
            ScanCode::Equals => bind::SDL_SCANCODE_EQUALS,
            ScanCode::LeftBracket => bind::SDL_SCANCODE_LEFTBRACKET,
            ScanCode::RightBracket => bind::SDL_SCANCODE_RIGHTBRACKET,
            ScanCode::Backslash => bind::SDL_SCANCODE_BACKSLASH,
            ScanCode::NonUsHash => bind::SDL_SCANCODE_NONUSHASH,
            ScanCode::Semicolon => bind::SDL_SCANCODE_SEMICOLON,
            ScanCode::Apostrophe => bind::SDL_SCANCODE_APOSTROPHE,
            ScanCode::Grave => bind::SDL_SCANCODE_GRAVE,
            ScanCode::Comma => bind::SDL_SCANCODE_COMMA,
            ScanCode::Period => bind::SDL_SCANCODE_PERIOD,
            ScanCode::Slash => bind::SDL_SCANCODE_SLASH,
            ScanCode::CapsLock => bind::SDL_SCANCODE_CAPSLOCK,
            ScanCode::F1 => bind::SDL_SCANCODE_F1,
            ScanCode::F2 => bind::SDL_SCANCODE_F2,
            ScanCode::F3 => bind::SDL_SCANCODE_F3,
            ScanCode::F4 => bind::SDL_SCANCODE_F4,
            ScanCode::F5 => bind::SDL_SCANCODE_F5,
            ScanCode::F6 => bind::SDL_SCANCODE_F6,
            ScanCode::F7 => bind::SDL_SCANCODE_F7,
            ScanCode::F8 => bind::SDL_SCANCODE_F8,
            ScanCode::F9 => bind::SDL_SCANCODE_F9,
            ScanCode::F10 => bind::SDL_SCANCODE_F10,
            ScanCode::F11 => bind::SDL_SCANCODE_F11,
            ScanCode::F12 => bind::SDL_SCANCODE_F12,
            ScanCode::PrintScreen => bind::SDL_SCANCODE_PRINTSCREEN,
            ScanCode::ScrollLock => bind::SDL_SCANCODE_SCROLLLOCK,
            ScanCode::Pause => bind::SDL_SCANCODE_PAUSE,
            ScanCode::Insert => bind::SDL_SCANCODE_INSERT,
            ScanCode::Home => bind::SDL_SCANCODE_HOME,
            ScanCode::PageUp => bind::SDL_SCANCODE_PAGEUP,
            ScanCode::Delete => bind::SDL_SCANCODE_DELETE,
            ScanCode::End => bind::SDL_SCANCODE_END,
            ScanCode::PageDown => bind::SDL_SCANCODE_PAGEDOWN,
            ScanCode::Right => bind::SDL_SCANCODE_RIGHT,
            ScanCode::Left => bind::SDL_SCANCODE_LEFT,
            ScanCode::Down => bind::SDL_SCANCODE_DOWN,
            ScanCode::Up => bind::SDL_SCANCODE_UP,
            ScanCode::NumLockClear => bind::SDL_SCANCODE_NUMLOCKCLEAR,
            ScanCode::KeypadDivide => bind::SDL_SCANCODE_KP_DIVIDE,
            ScanCode::KeypadMultiply => bind::SDL_SCANCODE_KP_MULTIPLY,
            ScanCode::KeypadMinus => bind::SDL_SCANCODE_KP_MINUS,
            ScanCode::KeypadPlus => bind::SDL_SCANCODE_KP_PLUS,
            ScanCode::KeypadEnter => bind::SDL_SCANCODE_KP_ENTER,
            ScanCode::Keypad1 => bind::SDL_SCANCODE_KP_1,
            ScanCode::Keypad2 => bind::SDL_SCANCODE_KP_2,
            ScanCode::Keypad3 => bind::SDL_SCANCODE_KP_3,
            ScanCode::Keypad4 => bind::SDL_SCANCODE_KP_4,
            ScanCode::Keypad5 => bind::SDL_SCANCODE_KP_5,
            ScanCode::Keypad6 => bind::SDL_SCANCODE_KP_6,
            ScanCode::Keypad7 => bind::SDL_SCANCODE_KP_7,
            ScanCode::Keypad8 => bind::SDL_SCANCODE_KP_8,
            ScanCode::Keypad9 => bind::SDL_SCANCODE_KP_9,
            ScanCode::Keypad0 => bind::SDL_SCANCODE_KP_0,
            ScanCode::KeypadPeriod => bind::SDL_SCANCODE_KP_PERIOD,
            ScanCode::NonUsBackslash => bind::SDL_SCANCODE_NONUSBACKSLASH,
            ScanCode::Application => bind::SDL_SCANCODE_APPLICATION,
            ScanCode::Power => bind::SDL_SCANCODE_POWER,
            ScanCode::KeypadEquals => bind::SDL_SCANCODE_KP_EQUALS,
            ScanCode::F13 => bind::SDL_SCANCODE_F13,
            ScanCode::F14 => bind::SDL_SCANCODE_F14,
            ScanCode::F15 => bind::SDL_SCANCODE_F15,
            ScanCode::F16 => bind::SDL_SCANCODE_F16,
            ScanCode::F17 => bind::SDL_SCANCODE_F17,
            ScanCode::F18 => bind::SDL_SCANCODE_F18,
            ScanCode::F19 => bind::SDL_SCANCODE_F19,
            ScanCode::F20 => bind::SDL_SCANCODE_F20,
            ScanCode::F21 => bind::SDL_SCANCODE_F21,
            ScanCode::F22 => bind::SDL_SCANCODE_F22,
            ScanCode::F23 => bind::SDL_SCANCODE_F23,
            ScanCode::F24 => bind::SDL_SCANCODE_F24,
            ScanCode::Execute => bind::SDL_SCANCODE_EXECUTE,
            ScanCode::Help => bind::SDL_SCANCODE_HELP,
            ScanCode::Menu => bind::SDL_SCANCODE_MENU,
            ScanCode::Select => bind::SDL_SCANCODE_SELECT,
            ScanCode::Stop => bind::SDL_SCANCODE_STOP,
            ScanCode::Again => bind::SDL_SCANCODE_AGAIN,
            ScanCode::Undo => bind::SDL_SCANCODE_UNDO,
            ScanCode::Cut => bind::SDL_SCANCODE_CUT,
            ScanCode::Copy => bind::SDL_SCANCODE_COPY,
            ScanCode::Paste => bind::SDL_SCANCODE_PASTE,
            ScanCode::Find => bind::SDL_SCANCODE_FIND,
            ScanCode::Mute => bind::SDL_SCANCODE_MUTE,
            ScanCode::VolumeUp => bind::SDL_SCANCODE_VOLUMEUP,
            ScanCode::VolumeDown => bind::SDL_SCANCODE_VOLUMEDOWN,
            ScanCode::KeypadComma => bind::SDL_SCANCODE_KP_COMMA,
            ScanCode::KeypadEqualsAs400 => bind::SDL_SCANCODE_KP_EQUALSAS400,
            ScanCode::International1 => bind::SDL_SCANCODE_INTERNATIONAL1,
            ScanCode::International2 => bind::SDL_SCANCODE_INTERNATIONAL2,
            ScanCode::International3 => bind::SDL_SCANCODE_INTERNATIONAL3,
            ScanCode::International4 => bind::SDL_SCANCODE_INTERNATIONAL4,
            ScanCode::International5 => bind::SDL_SCANCODE_INTERNATIONAL5,
            ScanCode::International6 => bind::SDL_SCANCODE_INTERNATIONAL6,
            ScanCode::International7 => bind::SDL_SCANCODE_INTERNATIONAL7,
            ScanCode::International8 => bind::SDL_SCANCODE_INTERNATIONAL8,
            ScanCode::International9 => bind::SDL_SCANCODE_INTERNATIONAL9,
            ScanCode::Lang1 => bind::SDL_SCANCODE_LANG1,
            ScanCode::Lang2 => bind::SDL_SCANCODE_LANG2,
            ScanCode::Lang3 => bind::SDL_SCANCODE_LANG3,
            ScanCode::Lang4 => bind::SDL_SCANCODE_LANG4,
            ScanCode::Lang5 => bind::SDL_SCANCODE_LANG5,
            ScanCode::Lang6 => bind::SDL_SCANCODE_LANG6,
            ScanCode::Lang7 => bind::SDL_SCANCODE_LANG7,
            ScanCode::Lang8 => bind::SDL_SCANCODE_LANG8,
            ScanCode::Lang9 => bind::SDL_SCANCODE_LANG9,
            ScanCode::AltErase => bind::SDL_SCANCODE_ALTERASE,
            ScanCode::SysReq => bind::SDL_SCANCODE_SYSREQ,
            ScanCode::Cancel => bind::SDL_SCANCODE_CANCEL,
            ScanCode::Clear => bind::SDL_SCANCODE_CLEAR,
            ScanCode::Prior => bind::SDL_SCANCODE_PRIOR,
            ScanCode::Return2 => bind::SDL_SCANCODE_RETURN2,
            ScanCode::Separator => bind::SDL_SCANCODE_SEPARATOR,
            ScanCode::Out => bind::SDL_SCANCODE_OUT,
            ScanCode::Oper => bind::SDL_SCANCODE_OPER,
            ScanCode::ClearAgain => bind::SDL_SCANCODE_CLEARAGAIN,
            ScanCode::CrSel => bind::SDL_SCANCODE_CRSEL,
            ScanCode::ExSel => bind::SDL_SCANCODE_EXSEL,
            ScanCode::Keypad00 => bind::SDL_SCANCODE_KP_00,
            ScanCode::Keypad000 => bind::SDL_SCANCODE_KP_000,
            ScanCode::ThousandsSeparator => bind::SDL_SCANCODE_THOUSANDSSEPARATOR,
            ScanCode::DecimalSeparator => bind::SDL_SCANCODE_DECIMALSEPARATOR,
            ScanCode::CurrencyUnit => bind::SDL_SCANCODE_CURRENCYUNIT,
            ScanCode::CurrencySubunit => bind::SDL_SCANCODE_CURRENCYSUBUNIT,
            ScanCode::KeypadLeftParen => bind::SDL_SCANCODE_KP_LEFTPAREN,
            ScanCode::KeypadRightParen => bind::SDL_SCANCODE_KP_RIGHTPAREN,
            ScanCode::KeypadLeftBrace => bind::SDL_SCANCODE_KP_LEFTBRACE,
            ScanCode::KeypadRightBrace => bind::SDL_SCANCODE_KP_RIGHTBRACE,
            ScanCode::KeypadTab => bind::SDL_SCANCODE_KP_TAB,
            ScanCode::KeypadBackspace => bind::SDL_SCANCODE_KP_BACKSPACE,
            ScanCode::KeypadA => bind::SDL_SCANCODE_KP_A,
            ScanCode::KeypadB => bind::SDL_SCANCODE_KP_B,
            ScanCode::KeypadC => bind::SDL_SCANCODE_KP_C,
            ScanCode::KeypadD => bind::SDL_SCANCODE_KP_D,
            ScanCode::KeypadE => bind::SDL_SCANCODE_KP_E,
            ScanCode::KeypadF => bind::SDL_SCANCODE_KP_F,
            ScanCode::KeypadXor => bind::SDL_SCANCODE_KP_XOR,
            ScanCode::KeypadPower => bind::SDL_SCANCODE_KP_POWER,
            ScanCode::KeypadPercent => bind::SDL_SCANCODE_KP_PERCENT,
            ScanCode::KeypadLess => bind::SDL_SCANCODE_KP_LESS,
            ScanCode::KeypadGreater => bind::SDL_SCANCODE_KP_GREATER,
            ScanCode::KeypadAmpersand => bind::SDL_SCANCODE_KP_AMPERSAND,
            ScanCode::KeypadDblAmpersand => bind::SDL_SCANCODE_KP_DBLAMPERSAND,
            ScanCode::KeypadVerticalBar => bind::SDL_SCANCODE_KP_VERTICALBAR,
            ScanCode::KeypadDblVerticalBar => bind::SDL_SCANCODE_KP_DBLVERTICALBAR,
            ScanCode::KeypadColon => bind::SDL_SCANCODE_KP_COLON,
            ScanCode::KeypadHash => bind::SDL_SCANCODE_KP_HASH,
            ScanCode::KeypadSpace => bind::SDL_SCANCODE_KP_SPACE,
            ScanCode::KeypadAt => bind::SDL_SCANCODE_KP_AT,
            ScanCode::KeypadExclam => bind::SDL_SCANCODE_KP_EXCLAM,
            ScanCode::KeypadMemStore => bind::SDL_SCANCODE_KP_MEMSTORE,
            ScanCode::KeypadMemRecall => bind::SDL_SCANCODE_KP_MEMRECALL,
            ScanCode::KeypadMemClear => bind::SDL_SCANCODE_KP_MEMCLEAR,
            ScanCode::KeypadMemAdd => bind::SDL_SCANCODE_KP_MEMADD,
            ScanCode::KeypadMemSubtract => bind::SDL_SCANCODE_KP_MEMSUBTRACT,
            ScanCode::KeypadMemMultiply => bind::SDL_SCANCODE_KP_MEMMULTIPLY,
            ScanCode::KeypadMemDivide => bind::SDL_SCANCODE_KP_MEMDIVIDE,
            ScanCode::KeypadPlusMinus => bind::SDL_SCANCODE_KP_PLUSMINUS,
            ScanCode::KeypadClear => bind::SDL_SCANCODE_KP_CLEAR,
            ScanCode::KeypadClearEntry => bind::SDL_SCANCODE_KP_CLEARENTRY,
            ScanCode::KeypadBinary => bind::SDL_SCANCODE_KP_BINARY,
            ScanCode::KeypadOctal => bind::SDL_SCANCODE_KP_OCTAL,
            ScanCode::KeypadDecimal => bind::SDL_SCANCODE_KP_DECIMAL,
            ScanCode::KeypadHexadecimal => bind::SDL_SCANCODE_KP_HEXADECIMAL,
            ScanCode::LCtrl => bind::SDL_SCANCODE_LCTRL,
            ScanCode::LShift => bind::SDL_SCANCODE_LSHIFT,
            ScanCode::LAlt => bind::SDL_SCANCODE_LALT,
            ScanCode::LGui => bind::SDL_SCANCODE_LGUI,
            ScanCode::RCtrl => bind::SDL_SCANCODE_RCTRL,
            ScanCode::RShift => bind::SDL_SCANCODE_RSHIFT,
            ScanCode::RAlt => bind::SDL_SCANCODE_RALT,
            ScanCode::RGui => bind::SDL_SCANCODE_RGUI,
            ScanCode::Mode => bind::SDL_SCANCODE_MODE,
            ScanCode::AudioNext => bind::SDL_SCANCODE_AUDIONEXT,
            ScanCode::AudioPrev => bind::SDL_SCANCODE_AUDIOPREV,
            ScanCode::AudioStop => bind::SDL_SCANCODE_AUDIOSTOP,
            ScanCode::AudioPlay => bind::SDL_SCANCODE_AUDIOPLAY,
            ScanCode::AudioMute => bind::SDL_SCANCODE_AUDIOMUTE,
            ScanCode::MediaSelect => bind::SDL_SCANCODE_MEDIASELECT,
            ScanCode::Www => bind::SDL_SCANCODE_WWW,
            ScanCode::Mail => bind::SDL_SCANCODE_MAIL,
            ScanCode::Calculator => bind::SDL_SCANCODE_CALCULATOR,
            ScanCode::Computer => bind::SDL_SCANCODE_COMPUTER,
            ScanCode::ApplicationSearch => bind::SDL_SCANCODE_AC_SEARCH,
            ScanCode::ApplicationHome => bind::SDL_SCANCODE_AC_HOME,
            ScanCode::ApplicationBack => bind::SDL_SCANCODE_AC_BACK,
            ScanCode::ApplicationForward => bind::SDL_SCANCODE_AC_FORWARD,
            ScanCode::ApplicationStop => bind::SDL_SCANCODE_AC_STOP,
            ScanCode::ApplicationRefresh => bind::SDL_SCANCODE_AC_REFRESH,
            ScanCode::ApplicationBookmarks => bind::SDL_SCANCODE_AC_BOOKMARKS,
            ScanCode::BrightnessDown => bind::SDL_SCANCODE_BRIGHTNESSDOWN,
            ScanCode::BrightnessUp => bind::SDL_SCANCODE_BRIGHTNESSUP,
            ScanCode::DisplaySwitch => bind::SDL_SCANCODE_DISPLAYSWITCH,
            ScanCode::KeyboardIllumToggle => bind::SDL_SCANCODE_KBDILLUMTOGGLE,
            ScanCode::KeyboardIllumDown => bind::SDL_SCANCODE_KBDILLUMDOWN,
            ScanCode::KeyboardIllumUp => bind::SDL_SCANCODE_KBDILLUMUP,
            ScanCode::Eject => bind::SDL_SCANCODE_EJECT,
            ScanCode::Sleep => bind::SDL_SCANCODE_SLEEP,
            ScanCode::App1 => bind::SDL_SCANCODE_APP1,
            ScanCode::App2 => bind::SDL_SCANCODE_APP2,
            ScanCode::AudioRewind => bind::SDL_SCANCODE_AUDIOREWIND,
            ScanCode::AudioFastForward => bind::SDL_SCANCODE_AUDIOFASTFORWARD,
        }
    }
}

impl From<KeyCode> for ScanCode {
    fn from(key_code: KeyCode) -> Self {
        unsafe { bind::SDL_GetScancodeFromKey(key_code.as_raw()) }.into()
    }
}

impl From<bind::SDL_Scancode> for ScanCode {
    fn from(code: bind::SDL_Scancode) -> Self {
        match code {
            bind::SDL_SCANCODE_A => ScanCode::A,
            bind::SDL_SCANCODE_B => ScanCode::B,
            bind::SDL_SCANCODE_C => ScanCode::C,
            bind::SDL_SCANCODE_D => ScanCode::D,
            bind::SDL_SCANCODE_E => ScanCode::E,
            bind::SDL_SCANCODE_F => ScanCode::F,
            bind::SDL_SCANCODE_G => ScanCode::G,
            bind::SDL_SCANCODE_H => ScanCode::H,
            bind::SDL_SCANCODE_I => ScanCode::I,
            bind::SDL_SCANCODE_J => ScanCode::J,
            bind::SDL_SCANCODE_K => ScanCode::K,
            bind::SDL_SCANCODE_L => ScanCode::L,
            bind::SDL_SCANCODE_M => ScanCode::M,
            bind::SDL_SCANCODE_N => ScanCode::N,
            bind::SDL_SCANCODE_O => ScanCode::O,
            bind::SDL_SCANCODE_P => ScanCode::P,
            bind::SDL_SCANCODE_Q => ScanCode::Q,
            bind::SDL_SCANCODE_R => ScanCode::R,
            bind::SDL_SCANCODE_S => ScanCode::S,
            bind::SDL_SCANCODE_T => ScanCode::T,
            bind::SDL_SCANCODE_U => ScanCode::U,
            bind::SDL_SCANCODE_V => ScanCode::V,
            bind::SDL_SCANCODE_W => ScanCode::W,
            bind::SDL_SCANCODE_X => ScanCode::X,
            bind::SDL_SCANCODE_Y => ScanCode::Y,
            bind::SDL_SCANCODE_Z => ScanCode::Z,
            bind::SDL_SCANCODE_1 => ScanCode::Num1,
            bind::SDL_SCANCODE_2 => ScanCode::Num2,
            bind::SDL_SCANCODE_3 => ScanCode::Num3,
            bind::SDL_SCANCODE_4 => ScanCode::Num4,
            bind::SDL_SCANCODE_5 => ScanCode::Num5,
            bind::SDL_SCANCODE_6 => ScanCode::Num6,
            bind::SDL_SCANCODE_7 => ScanCode::Num7,
            bind::SDL_SCANCODE_8 => ScanCode::Num8,
            bind::SDL_SCANCODE_9 => ScanCode::Num9,
            bind::SDL_SCANCODE_0 => ScanCode::Num0,
            bind::SDL_SCANCODE_RETURN => ScanCode::Return,
            bind::SDL_SCANCODE_ESCAPE => ScanCode::Escape,
            bind::SDL_SCANCODE_BACKSPACE => ScanCode::Backspace,
            bind::SDL_SCANCODE_TAB => ScanCode::Tab,
            bind::SDL_SCANCODE_SPACE => ScanCode::Space,
            bind::SDL_SCANCODE_MINUS => ScanCode::Minus,
            bind::SDL_SCANCODE_EQUALS => ScanCode::Equals,
            bind::SDL_SCANCODE_LEFTBRACKET => ScanCode::LeftBracket,
            bind::SDL_SCANCODE_RIGHTBRACKET => ScanCode::RightBracket,
            bind::SDL_SCANCODE_BACKSLASH => ScanCode::Backslash,
            bind::SDL_SCANCODE_NONUSHASH => ScanCode::NonUsHash,
            bind::SDL_SCANCODE_SEMICOLON => ScanCode::Semicolon,
            bind::SDL_SCANCODE_APOSTROPHE => ScanCode::Apostrophe,
            bind::SDL_SCANCODE_GRAVE => ScanCode::Grave,
            bind::SDL_SCANCODE_COMMA => ScanCode::Comma,
            bind::SDL_SCANCODE_PERIOD => ScanCode::Period,
            bind::SDL_SCANCODE_SLASH => ScanCode::Slash,
            bind::SDL_SCANCODE_CAPSLOCK => ScanCode::CapsLock,
            bind::SDL_SCANCODE_F1 => ScanCode::F1,
            bind::SDL_SCANCODE_F2 => ScanCode::F2,
            bind::SDL_SCANCODE_F3 => ScanCode::F3,
            bind::SDL_SCANCODE_F4 => ScanCode::F4,
            bind::SDL_SCANCODE_F5 => ScanCode::F5,
            bind::SDL_SCANCODE_F6 => ScanCode::F6,
            bind::SDL_SCANCODE_F7 => ScanCode::F7,
            bind::SDL_SCANCODE_F8 => ScanCode::F8,
            bind::SDL_SCANCODE_F9 => ScanCode::F9,
            bind::SDL_SCANCODE_F10 => ScanCode::F10,
            bind::SDL_SCANCODE_F11 => ScanCode::F11,
            bind::SDL_SCANCODE_F12 => ScanCode::F12,
            bind::SDL_SCANCODE_PRINTSCREEN => ScanCode::PrintScreen,
            bind::SDL_SCANCODE_SCROLLLOCK => ScanCode::ScrollLock,
            bind::SDL_SCANCODE_PAUSE => ScanCode::Pause,
            bind::SDL_SCANCODE_INSERT => ScanCode::Insert,
            bind::SDL_SCANCODE_HOME => ScanCode::Home,
            bind::SDL_SCANCODE_PAGEUP => ScanCode::PageUp,
            bind::SDL_SCANCODE_DELETE => ScanCode::Delete,
            bind::SDL_SCANCODE_END => ScanCode::End,
            bind::SDL_SCANCODE_PAGEDOWN => ScanCode::PageDown,
            bind::SDL_SCANCODE_RIGHT => ScanCode::Right,
            bind::SDL_SCANCODE_LEFT => ScanCode::Left,
            bind::SDL_SCANCODE_DOWN => ScanCode::Down,
            bind::SDL_SCANCODE_UP => ScanCode::Up,
            bind::SDL_SCANCODE_NUMLOCKCLEAR => ScanCode::NumLockClear,
            bind::SDL_SCANCODE_KP_DIVIDE => ScanCode::KeypadDivide,
            bind::SDL_SCANCODE_KP_MULTIPLY => ScanCode::KeypadMultiply,
            bind::SDL_SCANCODE_KP_MINUS => ScanCode::KeypadMinus,
            bind::SDL_SCANCODE_KP_PLUS => ScanCode::KeypadPlus,
            bind::SDL_SCANCODE_KP_ENTER => ScanCode::KeypadEnter,
            bind::SDL_SCANCODE_KP_1 => ScanCode::Keypad1,
            bind::SDL_SCANCODE_KP_2 => ScanCode::Keypad2,
            bind::SDL_SCANCODE_KP_3 => ScanCode::Keypad3,
            bind::SDL_SCANCODE_KP_4 => ScanCode::Keypad4,
            bind::SDL_SCANCODE_KP_5 => ScanCode::Keypad5,
            bind::SDL_SCANCODE_KP_6 => ScanCode::Keypad6,
            bind::SDL_SCANCODE_KP_7 => ScanCode::Keypad7,
            bind::SDL_SCANCODE_KP_8 => ScanCode::Keypad8,
            bind::SDL_SCANCODE_KP_9 => ScanCode::Keypad9,
            bind::SDL_SCANCODE_KP_0 => ScanCode::Keypad0,
            bind::SDL_SCANCODE_KP_PERIOD => ScanCode::KeypadPeriod,
            bind::SDL_SCANCODE_NONUSBACKSLASH => ScanCode::NonUsBackslash,
            bind::SDL_SCANCODE_APPLICATION => ScanCode::Application,
            bind::SDL_SCANCODE_POWER => ScanCode::Power,
            bind::SDL_SCANCODE_KP_EQUALS => ScanCode::KeypadEquals,
            bind::SDL_SCANCODE_F13 => ScanCode::F13,
            bind::SDL_SCANCODE_F14 => ScanCode::F14,
            bind::SDL_SCANCODE_F15 => ScanCode::F15,
            bind::SDL_SCANCODE_F16 => ScanCode::F16,
            bind::SDL_SCANCODE_F17 => ScanCode::F17,
            bind::SDL_SCANCODE_F18 => ScanCode::F18,
            bind::SDL_SCANCODE_F19 => ScanCode::F19,
            bind::SDL_SCANCODE_F20 => ScanCode::F20,
            bind::SDL_SCANCODE_F21 => ScanCode::F21,
            bind::SDL_SCANCODE_F22 => ScanCode::F22,
            bind::SDL_SCANCODE_F23 => ScanCode::F23,
            bind::SDL_SCANCODE_F24 => ScanCode::F24,
            bind::SDL_SCANCODE_EXECUTE => ScanCode::Execute,
            bind::SDL_SCANCODE_HELP => ScanCode::Help,
            bind::SDL_SCANCODE_MENU => ScanCode::Menu,
            bind::SDL_SCANCODE_SELECT => ScanCode::Select,
            bind::SDL_SCANCODE_STOP => ScanCode::Stop,
            bind::SDL_SCANCODE_AGAIN => ScanCode::Again,
            bind::SDL_SCANCODE_UNDO => ScanCode::Undo,
            bind::SDL_SCANCODE_CUT => ScanCode::Cut,
            bind::SDL_SCANCODE_COPY => ScanCode::Copy,
            bind::SDL_SCANCODE_PASTE => ScanCode::Paste,
            bind::SDL_SCANCODE_FIND => ScanCode::Find,
            bind::SDL_SCANCODE_MUTE => ScanCode::Mute,
            bind::SDL_SCANCODE_VOLUMEUP => ScanCode::VolumeUp,
            bind::SDL_SCANCODE_VOLUMEDOWN => ScanCode::VolumeDown,
            bind::SDL_SCANCODE_KP_COMMA => ScanCode::KeypadComma,
            bind::SDL_SCANCODE_KP_EQUALSAS400 => ScanCode::KeypadEqualsAs400,
            bind::SDL_SCANCODE_INTERNATIONAL1 => ScanCode::International1,
            bind::SDL_SCANCODE_INTERNATIONAL2 => ScanCode::International2,
            bind::SDL_SCANCODE_INTERNATIONAL3 => ScanCode::International3,
            bind::SDL_SCANCODE_INTERNATIONAL4 => ScanCode::International4,
            bind::SDL_SCANCODE_INTERNATIONAL5 => ScanCode::International5,
            bind::SDL_SCANCODE_INTERNATIONAL6 => ScanCode::International6,
            bind::SDL_SCANCODE_INTERNATIONAL7 => ScanCode::International7,
            bind::SDL_SCANCODE_INTERNATIONAL8 => ScanCode::International8,
            bind::SDL_SCANCODE_INTERNATIONAL9 => ScanCode::International9,
            bind::SDL_SCANCODE_LANG1 => ScanCode::Lang1,
            bind::SDL_SCANCODE_LANG2 => ScanCode::Lang2,
            bind::SDL_SCANCODE_LANG3 => ScanCode::Lang3,
            bind::SDL_SCANCODE_LANG4 => ScanCode::Lang4,
            bind::SDL_SCANCODE_LANG5 => ScanCode::Lang5,
            bind::SDL_SCANCODE_LANG6 => ScanCode::Lang6,
            bind::SDL_SCANCODE_LANG7 => ScanCode::Lang7,
            bind::SDL_SCANCODE_LANG8 => ScanCode::Lang8,
            bind::SDL_SCANCODE_LANG9 => ScanCode::Lang9,
            bind::SDL_SCANCODE_ALTERASE => ScanCode::AltErase,
            bind::SDL_SCANCODE_SYSREQ => ScanCode::SysReq,
            bind::SDL_SCANCODE_CANCEL => ScanCode::Cancel,
            bind::SDL_SCANCODE_CLEAR => ScanCode::Clear,
            bind::SDL_SCANCODE_PRIOR => ScanCode::Prior,
            bind::SDL_SCANCODE_RETURN2 => ScanCode::Return2,
            bind::SDL_SCANCODE_SEPARATOR => ScanCode::Separator,
            bind::SDL_SCANCODE_OUT => ScanCode::Out,
            bind::SDL_SCANCODE_OPER => ScanCode::Oper,
            bind::SDL_SCANCODE_CLEARAGAIN => ScanCode::ClearAgain,
            bind::SDL_SCANCODE_CRSEL => ScanCode::CrSel,
            bind::SDL_SCANCODE_EXSEL => ScanCode::ExSel,
            bind::SDL_SCANCODE_KP_00 => ScanCode::Keypad00,
            bind::SDL_SCANCODE_KP_000 => ScanCode::Keypad000,
            bind::SDL_SCANCODE_THOUSANDSSEPARATOR => ScanCode::ThousandsSeparator,
            bind::SDL_SCANCODE_DECIMALSEPARATOR => ScanCode::DecimalSeparator,
            bind::SDL_SCANCODE_CURRENCYUNIT => ScanCode::CurrencyUnit,
            bind::SDL_SCANCODE_CURRENCYSUBUNIT => ScanCode::CurrencySubunit,
            bind::SDL_SCANCODE_KP_LEFTPAREN => ScanCode::KeypadLeftParen,
            bind::SDL_SCANCODE_KP_RIGHTPAREN => ScanCode::KeypadRightParen,
            bind::SDL_SCANCODE_KP_LEFTBRACE => ScanCode::KeypadLeftBrace,
            bind::SDL_SCANCODE_KP_RIGHTBRACE => ScanCode::KeypadRightBrace,
            bind::SDL_SCANCODE_KP_TAB => ScanCode::KeypadTab,
            bind::SDL_SCANCODE_KP_BACKSPACE => ScanCode::KeypadBackspace,
            bind::SDL_SCANCODE_KP_A => ScanCode::KeypadA,
            bind::SDL_SCANCODE_KP_B => ScanCode::KeypadB,
            bind::SDL_SCANCODE_KP_C => ScanCode::KeypadC,
            bind::SDL_SCANCODE_KP_D => ScanCode::KeypadD,
            bind::SDL_SCANCODE_KP_E => ScanCode::KeypadE,
            bind::SDL_SCANCODE_KP_F => ScanCode::KeypadF,
            bind::SDL_SCANCODE_KP_XOR => ScanCode::KeypadXor,
            bind::SDL_SCANCODE_KP_POWER => ScanCode::KeypadPower,
            bind::SDL_SCANCODE_KP_PERCENT => ScanCode::KeypadPercent,
            bind::SDL_SCANCODE_KP_LESS => ScanCode::KeypadLess,
            bind::SDL_SCANCODE_KP_GREATER => ScanCode::KeypadGreater,
            bind::SDL_SCANCODE_KP_AMPERSAND => ScanCode::KeypadAmpersand,
            bind::SDL_SCANCODE_KP_DBLAMPERSAND => ScanCode::KeypadDblAmpersand,
            bind::SDL_SCANCODE_KP_VERTICALBAR => ScanCode::KeypadVerticalBar,
            bind::SDL_SCANCODE_KP_DBLVERTICALBAR => ScanCode::KeypadDblVerticalBar,
            bind::SDL_SCANCODE_KP_COLON => ScanCode::KeypadColon,
            bind::SDL_SCANCODE_KP_HASH => ScanCode::KeypadHash,
            bind::SDL_SCANCODE_KP_SPACE => ScanCode::KeypadSpace,
            bind::SDL_SCANCODE_KP_AT => ScanCode::KeypadAt,
            bind::SDL_SCANCODE_KP_EXCLAM => ScanCode::KeypadExclam,
            bind::SDL_SCANCODE_KP_MEMSTORE => ScanCode::KeypadMemStore,
            bind::SDL_SCANCODE_KP_MEMRECALL => ScanCode::KeypadMemRecall,
            bind::SDL_SCANCODE_KP_MEMCLEAR => ScanCode::KeypadMemClear,
            bind::SDL_SCANCODE_KP_MEMADD => ScanCode::KeypadMemAdd,
            bind::SDL_SCANCODE_KP_MEMSUBTRACT => ScanCode::KeypadMemSubtract,
            bind::SDL_SCANCODE_KP_MEMMULTIPLY => ScanCode::KeypadMemMultiply,
            bind::SDL_SCANCODE_KP_MEMDIVIDE => ScanCode::KeypadMemDivide,
            bind::SDL_SCANCODE_KP_PLUSMINUS => ScanCode::KeypadPlusMinus,
            bind::SDL_SCANCODE_KP_CLEAR => ScanCode::KeypadClear,
            bind::SDL_SCANCODE_KP_CLEARENTRY => ScanCode::KeypadClearEntry,
            bind::SDL_SCANCODE_KP_BINARY => ScanCode::KeypadBinary,
            bind::SDL_SCANCODE_KP_OCTAL => ScanCode::KeypadOctal,
            bind::SDL_SCANCODE_KP_DECIMAL => ScanCode::KeypadDecimal,
            bind::SDL_SCANCODE_KP_HEXADECIMAL => ScanCode::KeypadHexadecimal,
            bind::SDL_SCANCODE_LCTRL => ScanCode::LCtrl,
            bind::SDL_SCANCODE_LSHIFT => ScanCode::LShift,
            bind::SDL_SCANCODE_LALT => ScanCode::LAlt,
            bind::SDL_SCANCODE_LGUI => ScanCode::LGui,
            bind::SDL_SCANCODE_RCTRL => ScanCode::RCtrl,
            bind::SDL_SCANCODE_RSHIFT => ScanCode::RShift,
            bind::SDL_SCANCODE_RALT => ScanCode::RAlt,
            bind::SDL_SCANCODE_RGUI => ScanCode::RGui,
            bind::SDL_SCANCODE_MODE => ScanCode::Mode,
            bind::SDL_SCANCODE_AUDIONEXT => ScanCode::AudioNext,
            bind::SDL_SCANCODE_AUDIOPREV => ScanCode::AudioPrev,
            bind::SDL_SCANCODE_AUDIOSTOP => ScanCode::AudioStop,
            bind::SDL_SCANCODE_AUDIOPLAY => ScanCode::AudioPlay,
            bind::SDL_SCANCODE_AUDIOMUTE => ScanCode::AudioMute,
            bind::SDL_SCANCODE_MEDIASELECT => ScanCode::MediaSelect,
            bind::SDL_SCANCODE_WWW => ScanCode::Www,
            bind::SDL_SCANCODE_MAIL => ScanCode::Mail,
            bind::SDL_SCANCODE_CALCULATOR => ScanCode::Calculator,
            bind::SDL_SCANCODE_COMPUTER => ScanCode::Computer,
            bind::SDL_SCANCODE_AC_SEARCH => ScanCode::ApplicationSearch,
            bind::SDL_SCANCODE_AC_HOME => ScanCode::ApplicationHome,
            bind::SDL_SCANCODE_AC_BACK => ScanCode::ApplicationBack,
            bind::SDL_SCANCODE_AC_FORWARD => ScanCode::ApplicationForward,
            bind::SDL_SCANCODE_AC_STOP => ScanCode::ApplicationStop,
            bind::SDL_SCANCODE_AC_REFRESH => ScanCode::ApplicationRefresh,
            bind::SDL_SCANCODE_AC_BOOKMARKS => ScanCode::ApplicationBookmarks,
            bind::SDL_SCANCODE_BRIGHTNESSDOWN => ScanCode::BrightnessDown,
            bind::SDL_SCANCODE_BRIGHTNESSUP => ScanCode::BrightnessUp,
            bind::SDL_SCANCODE_DISPLAYSWITCH => ScanCode::DisplaySwitch,
            bind::SDL_SCANCODE_KBDILLUMTOGGLE => ScanCode::KeyboardIllumToggle,
            bind::SDL_SCANCODE_KBDILLUMDOWN => ScanCode::KeyboardIllumDown,
            bind::SDL_SCANCODE_KBDILLUMUP => ScanCode::KeyboardIllumUp,
            bind::SDL_SCANCODE_EJECT => ScanCode::Eject,
            bind::SDL_SCANCODE_SLEEP => ScanCode::Sleep,
            bind::SDL_SCANCODE_APP1 => ScanCode::App1,
            bind::SDL_SCANCODE_APP2 => ScanCode::App2,
            bind::SDL_SCANCODE_AUDIOREWIND => ScanCode::AudioRewind,
            bind::SDL_SCANCODE_AUDIOFASTFORWARD => ScanCode::AudioFastForward,
            _ => ScanCode::Unknown,
        }
    }
}