annotate src/video/bwindow/SDL_sysevents.cc @ 4012:4e29535b821b SDL-1.2

Fixed bug #360 Fixed fullscreen video modes and improved the mouse grab code.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 07 Jul 2007 19:20:28 +0000
parents f5794774970d
children a1b03ba2fcd0
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) {
4012
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
169 int x, y;
3878
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
170
4012
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
171 GetXYOffset(x, y);
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
172 x = (int)where.x - x;
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
173 y = (int)where.y - y;
3878
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
174
4012
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
175 //BeSman: I need another method for cursor catching !!!
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
176 if (view->input_grab != SDL_GRAB_OFF)
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
177 {
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
178 bool clipped = false;
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
179 if ( x < 0 ) {
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
180 x = 0;
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
181 clipped = true;
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
182 } else if ( x >= SDL_VideoSurface->w ) {
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
183 x = (SDL_VideoSurface->w-1);
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
184 clipped = true;
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
185 }
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
186 if ( y < 0 ) {
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
187 y = 0;
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
188 clipped = true;
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
189 } else if ( y >= SDL_VideoSurface->h ) {
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
190 y = (SDL_VideoSurface->h-1);
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
191 clipped = true;
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
192 }
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
193 if ( clipped ) {
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
194 BPoint edge;
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
195 GetXYOffset(edge.x, edge.y);
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
196 edge.x += x;
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
197 edge.y += y;
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
198 ConvertToScreen(&edge);
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
199 set_mouse_position((int)edge.x, (int)edge.y);
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
200 }
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
201 transit = B_INSIDE_VIEW;
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
202 }
3878
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);
4012
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
206 be_app->SetCursor(B_HAND_CURSOR);
3878
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 {
4012
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
209 if ( !(SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
3878
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
210 SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
211 SDL_SetCursor(NULL);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
212 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
213
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
214 if ( mouse_relative ) {
4012
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
215 int half_w = (SDL_VideoSurface->w/2);
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
216 int half_h = (SDL_VideoSurface->h/2);
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
217 x -= half_w;
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
218 y -= half_h;
3878
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
219 if ( x || y ) {
4012
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
220 BPoint center;
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
221 GetXYOffset(center.x, center.y);
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
222 center.x += half_w;
4e29535b821b Fixed bug #360
Sam Lantinga <slouken@libsdl.org>
parents: 4011
diff changeset
223 center.y += half_h;
3878
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
224 ConvertToScreen(&center);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
225 set_mouse_position((int)center.x, (int)center.y);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
226 SDL_PrivateMouseMotion(0, 1, x, y);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
227 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
228 } else {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
229 SDL_PrivateMouseMotion(0, 0, x, y);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
230 }
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 break;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
234 }
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 case B_MOUSE_DOWN:
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
237 {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
238 /* it looks like mouse down is send only for first clicked
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
239 button, each next is not send while last one is holded */
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
240 int32 buttons;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
241 int sdl_buttons = 0;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
242 if (msg->FindInt32("buttons", &buttons) == B_OK) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
243 /* Add any mouse button events */
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
244 if (buttons & B_PRIMARY_MOUSE_BUTTON) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
245 sdl_buttons |= SDL_BUTTON_LEFT;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
246 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
247 if (buttons & B_SECONDARY_MOUSE_BUTTON) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
248 sdl_buttons |= SDL_BUTTON_RIGHT;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
249 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
250 if (buttons & B_TERTIARY_MOUSE_BUTTON) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
251 sdl_buttons |= SDL_BUTTON_MIDDLE;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
252 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
253 SDL_PrivateMouseButton(SDL_PRESSED, sdl_buttons, 0, 0);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
254
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
255 last_buttons = buttons;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
256 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
257 break;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
258 }
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 case B_MOUSE_UP:
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
261 {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
262 /* mouse up doesn't give which button was released,
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
263 only state of buttons (after release, so it's always = 0),
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
264 which is not what we need ;]
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
265 So we need to store button in mouse down, and restore
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
266 in mouse up :(
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
267 mouse up is (similarly to mouse down) send only for
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
268 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
269 without releasing previous one first) - but that's probably
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
270 because of how drivers are written?, not BeOS itself. */
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
271 int32 buttons;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
272 int sdl_buttons = 0;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
273 if (msg->FindInt32("buttons", &buttons) == B_OK) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
274 /* Add any mouse button events */
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
275 if ((buttons ^ B_PRIMARY_MOUSE_BUTTON) & last_buttons) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
276 sdl_buttons |= SDL_BUTTON_LEFT;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
277 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
278 if ((buttons ^ B_SECONDARY_MOUSE_BUTTON) & last_buttons) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
279 sdl_buttons |= SDL_BUTTON_RIGHT;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
280 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
281 if ((buttons ^ B_TERTIARY_MOUSE_BUTTON) & last_buttons) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
282 sdl_buttons |= SDL_BUTTON_MIDDLE;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
283 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
284 SDL_PrivateMouseButton(SDL_RELEASED, sdl_buttons, 0, 0);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
285
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
286 last_buttons = buttons;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
287 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
288 break;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
289 }
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 case B_MOUSE_WHEEL_CHANGED:
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
292 {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
293 float x, y;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
294 x = y = 0;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
295 if (msg->FindFloat("be:wheel_delta_x", &x) == B_OK && msg->FindFloat("be:wheel_delta_y", &y) == B_OK) {
4011
f5794774970d Reverted mousewheel support in 1.2, since it breaks binary compatibility.
Sam Lantinga <slouken@libsdl.org>
parents: 4009
diff changeset
296 if (x < 0 || y < 0) {
f5794774970d Reverted mousewheel support in 1.2, since it breaks binary compatibility.
Sam Lantinga <slouken@libsdl.org>
parents: 4009
diff changeset
297 SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELDOWN, 0, 0);
f5794774970d Reverted mousewheel support in 1.2, since it breaks binary compatibility.
Sam Lantinga <slouken@libsdl.org>
parents: 4009
diff changeset
298 SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELDOWN, 0, 0);
f5794774970d Reverted mousewheel support in 1.2, since it breaks binary compatibility.
Sam Lantinga <slouken@libsdl.org>
parents: 4009
diff changeset
299 } else if (x > 0 || y > 0) {
f5794774970d Reverted mousewheel support in 1.2, since it breaks binary compatibility.
Sam Lantinga <slouken@libsdl.org>
parents: 4009
diff changeset
300 SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELUP, 0, 0);
f5794774970d Reverted mousewheel support in 1.2, since it breaks binary compatibility.
Sam Lantinga <slouken@libsdl.org>
parents: 4009
diff changeset
301 SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELUP, 0, 0);
3878
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
302 }
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 break;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
305 }
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 case B_KEY_DOWN:
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
308 case B_UNMAPPED_KEY_DOWN: /* modifier keys are unmapped */
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
309 {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
310 int32 key;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
311 int32 modifiers;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
312 int32 key_repeat;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
313 /* 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
314 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
315 break;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
316
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
317 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
318 SDL_keysym keysym;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
319 keysym.scancode = key;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
320 if (key < 128) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
321 keysym.sym = keymap[key];
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
322 } else {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
323 keysym.sym = SDLK_UNKNOWN;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
324 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
325 /* FIX THIS?
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
326 it seems SDL_PrivateKeyboard() changes mod value
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
327 anyway, and doesn't care about what we setup here */
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
328 keysym.mod = KMOD_NONE;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
329 keysym.unicode = 0;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
330 if (SDL_TranslateUNICODE) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
331 const char *bytes;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
332 if (msg->FindString("bytes", &bytes) == B_OK) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
333 /* FIX THIS?
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
334 this cares only about first "letter",
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
335 so if someone maps some key to print
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
336 "BeOS rulez!" only "B" will be used. */
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
337 keysym.unicode = Translate2Unicode(bytes);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
338 }
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 SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
341 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
342 break;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
343 }
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 case B_KEY_UP:
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
346 case B_UNMAPPED_KEY_UP: /* modifier keys are unmapped */
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
347 {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
348 int32 key;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
349 int32 modifiers;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
350 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
351 SDL_keysym keysym;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
352 keysym.scancode = key;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
353 if (key < 128) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
354 keysym.sym = keymap[key];
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
355 } else {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
356 keysym.sym = SDLK_UNKNOWN;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
357 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
358 keysym.mod = KMOD_NONE; /* FIX THIS? */
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
359 keysym.unicode = 0;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
360 if (SDL_TranslateUNICODE) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
361 const char *bytes;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
362 if (msg->FindString("bytes", &bytes) == B_OK) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
363 keysym.unicode = Translate2Unicode(bytes);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
364 }
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 SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
367 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
368 break;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
369 }
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 default:
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
372 /* move it after switch{} so it's always handled
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
373 that way we keep BeOS feautures like:
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
374 - CTRL+Q to close window (and other shortcuts)
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
375 - PrintScreen to make screenshot into /boot/home
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
376 - etc.. */
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
377 //BDirectWindow::DispatchMessage(msg, target);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
378 break;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
379 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
380 BDirectWindow::DispatchMessage(msg, target);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
381 }