Mercurial > sdl-ios-xcode
annotate src/video/photon/SDL_ph_events.c @ 320:66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
From: "Mike Gorchak" <mike@malva.ua>
Subject: New QNX patch.
Hi !
1. Removed warning (possible bug) with invalid type, passing to the function
in ph_WarpedMotion.
2. Rewritten handler of Ph_WM_RESIZE message, now works, but buggy (old
handler doesn't work at all).
3. Added stub handler for Ph_WM_MAX (maximize) message.
4. Added more #ifdef HAVE_OPENGL to disable OpenGL stuff when it not needed.
5. Added support for SDL_NOFRAME and SDL_RESIZABLE flags (in OpenGL windows
too).
6. Added cosmetic changes, if no SDL_RESIZABLE flag defined, disable resize
handlers in window border and maximize button at caption.
7. Fixed my bug with invalid arguments count passed to PtCreateWidget call.
8. Fixed some palette problems.
9. Updated README.QNX file.
And I changed testgl.c test application:
10. Added in testgl.c application support for SDL_NOFRAME flag and
option -noframe.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 28 Mar 2002 16:20:10 +0000 |
parents | f6ffac90895c |
children | 8e3ce997621c |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
297
f6ffac90895c
Updated copyright information for 2002
Sam Lantinga <slouken@libsdl.org>
parents:
283
diff
changeset
|
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 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:
220
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
22 | |
23 #ifdef SAVE_RCSID | |
24 static char rcsid = | |
25 "@(#) $Id$"; | |
26 #endif | |
27 | |
28 /* Handle the event stream, converting photon events into SDL events */ | |
29 | |
19
8cc4dbfab9ab
Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
30 #define DISABLE_X11 |
8cc4dbfab9ab
Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
31 |
0 | 32 #include <Ph.h> |
33 #include <stdio.h> | |
34 #include <setjmp.h> | |
35 #include <photon/PkKeyDef.h> | |
36 #include <sys/time.h> | |
37 | |
38 #include "SDL.h" | |
39 #include "SDL_syswm.h" | |
40 #include "SDL_sysevents.h" | |
41 #include "SDL_sysvideo.h" | |
42 #include "SDL_events_c.h" | |
43 #include "SDL_ph_video.h" | |
44 #include "SDL_ph_modes_c.h" | |
45 #include "SDL_ph_image_c.h" | |
46 #include "SDL_ph_events_c.h" | |
47 | |
48 | |
49 /* The translation tables from a photon keysym to a SDL keysym */ | |
50 static SDLKey ODD_keymap[256]; | |
51 static SDLKey MISC_keymap[0xFF + 1]; | |
52 SDL_keysym *ph_TranslateKey(PhKeyEvent_t *key, SDL_keysym *keysym); | |
53 | |
54 /* Check to see if this is a repeated key. | |
55 (idea shamelessly lifted from GII -- thanks guys! :) | |
56 */ | |
57 | |
283
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
58 #if 0 |
0 | 59 static int ph_KeyRepeat(_THIS, PhKeyEvent_t* keyevent) |
60 { | |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
61 // PhEvent_t* peekevent; |
0 | 62 PhKeyEvent_t* keyEvent; |
63 int repeated; | |
64 | |
65 repeated = 0; | |
66 switch (PhEventPeek( peekevent, EVENT_SIZE )) | |
67 { | |
68 case Ph_EVENT_MSG: { | |
69 if(peekevent->type == Ph_EV_KEY) | |
70 { | |
71 keyEvent = PhGetData( peekevent ); | |
72 if ( !(Pk_KF_Key_Down & keyEvent->key_flags) && | |
73 (keyEvent->key_cap == keyevent->key_cap) && | |
74 (peekevent->timestamp == event->timestamp) | |
75 ) { | |
76 repeated = 1; | |
320
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
77 /* PhEventNext( peekevent, EVENT_SIZE ); */ |
0 | 78 } |
79 } | |
80 } | |
81 break; | |
82 | |
83 case -1: { | |
84 perror( "PhEventPeek failed" ); | |
85 } | |
86 break; | |
87 | |
320
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
88 default: /* no events pending */ |
0 | 89 } |
90 return(repeated); | |
91 } | |
283
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
92 #endif |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
93 |
283
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
94 static int ph_WarpedMotion(_THIS, PhEvent_t *winEvent) |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
95 { |
320
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
96 /* PhPointerEvent_t *pointer = PhGetData( winEvent ); */ |
283
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
97 PhRect_t *rect = PhGetRects( winEvent ); |
0 | 98 |
283
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
99 int centre_x, centre_y; |
320
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
100 int dx, dy; |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
101 short abs_x, abs_y; |
0 | 102 int posted; |
103 | |
283
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
104 centre_x = SDL_VideoSurface->w / 2; |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
105 centre_y = SDL_VideoSurface->h / 2; |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
106 |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
107 dx = rect->ul.x - centre_x; |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
108 dy = rect->ul.y - centre_y; |
0 | 109 |
283
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
110 posted = SDL_PrivateMouseMotion( 0, 1, dx, dy ); |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
111 |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
112 /* Move mouse cursor to middle of the window */ |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
113 PtGetAbsPosition( window, &abs_x, &abs_y ); |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
114 PhMoveCursorAbs( PhInputGroup(NULL), |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
115 abs_x + centre_x, |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
116 abs_y + centre_y ); |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
117 |
0 | 118 return(posted); |
119 } | |
120 | |
220 | 121 /* Control which motion flags the window has set, a flags value of -1 sets |
122 * MOTION_BUTTON and MOTION_NOBUTTON */ | |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
123 |
220 | 124 static void set_motion_sensitivity(_THIS, unsigned int flags) |
125 { | |
126 int rid, fields = Ph_EV_PTR_MOTION_BUTTON | Ph_EV_PTR_MOTION_NOBUTTON; | |
127 PhRegion_t region; | |
128 | |
129 if( window ) | |
130 { | |
131 rid = PtWidgetRid( window ); | |
132 if( rid != 0 && PhRegionQuery( rid, ®ion, NULL, NULL, 0 ) == 0 ) | |
133 { | |
134 region.events_sense = ( region.events_sense & ~fields ) | | |
135 ( flags & fields ); | |
136 PhRegionChange( Ph_REGION_EV_SENSE, 0, ®ion, | |
137 NULL, NULL ); | |
138 } | |
139 } | |
140 } | |
141 | |
142 /* Convert the photon button state value to an SDL value */ | |
143 static Uint8 ph2sdl_mousebutton( unsigned short button_state ) | |
144 { | |
145 Uint8 mouse_button = 0; | |
146 | |
147 if( button_state & Ph_BUTTON_SELECT ) | |
148 mouse_button |= SDL_BUTTON_LEFT; | |
149 if( button_state & Ph_BUTTON_MENU ) | |
150 mouse_button |= SDL_BUTTON_RIGHT; | |
151 if( button_state & Ph_BUTTON_ADJUST ) | |
152 mouse_button |= SDL_BUTTON_MIDDLE; | |
153 | |
154 return( mouse_button ); | |
155 } | |
156 | |
0 | 157 static int ph_DispatchEvent(_THIS) |
158 { | |
320
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
159 int posted; |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
160 PhRect_t* rect; |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
161 PhPointerEvent_t* pointerEvent; |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
162 PhKeyEvent_t* keyEvent; |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
163 PhWindowEvent_t* winEvent; |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
164 int i, buttons; |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
165 SDL_Rect sdlrects[50]; |
0 | 166 |
320
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
167 posted = 0; |
0 | 168 |
320
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
169 switch (event->type) |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
170 { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
171 case Ph_EV_BOUNDARY: |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
172 { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
173 if (event->subtype == Ph_EV_PTR_ENTER) |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
174 { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
175 posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
176 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
177 else if (event->subtype ==Ph_EV_PTR_LEAVE) |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
178 { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
179 posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
180 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
181 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
182 break; |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
183 |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
184 case Ph_EV_PTR_MOTION_BUTTON: |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
185 case Ph_EV_PTR_MOTION_NOBUTTON: |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
186 { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
187 if (SDL_VideoSurface) |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
188 { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
189 pointerEvent = PhGetData(event); |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
190 rect = PhGetRects(event); |
0 | 191 |
320
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
192 if (mouse_relative) |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
193 { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
194 posted = ph_WarpedMotion(this, event); |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
195 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
196 else |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
197 { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
198 posted = SDL_PrivateMouseMotion(0, 0, rect->ul.x, rect->ul.y); |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
199 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
200 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
201 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
202 break; |
0 | 203 |
320
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
204 case Ph_EV_BUT_PRESS: |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
205 { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
206 pointerEvent = PhGetData( event ); |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
207 buttons = ph2sdl_mousebutton( pointerEvent->buttons ); |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
208 if (buttons != 0) |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
209 { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
210 posted = SDL_PrivateMouseButton(SDL_PRESSED, buttons, 0, 0); |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
211 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
212 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
213 break; |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
214 |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
215 case Ph_EV_BUT_RELEASE: |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
216 { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
217 pointerEvent = PhGetData(event); |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
218 buttons = ph2sdl_mousebutton(pointerEvent->buttons); |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
219 if (event->subtype == Ph_EV_RELEASE_REAL && buttons != 0) |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
220 { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
221 posted = SDL_PrivateMouseButton(SDL_RELEASED, buttons, 0, 0); |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
222 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
223 else if(event->subtype == Ph_EV_RELEASE_PHANTOM) |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
224 { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
225 /* If the mouse is outside the window, |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
226 * only a phantom release event is sent, so |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
227 * check if the window doesn't have mouse focus. |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
228 * Not perfect, maybe checking the mouse button |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
229 * state for Ph_EV_BOUNDARY events would be |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
230 * better. */ |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
231 if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS) == 0) |
0 | 232 { |
320
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
233 posted = SDL_PrivateMouseButton(SDL_RELEASED, buttons, 0, 0); |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
234 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
235 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
236 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
237 break; |
0 | 238 |
320
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
239 case Ph_EV_WM: |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
240 { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
241 winEvent = PhGetData(event); |
0 | 242 |
320
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
243 /* losing focus */ |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
244 if ((winEvent->event_f==Ph_WM_FOCUS) && (winEvent->event_state==Ph_WM_EVSTATE_FOCUSLOST)) |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
245 { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
246 set_motion_sensitivity(this, Ph_EV_PTR_MOTION_BUTTON); |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
247 posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); |
0 | 248 |
320
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
249 /* Queue leaving fullscreen mode */ |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
250 switch_waiting = 0x01; |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
251 switch_time = SDL_GetTicks() + 200; |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
252 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
253 /* gaining focus */ |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
254 else if ((winEvent->event_f==Ph_WM_FOCUS) && (winEvent->event_state==Ph_WM_EVSTATE_FOCUS)) |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
255 { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
256 set_motion_sensitivity(this, -1); |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
257 posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
258 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
259 /* request to quit */ |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
260 else if (winEvent->event_f==Ph_WM_CLOSE) |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
261 { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
262 posted = SDL_PrivateQuit(); |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
263 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
264 /* request to resize */ |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
265 else if (winEvent->event_f==Ph_WM_RESIZE) |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
266 { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
267 SDL_PrivateResize(winEvent->size.w, winEvent->size.h); |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
268 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
269 /* request to maximize */ |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
270 else if (winEvent->event_f==Ph_WM_MAX) |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
271 { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
272 /* TODO: get screen resolution, set window pos to 0, 0 and resize it ! */ |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
273 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
274 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
275 break; |
0 | 276 |
320
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
277 /* window has been resized, moved or removed */ |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
278 case Ph_EV_EXPOSE: |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
279 { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
280 if (SDL_VideoSurface) |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
281 { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
282 rect = PhGetRects(event); |
220 | 283 |
320
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
284 for(i=0;i<event->num_rects;i++) |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
285 { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
286 sdlrects[i].x = rect[i].ul.x; |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
287 sdlrects[i].y = rect[i].ul.y; |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
288 sdlrects[i].w = rect[i].lr.x - rect[i].ul.x + 1; |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
289 sdlrects[i].h = rect[i].lr.y - rect[i].ul.y + 1; |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
290 } |
0 | 291 |
320
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
292 this->UpdateRects(this, event->num_rects, sdlrects); |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
293 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
294 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
295 break; |
0 | 296 |
320
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
297 case Ph_EV_KEY: |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
298 { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
299 SDL_keysym keysym; |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
300 |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
301 posted = 0; |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
302 |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
303 keyEvent = PhGetData( event ); |
0 | 304 |
320
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
305 if (Pk_KF_Key_Down & keyEvent->key_flags) |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
306 { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
307 posted = SDL_PrivateKeyboard(SDL_PRESSED, ph_TranslateKey(keyEvent, &keysym)); |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
308 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
309 else /* must be key release */ |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
310 { |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
311 /* Ignore repeated key release events */ |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
312 /* if (! Pk_KF_Key_Repeat & keyEvent->key_flags ) */ |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
313 |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
314 posted = SDL_PrivateKeyboard(SDL_RELEASED, ph_TranslateKey( keyEvent, &keysym)); |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
315 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
316 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
317 break; |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
318 } |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
319 |
66f815c147ed
Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
320 return(posted); |
0 | 321 } |
322 | |
323 /* perform a blocking read if no events available */ | |
324 int ph_Pending(_THIS) | |
325 { | |
326 /* Flush the display connection and look to see if events are queued */ | |
327 PgFlush(); | |
328 | |
329 while( 1 ) | |
330 { //note this is a non-blocking call | |
331 switch( PhEventPeek( event, EVENT_SIZE ) ) | |
332 { | |
333 case Ph_EVENT_MSG: | |
334 | |
335 return 1; | |
336 break; | |
337 case -1: | |
338 perror( "PhEventNext failed" ); | |
339 break; | |
340 default: | |
341 | |
342 return 0; | |
343 } | |
344 } | |
345 | |
346 /* Oh well, nothing is ready .. */ | |
347 return(0); | |
348 } | |
349 | |
350 /* | |
351 SAMPLE EVENT PUMP | |
352 ================= | |
353 static void update( int block ){ | |
354 | |
355 int ch,fl; | |
356 PhKeyEvent_t *key; | |
357 | |
358 for( ;; ){ | |
359 | |
360 if( block ){ | |
361 do{ | |
362 fl=PhEventNext( event,EVENT_SIZE ); | |
363 }while( fl!=Ph_EVENT_MSG ); | |
364 block=0; | |
365 }else{ | |
366 do{ | |
367 fl=PhEventPeek( event,EVENT_SIZE ); | |
368 if( !fl ) return; | |
369 }while( fl!=Ph_EVENT_MSG ); | |
370 } | |
371 | |
372 switch( event->type ){ | |
373 case Ph_EV_KEY: | |
374 key=PhGetData( event ); | |
375 ch=key->key_cap; // & 127; | |
376 fl=key->key_flags; | |
377 if( ch<32 || ch>127 ) break; | |
378 if( fl & Pk_KF_Key_Down ){ | |
379 if( !(fl & Pk_KF_Key_Repeat) ){ | |
380 if( queput-queget<QUE_SIZE ) keyque[ queput++ & QUE_MASK ]=ch; | |
381 keyMatrix[ch]=1; | |
382 } | |
383 }else{ | |
384 keyMatrix[ch]=0; | |
385 } | |
386 break; | |
387 default: | |
388 PtEventHandler( event ); | |
389 } | |
390 } | |
391 } | |
392 */ | |
393 | |
394 void ph_PumpEvents(_THIS) | |
395 { | |
396 int pending; | |
397 | |
398 /* Keep processing pending events */ | |
399 pending = 0; | |
400 while ( ph_Pending(this) ) { | |
401 ph_DispatchEvent(this); | |
402 ++pending; | |
403 } | |
404 if ( switch_waiting ) { | |
405 Uint32 now; | |
406 | |
407 now = SDL_GetTicks(); | |
283
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
408 #if 0 |
0 | 409 if ( pending || !SDL_VideoSurface ) { |
410 /* Try again later... */ | |
411 if ( switch_waiting & SDL_FULLSCREEN ) { | |
412 switch_time = now + 1500; | |
413 } else { | |
414 switch_time = now + 200; | |
415 } | |
416 } else if ( now >= switch_time ) { | |
417 Uint32 go_fullscreen; | |
418 | |
419 go_fullscreen = switch_waiting & SDL_FULLSCREEN; | |
420 switch_waiting = 0; | |
421 if ( SDL_VideoSurface->flags & SDL_FULLSCREEN ) { | |
422 if ( go_fullscreen ) { | |
423 ph_EnterFullScreen(this); | |
424 } else { | |
425 ph_LeaveFullScreen(this); | |
426 } | |
427 } | |
428 /* Handle focus in/out when grabbed */ | |
429 /* | |
430 if ( go_fullscreen ) { | |
431 ph_GrabInputNoLock(this, this->input_grab); | |
432 } else { | |
433 ph_GrabInputNoLock(this, SDL_GRAB_OFF); | |
434 } | |
435 */ | |
436 } | |
283
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
437 #endif |
0 | 438 } |
439 } | |
440 | |
441 void ph_InitKeymap(void) | |
442 { | |
443 int i; | |
444 | |
445 /* Odd keys used in international keyboards */ | |
446 for ( i=0; i<SDL_TABLESIZE(ODD_keymap); ++i ) | |
447 ODD_keymap[i] = SDLK_UNKNOWN; | |
448 | |
449 /* Map the miscellaneous keys */ | |
450 for ( i=0; i<SDL_TABLESIZE(MISC_keymap); ++i ) | |
451 MISC_keymap[i] = SDLK_UNKNOWN; | |
452 | |
453 MISC_keymap[Pk_BackSpace&0xFF] = SDLK_BACKSPACE; | |
454 MISC_keymap[Pk_Tab&0xFF] = SDLK_TAB; | |
455 MISC_keymap[Pk_Clear&0xFF] = SDLK_CLEAR; | |
456 MISC_keymap[Pk_Return&0xFF] = SDLK_RETURN; | |
457 MISC_keymap[Pk_Pause&0xFF] = SDLK_PAUSE; | |
458 MISC_keymap[Pk_Escape&0xFF] = SDLK_ESCAPE; | |
459 MISC_keymap[Pk_Delete&0xFF] = SDLK_DELETE; | |
460 | |
461 MISC_keymap[Pk_KP_0&0xFF] = SDLK_KP0; | |
462 MISC_keymap[Pk_KP_1&0xFF] = SDLK_KP1; | |
463 MISC_keymap[Pk_KP_2&0xFF] = SDLK_KP2; | |
464 MISC_keymap[Pk_KP_3&0xFF] = SDLK_KP3; | |
465 MISC_keymap[Pk_KP_4&0xFF] = SDLK_KP4; | |
466 MISC_keymap[Pk_KP_5&0xFF] = SDLK_KP5; | |
467 MISC_keymap[Pk_KP_6&0xFF] = SDLK_KP6; | |
468 MISC_keymap[Pk_KP_7&0xFF] = SDLK_KP7; | |
469 MISC_keymap[Pk_KP_8&0xFF] = SDLK_KP8; | |
470 MISC_keymap[Pk_KP_9&0xFF] = SDLK_KP9; | |
471 | |
472 MISC_keymap[Pk_KP_Decimal&0xFF] = SDLK_KP_PERIOD; | |
473 MISC_keymap[Pk_KP_Divide&0xFF] = SDLK_KP_DIVIDE; | |
474 MISC_keymap[Pk_KP_Multiply&0xFF] = SDLK_KP_MULTIPLY; | |
475 MISC_keymap[Pk_KP_Subtract&0xFF] = SDLK_KP_MINUS; | |
476 MISC_keymap[Pk_KP_Add&0xFF] = SDLK_KP_PLUS; | |
477 MISC_keymap[Pk_KP_Enter&0xFF] = SDLK_KP_ENTER; | |
478 MISC_keymap[Pk_KP_Equal&0xFF] = SDLK_KP_EQUALS; | |
479 | |
480 MISC_keymap[Pk_Up&0xFF] = SDLK_UP; | |
481 MISC_keymap[Pk_Down&0xFF] = SDLK_DOWN; | |
482 MISC_keymap[Pk_Right&0xFF] = SDLK_RIGHT; | |
483 MISC_keymap[Pk_Left&0xFF] = SDLK_LEFT; | |
484 MISC_keymap[Pk_Insert&0xFF] = SDLK_INSERT; | |
485 MISC_keymap[Pk_Home&0xFF] = SDLK_HOME; | |
486 MISC_keymap[Pk_End&0xFF] = SDLK_END; | |
487 MISC_keymap[Pk_Pg_Up&0xFF] = SDLK_PAGEUP; | |
488 MISC_keymap[Pk_Pg_Down&0xFF] = SDLK_PAGEDOWN; | |
489 | |
490 MISC_keymap[Pk_F1&0xFF] = SDLK_F1; | |
491 MISC_keymap[Pk_F2&0xFF] = SDLK_F2; | |
492 MISC_keymap[Pk_F3&0xFF] = SDLK_F3; | |
493 MISC_keymap[Pk_F4&0xFF] = SDLK_F4; | |
494 MISC_keymap[Pk_F5&0xFF] = SDLK_F5; | |
495 MISC_keymap[Pk_F6&0xFF] = SDLK_F6; | |
496 MISC_keymap[Pk_F7&0xFF] = SDLK_F7; | |
497 MISC_keymap[Pk_F8&0xFF] = SDLK_F8; | |
498 MISC_keymap[Pk_F9&0xFF] = SDLK_F9; | |
499 MISC_keymap[Pk_F10&0xFF] = SDLK_F10; | |
500 MISC_keymap[Pk_F11&0xFF] = SDLK_F11; | |
501 MISC_keymap[Pk_F12&0xFF] = SDLK_F12; | |
502 MISC_keymap[Pk_F13&0xFF] = SDLK_F13; | |
503 MISC_keymap[Pk_F14&0xFF] = SDLK_F14; | |
504 MISC_keymap[Pk_F15&0xFF] = SDLK_F15; | |
505 | |
506 MISC_keymap[Pk_Num_Lock&0xFF] = SDLK_NUMLOCK; | |
507 MISC_keymap[Pk_Caps_Lock&0xFF] = SDLK_CAPSLOCK; | |
508 MISC_keymap[Pk_Scroll_Lock&0xFF] = SDLK_SCROLLOCK; | |
509 MISC_keymap[Pk_Shift_R&0xFF] = SDLK_RSHIFT; | |
510 MISC_keymap[Pk_Shift_L&0xFF] = SDLK_LSHIFT; | |
511 MISC_keymap[Pk_Control_R&0xFF] = SDLK_RCTRL; | |
512 MISC_keymap[Pk_Control_L&0xFF] = SDLK_LCTRL; | |
513 MISC_keymap[Pk_Alt_R&0xFF] = SDLK_RALT; | |
514 MISC_keymap[Pk_Alt_L&0xFF] = SDLK_LALT; | |
515 MISC_keymap[Pk_Meta_R&0xFF] = SDLK_RMETA; | |
516 MISC_keymap[Pk_Meta_L&0xFF] = SDLK_LMETA; | |
517 MISC_keymap[Pk_Super_L&0xFF] = SDLK_LSUPER; /* Left "Windows" */ | |
518 MISC_keymap[Pk_Super_R&0xFF] = SDLK_RSUPER; /* Right "Windows */ | |
519 MISC_keymap[Pk_Mode_switch&0xFF] = SDLK_MODE; /* "Alt Gr" key */ | |
520 | |
521 MISC_keymap[Pk_Help&0xFF] = SDLK_HELP; | |
522 MISC_keymap[Pk_Print&0xFF] = SDLK_PRINT; | |
523 // MISC_keymap[Pk_Sys_Req] = SDLK_SYSREQ; | |
524 MISC_keymap[Pk_Break&0xFF] = SDLK_BREAK; | |
525 MISC_keymap[Pk_Menu&0xFF] = SDLK_MENU; | |
526 MISC_keymap[Pk_Hyper_R&0xFF] = SDLK_MENU; /* Windows "Menu" key */ | |
527 } | |
528 | |
529 static unsigned long cap; | |
530 | |
531 SDL_keysym *ph_TranslateKey(PhKeyEvent_t *key, SDL_keysym *keysym) | |
532 { | |
533 /* | |
534 'sym' is set to the value of the key with modifiers applied to it. | |
535 This member is valid only if Pk_KF_Sym_Valid is set in the key_flags. | |
536 We will assume it is valid. | |
537 */ | |
283
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
538 /* FIXME: This needs to check whether the cap & scancode is valid */ |
0 | 539 cap = key->key_cap; |
220 | 540 switch (cap>>8) { |
0 | 541 case 0x00: /* Latin 1 */ |
542 case 0x01: /* Latin 2 */ | |
543 case 0x02: /* Latin 3 */ | |
544 case 0x03: /* Latin 4 */ | |
545 case 0x04: /* Katakana */ | |
546 case 0x05: /* Arabic */ | |
547 case 0x06: /* Cyrillic */ | |
548 case 0x07: /* Greek */ | |
549 case 0x08: /* Technical */ | |
550 case 0x0A: /* Publishing */ | |
551 case 0x0C: /* Hebrew */ | |
552 case 0x0D: /* Thai */ | |
553 keysym->sym = (SDLKey)(cap&0xFF); | |
554 /* Map capital letter syms to lowercase */ | |
555 if ((keysym->sym >= 'A')&&(keysym->sym <= 'Z')) | |
556 keysym->sym += ('a'-'A'); | |
557 break; | |
558 // case 0xFE: | |
559 // keysym->sym = ODD_keymap[sym&0xFF]; | |
560 // break; | |
561 case 0xF0: | |
562 keysym->sym = MISC_keymap[cap&0xFF]; | |
563 break; | |
564 default: | |
283
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
565 /* fprintf(stderr,"Photon: Unknown key_cap, cap = 0x%.4x\n", (unsigned int)cap); */ |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
566 keysym->sym = SDLK_UNKNOWN; |
0 | 567 break; |
220 | 568 } |
569 keysym->scancode = key->key_scan; | |
283
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
570 keysym->unicode = 0; |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
571 if( SDL_TranslateUNICODE ) |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
572 { |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
573 char utf8[MB_CUR_MAX]; |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
574 int utf8len; |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
575 wchar_t unicode; |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
576 |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
577 utf8len = PhKeyToMb( utf8, key ); |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
578 if( utf8len > 0 ) |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
579 { |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
580 utf8len = mbtowc( &unicode, utf8, utf8len ); |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
581 if( utf8len > 0) |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
582 keysym->unicode = unicode; |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
583 } |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
584 } |
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
585 |
0 | 586 return (keysym); |
587 } | |
588 | |
589 void ph_InitOSKeymap(_THIS) | |
590 { | |
591 ph_InitKeymap(); | |
592 } | |
593 |