annotate src/video/photon/SDL_ph_events.c @ 571:8e3ce997621c

Date: Thu, 16 Jan 2003 13:48:31 +0200 From: "Mike Gorchak" Subject: All QNX patches whole patches concerning QNX. Almost all code has been rewritten by Julian and me. Added initial support for hw overlays in QNX and many many others fixes. P.S. This patches has been reviewed by Dave Rempel from QSSL and included in SDL 1.2.5 distribution, which coming on 3rd party CD for newest 6.2.1 version of QNX, which will be available soon.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 20 Jan 2003 01:38:37 +0000
parents 66f815c147ed
children 8bedd6d61642
rev   line source
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1 /*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
4
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
9
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
13 Library General Public License for more details.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
14
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
16 License along with this library; if not, write to the Free
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
18
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
19 Sam Lantinga
252
e8157fcb3114 Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents: 220
diff changeset
20 slouken@libsdl.org
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
21 */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
22
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23 #ifdef SAVE_RCSID
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
24 static char rcsid =
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
25 "@(#) $Id$";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
26 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
27
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
28 /* Handle the event stream, converting photon events into SDL events */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
32 #include <Ph.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
33 #include <stdio.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
34 #include <setjmp.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
35 #include <photon/PkKeyDef.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
36 #include <sys/time.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
37
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
38 #include "SDL.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
39 #include "SDL_syswm.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
40 #include "SDL_sysevents.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
41 #include "SDL_sysvideo.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
42 #include "SDL_events_c.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
43 #include "SDL_ph_video.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
44 #include "SDL_ph_modes_c.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
45 #include "SDL_ph_image_c.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
46 #include "SDL_ph_events_c.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
47
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
48
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
49 /* The translation tables from a photon keysym to a SDL keysym */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
50 static SDLKey ODD_keymap[256];
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
51 static SDLKey MISC_keymap[0xFF + 1];
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
52 SDL_keysym *ph_TranslateKey(PhKeyEvent_t *key, SDL_keysym *keysym);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
53
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
54 /* Check to see if this is a repeated key.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
55 (idea shamelessly lifted from GII -- thanks guys! :)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
56 */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
57
283
3d8b6b9f1e18 Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
58 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
59 {
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
60 PhRect_t *rect = PhGetRects( winEvent );
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
61
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
62 int centre_x, centre_y;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
63 int dx, dy;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
64 short abs_x, abs_y;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
65 int posted;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
66
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
67 centre_x = SDL_VideoSurface->w / 2;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
68 centre_y = SDL_VideoSurface->h / 2;
283
3d8b6b9f1e18 Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
69
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
70 dx = rect->ul.x - centre_x;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
71 dy = rect->ul.y - centre_y;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
72
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
73 posted = SDL_PrivateMouseMotion( 0, 1, dx, dy );
283
3d8b6b9f1e18 Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
74
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
75 /* Move mouse cursor to middle of the window */
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
76 PtGetAbsPosition( window, &abs_x, &abs_y );
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
77 PhMoveCursorAbs(PhInputGroup(NULL), abs_x + centre_x, abs_y + centre_y);
283
3d8b6b9f1e18 Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
78
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
79 return (posted);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
80 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
81
220
7861d904fb77 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
82 /* Control which motion flags the window has set, a flags value of -1 sets
7861d904fb77 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
83 * MOTION_BUTTON and MOTION_NOBUTTON */
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
84
220
7861d904fb77 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
85 static void set_motion_sensitivity(_THIS, unsigned int flags)
7861d904fb77 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
86 {
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
87 int rid;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
88 int fields = Ph_EV_PTR_MOTION_BUTTON | Ph_EV_PTR_MOTION_NOBUTTON;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
89 PhRegion_t region;
220
7861d904fb77 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
90
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
91 if( window )
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
92 {
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
93 rid = PtWidgetRid( window );
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
94 if( rid != 0 && PhRegionQuery( rid, &region, NULL, NULL, 0 ) == 0 )
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
95 {
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
96 region.events_sense=(region.events_sense & ~fields)|(flags & fields);
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
97 PhRegionChange(Ph_REGION_EV_SENSE, 0, &region, NULL, NULL);
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
98 }
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
99 }
220
7861d904fb77 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
100 }
7861d904fb77 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
101
7861d904fb77 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
102 /* Convert the photon button state value to an SDL value */
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
103 static Uint8 ph2sdl_mousebutton(unsigned short button_state)
220
7861d904fb77 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
104 {
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
105 Uint8 mouse_button = 0;
220
7861d904fb77 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
106
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
107 if (button_state & Ph_BUTTON_SELECT)
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
108 mouse_button |= SDL_BUTTON_LEFT;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
109 if (button_state & Ph_BUTTON_MENU)
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
110 mouse_button |= SDL_BUTTON_RIGHT;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
111 if (button_state & Ph_BUTTON_ADJUST)
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
112 mouse_button |= SDL_BUTTON_MIDDLE;
220
7861d904fb77 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
113
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
114 return (mouse_button);
220
7861d904fb77 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
115 }
7861d904fb77 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
116
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
117 static int ph_DispatchEvent(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
118 {
320
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
119 int posted;
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
120 PhRect_t* rect;
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
121 PhPointerEvent_t* pointerEvent;
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
122 PhKeyEvent_t* keyEvent;
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
123 PhWindowEvent_t* winEvent;
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
124 int i, buttons;
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
125 SDL_Rect sdlrects[50];
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
126
320
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
127 posted = 0;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
128
320
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
129 switch (event->type)
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
130 {
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
131 case Ph_EV_BOUNDARY:
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
132 {
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
133 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
134 {
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
135 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
136 }
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
137 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
138 {
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
139 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
140 }
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
141 }
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
142 break;
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
143
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
144 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
145 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
146 {
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
147 if (SDL_VideoSurface)
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
148 {
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
149 pointerEvent = PhGetData(event);
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
150 rect = PhGetRects(event);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
151
320
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
152 if (mouse_relative)
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
153 {
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
154 posted = ph_WarpedMotion(this, event);
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
155 }
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
156 else
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
157 {
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
158 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
159 }
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
160 }
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
161 }
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
162 break;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
163
320
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
164 case Ph_EV_BUT_PRESS:
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
165 {
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
166 pointerEvent = PhGetData( event );
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
167 buttons = ph2sdl_mousebutton( pointerEvent->buttons );
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
168 if (buttons != 0)
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
169 {
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
170 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
171 }
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 break;
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 case Ph_EV_BUT_RELEASE:
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 pointerEvent = PhGetData(event);
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
178 buttons = ph2sdl_mousebutton(pointerEvent->buttons);
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
179 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
180 {
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
181 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
182 }
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
183 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
184 {
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
185 /* 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
186 * 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
187 * 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
188 * 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
189 * 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
190 * better. */
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
191 if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS) == 0)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
192 {
320
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
193 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
194 }
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 }
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
197 break;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
198
320
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
199 case Ph_EV_WM:
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 winEvent = PhGetData(event);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
202
320
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
203 /* losing focus */
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
204 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
205 {
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
206 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
207 posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
208 }
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
209 /* gaining focus */
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
210 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
211 {
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
212 set_motion_sensitivity(this, -1);
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
213 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
214 }
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
215 /* request to quit */
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
216 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
217 {
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
218 posted = SDL_PrivateQuit();
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
219 }
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
220 /* request to resize */
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
221 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
222 {
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
223 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
224 }
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
225 /* request to maximize */
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
226 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
227 {
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
228 /* 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
229 }
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
230 }
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
231 break;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
232
320
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
233 /* 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
234 case Ph_EV_EXPOSE:
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 if (SDL_VideoSurface)
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
237 {
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
238 rect = PhGetRects(event);
220
7861d904fb77 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
239
320
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
240 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
241 {
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
242 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
243 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
244 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
245 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
246 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
247
320
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
248 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
249 }
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
250 }
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
251 break;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
252
320
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
253 case Ph_EV_KEY:
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
254 {
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
255 SDL_keysym keysym;
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
256
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
257 posted = 0;
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 keyEvent = PhGetData( event );
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
260
320
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
261 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
262 {
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
263 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
264 }
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
265 else /* must be key release */
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 /* Ignore repeated key release events */
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
268 /* 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
269
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
270 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
271 }
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
272 }
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
273 break;
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
66f815c147ed Date: Thu, 28 Mar 2002 09:20:03 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
276 return(posted);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
277 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
278
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
279 /* perform a blocking read if no events available */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
280 int ph_Pending(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
281 {
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
282 /* Flush the display connection and look to see if events are queued */
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
283 PgFlush();
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
284
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
285 while( 1 )
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
286 { /* note this is a non-blocking call */
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
287 switch( PhEventPeek( event, EVENT_SIZE ) )
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
288 {
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
289 case Ph_EVENT_MSG:
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
290 return 1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
291 break;
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
292 case -1:
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
293 perror("ph_Pending(): PhEventNext failed");
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
294 break;
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
295 default:
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
296 return 0;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
297 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
298 }
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
299
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
300 /* Oh well, nothing is ready .. */
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
301 return(0);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
302 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
303
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
304 void ph_PumpEvents(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
305 {
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
306 /* Flush the display connection and look to see if events are queued */
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
307 PgFlush();
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
308
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
309 while (ph_Pending(this))
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
310 {
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
311 ph_DispatchEvent(this);
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
312 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
313 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
314
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
315 void ph_InitKeymap(void)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
316 {
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
317 int i;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
318
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
319 /* Odd keys used in international keyboards */
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
320 for (i=0; i<SDL_TABLESIZE(ODD_keymap); ++i)
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
321 ODD_keymap[i] = SDLK_UNKNOWN;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
322
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
323 /* Map the miscellaneous keys */
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
324 for (i=0; i<SDL_TABLESIZE(MISC_keymap); ++i)
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
325 MISC_keymap[i] = SDLK_UNKNOWN;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
326
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
327 MISC_keymap[Pk_BackSpace&0xFF] = SDLK_BACKSPACE;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
328 MISC_keymap[Pk_Tab&0xFF] = SDLK_TAB;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
329 MISC_keymap[Pk_Clear&0xFF] = SDLK_CLEAR;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
330 MISC_keymap[Pk_Return&0xFF] = SDLK_RETURN;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
331 MISC_keymap[Pk_Pause&0xFF] = SDLK_PAUSE;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
332 MISC_keymap[Pk_Escape&0xFF] = SDLK_ESCAPE;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
333 MISC_keymap[Pk_Delete&0xFF] = SDLK_DELETE;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
334
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
335 MISC_keymap[Pk_KP_0&0xFF] = SDLK_KP0;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
336 MISC_keymap[Pk_KP_1&0xFF] = SDLK_KP1;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
337 MISC_keymap[Pk_KP_2&0xFF] = SDLK_KP2;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
338 MISC_keymap[Pk_KP_3&0xFF] = SDLK_KP3;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
339 MISC_keymap[Pk_KP_4&0xFF] = SDLK_KP4;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
340 MISC_keymap[Pk_KP_5&0xFF] = SDLK_KP5;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
341 MISC_keymap[Pk_KP_6&0xFF] = SDLK_KP6;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
342 MISC_keymap[Pk_KP_7&0xFF] = SDLK_KP7;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
343 MISC_keymap[Pk_KP_8&0xFF] = SDLK_KP8;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
344 MISC_keymap[Pk_KP_9&0xFF] = SDLK_KP9;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
345
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
346 MISC_keymap[Pk_KP_Decimal&0xFF] = SDLK_KP_PERIOD;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
347 MISC_keymap[Pk_KP_Divide&0xFF] = SDLK_KP_DIVIDE;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
348 MISC_keymap[Pk_KP_Multiply&0xFF] = SDLK_KP_MULTIPLY;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
349 MISC_keymap[Pk_KP_Subtract&0xFF] = SDLK_KP_MINUS;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
350 MISC_keymap[Pk_KP_Add&0xFF] = SDLK_KP_PLUS;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
351 MISC_keymap[Pk_KP_Enter&0xFF] = SDLK_KP_ENTER;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
352 MISC_keymap[Pk_KP_Equal&0xFF] = SDLK_KP_EQUALS;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
353
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
354 MISC_keymap[Pk_Up&0xFF] = SDLK_UP;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
355 MISC_keymap[Pk_Down&0xFF] = SDLK_DOWN;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
356 MISC_keymap[Pk_Right&0xFF] = SDLK_RIGHT;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
357 MISC_keymap[Pk_Left&0xFF] = SDLK_LEFT;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
358 MISC_keymap[Pk_Insert&0xFF] = SDLK_INSERT;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
359 MISC_keymap[Pk_Home&0xFF] = SDLK_HOME;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
360 MISC_keymap[Pk_End&0xFF] = SDLK_END;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
361 MISC_keymap[Pk_Pg_Up&0xFF] = SDLK_PAGEUP;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
362 MISC_keymap[Pk_Pg_Down&0xFF] = SDLK_PAGEDOWN;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
363
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
364 MISC_keymap[Pk_F1&0xFF] = SDLK_F1;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
365 MISC_keymap[Pk_F2&0xFF] = SDLK_F2;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
366 MISC_keymap[Pk_F3&0xFF] = SDLK_F3;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
367 MISC_keymap[Pk_F4&0xFF] = SDLK_F4;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
368 MISC_keymap[Pk_F5&0xFF] = SDLK_F5;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
369 MISC_keymap[Pk_F6&0xFF] = SDLK_F6;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
370 MISC_keymap[Pk_F7&0xFF] = SDLK_F7;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
371 MISC_keymap[Pk_F8&0xFF] = SDLK_F8;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
372 MISC_keymap[Pk_F9&0xFF] = SDLK_F9;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
373 MISC_keymap[Pk_F10&0xFF] = SDLK_F10;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
374 MISC_keymap[Pk_F11&0xFF] = SDLK_F11;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
375 MISC_keymap[Pk_F12&0xFF] = SDLK_F12;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
376 MISC_keymap[Pk_F13&0xFF] = SDLK_F13;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
377 MISC_keymap[Pk_F14&0xFF] = SDLK_F14;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
378 MISC_keymap[Pk_F15&0xFF] = SDLK_F15;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
379
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
380 MISC_keymap[Pk_Num_Lock&0xFF] = SDLK_NUMLOCK;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
381 MISC_keymap[Pk_Caps_Lock&0xFF] = SDLK_CAPSLOCK;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
382 MISC_keymap[Pk_Scroll_Lock&0xFF] = SDLK_SCROLLOCK;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
383 MISC_keymap[Pk_Shift_R&0xFF] = SDLK_RSHIFT;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
384 MISC_keymap[Pk_Shift_L&0xFF] = SDLK_LSHIFT;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
385 MISC_keymap[Pk_Control_R&0xFF] = SDLK_RCTRL;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
386 MISC_keymap[Pk_Control_L&0xFF] = SDLK_LCTRL;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
387 MISC_keymap[Pk_Alt_R&0xFF] = SDLK_RALT;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
388 MISC_keymap[Pk_Alt_L&0xFF] = SDLK_LALT;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
389 MISC_keymap[Pk_Meta_R&0xFF] = SDLK_RMETA;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
390 MISC_keymap[Pk_Meta_L&0xFF] = SDLK_LMETA;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
391 MISC_keymap[Pk_Super_L&0xFF] = SDLK_LSUPER; /* Left "Windows" */
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
392 MISC_keymap[Pk_Super_R&0xFF] = SDLK_RSUPER; /* Right "Windows" */
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
393 MISC_keymap[Pk_Mode_switch&0xFF] = SDLK_MODE; /* "Alt Gr" key */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
394
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
395 MISC_keymap[Pk_Help&0xFF] = SDLK_HELP;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
396 MISC_keymap[Pk_Print&0xFF] = SDLK_PRINT;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
397 MISC_keymap[Pk_Break&0xFF] = SDLK_BREAK;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
398 MISC_keymap[Pk_Menu&0xFF] = SDLK_MENU;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
399 MISC_keymap[Pk_Hyper_R&0xFF] = SDLK_MENU; /* Windows "Menu" key */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
400 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
401
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
402 static unsigned long cap;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
403
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
404 SDL_keysym *ph_TranslateKey(PhKeyEvent_t *key, SDL_keysym *keysym)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
405 {
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
406 /* 'sym' is set to the value of the key with modifiers applied to it.
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
407 This member is valid only if Pk_KF_Sym_Valid is set in the key_flags.
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
408 We will assume it is valid. */
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
409
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
410 /* FIXME: This needs to check whether the cap & scancode is valid */
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
411
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
412 cap = key->key_cap;
283
3d8b6b9f1e18 Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
413
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
414 switch (cap>>8)
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
415 {
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
416 case 0x00: /* Latin 1 */
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
417 case 0x01: /* Latin 2 */
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
418 case 0x02: /* Latin 3 */
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
419 case 0x03: /* Latin 4 */
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
420 case 0x04: /* Katakana */
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
421 case 0x05: /* Arabic */
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
422 case 0x06: /* Cyrillic */
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
423 case 0x07: /* Greek */
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
424 case 0x08: /* Technical */
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
425 case 0x0A: /* Publishing */
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
426 case 0x0C: /* Hebrew */
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
427 case 0x0D: /* Thai */
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
428 keysym->sym = (SDLKey)(cap&0xFF);
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
429 /* Map capital letter syms to lowercase */
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
430 if ((keysym->sym >= 'A')&&(keysym->sym <= 'Z'))
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
431 keysym->sym += ('a'-'A');
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
432 break;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
433 case 0xF0:
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
434 keysym->sym = MISC_keymap[cap&0xFF];
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
435 break;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
436 default:
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
437 keysym->sym = SDLK_UNKNOWN;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
438 break;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
439 }
283
3d8b6b9f1e18 Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents: 266
diff changeset
440
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
441 keysym->scancode = key->key_scan;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
442 keysym->unicode = 0;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
443
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
444 if (SDL_TranslateUNICODE)
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
445 {
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
446 char utf8[MB_CUR_MAX];
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
447 int utf8len;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
448 wchar_t unicode;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
449
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
450 utf8len = PhKeyToMb(utf8, key);
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
451 if (utf8len > 0)
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
452 {
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
453 utf8len = mbtowc(&unicode, utf8, utf8len);
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
454 if (utf8len > 0)
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
455 keysym->unicode = unicode;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
456 }
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
457 }
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
458
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
459 return (keysym);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
460 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
461
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
462 void ph_InitOSKeymap(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
463 {
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 320
diff changeset
464 ph_InitKeymap();
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
465 }