annotate src/video/vgl/SDL_vglevents.c @ 1643:51038e80ae59

More general fix for bug #189 The clipping is done at a higher level, and the low level functions are passed clipped rectangles. Drivers which don't support source clipping have not been changed, so the image will be squished instead of clipped, but at least they will no longer crash when the destination rect was out of bounds.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 17 Apr 2006 06:47:23 +0000
parents d910939febfa
children 782fd950bd46 c121d94672cb a1b03ba2fcd0
rev   line source
75
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1 /*
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
75
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
4
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
6 modify it under the terms of the GNU Lesser General Public
75
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
75
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
9
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
13 Lesser General Public License for more details.
75
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
14
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
15 You should have received a copy of the GNU Lesser General Public
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
16 License along with this library; if not, write to the Free Software
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
75
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
18
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
19 Sam Lantinga
252
e8157fcb3114 Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents: 75
diff changeset
20 slouken@libsdl.org
75
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
21 */
1402
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1379
diff changeset
22 #include "SDL_config.h"
75
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
24 /* Handle the event stream, converting X11 events into SDL events */
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
25
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
26 #include <stdio.h>
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
27
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
28 #include <sys/fbio.h>
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
29 #include <sys/consio.h>
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
30 #include <sys/kbio.h>
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
31 #include <vgl.h>
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
32
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
33 #include "SDL.h"
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
34 #include "SDL_thread.h"
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
35 #include "../../events/SDL_sysevents.h"
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
36 #include "../../events/SDL_events_c.h"
75
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
37 #include "SDL_vglvideo.h"
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
38 #include "SDL_vglevents_c.h"
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
39
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
40 /* The translation tables from a console scancode to a SDL keysym */
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
41 /* FIXME: Free the keymap when we shut down the video mode */
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
42 static keymap_t *vga_keymap = NULL;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
43 static SDLKey keymap[128];
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
44 static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym);
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
45
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
46 static int posted = 0;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
47 static int oldx = -1;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
48 static int oldy = -1;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
49 static struct mouse_info mouseinfo;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
50
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
51 /* Ugh, we have to duplicate the kernel's keysym mapping code...
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
52 Oh, it's not so bad. :-)
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
53
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
54 FIXME: Add keyboard LED handling code
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
55 */
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
56 int VGL_initkeymaps(int fd)
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
57 {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
58 vga_keymap = SDL_malloc(sizeof(keymap_t));
75
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
59 if ( ! vga_keymap ) {
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
60 SDL_OutOfMemory();
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
61 return(-1);
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
62 }
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
63 if (ioctl(fd, GIO_KEYMAP, vga_keymap) == -1) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
64 SDL_free(vga_keymap);
75
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
65 vga_keymap = NULL;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
66 SDL_SetError("Unable to get keyboard map");
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
67 return(-1);
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
68 }
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
69 return(0);
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
70 }
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
71
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
72 static void handle_keyboard(_THIS)
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
73 {
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
74 SDL_keysym keysym;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
75 int c, pressed, scancode;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
76
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
77 while ((c = VGLKeyboardGetCh()) != 0) {
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
78 scancode = c & 0x7F;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
79 if (c & 0x80) {
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
80 pressed = SDL_RELEASED;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
81 } else {
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
82 pressed = SDL_PRESSED;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
83 }
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
84
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
85 posted += SDL_PrivateKeyboard(pressed,
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
86 TranslateKey(scancode, &keysym));
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
87 }
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
88 }
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
89
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
90 int VGL_initmouse(int fd)
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
91 {
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
92 mouseinfo.operation = MOUSE_GETINFO;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
93 if (ioctl(fd, CONS_MOUSECTL, &mouseinfo) != 0)
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
94 return -1;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
95
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
96 return 0;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
97 }
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
98
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
99 static void handle_mouse(_THIS)
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
100 {
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
101 char buttons;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
102 int x, y;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
103 int button_state, state_changed, state;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
104 int i;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
105
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
106 ioctl(0, CONS_MOUSECTL, &mouseinfo);
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
107 x = mouseinfo.u.data.x;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
108 y = mouseinfo.u.data.y;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
109 buttons = mouseinfo.u.data.buttons;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
110
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
111 if ((x != oldx) || (y != oldy)) {
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
112 posted += SDL_PrivateMouseMotion(0, 0, x, y);
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
113 oldx = x;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
114 oldy = y;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
115 }
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
116
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
117 /* See what's changed */
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
118 button_state = SDL_GetMouseState(NULL, NULL);
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
119 state_changed = button_state ^ buttons;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
120 for (i = 0; i < 8; i++) {
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
121 if (state_changed & (1<<i)) {
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
122 if (buttons & (1<<i)) {
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
123 state = SDL_PRESSED;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
124 } else {
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
125 state = SDL_RELEASED;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
126 }
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
127 posted += SDL_PrivateMouseButton(state, i + 1, 0, 0);
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
128 }
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
129 }
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
130 }
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
131
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
132
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
133 void VGL_PumpEvents(_THIS)
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
134 {
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
135 do {
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
136 posted = 0;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
137 handle_keyboard(this);
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
138 handle_mouse(this);
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
139 } while (posted != 0);
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
140 }
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
141
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
142 void VGL_InitOSKeymap(_THIS)
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
143 {
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
144 int i;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
145
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
146 /* Initialize the BeOS key translation table */
1379
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
147 for ( i=0; i<SDL_arraysize(keymap); ++i )
75
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
148 keymap[i] = SDLK_UNKNOWN;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
149
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
150 keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
151 keymap[SCANCODE_1] = SDLK_1;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
152 keymap[SCANCODE_2] = SDLK_2;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
153 keymap[SCANCODE_3] = SDLK_3;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
154 keymap[SCANCODE_4] = SDLK_4;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
155 keymap[SCANCODE_5] = SDLK_5;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
156 keymap[SCANCODE_6] = SDLK_6;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
157 keymap[SCANCODE_7] = SDLK_7;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
158 keymap[SCANCODE_8] = SDLK_8;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
159 keymap[SCANCODE_9] = SDLK_9;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
160 keymap[SCANCODE_0] = SDLK_0;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
161 keymap[SCANCODE_MINUS] = SDLK_MINUS;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
162 keymap[SCANCODE_EQUAL] = SDLK_EQUALS;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
163 keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
164 keymap[SCANCODE_TAB] = SDLK_TAB;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
165 keymap[SCANCODE_Q] = SDLK_q;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
166 keymap[SCANCODE_W] = SDLK_w;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
167 keymap[SCANCODE_E] = SDLK_e;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
168 keymap[SCANCODE_R] = SDLK_r;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
169 keymap[SCANCODE_T] = SDLK_t;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
170 keymap[SCANCODE_Y] = SDLK_y;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
171 keymap[SCANCODE_U] = SDLK_u;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
172 keymap[SCANCODE_I] = SDLK_i;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
173 keymap[SCANCODE_O] = SDLK_o;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
174 keymap[SCANCODE_P] = SDLK_p;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
175 keymap[SCANCODE_BRACKET_LEFT] = SDLK_LEFTBRACKET;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
176 keymap[SCANCODE_BRACKET_RIGHT] = SDLK_RIGHTBRACKET;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
177 keymap[SCANCODE_ENTER] = SDLK_RETURN;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
178 keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
179 keymap[SCANCODE_A] = SDLK_a;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
180 keymap[SCANCODE_S] = SDLK_s;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
181 keymap[SCANCODE_D] = SDLK_d;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
182 keymap[SCANCODE_F] = SDLK_f;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
183 keymap[SCANCODE_G] = SDLK_g;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
184 keymap[SCANCODE_H] = SDLK_h;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
185 keymap[SCANCODE_J] = SDLK_j;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
186 keymap[SCANCODE_K] = SDLK_k;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
187 keymap[SCANCODE_L] = SDLK_l;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
188 keymap[SCANCODE_SEMICOLON] = SDLK_SEMICOLON;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
189 keymap[SCANCODE_APOSTROPHE] = SDLK_QUOTE;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
190 keymap[SCANCODE_GRAVE] = SDLK_BACKQUOTE;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
191 keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
192 keymap[SCANCODE_BACKSLASH] = SDLK_BACKSLASH;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
193 keymap[SCANCODE_Z] = SDLK_z;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
194 keymap[SCANCODE_X] = SDLK_x;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
195 keymap[SCANCODE_C] = SDLK_c;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
196 keymap[SCANCODE_V] = SDLK_v;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
197 keymap[SCANCODE_B] = SDLK_b;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
198 keymap[SCANCODE_N] = SDLK_n;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
199 keymap[SCANCODE_M] = SDLK_m;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
200 keymap[SCANCODE_COMMA] = SDLK_COMMA;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
201 keymap[SCANCODE_PERIOD] = SDLK_PERIOD;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
202 keymap[SCANCODE_SLASH] = SDLK_SLASH;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
203 keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
204 keymap[SCANCODE_KEYPADMULTIPLY] = SDLK_KP_MULTIPLY;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
205 keymap[SCANCODE_LEFTALT] = SDLK_LALT;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
206 keymap[SCANCODE_SPACE] = SDLK_SPACE;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
207 keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
208 keymap[SCANCODE_F1] = SDLK_F1;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
209 keymap[SCANCODE_F2] = SDLK_F2;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
210 keymap[SCANCODE_F3] = SDLK_F3;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
211 keymap[SCANCODE_F4] = SDLK_F4;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
212 keymap[SCANCODE_F5] = SDLK_F5;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
213 keymap[SCANCODE_F6] = SDLK_F6;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
214 keymap[SCANCODE_F7] = SDLK_F7;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
215 keymap[SCANCODE_F8] = SDLK_F8;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
216 keymap[SCANCODE_F9] = SDLK_F9;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
217 keymap[SCANCODE_F10] = SDLK_F10;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
218 keymap[SCANCODE_NUMLOCK] = SDLK_NUMLOCK;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
219 keymap[SCANCODE_SCROLLLOCK] = SDLK_SCROLLOCK;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
220 keymap[SCANCODE_KEYPAD7] = SDLK_KP7;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
221 keymap[SCANCODE_CURSORUPLEFT] = SDLK_KP7;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
222 keymap[SCANCODE_KEYPAD8] = SDLK_KP8;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
223 keymap[SCANCODE_CURSORUP] = SDLK_KP8;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
224 keymap[SCANCODE_KEYPAD9] = SDLK_KP9;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
225 keymap[SCANCODE_CURSORUPRIGHT] = SDLK_KP9;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
226 keymap[SCANCODE_KEYPADMINUS] = SDLK_KP_MINUS;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
227 keymap[SCANCODE_KEYPAD4] = SDLK_KP4;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
228 keymap[SCANCODE_CURSORLEFT] = SDLK_KP4;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
229 keymap[SCANCODE_KEYPAD5] = SDLK_KP5;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
230 keymap[SCANCODE_KEYPAD6] = SDLK_KP6;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
231 keymap[SCANCODE_CURSORRIGHT] = SDLK_KP6;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
232 keymap[SCANCODE_KEYPADPLUS] = SDLK_KP_PLUS;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
233 keymap[SCANCODE_KEYPAD1] = SDLK_KP1;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
234 keymap[SCANCODE_CURSORDOWNLEFT] = SDLK_KP1;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
235 keymap[SCANCODE_KEYPAD2] = SDLK_KP2;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
236 keymap[SCANCODE_CURSORDOWN] = SDLK_KP2;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
237 keymap[SCANCODE_KEYPAD3] = SDLK_KP3;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
238 keymap[SCANCODE_CURSORDOWNRIGHT] = SDLK_KP3;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
239 keymap[SCANCODE_KEYPAD0] = SDLK_KP0;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
240 keymap[SCANCODE_KEYPADPERIOD] = SDLK_KP_PERIOD;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
241 keymap[SCANCODE_LESS] = SDLK_LESS;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
242 keymap[SCANCODE_F11] = SDLK_F11;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
243 keymap[SCANCODE_F12] = SDLK_F12;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
244 keymap[SCANCODE_KEYPADENTER] = SDLK_KP_ENTER;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
245 keymap[SCANCODE_RIGHTCONTROL] = SDLK_RCTRL;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
246 keymap[SCANCODE_CONTROL] = SDLK_RCTRL;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
247 keymap[SCANCODE_KEYPADDIVIDE] = SDLK_KP_DIVIDE;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
248 keymap[SCANCODE_PRINTSCREEN] = SDLK_PRINT;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
249 keymap[SCANCODE_RIGHTALT] = SDLK_RALT;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
250 keymap[SCANCODE_BREAK] = SDLK_BREAK;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
251 keymap[SCANCODE_BREAK_ALTERNATIVE] = SDLK_UNKNOWN;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
252 keymap[SCANCODE_HOME] = SDLK_HOME;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
253 keymap[SCANCODE_CURSORBLOCKUP] = SDLK_UP;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
254 keymap[SCANCODE_PAGEUP] = SDLK_PAGEUP;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
255 keymap[SCANCODE_CURSORBLOCKLEFT] = SDLK_LEFT;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
256 keymap[SCANCODE_CURSORBLOCKRIGHT] = SDLK_RIGHT;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
257 keymap[SCANCODE_END] = SDLK_END;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
258 keymap[SCANCODE_CURSORBLOCKDOWN] = SDLK_DOWN;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
259 keymap[SCANCODE_PAGEDOWN] = SDLK_PAGEDOWN;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
260 keymap[SCANCODE_INSERT] = SDLK_INSERT;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
261 keymap[SCANCODE_REMOVE] = SDLK_DELETE;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
262 keymap[119] = SDLK_PAUSE;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
263 keymap[SCANCODE_RIGHTWIN] = SDLK_RSUPER;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
264 keymap[SCANCODE_LEFTWIN] = SDLK_LSUPER;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
265 keymap[127] = SDLK_MENU;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
266 }
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
267
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
268 static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym)
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
269 {
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
270 /* Set the keysym information */
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
271 keysym->scancode = scancode;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
272 keysym->sym = keymap[scancode];
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
273 keysym->mod = KMOD_NONE;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
274
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
275 /* If UNICODE is on, get the UNICODE value for the key */
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
276 keysym->unicode = 0;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
277 if ( SDL_TranslateUNICODE && vga_keymap ) {
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
278 int map;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
279 SDLMod modstate;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
280
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
281 modstate = SDL_GetModState();
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
282 map = 0;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
283 if ( modstate & KMOD_SHIFT ) {
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
284 map += 1;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
285 }
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
286 if ( modstate & KMOD_CTRL ) {
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
287 map += 2;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
288 }
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
289 if ( modstate & KMOD_ALT ) {
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
290 map += 4;
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
291 }
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
292 if ( !(vga_keymap->key[scancode].spcl & (0x80 >> map)) ) {
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
293 keysym->unicode = vga_keymap->key[scancode].map[map];
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
294 }
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
295
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
296 }
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
297 return(keysym);
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
298 }
b0ae59d0f3ee Added patches from FreeBSD ports
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
299