@@ -361,12 +361,30 @@ class CKeyBind final : public CBind {
361
361
362
362
std::string GetBindName () const override
363
363
{
364
- if (key == SDL_SCANCODE_RETURN)
365
- return " Enter" ; // instead of "Return"
366
- else if (key == SDL_SCANCODE_INTERNATIONAL1)
367
- return " International 1" ; // instead of empty string
368
- else
369
- return SDL_GetScancodeName (key);
364
+ // Always map Return to Enter
365
+ if (key == SDL_SCANCODE_RETURN) {
366
+ return " Enter" ;
367
+ }
368
+
369
+ const std::string sdl_scancode_name = SDL_GetScancodeName (key);
370
+ if (!sdl_scancode_name.empty ()) {
371
+ return sdl_scancode_name;
372
+ }
373
+
374
+ // SDL Doesn't have a name for this key, so use our own
375
+ assert (sdl_scancode_name.empty ());
376
+
377
+ // Key between Left Shift and Z is "oem102"
378
+ if (key == SDL_SCANCODE_NONUSBACKSLASH) {
379
+ return " oem102" ; // called 'OEM_102" at kbdlayout.info
380
+ }
381
+ // Key to the left of Right Shift on ABNT layouts
382
+ if (key == SDL_SCANCODE_INTERNATIONAL1) {
383
+ return " abnt1" ; // called "ABNT_C1" at kbdlayout.info
384
+ }
385
+
386
+ DEBUG_LOG_MSG (" MAPPER: Please report unnamed SDL scancode %d (%xh)" , key, key);
387
+ return sdl_scancode_name;
370
388
}
371
389
372
390
void ConfigName (char *buf) override
@@ -2080,13 +2098,18 @@ static KeyBlock combo_3[12]={
2080
2098
{" \\ |" ," backslash" ,KBD_backslash},
2081
2099
};
2082
2100
2083
- static KeyBlock combo_4[11 ]={
2084
- {" <>" ," lessthan" ,KBD_extra_lt_gt},
2085
- {" Z" ," z" ,KBD_z}, {" X" ," x" ,KBD_x}, {" C" ," c" ,KBD_c},
2086
- {" V" ," v" ,KBD_v}, {" B" ," b" ,KBD_b}, {" N" ," n" ,KBD_n},
2087
- {" M" ," m" ,KBD_m}, {" ,<" ," comma" ,KBD_comma},
2088
- {" .>" ," period" ,KBD_period}, {" /?" ," slash" ,KBD_slash},
2089
- };
2101
+ static KeyBlock combo_4[12 ] = {{" \\ |" , " oem102" , KBD_oem102},
2102
+ {" Z" , " z" , KBD_z},
2103
+ {" X" , " x" , KBD_x},
2104
+ {" C" , " c" , KBD_c},
2105
+ {" V" , " v" , KBD_v},
2106
+ {" B" , " b" , KBD_b},
2107
+ {" N" , " n" , KBD_n},
2108
+ {" M" , " m" , KBD_m},
2109
+ {" ,<" , " comma" , KBD_comma},
2110
+ {" .>" , " period" , KBD_period},
2111
+ {" /?" , " slash" , KBD_slash},
2112
+ {" /?" , " abnt1" , KBD_abnt1}};
2090
2113
2091
2114
static CKeyEvent * caps_lock_event=NULL ;
2092
2115
static CKeyEvent * num_lock_event=NULL ;
@@ -2112,8 +2135,16 @@ static void CreateLayout() {
2112
2135
for (i=0 ;i<12 ;i++) AddKeyButtonEvent (PX (2 +i),PY (3 ),BW,BH,combo_3[i].title ,combo_3[i].entry ,combo_3[i].key );
2113
2136
2114
2137
AddKeyButtonEvent (PX (0 ),PY (4 ),BW*2 ,BH," SHIFT" ," lshift" ,KBD_leftshift);
2115
- for (i=0 ;i<11 ;i++) AddKeyButtonEvent (PX (2 +i),PY (4 ),BW,BH,combo_4[i].title ,combo_4[i].entry ,combo_4[i].key );
2116
- AddKeyButtonEvent (PX (13 ),PY (4 ),BW*3 ,BH," SHIFT" ," rshift" ,KBD_rightshift);
2138
+ for (i = 0 ; i < 12 ; i++) {
2139
+ AddKeyButtonEvent (PX (2 + i),
2140
+ PY (4 ),
2141
+ BW,
2142
+ BH,
2143
+ combo_4[i].title ,
2144
+ combo_4[i].entry ,
2145
+ combo_4[i].key );
2146
+ }
2147
+ AddKeyButtonEvent (PX (14 ), PY (4 ), BW * 3 , BH, " SHIFT" , " rshift" , KBD_rightshift);
2117
2148
2118
2149
/* Bottom Row */
2119
2150
AddKeyButtonEvent (PX (0 ), PY (5 ), BW * 2 , BH, MMOD1_NAME, " lctrl" , KBD_leftctrl);
@@ -2177,8 +2208,6 @@ static void CreateLayout() {
2177
2208
AddKeyButtonEvent (PX (XO),PY (YO+4 ),BW*2 ,BH," 0" ," kp_0" ,KBD_kp0);
2178
2209
AddKeyButtonEvent (PX (XO+2 ),PY (YO+4 ),BW,BH," ." ," kp_period" ,KBD_kpperiod);
2179
2210
2180
- /* International Keys */
2181
- AddKeyButtonEvent (PX (XO + 5 ), PY (YO), BW * 2 , BH, " Intl1" , " intl1" , KBD_intl1);
2182
2211
#undef XO
2183
2212
#undef YO
2184
2213
@@ -2478,11 +2507,15 @@ static struct {
2478
2507
{" kp_period" , SDL_SCANCODE_KP_PERIOD},
2479
2508
{" kp_enter" , SDL_SCANCODE_KP_ENTER},
2480
2509
2481
- /* Is that the extra backslash key ("less than" key) */
2482
- /* on some keyboards with the 102-keys layout?? */
2483
- {" lessthan" , SDL_SCANCODE_NONUSBACKSLASH},
2484
-
2485
- {" intl1" , SDL_SCANCODE_INTERNATIONAL1},
2510
+ // ABNT-arrangement, key between Left-Shift and Z: SDL
2511
+ // ccancode 100 (0x64) Maps to OEM102 key with scancode 86
2512
+ // (0x56)
2513
+ {" oem102" , SDL_SCANCODE_NONUSBACKSLASH},
2514
+
2515
+ // ABNT-arrangement, key between Left-Shift and Z: SDL
2516
+ // ccancode 135 (0x87) Maps to first ABNT key with scancode
2517
+ // 115 (0x73)
2518
+ {" abnt1" , SDL_SCANCODE_INTERNATIONAL1},
2486
2519
2487
2520
{0 , SDL_SCANCODE_UNKNOWN}};
2488
2521
0 commit comments