src/video/haiku/SDL_bkeyboard.cc
changeset 12201 8bdc4d340419
parent 12082 09999a0e8f9a
child 12503 806492103856
equal deleted inserted replaced
12200:c0b17b32b95e 12201:8bdc4d340419
    40 
    40 
    41 static SDL_Scancode keymap[KEYMAP_SIZE];
    41 static SDL_Scancode keymap[KEYMAP_SIZE];
    42 static int8 keystate[KEYMAP_SIZE];
    42 static int8 keystate[KEYMAP_SIZE];
    43 
    43 
    44 void HAIKU_InitOSKeymap(void) {
    44 void HAIKU_InitOSKeymap(void) {
    45 		for( uint i = 0; i < SDL_TABLESIZE(keymap); ++i ) {
    45         for( uint i = 0; i < SDL_TABLESIZE(keymap); ++i ) {
    46 			keymap[i] = SDL_SCANCODE_UNKNOWN;
    46             keymap[i] = SDL_SCANCODE_UNKNOWN;
    47 		}
    47         }
    48 
    48 
    49 		for( uint i = 0; i < KEYMAP_SIZE; ++i ) {
    49         for( uint i = 0; i < KEYMAP_SIZE; ++i ) {
    50 			keystate[i] = SDL_RELEASED;
    50             keystate[i] = SDL_RELEASED;
    51 		}
    51         }
    52 
    52 
    53 		keymap[0x01]		= SDL_GetScancodeFromKey(SDLK_ESCAPE);
    53         keymap[0x01]        = SDL_GetScancodeFromKey(SDLK_ESCAPE);
    54 		keymap[B_F1_KEY]	= SDL_GetScancodeFromKey(SDLK_F1);
    54         keymap[B_F1_KEY]    = SDL_GetScancodeFromKey(SDLK_F1);
    55 		keymap[B_F2_KEY]	= SDL_GetScancodeFromKey(SDLK_F2);
    55         keymap[B_F2_KEY]    = SDL_GetScancodeFromKey(SDLK_F2);
    56 		keymap[B_F3_KEY]	= SDL_GetScancodeFromKey(SDLK_F3);
    56         keymap[B_F3_KEY]    = SDL_GetScancodeFromKey(SDLK_F3);
    57 		keymap[B_F4_KEY]	= SDL_GetScancodeFromKey(SDLK_F4);
    57         keymap[B_F4_KEY]    = SDL_GetScancodeFromKey(SDLK_F4);
    58 		keymap[B_F5_KEY]	= SDL_GetScancodeFromKey(SDLK_F5);
    58         keymap[B_F5_KEY]    = SDL_GetScancodeFromKey(SDLK_F5);
    59 		keymap[B_F6_KEY]	= SDL_GetScancodeFromKey(SDLK_F6);
    59         keymap[B_F6_KEY]    = SDL_GetScancodeFromKey(SDLK_F6);
    60 		keymap[B_F7_KEY]	= SDL_GetScancodeFromKey(SDLK_F7);
    60         keymap[B_F7_KEY]    = SDL_GetScancodeFromKey(SDLK_F7);
    61 		keymap[B_F8_KEY]	= SDL_GetScancodeFromKey(SDLK_F8);
    61         keymap[B_F8_KEY]    = SDL_GetScancodeFromKey(SDLK_F8);
    62 		keymap[B_F9_KEY]	= SDL_GetScancodeFromKey(SDLK_F9);
    62         keymap[B_F9_KEY]    = SDL_GetScancodeFromKey(SDLK_F9);
    63 		keymap[B_F10_KEY]	= SDL_GetScancodeFromKey(SDLK_F10);
    63         keymap[B_F10_KEY]    = SDL_GetScancodeFromKey(SDLK_F10);
    64 		keymap[B_F11_KEY]	= SDL_GetScancodeFromKey(SDLK_F11);
    64         keymap[B_F11_KEY]    = SDL_GetScancodeFromKey(SDLK_F11);
    65 		keymap[B_F12_KEY]	= SDL_GetScancodeFromKey(SDLK_F12);
    65         keymap[B_F12_KEY]    = SDL_GetScancodeFromKey(SDLK_F12);
    66 		keymap[B_PRINT_KEY]	= SDL_GetScancodeFromKey(SDLK_PRINTSCREEN);
    66         keymap[B_PRINT_KEY]    = SDL_GetScancodeFromKey(SDLK_PRINTSCREEN);
    67 		keymap[B_SCROLL_KEY]	= SDL_GetScancodeFromKey(SDLK_SCROLLLOCK);
    67         keymap[B_SCROLL_KEY]    = SDL_GetScancodeFromKey(SDLK_SCROLLLOCK);
    68 		keymap[B_PAUSE_KEY]	= SDL_GetScancodeFromKey(SDLK_PAUSE);
    68         keymap[B_PAUSE_KEY]    = SDL_GetScancodeFromKey(SDLK_PAUSE);
    69 		keymap[0x11]		= SDL_GetScancodeFromKey(SDLK_BACKQUOTE);
    69         keymap[0x11]        = SDL_GetScancodeFromKey(SDLK_BACKQUOTE);
    70 		keymap[0x12]		= SDL_GetScancodeFromKey(SDLK_1);
    70         keymap[0x12]        = SDL_GetScancodeFromKey(SDLK_1);
    71 		keymap[0x13]		= SDL_GetScancodeFromKey(SDLK_2);
    71         keymap[0x13]        = SDL_GetScancodeFromKey(SDLK_2);
    72 		keymap[0x14]		= SDL_GetScancodeFromKey(SDLK_3);
    72         keymap[0x14]        = SDL_GetScancodeFromKey(SDLK_3);
    73 		keymap[0x15]		= SDL_GetScancodeFromKey(SDLK_4);
    73         keymap[0x15]        = SDL_GetScancodeFromKey(SDLK_4);
    74 		keymap[0x16]		= SDL_GetScancodeFromKey(SDLK_5);
    74         keymap[0x16]        = SDL_GetScancodeFromKey(SDLK_5);
    75 		keymap[0x17]		= SDL_GetScancodeFromKey(SDLK_6);
    75         keymap[0x17]        = SDL_GetScancodeFromKey(SDLK_6);
    76 		keymap[0x18]		= SDL_GetScancodeFromKey(SDLK_7);
    76         keymap[0x18]        = SDL_GetScancodeFromKey(SDLK_7);
    77 		keymap[0x19]		= SDL_GetScancodeFromKey(SDLK_8);
    77         keymap[0x19]        = SDL_GetScancodeFromKey(SDLK_8);
    78 		keymap[0x1a]		= SDL_GetScancodeFromKey(SDLK_9);
    78         keymap[0x1a]        = SDL_GetScancodeFromKey(SDLK_9);
    79 		keymap[0x1b]		= SDL_GetScancodeFromKey(SDLK_0);
    79         keymap[0x1b]        = SDL_GetScancodeFromKey(SDLK_0);
    80 		keymap[0x1c]		= SDL_GetScancodeFromKey(SDLK_MINUS);
    80         keymap[0x1c]        = SDL_GetScancodeFromKey(SDLK_MINUS);
    81 		keymap[0x1d]		= SDL_GetScancodeFromKey(SDLK_EQUALS);
    81         keymap[0x1d]        = SDL_GetScancodeFromKey(SDLK_EQUALS);
    82 		keymap[0x1e]		= SDL_GetScancodeFromKey(SDLK_BACKSPACE);
    82         keymap[0x1e]        = SDL_GetScancodeFromKey(SDLK_BACKSPACE);
    83 		keymap[0x1f]		= SDL_GetScancodeFromKey(SDLK_INSERT);
    83         keymap[0x1f]        = SDL_GetScancodeFromKey(SDLK_INSERT);
    84 		keymap[0x20]		= SDL_GetScancodeFromKey(SDLK_HOME);
    84         keymap[0x20]        = SDL_GetScancodeFromKey(SDLK_HOME);
    85 		keymap[0x21]		= SDL_GetScancodeFromKey(SDLK_PAGEUP);
    85         keymap[0x21]        = SDL_GetScancodeFromKey(SDLK_PAGEUP);
    86 		keymap[0x22]		= SDL_GetScancodeFromKey(SDLK_NUMLOCKCLEAR);
    86         keymap[0x22]        = SDL_GetScancodeFromKey(SDLK_NUMLOCKCLEAR);
    87 		keymap[0x23]		= SDL_GetScancodeFromKey(SDLK_KP_DIVIDE);
    87         keymap[0x23]        = SDL_GetScancodeFromKey(SDLK_KP_DIVIDE);
    88 		keymap[0x24]		= SDL_GetScancodeFromKey(SDLK_KP_MULTIPLY);
    88         keymap[0x24]        = SDL_GetScancodeFromKey(SDLK_KP_MULTIPLY);
    89 		keymap[0x25]		= SDL_GetScancodeFromKey(SDLK_KP_MINUS);
    89         keymap[0x25]        = SDL_GetScancodeFromKey(SDLK_KP_MINUS);
    90 		keymap[0x26]		= SDL_GetScancodeFromKey(SDLK_TAB);
    90         keymap[0x26]        = SDL_GetScancodeFromKey(SDLK_TAB);
    91 		keymap[0x27]		= SDL_GetScancodeFromKey(SDLK_q);
    91         keymap[0x27]        = SDL_GetScancodeFromKey(SDLK_q);
    92 		keymap[0x28]		= SDL_GetScancodeFromKey(SDLK_w);
    92         keymap[0x28]        = SDL_GetScancodeFromKey(SDLK_w);
    93 		keymap[0x29]		= SDL_GetScancodeFromKey(SDLK_e);
    93         keymap[0x29]        = SDL_GetScancodeFromKey(SDLK_e);
    94 		keymap[0x2a]		= SDL_GetScancodeFromKey(SDLK_r);
    94         keymap[0x2a]        = SDL_GetScancodeFromKey(SDLK_r);
    95 		keymap[0x2b]		= SDL_GetScancodeFromKey(SDLK_t);
    95         keymap[0x2b]        = SDL_GetScancodeFromKey(SDLK_t);
    96 		keymap[0x2c]		= SDL_GetScancodeFromKey(SDLK_y);
    96         keymap[0x2c]        = SDL_GetScancodeFromKey(SDLK_y);
    97 		keymap[0x2d]		= SDL_GetScancodeFromKey(SDLK_u);
    97         keymap[0x2d]        = SDL_GetScancodeFromKey(SDLK_u);
    98 		keymap[0x2e]		= SDL_GetScancodeFromKey(SDLK_i);
    98         keymap[0x2e]        = SDL_GetScancodeFromKey(SDLK_i);
    99 		keymap[0x2f]		= SDL_GetScancodeFromKey(SDLK_o);
    99         keymap[0x2f]        = SDL_GetScancodeFromKey(SDLK_o);
   100 		keymap[0x30]		= SDL_GetScancodeFromKey(SDLK_p);
   100         keymap[0x30]        = SDL_GetScancodeFromKey(SDLK_p);
   101 		keymap[0x31]		= SDL_GetScancodeFromKey(SDLK_LEFTBRACKET);
   101         keymap[0x31]        = SDL_GetScancodeFromKey(SDLK_LEFTBRACKET);
   102 		keymap[0x32]		= SDL_GetScancodeFromKey(SDLK_RIGHTBRACKET);
   102         keymap[0x32]        = SDL_GetScancodeFromKey(SDLK_RIGHTBRACKET);
   103 		keymap[0x33]		= SDL_GetScancodeFromKey(SDLK_BACKSLASH);
   103         keymap[0x33]        = SDL_GetScancodeFromKey(SDLK_BACKSLASH);
   104 		keymap[0x34]		= SDL_GetScancodeFromKey(SDLK_DELETE);
   104         keymap[0x34]        = SDL_GetScancodeFromKey(SDLK_DELETE);
   105 		keymap[0x35]		= SDL_GetScancodeFromKey(SDLK_END);
   105         keymap[0x35]        = SDL_GetScancodeFromKey(SDLK_END);
   106 		keymap[0x36]		= SDL_GetScancodeFromKey(SDLK_PAGEDOWN);
   106         keymap[0x36]        = SDL_GetScancodeFromKey(SDLK_PAGEDOWN);
   107 		keymap[0x37]		= SDL_GetScancodeFromKey(SDLK_KP_7);
   107         keymap[0x37]        = SDL_GetScancodeFromKey(SDLK_KP_7);
   108 		keymap[0x38]		= SDL_GetScancodeFromKey(SDLK_KP_8);
   108         keymap[0x38]        = SDL_GetScancodeFromKey(SDLK_KP_8);
   109 		keymap[0x39]		= SDL_GetScancodeFromKey(SDLK_KP_9);
   109         keymap[0x39]        = SDL_GetScancodeFromKey(SDLK_KP_9);
   110 		keymap[0x3a]		= SDL_GetScancodeFromKey(SDLK_KP_PLUS);
   110         keymap[0x3a]        = SDL_GetScancodeFromKey(SDLK_KP_PLUS);
   111 		keymap[0x3b]		= SDL_GetScancodeFromKey(SDLK_CAPSLOCK);
   111         keymap[0x3b]        = SDL_GetScancodeFromKey(SDLK_CAPSLOCK);
   112 		keymap[0x3c]		= SDL_GetScancodeFromKey(SDLK_a);
   112         keymap[0x3c]        = SDL_GetScancodeFromKey(SDLK_a);
   113 		keymap[0x3d]		= SDL_GetScancodeFromKey(SDLK_s);
   113         keymap[0x3d]        = SDL_GetScancodeFromKey(SDLK_s);
   114 		keymap[0x3e]		= SDL_GetScancodeFromKey(SDLK_d);
   114         keymap[0x3e]        = SDL_GetScancodeFromKey(SDLK_d);
   115 		keymap[0x3f]		= SDL_GetScancodeFromKey(SDLK_f);
   115         keymap[0x3f]        = SDL_GetScancodeFromKey(SDLK_f);
   116 		keymap[0x40]		= SDL_GetScancodeFromKey(SDLK_g);
   116         keymap[0x40]        = SDL_GetScancodeFromKey(SDLK_g);
   117 		keymap[0x41]		= SDL_GetScancodeFromKey(SDLK_h);
   117         keymap[0x41]        = SDL_GetScancodeFromKey(SDLK_h);
   118 		keymap[0x42]		= SDL_GetScancodeFromKey(SDLK_j);
   118         keymap[0x42]        = SDL_GetScancodeFromKey(SDLK_j);
   119 		keymap[0x43]		= SDL_GetScancodeFromKey(SDLK_k);
   119         keymap[0x43]        = SDL_GetScancodeFromKey(SDLK_k);
   120 		keymap[0x44]		= SDL_GetScancodeFromKey(SDLK_l);
   120         keymap[0x44]        = SDL_GetScancodeFromKey(SDLK_l);
   121 		keymap[0x45]		= SDL_GetScancodeFromKey(SDLK_SEMICOLON);
   121         keymap[0x45]        = SDL_GetScancodeFromKey(SDLK_SEMICOLON);
   122 		keymap[0x46]		= SDL_GetScancodeFromKey(SDLK_QUOTE);
   122         keymap[0x46]        = SDL_GetScancodeFromKey(SDLK_QUOTE);
   123 		keymap[0x47]		= SDL_GetScancodeFromKey(SDLK_RETURN);
   123         keymap[0x47]        = SDL_GetScancodeFromKey(SDLK_RETURN);
   124 		keymap[0x48]		= SDL_GetScancodeFromKey(SDLK_KP_4);
   124         keymap[0x48]        = SDL_GetScancodeFromKey(SDLK_KP_4);
   125 		keymap[0x49]		= SDL_GetScancodeFromKey(SDLK_KP_5);
   125         keymap[0x49]        = SDL_GetScancodeFromKey(SDLK_KP_5);
   126 		keymap[0x4a]		= SDL_GetScancodeFromKey(SDLK_KP_6);
   126         keymap[0x4a]        = SDL_GetScancodeFromKey(SDLK_KP_6);
   127 		keymap[0x4b]		= SDL_GetScancodeFromKey(SDLK_LSHIFT);
   127         keymap[0x4b]        = SDL_GetScancodeFromKey(SDLK_LSHIFT);
   128 		keymap[0x4c]		= SDL_GetScancodeFromKey(SDLK_z);
   128         keymap[0x4c]        = SDL_GetScancodeFromKey(SDLK_z);
   129 		keymap[0x4d]		= SDL_GetScancodeFromKey(SDLK_x);
   129         keymap[0x4d]        = SDL_GetScancodeFromKey(SDLK_x);
   130 		keymap[0x4e]		= SDL_GetScancodeFromKey(SDLK_c);
   130         keymap[0x4e]        = SDL_GetScancodeFromKey(SDLK_c);
   131 		keymap[0x4f]		= SDL_GetScancodeFromKey(SDLK_v);
   131         keymap[0x4f]        = SDL_GetScancodeFromKey(SDLK_v);
   132 		keymap[0x50]		= SDL_GetScancodeFromKey(SDLK_b);
   132         keymap[0x50]        = SDL_GetScancodeFromKey(SDLK_b);
   133 		keymap[0x51]		= SDL_GetScancodeFromKey(SDLK_n);
   133         keymap[0x51]        = SDL_GetScancodeFromKey(SDLK_n);
   134 		keymap[0x52]		= SDL_GetScancodeFromKey(SDLK_m);
   134         keymap[0x52]        = SDL_GetScancodeFromKey(SDLK_m);
   135 		keymap[0x53]		= SDL_GetScancodeFromKey(SDLK_COMMA);
   135         keymap[0x53]        = SDL_GetScancodeFromKey(SDLK_COMMA);
   136 		keymap[0x54]		= SDL_GetScancodeFromKey(SDLK_PERIOD);
   136         keymap[0x54]        = SDL_GetScancodeFromKey(SDLK_PERIOD);
   137 		keymap[0x55]		= SDL_GetScancodeFromKey(SDLK_SLASH);
   137         keymap[0x55]        = SDL_GetScancodeFromKey(SDLK_SLASH);
   138 		keymap[0x56]		= SDL_GetScancodeFromKey(SDLK_RSHIFT);
   138         keymap[0x56]        = SDL_GetScancodeFromKey(SDLK_RSHIFT);
   139 		keymap[0x57]		= SDL_GetScancodeFromKey(SDLK_UP);
   139         keymap[0x57]        = SDL_GetScancodeFromKey(SDLK_UP);
   140 		keymap[0x58]		= SDL_GetScancodeFromKey(SDLK_KP_1);
   140         keymap[0x58]        = SDL_GetScancodeFromKey(SDLK_KP_1);
   141 		keymap[0x59]		= SDL_GetScancodeFromKey(SDLK_KP_2);
   141         keymap[0x59]        = SDL_GetScancodeFromKey(SDLK_KP_2);
   142 		keymap[0x5a]		= SDL_GetScancodeFromKey(SDLK_KP_3);
   142         keymap[0x5a]        = SDL_GetScancodeFromKey(SDLK_KP_3);
   143 		keymap[0x5b]		= SDL_GetScancodeFromKey(SDLK_KP_ENTER);
   143         keymap[0x5b]        = SDL_GetScancodeFromKey(SDLK_KP_ENTER);
   144 		keymap[0x5c]		= SDL_GetScancodeFromKey(SDLK_LCTRL);
   144         keymap[0x5c]        = SDL_GetScancodeFromKey(SDLK_LCTRL);
   145 		keymap[0x5d]		= SDL_GetScancodeFromKey(SDLK_LALT);
   145         keymap[0x5d]        = SDL_GetScancodeFromKey(SDLK_LALT);
   146 		keymap[0x5e]		= SDL_GetScancodeFromKey(SDLK_SPACE);
   146         keymap[0x5e]        = SDL_GetScancodeFromKey(SDLK_SPACE);
   147 		keymap[0x5f]		= SDL_GetScancodeFromKey(SDLK_RALT);
   147         keymap[0x5f]        = SDL_GetScancodeFromKey(SDLK_RALT);
   148 		keymap[0x60]		= SDL_GetScancodeFromKey(SDLK_RCTRL);
   148         keymap[0x60]        = SDL_GetScancodeFromKey(SDLK_RCTRL);
   149 		keymap[0x61]		= SDL_GetScancodeFromKey(SDLK_LEFT);
   149         keymap[0x61]        = SDL_GetScancodeFromKey(SDLK_LEFT);
   150 		keymap[0x62]		= SDL_GetScancodeFromKey(SDLK_DOWN);
   150         keymap[0x62]        = SDL_GetScancodeFromKey(SDLK_DOWN);
   151 		keymap[0x63]		= SDL_GetScancodeFromKey(SDLK_RIGHT);
   151         keymap[0x63]        = SDL_GetScancodeFromKey(SDLK_RIGHT);
   152 		keymap[0x64]		= SDL_GetScancodeFromKey(SDLK_KP_0);
   152         keymap[0x64]        = SDL_GetScancodeFromKey(SDLK_KP_0);
   153 		keymap[0x65]		= SDL_GetScancodeFromKey(SDLK_KP_PERIOD);
   153         keymap[0x65]        = SDL_GetScancodeFromKey(SDLK_KP_PERIOD);
   154 		keymap[0x66]		= SDL_GetScancodeFromKey(SDLK_LGUI);
   154         keymap[0x66]        = SDL_GetScancodeFromKey(SDLK_LGUI);
   155 		keymap[0x67]		= SDL_GetScancodeFromKey(SDLK_RGUI);
   155         keymap[0x67]        = SDL_GetScancodeFromKey(SDLK_RGUI);
   156 		keymap[0x68]		= SDL_GetScancodeFromKey(SDLK_MENU);
   156         keymap[0x68]        = SDL_GetScancodeFromKey(SDLK_MENU);
   157 		keymap[0x69]		= SDL_GetScancodeFromKey(SDLK_2); /* SDLK_EURO */
   157         keymap[0x69]        = SDL_GetScancodeFromKey(SDLK_2); /* SDLK_EURO */
   158 		keymap[0x6a]		= SDL_GetScancodeFromKey(SDLK_KP_EQUALS);
   158         keymap[0x6a]        = SDL_GetScancodeFromKey(SDLK_KP_EQUALS);
   159 		keymap[0x6b]		= SDL_GetScancodeFromKey(SDLK_POWER);
   159         keymap[0x6b]        = SDL_GetScancodeFromKey(SDLK_POWER);
   160 }
   160 }
   161 
   161 
   162 SDL_Scancode HAIKU_GetScancodeFromBeKey(int32 bkey) {
   162 SDL_Scancode HAIKU_GetScancodeFromBeKey(int32 bkey) {
   163 	if(bkey > 0 && bkey < (int32)SDL_TABLESIZE(keymap)) {
   163     if(bkey > 0 && bkey < (int32)SDL_TABLESIZE(keymap)) {
   164 		return keymap[bkey];
   164         return keymap[bkey];
   165 	} else {
   165     } else {
   166 		return SDL_SCANCODE_UNKNOWN;
   166         return SDL_SCANCODE_UNKNOWN;
   167 	}
   167     }
   168 }
   168 }
   169 
   169 
   170 int8 HAIKU_GetKeyState(int32 bkey) {
   170 int8 HAIKU_GetKeyState(int32 bkey) {
   171 	if(bkey > 0 && bkey < KEYMAP_SIZE) {
   171     if(bkey > 0 && bkey < KEYMAP_SIZE) {
   172 		return keystate[bkey];
   172         return keystate[bkey];
   173 	} else {
   173     } else {
   174 		return SDL_RELEASED;
   174         return SDL_RELEASED;
   175 	}
   175     }
   176 }
   176 }
   177 
   177 
   178 void HAIKU_SetKeyState(int32 bkey, int8 state) {
   178 void HAIKU_SetKeyState(int32 bkey, int8 state) {
   179 	if(bkey > 0 && bkey < KEYMAP_SIZE) {
   179     if(bkey > 0 && bkey < KEYMAP_SIZE) {
   180 		keystate[bkey] = state;
   180         keystate[bkey] = state;
   181 	}
   181     }
   182 }
   182 }
   183 
   183 
   184 #ifdef __cplusplus
   184 #ifdef __cplusplus
   185 }
   185 }
   186 #endif
   186 #endif