annotate src/video/bwindow/SDL_sysevents.cc @ 3911:ba3abfa20e18 SDL-1.2

Digital Mars has stdint.h, so use the header on Windows with that compiler. Fixes Bugzilla #376.
author Ryan C. Gordon <icculus@icculus.org>
date Mon, 12 Feb 2007 11:45:18 +0000
parents 678576473849
children 1146681dbb74
rev   line source
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1 /*
74212992fb08 Initial revision
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: 907
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
4
74212992fb08 Initial revision
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: 907
diff changeset
6 modify it under the terms of the GNU Lesser General Public
0
74212992fb08 Initial revision
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: 907
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
9
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
74212992fb08 Initial revision
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: 907
diff changeset
13 Lesser General Public License for more details.
0
74212992fb08 Initial revision
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: 907
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: 907
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: 907
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
18
74212992fb08 Initial revision
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: 1
diff changeset
20 slouken@libsdl.org
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
21 */
1403
376665398b25 Catch the C++ and Objective C sources too...
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
22 #include "SDL_config.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
24 #include <support/UTF8.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
25 #include <stdio.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
26 #include <string.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
27 #include "SDL_error.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
28 #include "SDL_events.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
29 #include "SDL_BWin.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
30 #include "SDL_lowvideo.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
31
3878
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
32 static SDLKey keymap[128];
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
33 int mouse_relative = 0;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
34 extern "C" {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
35
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
36 #include "../../events/SDL_sysevents.h"
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
37 #include "../../events/SDL_events_c.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
38 #include "SDL_sysevents_c.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
39
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
40 void BE_PumpEvents(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
41 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
42 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
43
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
44 void BE_InitOSKeymap(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
45 {
3878
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
46 for ( uint i=0; i<SDL_TABLESIZE(keymap); ++i )
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
47 keymap[i] = SDLK_UNKNOWN;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
48
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
49 keymap[0x01] = SDLK_ESCAPE;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
50 keymap[B_F1_KEY] = SDLK_F1;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
51 keymap[B_F2_KEY] = SDLK_F2;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
52 keymap[B_F3_KEY] = SDLK_F3;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
53 keymap[B_F4_KEY] = SDLK_F4;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
54 keymap[B_F5_KEY] = SDLK_F5;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
55 keymap[B_F6_KEY] = SDLK_F6;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
56 keymap[B_F7_KEY] = SDLK_F7;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
57 keymap[B_F8_KEY] = SDLK_F8;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
58 keymap[B_F9_KEY] = SDLK_F9;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
59 keymap[B_F10_KEY] = SDLK_F10;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
60 keymap[B_F11_KEY] = SDLK_F11;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
61 keymap[B_F12_KEY] = SDLK_F12;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
62 keymap[B_PRINT_KEY] = SDLK_PRINT;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
63 keymap[B_SCROLL_KEY] = SDLK_SCROLLOCK;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
64 keymap[B_PAUSE_KEY] = SDLK_PAUSE;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
65 keymap[0x11] = SDLK_BACKQUOTE;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
66 keymap[0x12] = SDLK_1;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
67 keymap[0x13] = SDLK_2;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
68 keymap[0x14] = SDLK_3;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
69 keymap[0x15] = SDLK_4;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
70 keymap[0x16] = SDLK_5;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
71 keymap[0x17] = SDLK_6;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
72 keymap[0x18] = SDLK_7;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
73 keymap[0x19] = SDLK_8;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
74 keymap[0x1a] = SDLK_9;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
75 keymap[0x1b] = SDLK_0;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
76 keymap[0x1c] = SDLK_MINUS;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
77 keymap[0x1d] = SDLK_EQUALS;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
78 keymap[0x1e] = SDLK_BACKSPACE;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
79 keymap[0x1f] = SDLK_INSERT;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
80 keymap[0x20] = SDLK_HOME;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
81 keymap[0x21] = SDLK_PAGEUP;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
82 keymap[0x22] = SDLK_NUMLOCK;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
83 keymap[0x23] = SDLK_KP_DIVIDE;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
84 keymap[0x24] = SDLK_KP_MULTIPLY;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
85 keymap[0x25] = SDLK_KP_MINUS;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
86 keymap[0x26] = SDLK_TAB;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
87 keymap[0x27] = SDLK_q;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
88 keymap[0x28] = SDLK_w;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
89 keymap[0x29] = SDLK_e;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
90 keymap[0x2a] = SDLK_r;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
91 keymap[0x2b] = SDLK_t;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
92 keymap[0x2c] = SDLK_y;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
93 keymap[0x2d] = SDLK_u;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
94 keymap[0x2e] = SDLK_i;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
95 keymap[0x2f] = SDLK_o;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
96 keymap[0x30] = SDLK_p;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
97 keymap[0x31] = SDLK_LEFTBRACKET;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
98 keymap[0x32] = SDLK_RIGHTBRACKET;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
99 keymap[0x33] = SDLK_BACKSLASH;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
100 keymap[0x34] = SDLK_DELETE;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
101 keymap[0x35] = SDLK_END;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
102 keymap[0x36] = SDLK_PAGEDOWN;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
103 keymap[0x37] = SDLK_KP7;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
104 keymap[0x38] = SDLK_KP8;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
105 keymap[0x39] = SDLK_KP9;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
106 keymap[0x3a] = SDLK_KP_PLUS;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
107 keymap[0x3b] = SDLK_CAPSLOCK;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
108 keymap[0x3c] = SDLK_a;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
109 keymap[0x3d] = SDLK_s;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
110 keymap[0x3e] = SDLK_d;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
111 keymap[0x3f] = SDLK_f;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
112 keymap[0x40] = SDLK_g;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
113 keymap[0x41] = SDLK_h;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
114 keymap[0x42] = SDLK_j;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
115 keymap[0x43] = SDLK_k;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
116 keymap[0x44] = SDLK_l;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
117 keymap[0x45] = SDLK_SEMICOLON;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
118 keymap[0x46] = SDLK_QUOTE;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
119 keymap[0x47] = SDLK_RETURN;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
120 keymap[0x48] = SDLK_KP4;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
121 keymap[0x49] = SDLK_KP5;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
122 keymap[0x4a] = SDLK_KP6;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
123 keymap[0x4b] = SDLK_LSHIFT;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
124 keymap[0x4c] = SDLK_z;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
125 keymap[0x4d] = SDLK_x;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
126 keymap[0x4e] = SDLK_c;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
127 keymap[0x4f] = SDLK_v;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
128 keymap[0x50] = SDLK_b;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
129 keymap[0x51] = SDLK_n;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
130 keymap[0x52] = SDLK_m;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
131 keymap[0x53] = SDLK_COMMA;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
132 keymap[0x54] = SDLK_PERIOD;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
133 keymap[0x55] = SDLK_SLASH;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
134 keymap[0x56] = SDLK_RSHIFT;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
135 keymap[0x57] = SDLK_UP;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
136 keymap[0x58] = SDLK_KP1;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
137 keymap[0x59] = SDLK_KP2;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
138 keymap[0x5a] = SDLK_KP3;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
139 keymap[0x5b] = SDLK_KP_ENTER;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
140 keymap[0x5c] = SDLK_LCTRL;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
141 keymap[0x5d] = SDLK_LALT;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
142 keymap[0x5e] = SDLK_SPACE;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
143 keymap[0x5f] = SDLK_RALT;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
144 keymap[0x60] = SDLK_RCTRL;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
145 keymap[0x61] = SDLK_LEFT;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
146 keymap[0x62] = SDLK_DOWN;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
147 keymap[0x63] = SDLK_RIGHT;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
148 keymap[0x64] = SDLK_KP0;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
149 keymap[0x65] = SDLK_KP_PERIOD;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
150 keymap[0x66] = SDLK_LMETA;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
151 keymap[0x67] = SDLK_RMETA;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
152 keymap[0x68] = SDLK_MENU;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
153 keymap[0x69] = SDLK_EURO;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
154 keymap[0x6a] = SDLK_KP_EQUALS;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
155 keymap[0x6b] = SDLK_POWER;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
156 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
157
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
158 }; /* Extern C */
3878
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
159
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
160 void SDL_BWin::DispatchMessage(BMessage *msg, BHandler *target)
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
161 {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
162 switch (msg->what) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
163 case B_MOUSE_MOVED:
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
164 {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
165 SDL_VideoDevice *view = current_video;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
166 BPoint where;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
167 int32 transit;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
168 if (msg->FindPoint("where", &where) == B_OK && msg->FindInt32("be:transit", &transit) == B_OK) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
169
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
170 //BeSman: I need another method for cursor catching !!!
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
171 if(view->input_grab != SDL_GRAB_OFF)
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
172 {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
173 BPoint center;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
174 center.x = (SDL_VideoSurface->w/2);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
175 center.y = (SDL_VideoSurface->h/2);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
176 BPoint delta = where - center;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
177 if(delta.x > center.x)
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
178 SDL_WarpMouse((int)center.x*2,(int)where.y);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
179
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
180 if(delta.x < -center.x)
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
181 SDL_WarpMouse(0,(int)where.y);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
182
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
183 if(delta.y > center.y)
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
184 SDL_WarpMouse((int)where.x,(int)center.y*2);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
185
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
186 if(delta.y < -center.y)
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
187 SDL_WarpMouse((int)where.x,0);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
188
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
189
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
190 if((delta.x-1 < -center.x)&&(delta.y-1 < -center.y))
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
191 SDL_WarpMouse(1,1);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
192
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
193 if((delta.x-1 < -center.x)&&(delta.y+1 > center.y))
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
194 SDL_WarpMouse(1,(int)center.y*2-1);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
195
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
196 if((delta.x+1 > center.x)&&(delta.y-1 < -center.y))
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
197 SDL_WarpMouse((int)center.x*2-1,1);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
198
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
199 if((delta.x+1 > center.x)&&(delta.y+1 > center.y))
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
200 SDL_WarpMouse((int)center.x*2-1,(int)center.y*2-1);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
201
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
202 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
203 if (transit == B_EXITED_VIEW) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
204 if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
205 SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
206 // be_app->SetCursor(B_HAND_CURSOR);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
207 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
208 } else {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
209
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
210 int x, y;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
211 if ( ! (SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
212 SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
213 SDL_SetCursor(NULL);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
214 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
215 x = (int)where.x;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
216 y = (int)where.y;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
217
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
218 if ( mouse_relative ) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
219 BPoint center;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
220 center.x = (SDL_VideoSurface->w/2);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
221 center.y = (SDL_VideoSurface->h/2);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
222 x -= (int)center.x;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
223 y -= (int)center.y;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
224 if ( x || y ) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
225 ConvertToScreen(&center);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
226 set_mouse_position((int)center.x, (int)center.y);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
227 SDL_PrivateMouseMotion(0, 1, x, y);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
228 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
229 } else {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
230 SDL_PrivateMouseMotion(0, 0, x, y);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
231 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
232 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
233 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
234 break;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
235 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
236
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
237 case B_MOUSE_DOWN:
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
238 {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
239 /* it looks like mouse down is send only for first clicked
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
240 button, each next is not send while last one is holded */
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
241 int32 buttons;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
242 int sdl_buttons = 0;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
243 if (msg->FindInt32("buttons", &buttons) == B_OK) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
244 /* Add any mouse button events */
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
245 if (buttons & B_PRIMARY_MOUSE_BUTTON) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
246 sdl_buttons |= SDL_BUTTON_LEFT;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
247 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
248 if (buttons & B_SECONDARY_MOUSE_BUTTON) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
249 sdl_buttons |= SDL_BUTTON_RIGHT;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
250 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
251 if (buttons & B_TERTIARY_MOUSE_BUTTON) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
252 sdl_buttons |= SDL_BUTTON_MIDDLE;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
253 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
254 SDL_PrivateMouseButton(SDL_PRESSED, sdl_buttons, 0, 0);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
255
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
256 last_buttons = buttons;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
257 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
258 break;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
259 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
260
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
261 case B_MOUSE_UP:
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
262 {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
263 /* mouse up doesn't give which button was released,
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
264 only state of buttons (after release, so it's always = 0),
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
265 which is not what we need ;]
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
266 So we need to store button in mouse down, and restore
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
267 in mouse up :(
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
268 mouse up is (similarly to mouse down) send only for
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
269 first button down (ie. it's no send if we click another button
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
270 without releasing previous one first) - but that's probably
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
271 because of how drivers are written?, not BeOS itself. */
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
272 int32 buttons;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
273 int sdl_buttons = 0;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
274 if (msg->FindInt32("buttons", &buttons) == B_OK) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
275 /* Add any mouse button events */
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
276 if ((buttons ^ B_PRIMARY_MOUSE_BUTTON) & last_buttons) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
277 sdl_buttons |= SDL_BUTTON_LEFT;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
278 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
279 if ((buttons ^ B_SECONDARY_MOUSE_BUTTON) & last_buttons) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
280 sdl_buttons |= SDL_BUTTON_RIGHT;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
281 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
282 if ((buttons ^ B_TERTIARY_MOUSE_BUTTON) & last_buttons) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
283 sdl_buttons |= SDL_BUTTON_MIDDLE;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
284 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
285 SDL_PrivateMouseButton(SDL_RELEASED, sdl_buttons, 0, 0);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
286
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
287 last_buttons = buttons;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
288 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
289 break;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
290 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
291
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
292 case B_MOUSE_WHEEL_CHANGED:
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
293 {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
294 float x, y;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
295 x = y = 0;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
296 if (msg->FindFloat("be:wheel_delta_x", &x) == B_OK && msg->FindFloat("be:wheel_delta_y", &y) == B_OK) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
297 if (x < 0 || y < 0) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
298 SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELDOWN, 0, 0);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
299 SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELDOWN, 0, 0);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
300 } else if (x > 0 || y > 0) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
301 SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELUP, 0, 0);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
302 SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELUP, 0, 0);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
303 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
304 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
305 break;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
306 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
307
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
308 case B_KEY_DOWN:
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
309 case B_UNMAPPED_KEY_DOWN: /* modifier keys are unmapped */
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
310 {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
311 int32 key;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
312 int32 modifiers;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
313 int32 key_repeat;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
314 /* Workaround for SDL message queue being filled too fast because of BeOS own key-repeat mechanism */
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
315 if (msg->FindInt32("be:key_repeat", &key_repeat) == B_OK && key_repeat > 0)
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
316 break;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
317
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
318 if (msg->FindInt32("key", &key) == B_OK && msg->FindInt32("modifiers", &modifiers) == B_OK) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
319 SDL_keysym keysym;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
320 keysym.scancode = key;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
321 if (key < 128) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
322 keysym.sym = keymap[key];
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
323 } else {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
324 keysym.sym = SDLK_UNKNOWN;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
325 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
326 /* FIX THIS?
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
327 it seems SDL_PrivateKeyboard() changes mod value
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
328 anyway, and doesn't care about what we setup here */
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
329 keysym.mod = KMOD_NONE;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
330 keysym.unicode = 0;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
331 if (SDL_TranslateUNICODE) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
332 const char *bytes;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
333 if (msg->FindString("bytes", &bytes) == B_OK) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
334 /* FIX THIS?
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
335 this cares only about first "letter",
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
336 so if someone maps some key to print
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
337 "BeOS rulez!" only "B" will be used. */
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
338 keysym.unicode = Translate2Unicode(bytes);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
339 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
340 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
341 SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
342 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
343 break;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
344 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
345
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
346 case B_KEY_UP:
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
347 case B_UNMAPPED_KEY_UP: /* modifier keys are unmapped */
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
348 {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
349 int32 key;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
350 int32 modifiers;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
351 if (msg->FindInt32("key", &key) == B_OK && msg->FindInt32("modifiers", &modifiers) == B_OK) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
352 SDL_keysym keysym;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
353 keysym.scancode = key;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
354 if (key < 128) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
355 keysym.sym = keymap[key];
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
356 } else {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
357 keysym.sym = SDLK_UNKNOWN;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
358 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
359 keysym.mod = KMOD_NONE; /* FIX THIS? */
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
360 keysym.unicode = 0;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
361 if (SDL_TranslateUNICODE) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
362 const char *bytes;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
363 if (msg->FindString("bytes", &bytes) == B_OK) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
364 keysym.unicode = Translate2Unicode(bytes);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
365 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
366 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
367 SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
368 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
369 break;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
370 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
371
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
372 default:
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
373 /* move it after switch{} so it's always handled
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
374 that way we keep BeOS feautures like:
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
375 - CTRL+Q to close window (and other shortcuts)
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
376 - PrintScreen to make screenshot into /boot/home
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
377 - etc.. */
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
378 //BDirectWindow::DispatchMessage(msg, target);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
379 break;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
380 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
381 BDirectWindow::DispatchMessage(msg, target);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
382 }