Mercurial > sdl-ios-xcode
annotate src/video/bwindow/SDL_BWin.h @ 1102:f0919504adfd
Revert back change between 1.29 and 1.30
author | Patrice Mandin <patmandin@gmail.com> |
---|---|
date | Wed, 27 Jul 2005 16:30:12 +0000 |
parents | a649064a3215 |
children | c9b51268668f |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
769
b8d311d90021
Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
3 Copyright (C) 1997-2004 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Library General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2 of the License, or (at your option) any later version. | |
9 | |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 Library General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Library General Public | |
16 License along with this library; if not, write to the Free | |
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | |
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 | 21 */ |
22 | |
23 #ifdef SAVE_RCSID | |
24 static char rcsid = | |
25 "@(#) $Id$"; | |
26 #endif | |
27 | |
28 #ifndef _SDL_BWin_h | |
29 #define _SDL_BWin_h | |
30 | |
31 #include <stdio.h> | |
32 #include <AppKit.h> | |
33 #include <InterfaceKit.h> | |
34 #include <be/game/DirectWindow.h> | |
35 #ifdef HAVE_OPENGL | |
36 #include <be/opengl/GLView.h> | |
37 #endif | |
907
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
38 #include <support/UTF8.h> |
0 | 39 |
40 #include "SDL_BeApp.h" | |
41 #include "SDL_events.h" | |
42 #include "SDL_BView.h" | |
43 | |
44 extern "C" { | |
45 #include "SDL_events_c.h" | |
46 }; | |
47 | |
48 class SDL_BWin : public BDirectWindow | |
49 { | |
50 public: | |
51 SDL_BWin(BRect bounds) : | |
52 BDirectWindow(bounds, "Untitled", B_TITLED_WINDOW, 0) { | |
907
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
53 InitKeyboard(); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
54 last_buttons = 0; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
55 |
0 | 56 the_view = NULL; |
57 #ifdef HAVE_OPENGL | |
58 SDL_GLView = NULL; | |
59 #endif | |
60 SDL_View = NULL; | |
61 Unlock(); | |
62 shown = false; | |
63 inhibit_resize = false; | |
64 } | |
907
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
65 |
0 | 66 virtual ~SDL_BWin() { |
67 Lock(); | |
68 if ( the_view ) { | |
69 #ifdef HAVE_OPENGL | |
70 if ( the_view == SDL_GLView ) { | |
71 SDL_GLView->UnlockGL(); | |
72 } | |
73 #endif | |
74 RemoveChild(the_view); | |
75 the_view = NULL; | |
76 } | |
77 Unlock(); | |
78 #ifdef HAVE_OPENGL | |
79 if ( SDL_GLView ) { | |
80 delete SDL_GLView; | |
81 } | |
82 #endif | |
83 if ( SDL_View ) { | |
84 delete SDL_View; | |
85 } | |
86 } | |
907
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
87 |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
88 virtual void InitKeyboard(void) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
89 for ( uint i=0; i<SDL_TABLESIZE(keymap); ++i ) |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
90 keymap[i] = SDLK_UNKNOWN; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
91 |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
92 keymap[0x01] = SDLK_ESCAPE; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
93 keymap[B_F1_KEY] = SDLK_F1; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
94 keymap[B_F2_KEY] = SDLK_F2; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
95 keymap[B_F3_KEY] = SDLK_F3; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
96 keymap[B_F4_KEY] = SDLK_F4; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
97 keymap[B_F5_KEY] = SDLK_F5; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
98 keymap[B_F6_KEY] = SDLK_F6; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
99 keymap[B_F7_KEY] = SDLK_F7; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
100 keymap[B_F8_KEY] = SDLK_F8; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
101 keymap[B_F9_KEY] = SDLK_F9; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
102 keymap[B_F10_KEY] = SDLK_F10; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
103 keymap[B_F11_KEY] = SDLK_F11; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
104 keymap[B_F12_KEY] = SDLK_F12; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
105 keymap[B_PRINT_KEY] = SDLK_PRINT; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
106 keymap[B_SCROLL_KEY] = SDLK_SCROLLOCK; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
107 keymap[B_PAUSE_KEY] = SDLK_PAUSE; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
108 keymap[0x11] = SDLK_BACKQUOTE; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
109 keymap[0x12] = SDLK_1; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
110 keymap[0x13] = SDLK_2; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
111 keymap[0x14] = SDLK_3; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
112 keymap[0x15] = SDLK_4; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
113 keymap[0x16] = SDLK_5; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
114 keymap[0x17] = SDLK_6; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
115 keymap[0x18] = SDLK_7; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
116 keymap[0x19] = SDLK_8; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
117 keymap[0x1a] = SDLK_9; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
118 keymap[0x1b] = SDLK_0; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
119 keymap[0x1c] = SDLK_MINUS; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
120 keymap[0x1d] = SDLK_EQUALS; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
121 keymap[0x1e] = SDLK_BACKSPACE; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
122 keymap[0x1f] = SDLK_INSERT; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
123 keymap[0x20] = SDLK_HOME; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
124 keymap[0x21] = SDLK_PAGEUP; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
125 keymap[0x22] = SDLK_NUMLOCK; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
126 keymap[0x23] = SDLK_KP_DIVIDE; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
127 keymap[0x24] = SDLK_KP_MULTIPLY; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
128 keymap[0x25] = SDLK_KP_MINUS; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
129 keymap[0x26] = SDLK_TAB; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
130 keymap[0x27] = SDLK_q; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
131 keymap[0x28] = SDLK_w; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
132 keymap[0x29] = SDLK_e; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
133 keymap[0x2a] = SDLK_r; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
134 keymap[0x2b] = SDLK_t; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
135 keymap[0x2c] = SDLK_y; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
136 keymap[0x2d] = SDLK_u; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
137 keymap[0x2e] = SDLK_i; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
138 keymap[0x2f] = SDLK_o; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
139 keymap[0x30] = SDLK_p; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
140 keymap[0x31] = SDLK_LEFTBRACKET; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
141 keymap[0x32] = SDLK_RIGHTBRACKET; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
142 keymap[0x33] = SDLK_BACKSLASH; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
143 keymap[0x34] = SDLK_DELETE; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
144 keymap[0x35] = SDLK_END; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
145 keymap[0x36] = SDLK_PAGEDOWN; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
146 keymap[0x37] = SDLK_KP7; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
147 keymap[0x38] = SDLK_KP8; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
148 keymap[0x39] = SDLK_KP9; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
149 keymap[0x3a] = SDLK_KP_PLUS; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
150 keymap[0x3b] = SDLK_CAPSLOCK; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
151 keymap[0x3c] = SDLK_a; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
152 keymap[0x3d] = SDLK_s; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
153 keymap[0x3e] = SDLK_d; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
154 keymap[0x3f] = SDLK_f; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
155 keymap[0x40] = SDLK_g; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
156 keymap[0x41] = SDLK_h; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
157 keymap[0x42] = SDLK_j; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
158 keymap[0x43] = SDLK_k; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
159 keymap[0x44] = SDLK_l; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
160 keymap[0x45] = SDLK_SEMICOLON; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
161 keymap[0x46] = SDLK_QUOTE; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
162 keymap[0x47] = SDLK_RETURN; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
163 keymap[0x48] = SDLK_KP4; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
164 keymap[0x49] = SDLK_KP5; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
165 keymap[0x4a] = SDLK_KP6; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
166 keymap[0x4b] = SDLK_LSHIFT; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
167 keymap[0x4c] = SDLK_z; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
168 keymap[0x4d] = SDLK_x; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
169 keymap[0x4e] = SDLK_c; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
170 keymap[0x4f] = SDLK_v; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
171 keymap[0x50] = SDLK_b; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
172 keymap[0x51] = SDLK_n; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
173 keymap[0x52] = SDLK_m; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
174 keymap[0x53] = SDLK_COMMA; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
175 keymap[0x54] = SDLK_PERIOD; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
176 keymap[0x55] = SDLK_SLASH; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
177 keymap[0x56] = SDLK_RSHIFT; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
178 keymap[0x57] = SDLK_UP; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
179 keymap[0x58] = SDLK_KP1; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
180 keymap[0x59] = SDLK_KP2; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
181 keymap[0x5a] = SDLK_KP3; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
182 keymap[0x5b] = SDLK_KP_ENTER; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
183 keymap[0x5c] = SDLK_LCTRL; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
184 keymap[0x5d] = SDLK_LALT; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
185 keymap[0x5e] = SDLK_SPACE; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
186 keymap[0x5f] = SDLK_RALT; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
187 keymap[0x60] = SDLK_RCTRL; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
188 keymap[0x61] = SDLK_LEFT; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
189 keymap[0x62] = SDLK_DOWN; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
190 keymap[0x63] = SDLK_RIGHT; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
191 keymap[0x64] = SDLK_KP0; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
192 keymap[0x65] = SDLK_KP_PERIOD; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
193 keymap[0x66] = SDLK_LMETA; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
194 keymap[0x67] = SDLK_RMETA; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
195 keymap[0x68] = SDLK_MENU; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
196 keymap[0x69] = SDLK_EURO; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
197 keymap[0x6a] = SDLK_KP_EQUALS; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
198 keymap[0x6b] = SDLK_POWER; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
199 } |
0 | 200 |
201 /* Override the Show() method so we can tell when we've been shown */ | |
202 virtual void Show(void) { | |
203 BWindow::Show(); | |
204 shown = true; | |
205 } | |
206 virtual bool Shown(void) { | |
207 return (shown); | |
208 } | |
209 /* If called, the next resize event will not be forwarded to SDL. */ | |
210 virtual void InhibitResize(void) { | |
211 inhibit_resize=true; | |
212 } | |
213 /* Handle resizing of the window */ | |
214 virtual void FrameResized(float width, float height) { | |
215 if(inhibit_resize) | |
216 inhibit_resize = false; | |
217 else | |
218 SDL_PrivateResize((int)width, (int)height); | |
219 } | |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
220 virtual int CreateView(Uint32 flags, Uint32 gl_flags) { |
0 | 221 int retval; |
222 | |
223 retval = 0; | |
224 Lock(); | |
225 if ( flags & SDL_OPENGL ) { | |
226 #ifdef HAVE_OPENGL | |
227 if ( SDL_GLView == NULL ) { | |
228 SDL_GLView = new BGLView(Bounds(), "SDL GLView", | |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
229 B_FOLLOW_ALL_SIDES, (B_WILL_DRAW|B_FRAME_EVENTS), |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
230 gl_flags); |
0 | 231 } |
232 if ( the_view != SDL_GLView ) { | |
233 if ( the_view ) { | |
234 RemoveChild(the_view); | |
235 } | |
236 AddChild(SDL_GLView); | |
237 SDL_GLView->LockGL(); | |
238 the_view = SDL_GLView; | |
239 } | |
240 #else | |
241 SDL_SetError("OpenGL support not enabled"); | |
242 retval = -1; | |
243 #endif | |
244 } else { | |
245 if ( SDL_View == NULL ) { | |
246 SDL_View = new SDL_BView(Bounds()); | |
247 } | |
248 if ( the_view != SDL_View ) { | |
249 if ( the_view ) { | |
250 #ifdef HAVE_OPENGL | |
251 if ( the_view == SDL_GLView ) { | |
252 SDL_GLView->UnlockGL(); | |
253 } | |
254 #endif | |
255 RemoveChild(the_view); | |
256 } | |
257 AddChild(SDL_View); | |
258 the_view = SDL_View; | |
259 } | |
260 } | |
261 Unlock(); | |
262 return(retval); | |
263 } | |
264 virtual void SetBitmap(BBitmap *bitmap) { | |
265 SDL_View->SetBitmap(bitmap); | |
266 } | |
267 virtual void SetXYOffset(int x, int y) { | |
268 #ifdef HAVE_OPENGL | |
269 if ( the_view == SDL_GLView ) { | |
270 return; | |
271 } | |
272 #endif | |
273 SDL_View->SetXYOffset(x, y); | |
274 } | |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
275 virtual void GetXYOffset(int &x, int &y) { |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
276 #ifdef HAVE_OPENGL |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
277 if ( the_view == SDL_GLView ) { |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
278 x = 0; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
279 y = 0; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
280 return; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
281 } |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
282 #endif |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
283 SDL_View->GetXYOffset(x, y); |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
284 } |
0 | 285 virtual bool BeginDraw(void) { |
286 return(Lock()); | |
287 } | |
288 virtual void DrawAsync(BRect updateRect) { | |
289 SDL_View->DrawAsync(updateRect); | |
290 } | |
291 virtual void EndDraw(void) { | |
292 SDL_View->Sync(); | |
293 Unlock(); | |
294 } | |
295 #ifdef HAVE_OPENGL | |
296 virtual void SwapBuffers(void) { | |
297 SDL_GLView->UnlockGL(); | |
298 SDL_GLView->LockGL(); | |
299 SDL_GLView->SwapBuffers(); | |
300 } | |
301 #endif | |
302 virtual BView *View(void) { | |
303 return(the_view); | |
304 } | |
305 | |
306 /* Hook functions -- overridden */ | |
307 virtual void Minimize(bool minimize) { | |
308 /* This is only called when mimimized, not when restored */ | |
309 //SDL_PrivateAppActive(minimize, SDL_APPACTIVE); | |
310 BWindow::Minimize(minimize); | |
311 } | |
312 virtual void WindowActivated(bool active) { | |
313 SDL_PrivateAppActive(active, SDL_APPINPUTFOCUS); | |
314 } | |
315 virtual bool QuitRequested(void) { | |
316 if ( SDL_BeAppActive > 0 ) { | |
317 SDL_PrivateQuit(); | |
318 /* We don't ever actually close the window here because | |
319 the application should respond to the quit request, | |
320 or ignore it as desired. | |
321 */ | |
322 return(false); | |
323 } | |
324 return(true); /* Close the app window */ | |
325 } | |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
326 virtual void Quit() { |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
327 if (!IsLocked()) |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
328 Lock(); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
329 BDirectWindow::Quit(); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
330 } |
0 | 331 |
907
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
332 virtual int16 Translate2Unicode(const char *buf) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
333 int32 state, srclen, dstlen; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
334 unsigned char destbuf[2]; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
335 Uint16 unicode = 0; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
336 |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
337 if ((uchar)buf[0] > 127) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
338 state = 0; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
339 srclen = strlen(buf); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
340 dstlen = sizeof(destbuf); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
341 convert_from_utf8(B_UNICODE_CONVERSION, buf, &srclen, (char *)destbuf, &dstlen, &state); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
342 unicode = destbuf[0]; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
343 unicode <<= 8; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
344 unicode |= destbuf[1]; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
345 } else |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
346 unicode = buf[0]; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
347 |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
348 /* For some reason function keys map to control characters */ |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
349 # define CTRL(X) ((X)-'@') |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
350 switch (unicode) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
351 case CTRL('A'): |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
352 case CTRL('B'): |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
353 case CTRL('C'): |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
354 case CTRL('D'): |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
355 case CTRL('E'): |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
356 case CTRL('K'): |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
357 case CTRL('L'): |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
358 case CTRL('P'): |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
359 if ( ! (SDL_GetModState() & KMOD_CTRL) ) |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
360 unicode = 0; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
361 break; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
362 /* Keyboard input maps newline to carriage return */ |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
363 case '\n': |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
364 unicode = '\r'; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
365 break; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
366 default: |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
367 break; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
368 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
369 |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
370 return unicode; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
371 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
372 |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
373 virtual void DispatchMessage(BMessage *msg, BHandler *target) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
374 switch (msg->what) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
375 case B_MOUSE_MOVED: |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
376 { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
377 BPoint where; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
378 int32 transit; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
379 if (msg->FindPoint("where", &where) == B_OK && msg->FindInt32("be:transit", &transit) == B_OK) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
380 if (transit == B_EXITED_VIEW) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
381 if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
382 SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
383 be_app->SetCursor(B_HAND_CURSOR); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
384 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
385 } else { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
386 int x, y; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
387 if ( ! (SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
388 SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
389 SDL_SetCursor(NULL); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
390 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
391 GetXYOffset(x, y); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
392 x = (int)where.x - x; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
393 y = (int)where.y - y; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
394 SDL_PrivateMouseMotion(0, 0, x, y); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
395 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
396 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
397 break; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
398 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
399 |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
400 case B_MOUSE_DOWN: |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
401 { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
402 /* it looks like mouse down is send only for first clicked |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
403 button, each next is not send while last one is holded */ |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
404 int32 buttons; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
405 int sdl_buttons = 0; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
406 if (msg->FindInt32("buttons", &buttons) == B_OK) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
407 /* Add any mouse button events */ |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
408 if (buttons & B_PRIMARY_MOUSE_BUTTON) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
409 sdl_buttons |= SDL_BUTTON_LEFT; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
410 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
411 if (buttons & B_SECONDARY_MOUSE_BUTTON) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
412 sdl_buttons |= SDL_BUTTON_RIGHT; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
413 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
414 if (buttons & B_TERTIARY_MOUSE_BUTTON) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
415 sdl_buttons |= SDL_BUTTON_MIDDLE; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
416 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
417 SDL_PrivateMouseButton(SDL_PRESSED, sdl_buttons, 0, 0); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
418 |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
419 last_buttons = buttons; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
420 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
421 break; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
422 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
423 |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
424 case B_MOUSE_UP: |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
425 { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
426 /* mouse up doesn't give which button was released, |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
427 only state of buttons (after release, so it's always = 0), |
1013
a649064a3215
Date: Tue, 14 Dec 2004 12:08:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
907
diff
changeset
|
428 which is not what we need ;] |
907
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
429 So we need to store button in mouse down, and restore |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
430 in mouse up :( |
1013
a649064a3215
Date: Tue, 14 Dec 2004 12:08:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
907
diff
changeset
|
431 mouse up is (similarly to mouse down) send only for |
a649064a3215
Date: Tue, 14 Dec 2004 12:08:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
907
diff
changeset
|
432 first button down (ie. it's no send if we click another button |
a649064a3215
Date: Tue, 14 Dec 2004 12:08:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
907
diff
changeset
|
433 without releasing previous one first) - but that's probably |
a649064a3215
Date: Tue, 14 Dec 2004 12:08:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
907
diff
changeset
|
434 because of how drivers are written?, not BeOS itself. */ |
907
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
435 int32 buttons; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
436 int sdl_buttons = 0; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
437 if (msg->FindInt32("buttons", &buttons) == B_OK) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
438 /* Add any mouse button events */ |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
439 if ((buttons ^ B_PRIMARY_MOUSE_BUTTON) & last_buttons) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
440 sdl_buttons |= SDL_BUTTON_LEFT; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
441 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
442 if ((buttons ^ B_SECONDARY_MOUSE_BUTTON) & last_buttons) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
443 sdl_buttons |= SDL_BUTTON_RIGHT; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
444 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
445 if ((buttons ^ B_TERTIARY_MOUSE_BUTTON) & last_buttons) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
446 sdl_buttons |= SDL_BUTTON_MIDDLE; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
447 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
448 SDL_PrivateMouseButton(SDL_RELEASED, sdl_buttons, 0, 0); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
449 |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
450 last_buttons = buttons; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
451 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
452 break; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
453 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
454 |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
455 case B_MOUSE_WHEEL_CHANGED: |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
456 { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
457 float x, y; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
458 x = y = 0; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
459 if (msg->FindFloat("be:wheel_delta_x", &x) == B_OK && msg->FindFloat("be:wheel_delta_y", &y) == B_OK) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
460 if (x < 0 || y < 0) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
461 SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELDOWN, 0, 0); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
462 SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELDOWN, 0, 0); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
463 } else if (x > 0 || y > 0) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
464 SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELUP, 0, 0); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
465 SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELUP, 0, 0); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
466 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
467 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
468 break; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
469 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
470 |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
471 case B_KEY_DOWN: |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
472 case B_UNMAPPED_KEY_DOWN: /* modifier keys are unmapped */ |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
473 { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
474 int32 key; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
475 int32 modifiers; |
1013
a649064a3215
Date: Tue, 14 Dec 2004 12:08:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
907
diff
changeset
|
476 int32 key_repeat; |
a649064a3215
Date: Tue, 14 Dec 2004 12:08:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
907
diff
changeset
|
477 /* Workaround for SDL message queue being filled too fast because of BeOS own key-repeat mechanism */ |
a649064a3215
Date: Tue, 14 Dec 2004 12:08:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
907
diff
changeset
|
478 if (msg->FindInt32("be:key_repeat", &key_repeat) == B_OK && key_repeat > 0) |
a649064a3215
Date: Tue, 14 Dec 2004 12:08:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
907
diff
changeset
|
479 break; |
a649064a3215
Date: Tue, 14 Dec 2004 12:08:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
907
diff
changeset
|
480 |
907
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
481 if (msg->FindInt32("key", &key) == B_OK && msg->FindInt32("modifiers", &modifiers) == B_OK) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
482 SDL_keysym keysym; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
483 keysym.scancode = key; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
484 if (key < 128) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
485 keysym.sym = keymap[key]; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
486 } else { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
487 keysym.sym = SDLK_UNKNOWN; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
488 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
489 /* FIX THIS? |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
490 it seems SDL_PrivateKeyboard() changes mod value |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
491 anyway, and doesn't care about what we setup here */ |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
492 keysym.mod = KMOD_NONE; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
493 keysym.unicode = 0; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
494 if (SDL_TranslateUNICODE) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
495 const char *bytes; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
496 if (msg->FindString("bytes", &bytes) == B_OK) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
497 /* FIX THIS? |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
498 this cares only about first "letter", |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
499 so if someone maps some key to print |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
500 "BeOS rulez!" only "B" will be used. */ |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
501 keysym.unicode = Translate2Unicode(bytes); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
502 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
503 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
504 SDL_PrivateKeyboard(SDL_PRESSED, &keysym); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
505 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
506 break; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
507 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
508 |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
509 case B_KEY_UP: |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
510 case B_UNMAPPED_KEY_UP: /* modifier keys are unmapped */ |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
511 { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
512 int32 key; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
513 int32 modifiers; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
514 if (msg->FindInt32("key", &key) == B_OK && msg->FindInt32("modifiers", &modifiers) == B_OK) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
515 SDL_keysym keysym; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
516 keysym.scancode = key; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
517 if (key < 128) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
518 keysym.sym = keymap[key]; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
519 } else { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
520 keysym.sym = SDLK_UNKNOWN; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
521 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
522 keysym.mod = KMOD_NONE; /* FIX THIS? */ |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
523 keysym.unicode = 0; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
524 if (SDL_TranslateUNICODE) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
525 const char *bytes; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
526 if (msg->FindString("bytes", &bytes) == B_OK) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
527 keysym.unicode = Translate2Unicode(bytes); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
528 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
529 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
530 SDL_PrivateKeyboard(SDL_RELEASED, &keysym); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
531 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
532 break; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
533 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
534 |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
535 default: |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
536 /* move it after switch{} so it's always handled |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
537 that way we keep BeOS feautures like: |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
538 - CTRL+Q to close window (and other shortcuts) |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
539 - PrintScreen to make screenshot into /boot/home |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
540 - etc.. */ |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
541 //BDirectWindow::DispatchMessage(msg, target); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
542 break; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
543 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
544 BDirectWindow::DispatchMessage(msg, target); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
545 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
546 |
0 | 547 private: |
548 #ifdef HAVE_OPENGL | |
549 BGLView *SDL_GLView; | |
550 #endif | |
551 SDL_BView *SDL_View; | |
552 BView *the_view; | |
553 | |
554 bool shown; | |
555 bool inhibit_resize; | |
907
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
556 |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
557 int32 last_buttons; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
558 SDLKey keymap[128]; |
0 | 559 }; |
560 | |
561 #endif /* _SDL_BWin_h */ |