Skip to content

Commit

Permalink
Enable SWITCH controls
Browse files Browse the repository at this point in the history
  • Loading branch information
aagallag committed Aug 5, 2018
1 parent 0dcd84c commit 0133ae4
Show file tree
Hide file tree
Showing 2 changed files with 285 additions and 0 deletions.
23 changes: 23 additions & 0 deletions d2/arch/include/key.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,29 @@ extern void key_toggle_repeat(int enable);

#define KEY_PAUSE 0x61

#ifdef __SWITCH__
#define NX_KEY_A SDLK_a
#define NX_KEY_B SDLK_b
#define NX_KEY_X SDLK_x
#define NX_KEY_Y SDLK_y

#define NX_KEY_LSTICK SDLK_LSHIFT
#define NX_KEY_RSTICK SDLK_RSHIFT

#define NX_KEY_L SDLK_l
#define NX_KEY_R SDLK_r
#define NX_KEY_ZL SDLK_j
#define NX_KEY_ZR SDLK_k

#define NX_KEY_MINUS SDLK_MINUS
#define NX_KEY_PLUS SDLK_PLUS

#define NX_KEY_LEFT SDLK_LEFT
#define NX_KEY_UP SDLK_UP
#define NX_KEY_RIGHT SDLK_RIGHT
#define NX_KEY_DOWN SDLK_DOWN
#endif

