src/video/haiku/SDL_bkeyboard.cc
author Sam Lantinga <slouken@libsdl.org>
Mon, 26 Dec 2016 02:12:21 -0800
changeset 10721 88943d97bf00
parent 10690 23a825f341e6
child 10737 3406a0f8b041
permissions -rw-r--r--
Fixed bug 3517 - Compiler warnings with gcc -Wstrict-prototypes

felix

Compiling even a simple SDL2 'hello world' program with gcc -Wstrict-prototypes (GCC 6.2.1) results in warnings like:

/usr/include/SDL2/SDL_gamecontroller.h:143:1: attention : function declaration isn't a prototype [-Wstrict-prototypes]
extern DECLSPEC int SDLCALL SDL_GameControllerNumMappings();
^~~~~~

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