Mercurial > sdl-ios-xcode
annotate src/video/bwindow/SDL_BWin.h @ 1780:7a36f01acf71
Fixed bug #49
Added support for non-blocking VT switching on the framebuffer console.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 08 May 2006 05:33:02 +0000 |
parents | 6162b8d921ce |
children | e49147870aac c121d94672cb 678576473849 |
rev | line source |
---|---|
0 | 1 /* |
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:
1013
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
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:
1013
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 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:
1013
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 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 | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1013
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1013
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:
1013
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:
1013
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 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 #ifndef _SDL_BWin_h | |
24 #define _SDL_BWin_h | |
25 | |
1367
e440d5c488c1
Fixes for BeOS and Solaris builds
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
26 #include "SDL_config.h" |
e440d5c488c1
Fixes for BeOS and Solaris builds
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
27 |
0 | 28 #include <stdio.h> |
29 #include <AppKit.h> | |
30 #include <InterfaceKit.h> | |
31 #include <be/game/DirectWindow.h> | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
32 #if SDL_VIDEO_OPENGL |
0 | 33 #include <be/opengl/GLView.h> |
34 #endif | |
907
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
35 #include <support/UTF8.h> |
0 | 36 |
1367
e440d5c488c1
Fixes for BeOS and Solaris builds
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
37 #include "../../main/beos/SDL_BeApp.h" |
0 | 38 #include "SDL_events.h" |
39 #include "SDL_BView.h" | |
40 | |
41 extern "C" { | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
42 #include "../../events/SDL_events_c.h" |
0 | 43 }; |
44 | |
45 class SDL_BWin : public BDirectWindow | |
46 { | |
47 public: | |
48 SDL_BWin(BRect bounds) : | |
49 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
|
50 InitKeyboard(); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
51 last_buttons = 0; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
52 |
0 | 53 the_view = NULL; |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
54 #if SDL_VIDEO_OPENGL |
0 | 55 SDL_GLView = NULL; |
56 #endif | |
57 SDL_View = NULL; | |
58 Unlock(); | |
59 shown = false; | |
60 inhibit_resize = false; | |
61 } | |
907
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
62 |
0 | 63 virtual ~SDL_BWin() { |
64 Lock(); | |
65 if ( the_view ) { | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
66 #if SDL_VIDEO_OPENGL |
0 | 67 if ( the_view == SDL_GLView ) { |
68 SDL_GLView->UnlockGL(); | |
69 } | |
70 #endif | |
71 RemoveChild(the_view); | |
72 the_view = NULL; | |
73 } | |
74 Unlock(); | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
75 #if SDL_VIDEO_OPENGL |
0 | 76 if ( SDL_GLView ) { |
77 delete SDL_GLView; | |
78 } | |
79 #endif | |
80 if ( SDL_View ) { | |
81 delete SDL_View; | |
82 } | |
83 } | |
907
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
84 |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
85 virtual void InitKeyboard(void) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
86 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
|
87 keymap[i] = SDLK_UNKNOWN; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
88 |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
89 keymap[0x01] = SDLK_ESCAPE; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
90 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
|
91 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
|
92 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
|
93 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
|
94 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
|
95 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
|
96 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
|
97 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
|
98 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
|
99 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
|
100 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
|
101 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
|
102 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
|
103 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
|
104 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
|
105 keymap[0x11] = SDLK_BACKQUOTE; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
106 keymap[0x12] = SDLK_1; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
107 keymap[0x13] = SDLK_2; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
108 keymap[0x14] = SDLK_3; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
109 keymap[0x15] = SDLK_4; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
110 keymap[0x16] = SDLK_5; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
111 keymap[0x17] = SDLK_6; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
112 keymap[0x18] = SDLK_7; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
113 keymap[0x19] = SDLK_8; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
114 keymap[0x1a] = SDLK_9; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
115 keymap[0x1b] = SDLK_0; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
116 keymap[0x1c] = SDLK_MINUS; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
117 keymap[0x1d] = SDLK_EQUALS; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
118 keymap[0x1e] = SDLK_BACKSPACE; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
119 keymap[0x1f] = SDLK_INSERT; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
120 keymap[0x20] = SDLK_HOME; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
121 keymap[0x21] = SDLK_PAGEUP; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
122 keymap[0x22] = SDLK_NUMLOCK; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
123 keymap[0x23] = SDLK_KP_DIVIDE; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
124 keymap[0x24] = SDLK_KP_MULTIPLY; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
125 keymap[0x25] = SDLK_KP_MINUS; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
126 keymap[0x26] = SDLK_TAB; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
127 keymap[0x27] = SDLK_q; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
128 keymap[0x28] = SDLK_w; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
129 keymap[0x29] = SDLK_e; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
130 keymap[0x2a] = SDLK_r; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
131 keymap[0x2b] = SDLK_t; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
132 keymap[0x2c] = SDLK_y; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
133 keymap[0x2d] = SDLK_u; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
134 keymap[0x2e] = SDLK_i; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
135 keymap[0x2f] = SDLK_o; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
136 keymap[0x30] = SDLK_p; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
137 keymap[0x31] = SDLK_LEFTBRACKET; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
138 keymap[0x32] = SDLK_RIGHTBRACKET; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
139 keymap[0x33] = SDLK_BACKSLASH; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
140 keymap[0x34] = SDLK_DELETE; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
141 keymap[0x35] = SDLK_END; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
142 keymap[0x36] = SDLK_PAGEDOWN; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
143 keymap[0x37] = SDLK_KP7; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
144 keymap[0x38] = SDLK_KP8; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
145 keymap[0x39] = SDLK_KP9; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
146 keymap[0x3a] = SDLK_KP_PLUS; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
147 keymap[0x3b] = SDLK_CAPSLOCK; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
148 keymap[0x3c] = SDLK_a; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
149 keymap[0x3d] = SDLK_s; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
150 keymap[0x3e] = SDLK_d; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
151 keymap[0x3f] = SDLK_f; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
152 keymap[0x40] = SDLK_g; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
153 keymap[0x41] = SDLK_h; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
154 keymap[0x42] = SDLK_j; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
155 keymap[0x43] = SDLK_k; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
156 keymap[0x44] = SDLK_l; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
157 keymap[0x45] = SDLK_SEMICOLON; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
158 keymap[0x46] = SDLK_QUOTE; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
159 keymap[0x47] = SDLK_RETURN; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
160 keymap[0x48] = SDLK_KP4; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
161 keymap[0x49] = SDLK_KP5; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
162 keymap[0x4a] = SDLK_KP6; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
163 keymap[0x4b] = SDLK_LSHIFT; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
164 keymap[0x4c] = SDLK_z; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
165 keymap[0x4d] = SDLK_x; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
166 keymap[0x4e] = SDLK_c; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
167 keymap[0x4f] = SDLK_v; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
168 keymap[0x50] = SDLK_b; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
169 keymap[0x51] = SDLK_n; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
170 keymap[0x52] = SDLK_m; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
171 keymap[0x53] = SDLK_COMMA; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
172 keymap[0x54] = SDLK_PERIOD; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
173 keymap[0x55] = SDLK_SLASH; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
174 keymap[0x56] = SDLK_RSHIFT; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
175 keymap[0x57] = SDLK_UP; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
176 keymap[0x58] = SDLK_KP1; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
177 keymap[0x59] = SDLK_KP2; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
178 keymap[0x5a] = SDLK_KP3; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
179 keymap[0x5b] = SDLK_KP_ENTER; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
180 keymap[0x5c] = SDLK_LCTRL; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
181 keymap[0x5d] = SDLK_LALT; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
182 keymap[0x5e] = SDLK_SPACE; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
183 keymap[0x5f] = SDLK_RALT; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
184 keymap[0x60] = SDLK_RCTRL; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
185 keymap[0x61] = SDLK_LEFT; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
186 keymap[0x62] = SDLK_DOWN; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
187 keymap[0x63] = SDLK_RIGHT; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
188 keymap[0x64] = SDLK_KP0; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
189 keymap[0x65] = SDLK_KP_PERIOD; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
190 keymap[0x66] = SDLK_LMETA; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
191 keymap[0x67] = SDLK_RMETA; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
192 keymap[0x68] = SDLK_MENU; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
193 keymap[0x69] = SDLK_EURO; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
194 keymap[0x6a] = SDLK_KP_EQUALS; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
195 keymap[0x6b] = SDLK_POWER; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
196 } |
0 | 197 |
198 /* Override the Show() method so we can tell when we've been shown */ | |
199 virtual void Show(void) { | |
200 BWindow::Show(); | |
201 shown = true; | |
202 } | |
203 virtual bool Shown(void) { | |
204 return (shown); | |
205 } | |
206 /* If called, the next resize event will not be forwarded to SDL. */ | |
207 virtual void InhibitResize(void) { | |
208 inhibit_resize=true; | |
209 } | |
210 /* Handle resizing of the window */ | |
211 virtual void FrameResized(float width, float height) { | |
212 if(inhibit_resize) | |
213 inhibit_resize = false; | |
214 else | |
215 SDL_PrivateResize((int)width, (int)height); | |
216 } | |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
217 virtual int CreateView(Uint32 flags, Uint32 gl_flags) { |
0 | 218 int retval; |
219 | |
220 retval = 0; | |
221 Lock(); | |
222 if ( flags & SDL_OPENGL ) { | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
223 #if SDL_VIDEO_OPENGL |
0 | 224 if ( SDL_GLView == NULL ) { |
225 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
|
226 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
|
227 gl_flags); |
0 | 228 } |
229 if ( the_view != SDL_GLView ) { | |
230 if ( the_view ) { | |
231 RemoveChild(the_view); | |
232 } | |
233 AddChild(SDL_GLView); | |
234 SDL_GLView->LockGL(); | |
235 the_view = SDL_GLView; | |
236 } | |
237 #else | |
238 SDL_SetError("OpenGL support not enabled"); | |
239 retval = -1; | |
240 #endif | |
241 } else { | |
242 if ( SDL_View == NULL ) { | |
243 SDL_View = new SDL_BView(Bounds()); | |
244 } | |
245 if ( the_view != SDL_View ) { | |
246 if ( the_view ) { | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
247 #if SDL_VIDEO_OPENGL |
0 | 248 if ( the_view == SDL_GLView ) { |
249 SDL_GLView->UnlockGL(); | |
250 } | |
251 #endif | |
252 RemoveChild(the_view); | |
253 } | |
254 AddChild(SDL_View); | |
255 the_view = SDL_View; | |
256 } | |
257 } | |
258 Unlock(); | |
259 return(retval); | |
260 } | |
261 virtual void SetBitmap(BBitmap *bitmap) { | |
262 SDL_View->SetBitmap(bitmap); | |
263 } | |
264 virtual void SetXYOffset(int x, int y) { | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
265 #if SDL_VIDEO_OPENGL |
0 | 266 if ( the_view == SDL_GLView ) { |
267 return; | |
268 } | |
269 #endif | |
270 SDL_View->SetXYOffset(x, y); | |
271 } | |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
272 virtual void GetXYOffset(int &x, int &y) { |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
273 #if SDL_VIDEO_OPENGL |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
274 if ( the_view == SDL_GLView ) { |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
275 x = 0; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
276 y = 0; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
277 return; |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
278 } |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
279 #endif |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
280 SDL_View->GetXYOffset(x, y); |
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
281 } |
0 | 282 virtual bool BeginDraw(void) { |
283 return(Lock()); | |
284 } | |
285 virtual void DrawAsync(BRect updateRect) { | |
286 SDL_View->DrawAsync(updateRect); | |
287 } | |
288 virtual void EndDraw(void) { | |
289 SDL_View->Sync(); | |
290 Unlock(); | |
291 } | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
292 #if SDL_VIDEO_OPENGL |
0 | 293 virtual void SwapBuffers(void) { |
294 SDL_GLView->UnlockGL(); | |
295 SDL_GLView->LockGL(); | |
296 SDL_GLView->SwapBuffers(); | |
297 } | |
298 #endif | |
299 virtual BView *View(void) { | |
300 return(the_view); | |
301 } | |
302 | |
303 /* Hook functions -- overridden */ | |
304 virtual void Minimize(bool minimize) { | |
305 /* This is only called when mimimized, not when restored */ | |
306 //SDL_PrivateAppActive(minimize, SDL_APPACTIVE); | |
307 BWindow::Minimize(minimize); | |
308 } | |
309 virtual void WindowActivated(bool active) { | |
310 SDL_PrivateAppActive(active, SDL_APPINPUTFOCUS); | |
311 } | |
312 virtual bool QuitRequested(void) { | |
313 if ( SDL_BeAppActive > 0 ) { | |
314 SDL_PrivateQuit(); | |
315 /* We don't ever actually close the window here because | |
316 the application should respond to the quit request, | |
317 or ignore it as desired. | |
318 */ | |
319 return(false); | |
320 } | |
321 return(true); /* Close the app window */ | |
322 } | |
906
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
323 virtual void Quit() { |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
324 if (!IsLocked()) |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
325 Lock(); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
326 BDirectWindow::Quit(); |
a48acf6ee48f
Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
327 } |
0 | 328 |
907
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
329 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
|
330 int32 state, srclen, dstlen; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
331 unsigned char destbuf[2]; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
332 Uint16 unicode = 0; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
333 |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
334 if ((uchar)buf[0] > 127) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
335 state = 0; |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
336 srclen = SDL_strlen(buf); |
907
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
337 dstlen = sizeof(destbuf); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
338 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
|
339 unicode = destbuf[0]; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
340 unicode <<= 8; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
341 unicode |= destbuf[1]; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
342 } else |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
343 unicode = buf[0]; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
344 |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
345 /* 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
|
346 # define CTRL(X) ((X)-'@') |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
347 switch (unicode) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
348 case CTRL('A'): |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
349 case CTRL('B'): |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
350 case CTRL('C'): |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
351 case CTRL('D'): |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
352 case CTRL('E'): |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
353 case CTRL('K'): |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
354 case CTRL('L'): |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
355 case CTRL('P'): |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
356 if ( ! (SDL_GetModState() & KMOD_CTRL) ) |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
357 unicode = 0; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
358 break; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
359 /* 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
|
360 case '\n': |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
361 unicode = '\r'; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
362 break; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
363 default: |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
364 break; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
365 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
366 |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
367 return unicode; |
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 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
|
371 switch (msg->what) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
372 case B_MOUSE_MOVED: |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
373 { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
374 BPoint where; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
375 int32 transit; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
376 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
|
377 if (transit == B_EXITED_VIEW) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
378 if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
379 SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
380 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
|
381 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
382 } else { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
383 int x, y; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
384 if ( ! (SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
385 SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
386 SDL_SetCursor(NULL); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
387 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
388 GetXYOffset(x, y); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
389 x = (int)where.x - x; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
390 y = (int)where.y - y; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
391 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
|
392 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
393 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
394 break; |
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 case B_MOUSE_DOWN: |
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 /* 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
|
400 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
|
401 int32 buttons; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
402 int sdl_buttons = 0; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
403 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
|
404 /* Add any mouse button events */ |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
405 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
|
406 sdl_buttons |= SDL_BUTTON_LEFT; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
407 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
408 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
|
409 sdl_buttons |= SDL_BUTTON_RIGHT; |
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_TERTIARY_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_MIDDLE; |
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 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
|
415 |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
416 last_buttons = buttons; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
417 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
418 break; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
419 } |
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 case B_MOUSE_UP: |
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 /* 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
|
424 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
|
425 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
|
426 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
|
427 in mouse up :( |
1013
a649064a3215
Date: Tue, 14 Dec 2004 12:08:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
907
diff
changeset
|
428 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
|
429 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
|
430 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
|
431 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
|
432 int32 buttons; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
433 int sdl_buttons = 0; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
434 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
|
435 /* Add any mouse button events */ |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
436 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
|
437 sdl_buttons |= SDL_BUTTON_LEFT; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
438 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
439 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
|
440 sdl_buttons |= SDL_BUTTON_RIGHT; |
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_TERTIARY_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_MIDDLE; |
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 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
|
446 |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
447 last_buttons = buttons; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
448 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
449 break; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
450 } |
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 case B_MOUSE_WHEEL_CHANGED: |
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 float x, y; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
455 x = y = 0; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
456 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
|
457 if (x < 0 || y < 0) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
458 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
|
459 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
|
460 } 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
|
461 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
|
462 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
|
463 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
464 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
465 break; |
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 case B_KEY_DOWN: |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
469 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
|
470 { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
471 int32 key; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
472 int32 modifiers; |
1013
a649064a3215
Date: Tue, 14 Dec 2004 12:08:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
907
diff
changeset
|
473 int32 key_repeat; |
a649064a3215
Date: Tue, 14 Dec 2004 12:08:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
907
diff
changeset
|
474 /* 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
|
475 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
|
476 break; |
a649064a3215
Date: Tue, 14 Dec 2004 12:08:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
907
diff
changeset
|
477 |
907
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
478 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
|
479 SDL_keysym keysym; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
480 keysym.scancode = key; |
1614
6162b8d921ce
Date: Wed, 29 Mar 2006 17:26:55 +0200 CEST
Sam Lantinga <slouken@libsdl.org>
parents:
1367
diff
changeset
|
481 if ((key > 0) && (key < 128)) { |
907
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
482 keysym.sym = keymap[key]; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
483 } else { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
484 keysym.sym = SDLK_UNKNOWN; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
485 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
486 /* FIX THIS? |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
487 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
|
488 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
|
489 keysym.mod = KMOD_NONE; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
490 keysym.unicode = 0; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
491 if (SDL_TranslateUNICODE) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
492 const char *bytes; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
493 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
|
494 /* FIX THIS? |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
495 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
|
496 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
|
497 "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
|
498 keysym.unicode = Translate2Unicode(bytes); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
499 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
500 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
501 SDL_PrivateKeyboard(SDL_PRESSED, &keysym); |
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 break; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
504 } |
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 case B_KEY_UP: |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
507 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
|
508 { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
509 int32 key; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
510 int32 modifiers; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
511 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
|
512 SDL_keysym keysym; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
513 keysym.scancode = key; |
1614
6162b8d921ce
Date: Wed, 29 Mar 2006 17:26:55 +0200 CEST
Sam Lantinga <slouken@libsdl.org>
parents:
1367
diff
changeset
|
514 if ((key > 0) && (key < 128)) { |
907
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
515 keysym.sym = keymap[key]; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
516 } else { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
517 keysym.sym = SDLK_UNKNOWN; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
518 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
519 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
|
520 keysym.unicode = 0; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
521 if (SDL_TranslateUNICODE) { |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
522 const char *bytes; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
523 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
|
524 keysym.unicode = Translate2Unicode(bytes); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
525 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
526 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
527 SDL_PrivateKeyboard(SDL_RELEASED, &keysym); |
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 break; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
530 } |
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 default: |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
533 /* 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
|
534 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
|
535 - 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
|
536 - 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
|
537 - etc.. */ |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
538 //BDirectWindow::DispatchMessage(msg, target); |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
539 break; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
540 } |
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 } |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
543 |
0 | 544 private: |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
545 #if SDL_VIDEO_OPENGL |
0 | 546 BGLView *SDL_GLView; |
547 #endif | |
548 SDL_BView *SDL_View; | |
549 BView *the_view; | |
550 | |
551 bool shown; | |
552 bool inhibit_resize; | |
907
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
553 |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
554 int32 last_buttons; |
3bd4d7a1ee04
Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
906
diff
changeset
|
555 SDLKey keymap[128]; |
0 | 556 }; |
557 | |
558 #endif /* _SDL_BWin_h */ |