typedef struct key_props {
const char *key_text;
unsigned char ascii_value;
Expand Down
262 changes: 262 additions & 0 deletions d2/arch/sdl/key.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,267 @@ typedef struct keyboard {

static keyboard key_data;

#ifdef __SWITCH__
const key_props key_properties[256] = {
{ "", 255, SDLK_UNKNOWN }, // 0
{ "ESC", 255, NX_KEY_PLUS },
{ "1", '1', SDLK_1 },
{ "2", '2', SDLK_2 },
{ "3", '3', SDLK_3 },
{ "4", '4', SDLK_4 },
{ "5", '5', SDLK_5 },
{ "6", '6', SDLK_6 },
{ "7", '7', SDLK_7 },
{ "8", '8', SDLK_8 },
{ "9", '9', SDLK_9 }, // 10
{ "0", '0', SDLK_0 },
{ "-", '-', SDLK_UNKNOWN },
{ "=", '=', SDLK_EQUALS },
{ "BSPC", 255, SDLK_BACKSPACE },
{ "TAB", 255, SDLK_TAB },
{ "Q", 'q', SDLK_q },
{ "W", 'w', SDLK_w },
{ "E", 'e', SDLK_e },
{ "R", 'r', SDLK_r },
{ "T", 't', SDLK_t }, // 20
{ "Y", 'y', SDLK_y },
{ "U", 'u', SDLK_u },
{ "I", 'i', SDLK_i },
{ "O", 'o', SDLK_o },
{ "P", 'p', SDLK_p },
{ "[", '[', SDLK_LEFTBRACKET },
{ "]", ']', SDLK_RIGHTBRACKET },
{ "ENTER", 255, NX_KEY_MINUS },
{ "LCTRL", 255, NX_KEY_A },
{ "A", 'a', NX_KEY_ZR }, // 30
{ "S", 's', SDLK_s },
{ "D", 'd', SDLK_d },
{ "F", 'f', SDLK_f },
{ "G", 'g', SDLK_g },
{ "H", 'h', SDLK_h },
{ "J", 'j', SDLK_UNKNOWN },
{ "K", 'k', SDLK_UNKNOWN },
{ "L", 'l', SDLK_l },
{ ";", ';', SDLK_SEMICOLON },
{ "'", '\'', SDLK_QUOTE }, // 40
{ "`", '`', SDLK_BACKQUOTE },
{ "LSHFT", 255, SDLK_LSHIFT },
{ "\\", '\\', SDLK_BACKSLASH },
{ "Z", 'z', NX_KEY_ZL },
{ "X", 'x', SDLK_x },
{ "C", 'c', SDLK_c },
{ "V", 'v', SDLK_v },
{ "B", 'b', SDLK_UNKNOWN },
{ "N", 'n', SDLK_n },
{ "M", 'm', SDLK_m }, // 50
{ ",", ',', SDLK_COMMA },
{ ".", '.', SDLK_PERIOD },
{ "/", '/', SDLK_SLASH },
{ "RSHFT", 255, SDLK_RSHIFT },
{ "PAD*", '*', SDLK_KP_MULTIPLY },
{ "LALT", 255, SDLK_LALT },
{ "SPC", ' ', NX_KEY_B },
{ "CPSLK", 255, SDLK_CAPSLOCK },
{ "F1", 255, SDLK_F1 },
{ "F2", 255, SDLK_F2 }, // 60
{ "F3", 255, SDLK_F3 },
{ "F4", 255, SDLK_F4 },
{ "F5", 255, SDLK_F5 },
{ "F6", 255, SDLK_F6 },
{ "F7", 255, SDLK_F7 },
{ "F8", 255, SDLK_F8 },
{ "F9", 255, SDLK_F9 },
{ "F10", 255, SDLK_F10 },
{ "NMLCK", 255, SDLK_NUMLOCK },
{ "SCLK", 255, SDLK_SCROLLOCK }, // 70
{ "PAD7", 255, SDLK_KP7 },
{ "PAD8", 255, SDLK_KP8 },
{ "PAD9", 255, SDLK_KP9 },
{ "PAD-", 255, SDLK_KP_MINUS },
{ "PAD4", 255, SDLK_KP4 },
{ "PAD5", 255, SDLK_KP5 },
{ "PAD6", 255, SDLK_KP6 },
{ "PAD+", 255, SDLK_KP_PLUS },
{ "PAD1", 255, SDLK_KP1 },
{ "PAD2", 255, SDLK_KP2 }, // 80
{ "PAD3", 255, SDLK_KP3 },
{ "PAD0", 255, SDLK_KP0 },
{ "PAD.", 255, SDLK_KP_PERIOD },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "F11", 255, SDLK_F11 },
{ "F12", 255, SDLK_F12 },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN }, // 90
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "PAUSE", 255, SDLK_PAUSE },
{ "W0", 255, SDLK_WORLD_0 },
{ "W1", 255, SDLK_WORLD_1 },
{ "W2", 255, SDLK_WORLD_2 }, // 100
{ "W3", 255, SDLK_WORLD_3 },
{ "W4", 255, SDLK_WORLD_4 },
{ "W5", 255, SDLK_WORLD_5 },
{ "W6", 255, SDLK_WORLD_6 },
{ "W7", 255, SDLK_WORLD_7 },
{ "W8", 255, SDLK_WORLD_8 },
{ "W9", 255, SDLK_WORLD_9 },
{ "W10", 255, SDLK_WORLD_10 },
{ "W11", 255, SDLK_WORLD_11 },
{ "W12", 255, SDLK_WORLD_12 }, // 110
{ "W13", 255, SDLK_WORLD_13 },
{ "W14", 255, SDLK_WORLD_14 },
{ "W15", 255, SDLK_WORLD_15 },
{ "W16", 255, SDLK_WORLD_16 },
{ "W17", 255, SDLK_WORLD_17 },
{ "W18", 255, SDLK_WORLD_18 },
{ "W19", 255, SDLK_WORLD_19 },
{ "W20", 255, SDLK_WORLD_20 },
{ "W21", 255, SDLK_WORLD_21 },
{ "W22", 255, SDLK_WORLD_22 }, // 120
{ "W23", 255, SDLK_WORLD_23 },
{ "W24", 255, SDLK_WORLD_24 },
{ "W25", 255, SDLK_WORLD_25 },
{ "W26", 255, SDLK_WORLD_26 },
{ "W27", 255, SDLK_WORLD_27 },
{ "W28", 255, SDLK_WORLD_28 },
{ "W29", 255, SDLK_WORLD_29 },
{ "W30", 255, SDLK_WORLD_30 },
{ "W31", 255, SDLK_WORLD_31 },
{ "W32", 255, SDLK_WORLD_32 }, // 130
{ "W33", 255, SDLK_WORLD_33 },
{ "W34", 255, SDLK_WORLD_34 },
{ "W35", 255, SDLK_WORLD_35 },
{ "W36", 255, SDLK_WORLD_36 },
{ "W37", 255, SDLK_WORLD_37 },
{ "W38", 255, SDLK_WORLD_38 },
{ "W39", 255, SDLK_WORLD_39 },
{ "W40", 255, SDLK_WORLD_40 },
{ "W41", 255, SDLK_WORLD_41 },
{ "W42", 255, SDLK_WORLD_42 }, // 140
{ "W43", 255, SDLK_WORLD_43 },
{ "W44", 255, SDLK_WORLD_44 },
{ "W45", 255, SDLK_WORLD_45 },
{ "W46", 255, SDLK_WORLD_46 },
{ "W47", 255, SDLK_WORLD_47 },
{ "W48", 255, SDLK_WORLD_48 },
{ "W49", 255, SDLK_WORLD_49 },
{ "W50", 255, SDLK_WORLD_50 },
{ "W51", 255, SDLK_WORLD_51 },
{ "", 255, SDLK_UNKNOWN }, // 150
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "PAD", 255, SDLK_KP_ENTER },
{ "RCTRL", 255, SDLK_RCTRL },
{ "LCMD", 255, SDLK_LMETA },
{ "RCMD", 255, SDLK_RMETA },
{ "", 255, SDLK_UNKNOWN }, // 160
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN }, // 170
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN }, // 180
{ "PAD/", 255, SDLK_KP_DIVIDE },
{ "", 255, SDLK_UNKNOWN },
{ "PRSCR", 255, SDLK_PRINT },
{ "RALT", 255, SDLK_RALT },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN }, // 190
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "", 255, SDLK_UNKNOWN },
{ "HOME", 255, SDLK_HOME },
{ "UP", 255, NX_KEY_UP }, // 200
{ "PGUP", 255, SDLK_PAGEUP },
{ "", 255, SDLK_UNKNOWN },
{ "LEFT", 255, NX_KEY_LEFT },
{ "", 255, SDLK_UNKNOWN },
{ "RIGHT", 255, NX_KEY_RIGHT },
{ "", 255, SDLK_UNKNOWN },
{ "END", 255, SDLK_END },
{ "DOWN", 255, NX_KEY_DOWN },
{ "PGDN", 255, SDLK_PAGEDOWN },
{ "INS", 255, SDLK_INSERT }, // 210
{ "DEL", 255, SDLK_DELETE },
{ "W52", 255, SDLK_WORLD_52 },
{ "W53", 255, SDLK_WORLD_53 },
{ "W54", 255, SDLK_WORLD_54 },
{ "W55", 255, SDLK_WORLD_55 },
{ "W56", 255, SDLK_WORLD_56 },
{ "W57", 255, SDLK_WORLD_57 },
{ "W58", 255, SDLK_WORLD_58 },
{ "W59", 255, SDLK_WORLD_59 },
{ "W60", 255, SDLK_WORLD_60 }, // 220
{ "W61", 255, SDLK_WORLD_61 },
{ "W62", 255, SDLK_WORLD_62 },
{ "W63", 255, SDLK_WORLD_63 },
{ "W64", 255, SDLK_WORLD_64 },
{ "W65", 255, SDLK_WORLD_65 },
{ "W66", 255, SDLK_WORLD_66 },
{ "W67", 255, SDLK_WORLD_67 },
{ "W68", 255, SDLK_WORLD_68 },
{ "W69", 255, SDLK_WORLD_69 },
{ "W70", 255, SDLK_WORLD_70 }, // 230
{ "W71", 255, SDLK_WORLD_71 },
{ "W72", 255, SDLK_WORLD_72 },
{ "W73", 255, SDLK_WORLD_73 },
{ "W74", 255, SDLK_WORLD_74 },
{ "W75", 255, SDLK_WORLD_75 },
{ "W76", 255, SDLK_WORLD_76 },
{ "W77", 255, SDLK_WORLD_77 },
{ "W78", 255, SDLK_WORLD_78 },
{ "W79", 255, SDLK_WORLD_79 },
{ "W80", 255, SDLK_WORLD_80 }, // 240
{ "W81", 255, SDLK_WORLD_81 },
{ "W82", 255, SDLK_WORLD_82 },
{ "W83", 255, SDLK_WORLD_83 },
{ "W84", 255, SDLK_WORLD_84 },
{ "W85", 255, SDLK_WORLD_85 },
{ "W86", 255, SDLK_WORLD_86 },
{ "W87", 255, SDLK_WORLD_87 },
{ "W88", 255, SDLK_WORLD_88 },
{ "W89", 255, SDLK_WORLD_89 },
{ "W90", 255, SDLK_WORLD_90 }, // 250
{ "W91", 255, SDLK_WORLD_91 },
{ "W92", 255, SDLK_WORLD_92 },
{ "W93", 255, SDLK_WORLD_93 },
{ "W94", 255, SDLK_WORLD_94 },
{ "W95", 255, SDLK_WORLD_95 }, // 255
};
#else

const key_props key_properties[256] = {
{ "", 255, SDLK_UNKNOWN }, // 0
{ "ESC", 255, SDLK_ESCAPE },
Expand Down Expand Up @@ -292,6 +553,7 @@ const key_props key_properties[256] = {
{ "W94", 255, SDLK_WORLD_94 },
{ "W95", 255, SDLK_WORLD_95 }, // 255
};
#endif // ! __SWITCH__

typedef struct d_event_keycommand
{
Expand Down

0 comments on commit 0133ae4

Please sign in to comment.