src/video/haiku/SDL_bkeyboard.cc
author Sam Lantinga <slouken@libsdl.org>
Mon, 24 Sep 2018 11:49:25 -0700
changeset 12201 8bdc4d340419
parent 12082 09999a0e8f9a
child 12503 806492103856
permissions -rw-r--r--
Fixed whitespace
nathanheisey@5928
     1
/*
slouken@6884
     2
  Simple DirectMedia Layer
slouken@11811
     3
  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
nathanheisey@5928
     4
slouken@6884
     5
  This software is provided 'as-is', without any express or implied
slouken@6884
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@6884
     7
  arising from the use of this software.
nathanheisey@5928
     8
slouken@6884
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@6884
    10
  including commercial applications, and to alter it and redistribute it
slouken@6884
    11
  freely, subject to the following restrictions:
nathanheisey@5928
    12
slouken@6884
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@6884
    14
     claim that you wrote the original software. If you use this software
slouken@6884
    15
     in a product, an acknowledgment in the product documentation would be
slouken@6884
    16
     appreciated but is not required.
slouken@6884
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@6884
    18
     misrepresented as being the original software.
slouken@6884
    19
  3. This notice may not be removed or altered from any source distribution.
nathanheisey@5928
    20
*/
icculus@8093
    21
#include "../../SDL_internal.h"
slouken@6044
    22
icculus@7981
    23
#if SDL_VIDEO_DRIVER_HAIKU
nathanheisey@5928
    24
nathanheisey@5928
    25
#include <SupportDefs.h>
nathanheisey@5928
    26
#include <support/UTF8.h>
nathanheisey@5928
    27
nathanheisey@5928
    28
#ifdef __cplusplus
nathanheisey@5928
    29
