SDL_bkeyboard.cc
Go to the documentation of this file.
/*
Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_HAIKU
#include <SupportDefs.h>
#include <support/UTF8.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "SDL_events.h"
#include "SDL_keycode.h"
#include "SDL_bkeyboard.h"
#define KEYMAP_SIZE 128
static SDL_Scancode keymap[KEYMAP_SIZE];
static int8 keystate[KEYMAP_SIZE];
void HAIKU_InitOSKeymap(void) {
for( uint i = 0; i < SDL_TABLESIZE(keymap); ++i ) {
keymap[i] = SDL_SCANCODE_UNKNOWN;
}
for( uint i = 0; i < KEYMAP_SIZE; ++i ) {
keystate[i] = SDL_RELEASED;
}
keymap[0x01] = SDL_GetScancodeFromKey(SDLK_ESCAPE);
keymap[B_F1_KEY] = SDL_GetScancodeFromKey(SDLK_F1);
keymap[B_F2_KEY] = SDL_GetScancodeFromKey(SDLK_F2);
keymap[B_F3_KEY] = SDL_GetScancodeFromKey(SDLK_F3);
keymap[B_F4_KEY] = SDL_GetScancodeFromKey(SDLK_F4);
keymap[B_F5_KEY] = SDL_GetScancodeFromKey(SDLK_F5);
keymap[B_F6_KEY] = SDL_GetScancodeFromKey(SDLK_F6);
keymap[B_F7_KEY] = SDL_GetScancodeFromKey(SDLK_F7);
keymap[B_F8_KEY] = SDL_GetScancodeFromKey(SDLK_F8);
keymap[B_F9_KEY] = SDL_GetScancodeFromKey(SDLK_F9);
keymap[B_F10_KEY] = SDL_GetScancodeFromKey(SDLK_F10);
keymap[B_F11_KEY] = SDL_GetScancodeFromKey(SDLK_F11);
keymap[B_F12_KEY] = SDL_GetScancodeFromKey(SDLK_F12);
keymap[B_PRINT_KEY] = SDL_GetScancodeFromKey(SDLK_PRINTSCREEN);
keymap[B_SCROLL_KEY] = SDL_GetScancodeFromKey(SDLK_SCROLLLOCK);
keymap[B_PAUSE_KEY] = SDL_GetScancodeFromKey(SDLK_PAUSE);
keymap[0x11] = SDL_GetScancodeFromKey(SDLK_BACKQUOTE);
keymap[0x12] = SDL_GetScancodeFromKey(SDLK_1);
keymap[0x13] = SDL_GetScancodeFromKey(SDLK_2);
keymap[0x14] = SDL_GetScancodeFromKey(SDLK_3);
keymap[0x15] = SDL_GetScancodeFromKey(SDLK_4);
keymap[0x16] = SDL_GetScancodeFromKey(SDLK_5);
keymap[0x17] = SDL_GetScancodeFromKey(SDLK_6);
keymap[0x18] = SDL_GetScancodeFromKey(SDLK_7);
keymap[0x19] = SDL_GetScancodeFromKey(SDLK_8);
keymap[0x1a] = SDL_GetScancodeFromKey(SDLK_9);
keymap[0x1b] = SDL_GetScancodeFromKey(SDLK_0);
keymap[0x1c] = SDL_GetScancodeFromKey(SDLK_MINUS);
keymap[0x1d] = SDL_GetScancodeFromKey(SDLK_EQUALS);
keymap[0x1e] = SDL_GetScancodeFromKey(SDLK_BACKSPACE);
keymap[0x1f] = SDL_GetScancodeFromKey(SDLK_INSERT);
keymap[0x20] = SDL_GetScancodeFromKey(SDLK_HOME);
keymap[0x21] = SDL_GetScancodeFromKey(SDLK_PAGEUP);
keymap[0x22] = SDL_GetScancodeFromKey(SDLK_NUMLOCKCLEAR);
keymap[0x23] = SDL_GetScancodeFromKey(SDLK_KP_DIVIDE);
keymap[0x24] = SDL_GetScancodeFromKey(SDLK_KP_MULTIPLY);
keymap[0x25] = SDL_GetScancodeFromKey(SDLK_KP_MINUS);
keymap[0x26] = SDL_GetScancodeFromKey(SDLK_TAB);
keymap[0x27] = SDL_GetScancodeFromKey(SDLK_q);
keymap[0x28] = SDL_GetScancodeFromKey(SDLK_w);
keymap[0x29] = SDL_GetScancodeFromKey(SDLK_e);
keymap[0x2a] = SDL_GetScancodeFromKey(SDLK_r);
keymap[0x2b] = SDL_GetScancodeFromKey(SDLK_t);
keymap[0x2c] = SDL_GetScancodeFromKey(SDLK_y);
keymap[0x2d] = SDL_GetScancodeFromKey(SDLK_u);
keymap[0x2e] = SDL_GetScancodeFromKey(SDLK_i);
keymap[0x2f] = SDL_GetScancodeFromKey(SDLK_o);
keymap[0x30] = SDL_GetScancodeFromKey(SDLK_p);
keymap[0x31] = SDL_GetScancodeFromKey(SDLK_LEFTBRACKET);
keymap[0x32] = SDL_GetScancodeFromKey(SDLK_RIGHTBRACKET);
keymap[0x33] = SDL_GetScancodeFromKey(SDLK_BACKSLASH);
keymap[0x34] = SDL_GetScancodeFromKey(SDLK_DELETE);
keymap[0x35] = SDL_GetScancodeFromKey(SDLK_END);
keymap[0x36] = SDL_GetScancodeFromKey(SDLK_PAGEDOWN);
keymap[0x37] = SDL_GetScancodeFromKey(SDLK_KP_7);
keymap[0x38] = SDL_GetScancodeFromKey(SDLK_KP_8);
keymap[0x39] = SDL_GetScancodeFromKey(SDLK_KP_9);
keymap[0x3a] = SDL_GetScancodeFromKey(SDLK_KP_PLUS);
keymap[0x3b] = SDL_GetScancodeFromKey(SDLK_CAPSLOCK);
keymap[0x3c] = SDL_GetScancodeFromKey(SDLK_a);
keymap[0x3d] = SDL_GetScancodeFromKey(SDLK_s);
keymap[0x3e] = SDL_GetScancodeFromKey(SDLK_d);
keymap[0x3f] = SDL_GetScancodeFromKey(SDLK_f);
keymap[0x40] = SDL_GetScancodeFromKey(SDLK_g);
keymap[0x41] = SDL_GetScancodeFromKey(SDLK_h);
keymap[0x42] = SDL_GetScancodeFromKey(SDLK_j);
keymap[0x43] = SDL_GetScancodeFromKey(SDLK_k);
keymap[0x44] = SDL_GetScancodeFromKey(SDLK_l);
keymap[0x45] = SDL_GetScancodeFromKey(SDLK_SEMICOLON);
keymap[0x46] = SDL_GetScancodeFromKey(SDLK_QUOTE);
keymap[0x47] = SDL_GetScancodeFromKey(SDLK_RETURN);
keymap[0x48] = SDL_GetScancodeFromKey(SDLK_KP_4);
keymap[0x49] = SDL_GetScancodeFromKey(SDLK_KP_5);
keymap[0x4a] = SDL_GetScancodeFromKey(SDLK_KP_6);
keymap[0x4b] = SDL_GetScancodeFromKey(SDLK_LSHIFT);
keymap[0x4c] = SDL_GetScancodeFromKey(SDLK_z);
keymap[0x4d] = SDL_GetScancodeFromKey(SDLK_x);
keymap[0x4e] = SDL_GetScancodeFromKey(SDLK_c);
keymap[0x4f] = SDL_GetScancodeFromKey(SDLK_v);
keymap[0x50] = SDL_GetScancodeFromKey(SDLK_b);
keymap[0x51] = SDL_GetScancodeFromKey(SDLK_n);
keymap[0x52] = SDL_GetScancodeFromKey(SDLK_m);
keymap[0x53] = SDL_GetScancodeFromKey(SDLK_COMMA);
keymap[0x54] = SDL_GetScancodeFromKey(SDLK_PERIOD);
keymap[0x55] = SDL_GetScancodeFromKey(SDLK_SLASH);
keymap[0x56] = SDL_GetScancodeFromKey(SDLK_RSHIFT);
keymap[0x57] = SDL_GetScancodeFromKey(SDLK_UP);
keymap[0x58] = SDL_GetScancodeFromKey(SDLK_KP_1);
keymap[0x59] = SDL_GetScancodeFromKey(SDLK_KP_2);
keymap[0x5a] = SDL_GetScancodeFromKey(SDLK_KP_3);
keymap[0x5b] = SDL_GetScancodeFromKey(SDLK_KP_ENTER);
keymap[0x5c] = SDL_GetScancodeFromKey(SDLK_LCTRL);
keymap[0x5d] = SDL_GetScancodeFromKey(SDLK_LALT);
keymap[0x5e] = SDL_GetScancodeFromKey(SDLK_SPACE);
keymap[0x5f] = SDL_GetScancodeFromKey(SDLK_RALT);
keymap[0x60] = SDL_GetScancodeFromKey(SDLK_RCTRL);
keymap[0x61] = SDL_GetScancodeFromKey(SDLK_LEFT);
keymap[0x62] = SDL_GetScancodeFromKey(SDLK_DOWN);
keymap[0x63] = SDL_GetScancodeFromKey(SDLK_RIGHT);
keymap[0x64] = SDL_GetScancodeFromKey(SDLK_KP_0);
keymap[0x65] = SDL_GetScancodeFromKey(SDLK_KP_PERIOD);
keymap[0x66] = SDL_GetScancodeFromKey(SDLK_LGUI);
keymap[0x67] = SDL_GetScancodeFromKey(SDLK_RGUI);
keymap[0x68] = SDL_GetScancodeFromKey(SDLK_MENU);
keymap[0x69] = SDL_GetScancodeFromKey(SDLK_2); /* SDLK_EURO */
keymap[0x6a] = SDL_GetScancodeFromKey(SDLK_KP_EQUALS);
keymap[0x6b] = SDL_GetScancodeFromKey(SDLK_POWER);
}
SDL_Scancode HAIKU_GetScancodeFromBeKey(int32 bkey) {
if(bkey > 0 && bkey < (int32)SDL_TABLESIZE(keymap)) {
return keymap[bkey];
} else {
return SDL_SCANCODE_UNKNOWN;
}
}
int8 HAIKU_GetKeyState(int32 bkey) {
if(bkey > 0 && bkey < KEYMAP_SIZE) {
return keystate[bkey];
} else {
return SDL_RELEASED;
}
}
void HAIKU_SetKeyState(int32 bkey, int8 state) {
if(bkey > 0 && bkey < KEYMAP_SIZE) {
keystate[bkey] = state;
}
}
#ifdef __cplusplus
}
#endif
#endif /* SDL_VIDEO_DRIVER_HAIKU */
/* vi: set ts=4 sw=4 expandtab: */
SDLK_KP_6
@ SDLK_KP_6
Definition: SDL_keycode.h:167
SDLK_KP_5
@ SDLK_KP_5
Definition: SDL_keycode.h:166
SDLK_KP_MINUS
@ SDLK_KP_MINUS
Definition: SDL_keycode.h:159
SDLK_F6
@ SDLK_F6
Definition: SDL_keycode.h:134
SDL_events.h
SDLK_F5
@ SDLK_F5
Definition: SDL_keycode.h:133
SDLK_x
@ SDLK_x
Definition: SDL_keycode.h:123
SDLK_j
@ SDLK_j
Definition: SDL_keycode.h:109
SDLK_8
@ SDLK_8
Definition: SDL_keycode.h:82
SDLK_2
@ SDLK_2
Definition: SDL_keycode.h:76
SDLK_RALT
@ SDLK_RALT
Definition: SDL_keycode.h:282
SDLK_u
@ SDLK_u
Definition: SDL_keycode.h:120
SDLK_e
@ SDLK_e
Definition: SDL_keycode.h:104
SDLK_6
@ SDLK_6
Definition: SDL_keycode.h:80
SDLK_LSHIFT
@ SDLK_LSHIFT
Definition: SDL_keycode.h:277
SDLK_F7
@ SDLK_F7
Definition: SDL_keycode.h:135
HAIKU_GetKeyState
int8 HAIKU_GetKeyState(int32 bkey)
SDLK_F8
@ SDLK_F8
Definition: SDL_keycode.h:136
SDLK_NUMLOCKCLEAR
@ SDLK_NUMLOCKCLEAR
Definition: SDL_keycode.h:156
SDLK_PAUSE
@ SDLK_PAUSE
Definition: SDL_keycode.h:144
SDLK_KP_MULTIPLY
@ SDLK_KP_MULTIPLY
Definition: SDL_keycode.h:158
SDLK_F9
@ SDLK_F9
Definition: SDL_keycode.h:137
SDLK_t
@ SDLK_t
Definition: SDL_keycode.h:119
SDLK_f
@ SDLK_f
Definition: SDL_keycode.h:105
SDLK_9
@ SDLK_9
Definition: SDL_keycode.h:83
SDL_keycode.h
SDLK_F3
@ SDLK_F3
Definition: SDL_keycode.h:131
SDLK_F11
@ SDLK_F11
Definition: SDL_keycode.h:139
SDL_Scancode
SDL_Scancode
The SDL keyboard scancode representation.
Definition: SDL_scancode.h:43
SDLK_DOWN
@ SDLK_DOWN
Definition: SDL_keycode.h:153
SDLK_RIGHTBRACKET
@ SDLK_RIGHTBRACKET
Definition: SDL_keycode.h:96
SDLK_KP_PLUS
@ SDLK_KP_PLUS
Definition: SDL_keycode.h:160
SDLK_UP
@ SDLK_UP
Definition: SDL_keycode.h:154
uint
#define uint
SDLK_KP_0
@ SDLK_KP_0
Definition: SDL_keycode.h:171
SDLK_KP_DIVIDE
@ SDLK_KP_DIVIDE
Definition: SDL_keycode.h:157
SDLK_KP_4
@ SDLK_KP_4
Definition: SDL_keycode.h:165
SDL_RELEASED
#define SDL_RELEASED
Definition: SDL_events.h:49
SDLK_LEFT
@ SDLK_LEFT
Definition: SDL_keycode.h:152
SDLK_m
@ SDLK_m
Definition: SDL_keycode.h:112
SDLK_QUOTE
@ SDLK_QUOTE
Definition: SDL_keycode.h:65
SDLK_KP_EQUALS
@ SDLK_KP_EQUALS
Definition: SDL_keycode.h:176
SDLK_w
@ SDLK_w
Definition: SDL_keycode.h:122
SDL_GetScancodeFromKey
#define SDL_GetScancodeFromKey
Definition: SDL_dynapi_overrides.h:221
SDLK_v
@ SDLK_v
Definition: SDL_keycode.h:121
SDLK_l
@ SDLK_l
Definition: SDL_keycode.h:111
SDLK_LGUI
@ SDLK_LGUI
Definition: SDL_keycode.h:279
SDLK_ESCAPE
@ SDLK_ESCAPE
Definition: SDL_keycode.h:55
SDLK_g
@ SDLK_g
Definition: SDL_keycode.h:106
SDLK_7
@ SDLK_7
Definition: SDL_keycode.h:81
SDLK_F1
@ SDLK_F1
Definition: SDL_keycode.h:129
SDLK_COMMA
@ SDLK_COMMA
Definition: SDL_keycode.h:70
SDLK_4
@ SDLK_4
Definition: SDL_keycode.h:78
SDLK_KP_7
@ SDLK_KP_7
Definition: SDL_keycode.h:168
SDLK_p
@ SDLK_p
Definition: SDL_keycode.h:115
SDLK_F10
@ SDLK_F10
Definition: SDL_keycode.h:138
SDLK_INSERT
@ SDLK_INSERT
Definition: SDL_keycode.h:145
HAIKU_SetKeyState
void HAIKU_SetKeyState(int32 bkey, int8 state)
HAIKU_InitOSKeymap
void HAIKU_InitOSKeymap(void)
HAIKU_GetScancodeFromBeKey
SDL_Scancode HAIKU_GetScancodeFromBeKey(int32 bkey)
SDLK_SPACE
@ SDLK_SPACE
Definition: SDL_keycode.h:58
SDLK_KP_8
@ SDLK_KP_8
Definition: SDL_keycode.h:169
SDLK_z
@ SDLK_z
Definition: SDL_keycode.h:125
SDLK_q
@ SDLK_q
Definition: SDL_keycode.h:116
SDLK_BACKQUOTE
@ SDLK_BACKQUOTE
Definition: SDL_keycode.h:99
SDLK_a
@ SDLK_a
Definition: SDL_keycode.h:100
SDLK_KP_1
@ SDLK_KP_1
Definition: SDL_keycode.h:162
SDLK_h
@ SDLK_h
Definition: SDL_keycode.h:107
SDLK_0
@ SDLK_0
Definition: SDL_keycode.h:74
SDLK_KP_3
@ SDLK_KP_3
Definition: SDL_keycode.h:164
SDLK_PAGEUP
@ SDLK_PAGEUP
Definition: SDL_keycode.h:147
SDLK_END
@ SDLK_END
Definition: SDL_keycode.h:149
SDLK_KP_2
@ SDLK_KP_2
Definition: SDL_keycode.h:163
SDLK_KP_9
@ SDLK_KP_9
Definition: SDL_keycode.h:170
SDLK_SLASH
@ SDLK_SLASH
Definition: SDL_keycode.h:73
SDLK_BACKSPACE
@ SDLK_BACKSPACE
Definition: SDL_keycode.h:56
SDL_SCANCODE_UNKNOWN
@ SDL_SCANCODE_UNKNOWN
Definition: SDL_scancode.h:45
SDLK_MENU
@ SDLK_MENU
Definition: SDL_keycode.h:191
SDLK_DELETE
@ SDLK_DELETE
Definition: SDL_keycode.h:148
SDLK_BACKSLASH
@ SDLK_BACKSLASH
Definition: SDL_keycode.h:95
SDLK_PERIOD
@ SDLK_PERIOD
Definition: SDL_keycode.h:72
SDLK_i
@ SDLK_i
Definition: SDL_keycode.h:108
SDLK_RGUI
@ SDLK_RGUI
Definition: SDL_keycode.h:283
SDLK_d
@ SDLK_d
Definition: SDL_keycode.h:103
SDLK_RCTRL
@ SDLK_RCTRL
Definition: SDL_keycode.h:280
SDLK_KP_PERIOD
@ SDLK_KP_PERIOD
Definition: SDL_keycode.h:172
SDLK_RETURN
@ SDLK_RETURN
Definition: SDL_keycode.h:54
SDLK_MINUS
@ SDLK_MINUS
Definition: SDL_keycode.h:71
SDLK_LEFTBRACKET
@ SDLK_LEFTBRACKET
Definition: SDL_keycode.h:94
SDLK_F4
@ SDLK_F4
Definition: SDL_keycode.h:132
SDL_TABLESIZE
#define SDL_TABLESIZE(table)
Definition: SDL_stdinc.h:116
SDLK_RSHIFT
@ SDLK_RSHIFT
Definition: SDL_keycode.h:281
SDLK_EQUALS
@ SDLK_EQUALS
Definition: SDL_keycode.h:87
SDLK_TAB
@ SDLK_TAB
Definition: SDL_keycode.h:57
SDLK_c
@ SDLK_c
Definition: SDL_keycode.h:102
SDL_bkeyboard.h
SDLK_POWER
@ SDLK_POWER
Definition: SDL_keycode.h:175
SDLK_k
@ SDLK_k
Definition: SDL_keycode.h:110
SDLK_5
@ SDLK_5
Definition: SDL_keycode.h:79
SDLK_CAPSLOCK
@ SDLK_CAPSLOCK
Definition: SDL_keycode.h:127
SDLK_RIGHT
@ SDLK_RIGHT
Definition: SDL_keycode.h:151
SDLK_F12
@ SDLK_F12
Definition: SDL_keycode.h:140
SDLK_3
@ SDLK_3
Definition: SDL_keycode.h:77
SDLK_o
@ SDLK_o
Definition: SDL_keycode.h:114
SDLK_KP_ENTER
@ SDLK_KP_ENTER
Definition: SDL_keycode.h:161
SDLK_LALT
@ SDLK_LALT
Definition: SDL_keycode.h:278
SDLK_PAGEDOWN
@ SDLK_PAGEDOWN
Definition: SDL_keycode.h:150
SDLK_s
@ SDLK_s
Definition: SDL_keycode.h:118
SDLK_HOME
@ SDLK_HOME
Definition: SDL_keycode.h:146
SDLK_r
@ SDLK_r
Definition: SDL_keycode.h:117
SDLK_F2
@ SDLK_F2
Definition: SDL_keycode.h:130
state
struct xkb_state * state
Definition: SDL_waylandsym.h:113
SDLK_LCTRL
@ SDLK_LCTRL
Definition: SDL_keycode.h:276
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
SDLK_1
@ SDLK_1
Definition: SDL_keycode.h:75
SDLK_SCROLLLOCK
@ SDLK_SCROLLLOCK
Definition: SDL_keycode.h:143
SDLK_b
@ SDLK_b
Definition: SDL_keycode.h:101
SDLK_y
@ SDLK_y
Definition: SDL_keycode.h:124
SDLK_PRINTSCREEN
@ SDLK_PRINTSCREEN
Definition: SDL_keycode.h:142
SDLK_SEMICOLON
@ SDLK_SEMICOLON
Definition: SDL_keycode.h:85
SDLK_n
@ SDLK_n
Definition: SDL_keycode.h:113