extern "C" {
nathanheisey@5928
    30
#endif
nathanheisey@5928
    31
nathanheisey@5928
    32
#include "SDL_events.h"
nathanheisey@5928
    33
#include "SDL_keycode.h"
nathanheisey@5928
    34
nathanheisey@5928
    35
#include "SDL_bkeyboard.h"
nathanheisey@5928
    36
nathanheisey@5928
    37
nathanheisey@5928
    38
#define KEYMAP_SIZE 128
nathanheisey@5928
    39
nathanheisey@5928
    40
nathanheisey@5928
    41
static SDL_Scancode keymap[KEYMAP_SIZE];
nathanheisey@5928
    42
static int8 keystate[KEYMAP_SIZE];
nathanheisey@5928
    43
icculus@12082
    44
void HAIKU_InitOSKeymap(void) {
slouken@12201
    45
        for( uint i = 0; i < SDL_TABLESIZE(keymap); ++i ) {
slouken@12201
    46
            keymap[i] = SDL_SCANCODE_UNKNOWN;
slouken@12201
    47
        }
nathanheisey@5928
    48
slouken@12201
    49
        for( uint i = 0; i < KEYMAP_SIZE; ++i ) {
slouken@12201
    50
            keystate[i] = SDL_RELEASED;
slouken@12201
    51
        }
nathanheisey@5928
    52
slouken@12201
    53
        keymap[0x01]        = SDL_GetScancodeFromKey(SDLK_ESCAPE);
slouken@12201
    54
        keymap[B_F1_KEY]    = SDL_GetScancodeFromKey(SDLK_F1);
slouken@12201
    55
        keymap[B_F2_KEY]    = SDL_GetScancodeFromKey(SDLK_F2);
slouken@12201
    56
        keymap[B_F3_KEY]    = SDL_GetScancodeFromKey(SDLK_F3);
slouken@12201
    57
        keymap[B_F4_KEY]    = SDL_GetScancodeFromKey(SDLK_F4);
slouken@12201
    58
        keymap[B_F5_KEY]    = SDL_GetScancodeFromKey(SDLK_F5);
slouken@12201
    59
        keymap[B_F6_KEY]    = SDL_GetScancodeFromKey(SDLK_F6);
slouken@12201
    60
        keymap[B_F7_KEY]    = SDL_GetScancodeFromKey(SDLK_F7);
slouken@12201
    61
        keymap[B_F8_KEY]    = SDL_GetScancodeFromKey(SDLK_F8);
slouken@12201
    62
        keymap[B_F9_KEY]    = SDL_GetScancodeFromKey(SDLK_F9);
slouken@12201
    63
        keymap[B_F10_KEY]    = SDL_GetScancodeFromKey(SDLK_F10);
slouken@12201
    64
        keymap[B_F11_KEY]    = SDL_GetScancodeFromKey(SDLK_F11);
slouken@12201
    65
        keymap[B_F12_KEY]    = SDL_GetScancodeFromKey(SDLK_F12);
slouken@12201
    66
        keymap[B_PRINT_KEY]    = SDL_GetScancodeFromKey(SDLK_PRINTSCREEN);
slouken@12201
    67
        keymap[B_SCROLL_KEY]    = SDL_GetScancodeFromKey(SDLK_SCROLLLOCK);
slouken@12201
    68
        keymap[B_PAUSE_KEY]    = SDL_GetScancodeFromKey(SDLK_PAUSE);
slouken@12201
    69
        keymap[0x11]        = SDL_GetScancodeFromKey(SDLK_BACKQUOTE);
slouken@12201
    70
        keymap[0x12]        = SDL_GetScancodeFromKey(SDLK_1);
slouken@12201
    71
        keymap[0x13]        = SDL_GetScancodeFromKey(SDLK_2);
slouken@12201
    72
        keymap[0x14]        = SDL_GetScancodeFromKey(SDLK_3);
slouken@12201
    73
        keymap[0x15]        = SDL_GetScancodeFromKey(SDLK_4);
slouken@12201
    74
        keymap[0x16]        = SDL_GetScancodeFromKey(SDLK_5);
slouken@12201
    75
        keymap[0x17]        = SDL_GetScancodeFromKey(SDLK_6);
slouken@12201
    76
        keymap[0x18]        = SDL_GetScancodeFromKey(SDLK_7);
slouken@12201
    77
        keymap[0x19]        = SDL_GetScancodeFromKey(SDLK_8);
slouken@12201
    78
        keymap[0x1a]        = SDL_GetScancodeFromKey(SDLK_9);
slouken@12201
    79
        keymap[0x1b]        = SDL_GetScancodeFromKey(SDLK_0);
slouken@12201
    80
        keymap[0x1c]        = SDL_GetScancodeFromKey(SDLK_MINUS);
slouken@12201
    81
        keymap[0x1d]        = SDL_GetScancodeFromKey(SDLK_EQUALS);
slouken@12201
    82
        keymap[0x1e]        = SDL_GetScancodeFromKey(SDLK_BACKSPACE);
slouken@12201
    83
        keymap[0x1f]        = SDL_GetScancodeFromKey(SDLK_INSERT);
slouken@12201
    84
        keymap[0x20]        = SDL_GetScancodeFromKey(SDLK_HOME);
slouken@12201
    85
        keymap[0x21]        = SDL_GetScancodeFromKey(SDLK_PAGEUP);
slouken@12201
    86
        keymap[0x22]        = SDL_GetScancodeFromKey(SDLK_NUMLOCKCLEAR);
slouken@12201
    87
        keymap[0x23]        = SDL_GetScancodeFromKey(SDLK_KP_DIVIDE);
slouken@12201
    88
        keymap[0x24]        = SDL_GetScancodeFromKey(SDLK_KP_MULTIPLY);
slouken@12201
    89
        keymap[0x25]        = SDL_GetScancodeFromKey(SDLK_KP_MINUS);
slouken@12201
    90
        keymap[0x26]        = SDL_GetScancodeFromKey(SDLK_TAB);
slouken@12201
    91
        keymap[0x27]        = SDL_GetScancodeFromKey(SDLK_q);
slouken@12201
    92
        keymap[0x28]        = SDL_GetScancodeFromKey(SDLK_w);
slouken@12201
    93
        keymap[0x29]        = SDL_GetScancodeFromKey(SDLK_e);
slouken@12201
    94
        keymap[0x2a]        = SDL_GetScancodeFromKey(SDLK_r);
slouken@12201
    95
        keymap[0x2b]        = SDL_GetScancodeFromKey(SDLK_t);
slouken@12201
    96
        keymap[0x2c]        = SDL_GetScancodeFromKey(SDLK_y);
slouken@12201
    97
        keymap[0x2d]        = SDL_GetScancodeFromKey(SDLK_u);
slouken@12201
    98
        keymap[0x2e]        = SDL_GetScancodeFromKey(SDLK_i);
slouken@12201
    99
        keymap[0x2f]        = SDL_GetScancodeFromKey(SDLK_o);
slouken@12201
   100
        keymap[0x30]        = SDL_GetScancodeFromKey(SDLK_p);
slouken@12201
   101
        keymap[0x31]        = SDL_GetScancodeFromKey(SDLK_LEFTBRACKET);
slouken@12201
   102
        keymap[0x32]        = SDL_GetScancodeFromKey(SDLK_RIGHTBRACKET);
slouken@12201
   103
        keymap[0x33]        = SDL_GetScancodeFromKey(SDLK_BACKSLASH);
slouken@12201
   104
        keymap[0x34]        = SDL_GetScancodeFromKey(SDLK_DELETE);
slouken@12201
   105
        keymap[0x35]        = SDL_GetScancodeFromKey(SDLK_END);
slouken@12201
   106
        keymap[0x36]        = SDL_GetScancodeFromKey(SDLK_PAGEDOWN);
slouken@12201
   107
        keymap[0x37]        = SDL_GetScancodeFromKey(SDLK_KP_7);
slouken@12201
   108
        keymap[0x38]        = SDL_GetScancodeFromKey(SDLK_KP_8);
slouken@12201
   109
        keymap[0x39]        = SDL_GetScancodeFromKey(SDLK_KP_9);
slouken@12201
   110
        keymap[0x3a]        = SDL_GetScancodeFromKey(SDLK_KP_PLUS);
slouken@12201
   111
        keymap[0x3b]        = SDL_GetScancodeFromKey(SDLK_CAPSLOCK);
slouken@12201
   112
        keymap[0x3c]        = SDL_GetScancodeFromKey(SDLK_a);
slouken@12201
   113
        keymap[0x3d]        = SDL_GetScancodeFromKey(SDLK_s);
slouken@12201
   114
        keymap[0x3e]        = SDL_GetScancodeFromKey(SDLK_d);
slouken@12201
   115
        keymap[0x3f]        = SDL_GetScancodeFromKey(SDLK_f);
slouken@12201
   116
        keymap[0x40]        = SDL_GetScancodeFromKey(SDLK_g);
slouken@12201
   117
        keymap[0x41]        = SDL_GetScancodeFromKey(SDLK_h);
slouken@12201
   118
        keymap[0x42]        = SDL_GetScancodeFromKey(SDLK_j);
slouken@12201
   119
        keymap[0x43]        = SDL_GetScancodeFromKey(SDLK_k);
slouken@12201
   120
        keymap[0x44]        = SDL_GetScancodeFromKey(SDLK_l);
slouken@12201
   121
        keymap[0x45]        = SDL_GetScancodeFromKey(SDLK_SEMICOLON);
slouken@12201
   122
        keymap[0x46]        = SDL_GetScancodeFromKey(SDLK_QUOTE);
slouken@12201
   123
        keymap[0x47]        = SDL_GetScancodeFromKey(SDLK_RETURN);
slouken@12201
   124
        keymap[0x48]        = SDL_GetScancodeFromKey(SDLK_KP_4);
slouken@12201
   125
        keymap[0x49]        = SDL_GetScancodeFromKey(SDLK_KP_5);
slouken@12201
   126
        keymap[0x4a]        = SDL_GetScancodeFromKey(SDLK_KP_6);
slouken@12201
   127
        keymap[0x4b]        = SDL_GetScancodeFromKey(SDLK_LSHIFT);
slouken@12201
   128
        keymap[0x4c]        = SDL_GetScancodeFromKey(SDLK_z);
slouken@12201
   129
        keymap[0x4d]        = SDL_GetScancodeFromKey(SDLK_x);
slouken@12201
   130
        keymap[0x4e]        = SDL_GetScancodeFromKey(SDLK_c);
slouken@12201
   131
        keymap[0x4f]        = SDL_GetScancodeFromKey(SDLK_v);
slouken@12201
   132
        keymap[0x50]        = SDL_GetScancodeFromKey(SDLK_b);
slouken@12201
   133
        keymap[0x51]        = SDL_GetScancodeFromKey(SDLK_n);
slouken@12201
   134
        keymap[0x52]        = SDL_GetScancodeFromKey(SDLK_m);
slouken@12201
   135
        keymap[0x53]        = SDL_GetScancodeFromKey(SDLK_COMMA);
slouken@12201
   136
        keymap[0x54]        = SDL_GetScancodeFromKey(SDLK_PERIOD);
slouken@12201
   137
        keymap[0x55]        = SDL_GetScancodeFromKey(SDLK_SLASH);
slouken@12201
   138
        keymap[0x56]        = SDL_GetScancodeFromKey(SDLK_RSHIFT);
slouken@12201
   139
        keymap[0x57]        = SDL_GetScancodeFromKey(SDLK_UP);
slouken@12201
   140
        keymap[0x58]        = SDL_GetScancodeFromKey(SDLK_KP_1);
slouken@12201
   141
        keymap[0x59]        = SDL_GetScancodeFromKey(SDLK_KP_2);
slouken@12201
   142
        keymap[0x5a]        = SDL_GetScancodeFromKey(SDLK_KP_3);
slouken@12201
   143
        keymap[0x5b]        = SDL_GetScancodeFromKey(SDLK_KP_ENTER);
slouken@12201
   144
        keymap[0x5c]        = SDL_GetScancodeFromKey(SDLK_LCTRL);
slouken@12201
   145
        keymap[0x5d]        = SDL_GetScancodeFromKey(SDLK_LALT);
slouken@12201
   146
        keymap[0x5e]        = SDL_GetScancodeFromKey(SDLK_SPACE);
slouken@12201
   147
        keymap[0x5f]        = SDL_GetScancodeFromKey(SDLK_RALT);
slouken@12201
   148
        keymap[0x60]        = SDL_GetScancodeFromKey(SDLK_RCTRL);
slouken@12201
   149
        keymap[0x61]        = SDL_GetScancodeFromKey(SDLK_LEFT);
slouken@12201
   150
        keymap[0x62]        = SDL_GetScancodeFromKey(SDLK_DOWN);
slouken@12201
   151
        keymap[0x63]        = SDL_GetScancodeFromKey(SDLK_RIGHT);
slouken@12201
   152
        keymap[0x64]        = SDL_GetScancodeFromKey(SDLK_KP_0);
slouken@12201
   153
        keymap[0x65]        = SDL_GetScancodeFromKey(SDLK_KP_PERIOD);
slouken@12201
   154
        keymap[0x66]        = SDL_GetScancodeFromKey(SDLK_LGUI);
slouken@12201
   155
        keymap[0x67]        = SDL_GetScancodeFromKey(SDLK_RGUI);
slouken@12201
   156
        keymap[0x68]        = SDL_GetScancodeFromKey(SDLK_MENU);
slouken@12201
   157
        keymap[0x69]        = SDL_GetScancodeFromKey(SDLK_2); /* SDLK_EURO */
slouken@12201
   158
        keymap[0x6a]        = SDL_GetScancodeFromKey(SDLK_KP_EQUALS);
slouken@12201
   159
        keymap[0x6b]        = SDL_GetScancodeFromKey(SDLK_POWER);
nathanheisey@5928
   160
}
nathanheisey@5928
   161
icculus@12082
   162
SDL_Scancode HAIKU_GetScancodeFromBeKey(int32 bkey) {
slouken@12201
   163
    if(bkey > 0 && bkey < (int32)SDL_TABLESIZE(keymap)) {
slouken@12201
   164
        return keymap[bkey];
slouken@12201
   165
    } else {
slouken@12201
   166
        return SDL_SCANCODE_UNKNOWN;
slouken@12201
   167
    }
nathanheisey@5928
   168
}
nathanheisey@5928
   169
icculus@12082
   170
int8 HAIKU_GetKeyState(int32 bkey) {
slouken@12201
   171
    if(bkey > 0 && bkey < KEYMAP_SIZE) {
slouken@12201
   172
        return keystate[bkey];
slouken@12201
   173
    } else {
slouken@12201
   174
        return SDL_RELEASED;
slouken@12201
   175
    }
nathanheisey@5928
   176
}
nathanheisey@5928
   177
icculus@12082
   178
void HAIKU_SetKeyState(int32 bkey, int8 state) {
slouken@12201
   179
    if(bkey > 0 && bkey < KEYMAP_SIZE) {
slouken@12201
   180
        keystate[bkey] = state;
slouken@12201
   181
    }
nathanheisey@5928
   182
}
nathanheisey@5928
   183
nathanheisey@5928
   184
#ifdef __cplusplus
nathanheisey@5928
   185
}
nathanheisey@5928
   186
#endif
slouken@6044
   187
icculus@7981
   188
#endif /* SDL_VIDEO_DRIVER_HAIKU */
slouken@10690
   189
slouken@10690
   190
/* vi: set ts=4 sw=4 expandtab: */