Mercurial > sdl-ios-xcode
annotate src/video/gem/SDL_gemevents.c @ 4157:baf615f9f2a0 SDL-1.2
Date: Thu, 16 Oct 2008 20:27:34 +0400
From: "Ilya Kasnacheev" <ilya.kasnacheev@gmail.com>
To: sdl@lists.libsdl.org
Subject: [SDL] SDL for Windows CE: a few GAPI patches
Hi *!
I've just ported a POWDER roguelike ( http://www.zincland.com/powder/ ) to
Windows CE (PDAs, Windows Mobile/Pocket PC). To do that, I had to get libsdl
working. Thanks for the awesome project files, it built without a hitch.
Nevertheless, I've found quite a few bugs in Windows CE (GAPI) SDL
implementation, which I've solved and now present as a serie of patches.
I'll try carefully annotate them. Please annotate them so I can work
toward accepting
them into the main source tree since without them SDL isn't really working on
Windows CE (I wonder why nobody fixed them before, btw: why isn't SDL popular as
a way to develop Windows CE games? Where are no ports?)
These changes can't be considered flawless, but they can be considered working
because I've yet to hear complains about things I fixed and POWDER build for
Windows CE is now considered stable.
Note: my comments start with !!, delete them before applying.
diff -bru SDL-1.2.13/src/video/gapi/SDL_gapivideo.c
SDL-1.2.13-new/src/video/gapi/SDL_gapivideo.c
--- SDL-1.2.13/src/video/gapi/SDL_gapivideo.c 2007-12-31
07:48:00.000000000 +0300
+++ SDL-1.2.13-new/src/video/gapi/SDL_gapivideo.c 2008-10-16
20:02:11.000000000 +0400
@@ -643,6 +643,7 @@
}
gapi->userOrientation = SDL_ORIENTATION_UP;
+ gapi->systemOrientation = SDL_ORIENTATION_UP;
video->flags = SDL_FULLSCREEN; /* Clear flags, GAPI supports
fullscreen only */
/* GAPI or VGA? */
@@ -661,18 +662,21 @@
}
/* detect user landscape mode */
- if( (width > height) && (GetSystemMetrics(SM_CXSCREEN) <
GetSystemMetrics(SM_CYSCREEN)))
+ if( (width > height) && (gapi->gxProperties.cxWidth <
gapi->gxProperties.cyHeight))
gapi->userOrientation = SDL_ORIENTATION_RIGHT;
+ if(GetSystemMetrics(SM_CYSCREEN) < GetSystemMetrics(SM_CXSCREEN))
+ gapi->systemOrientation = SDL_ORIENTATION_RIGHT;
+
/* shall we apply hires fix? for example when we do not use
hires resource */
gapi->hiresFix = 0;
- if( gapi->userOrientation == SDL_ORIENTATION_RIGHT )
+ if( gapi->systemOrientation == gapi->userOrientation )
{
- if( (width > GetSystemMetrics(SM_CYSCREEN)) || (height
> GetSystemMetrics(SM_CXSCREEN)))
+ if( (width > GetSystemMetrics(SM_CXSCREEN)) || (height
> GetSystemMetrics(SM_CYSCREEN)))
gapi->hiresFix = 1;
} else
- if( (width > GetSystemMetrics(SM_CXSCREEN)) || (height
> GetSystemMetrics(SM_CYSCREEN)))
- if( !((width == GetSystemMetrics(SM_CYSCREEN))
&& (height == GetSystemMetrics(SM_CXSCREEN)))) // user portrait,
device landscape
+ if( (width > GetSystemMetrics(SM_CYSCREEN)) || (height
> GetSystemMetrics(SM_CXSCREEN)))
+// if( !((width == gapi->gxProperties.cyHeight)
&& (height == gapi->gxProperties.cxWidth))) // user portrait, device
landscape
gapi->hiresFix = 1;
switch( gapi->userOrientation )
!! It used to query system metrics which return dimensions according to screen
!! orientation, which can really be portrait, left landscape or right landscape.
!! This is presumably incorrect because we couldn't care less about user mode
!! dimensions - all we want are the GAPI framebuffer dimensions, which
only match
!! user dimensions in one of possible orientations.
!! There's a fair dose of cargo cult programming involved in this fix, but it
!! used to work only in one orientation (portrait for PDAs, where frame-buffer
!! have same orientation as user screen), and now it works on all orientations.
@@ -742,21 +746,30 @@
WIN_FlushMessageQueue();
/* Open GAPI display */
- if( !gapi->useVga && this->hidden->useGXOpenDisplay )
+ if( !gapi->useVga && this->hidden->useGXOpenDisplay &&
!this->hidden->alreadyGXOpened )
+ {
+ this->hidden->alreadyGXOpened = 1;
if( !gapi->gxFunc.GXOpenDisplay(SDL_Window, GX_FULLSCREEN) )
{
SDL_SetError("Couldn't initialize GAPI");
return(NULL);
}
+ }
#if REPORT_VIDEO_INFO
printf("Video properties:\n");
printf("display bpp: %d\n", gapi->gxProperties.cBPP);
printf("display width: %d\n", gapi->gxProperties.cxWidth);
printf("display height: %d\n", gapi->gxProperties.cyHeight);
+ printf("system display width: %d\n", GetSystemMetrics(SM_CXSCREEN));
+ printf("system display height: %d\n", GetSystemMetrics(SM_CYSCREEN));
printf("x pitch: %d\n", gapi->gxProperties.cbxPitch);
printf("y pitch: %d\n", gapi->gxProperties.cbyPitch);
printf("gapi flags: 0x%x\n", gapi->gxProperties.ffFormat);
+ printf("user orientation: %d\n", gapi->userOrientation);
+ printf("system orientation: %d\n", gapi->userOrientation);
+ printf("gapi orientation: %d\n", gapi->gapiOrientation);
+
if( !gapi->useVga && this->hidden->useGXOpenDisplay && gapi->needUpdate)
{
!! Previous version used to call gapi->gxFunc.GXOpenDisplay each time the video
!! mode would be changed. You shouldn't, because this call has a
meaning "Lock the
!! GAPI framebuffer, designate it as busy", so the second call will fail (it is
!! already locked/busy).
!! Testing might not find that because most programs set up the video mode only
!! once, but POWDER does this once in a while, so it crashed when in
320x240 mode
!! (640x480 mode doesn't use that code, it worked fine).
diff -bru SDL-1.2.13/src/video/gapi/SDL_gapivideo.h
SDL-1.2.13-new/src/video/gapi/SDL_gapivideo.h
--- SDL-1.2.13/src/video/gapi/SDL_gapivideo.h 2007-12-31
07:48:00.000000000 +0300
+++ SDL-1.2.13-new/src/video/gapi/SDL_gapivideo.h 2008-10-16
20:02:11.000000000 +0400
@@ -132,12 +132,17 @@
#define NUM_MODELISTS 4 /* 8, 16, 24, and 32 bits-per-pixel */
int SDL_nummodes[NUM_MODELISTS];
SDL_Rect **SDL_modelist[NUM_MODELISTS];
+ // The orientation of the video mode user wants to get
+ // Probably restricted to UP and RIGHT
enum SDL_ScreenOrientation userOrientation;
int invert;
char hiresFix; // using hires mode without defining hires resource
// --------------
int useGXOpenDisplay; /* use GXOpenDispplay */
+ int alreadyGXOpened;
int w, h;
+ // The orientation of GAPI framebuffer.
+ // Never changes on the same device.
enum SDL_ScreenOrientation gapiOrientation;
void *buffer; // may be 8, 16, 24, 32 bpp
@@ -153,6 +158,10 @@
int startOffset; // in bytes
int useVga;
int suspended; // do not pu anything into video memory
+ // The orientation of the system, as defined by SM_CXSCREEN
and SM_CYSCREEN
+ // User can change it by using 'screen layout' in system options
+ // Restricted to UP or RIGHT
+ enum SDL_ScreenOrientation systemOrientation;
};
!! This is a flag variable, see the previous comment
!! And yet another orientation: now we have to keep three of them in mind.
diff -bru SDL-1.2.13/src/video/wincommon/SDL_sysevents.c
SDL-1.2.13-new/src/video/wincommon/SDL_sysevents.c
--- SDL-1.2.13/src/video/wincommon/SDL_sysevents.c 2007-12-31
07:48:02.000000000 +0300
+++ SDL-1.2.13-new/src/video/wincommon/SDL_sysevents.c 2008-10-16
20:02:12.000000000 +0400
@@ -160,10 +160,22 @@
#endif */
}
break;
+ // FIXME: Older version used just SDL_VideoSurface->(w, h)
+ // w and h are "clipped" while x and y are "raw", which caused
+ // x in former and y in latter case to be clipped in a
wrong direction,
+ // thus offsetting the coordinate on 2 x clip pixels
+ // (like, 128 for 640 -> 512 clipping).
+ // We will now try to extract and use raw values.
+ // The way to do that RIGHT is do
(orientation-dependent) clipping before
+ // doing this transform, but it's hardly possible.
+
+ // SEE SDL_mouse.c /ClipOffset to understand these calculations.
case SDL_ORIENTATION_RIGHT:
if (!SDL_VideoSurface)
break;
- rotatedX = SDL_VideoSurface->w - *y;
+ rotatedX = (2 *
((SDL_VideoSurface->offset%SDL_VideoSurface->pitch)/
+ SDL_VideoSurface->format->BytesPerPixel))
+ + SDL_VideoSurface->w - *y;
rotatedY = *x;
*x = rotatedX;
*y = rotatedY;
@@ -172,7 +184,8 @@
if (!SDL_VideoSurface)
break;
rotatedX = *y;
- rotatedY = SDL_VideoSurface->h - *x;
+ rotatedY = (2 *
(SDL_VideoSurface->offset/SDL_VideoSurface->pitch))
+ + SDL_VideoSurface->h - *x;
*x = rotatedX;
*y = rotatedY;
break;
!! That's the trickest part, hence the long comment.
!! GAPI would really support only 320x240 or 640x480 mode, if application
!! requested the different screen size (as POWDER did, wishing
256x192), then SDL
!! is going to grab the first mode that fits the requested, and pad the screen
!! with black bars (as they do with wide-screen films).
!! It would also get, say, 240x320 mode, and to turn it into 256x192 it would
!! need to rotate mouse clicks.
!! It worked, but one bug slipped through: it would receive mouse clicks
!! unpadded, then rotate them, and then pad the black bars. The
problem is: rotate
!! is done by GAPI driver while padding is done by SDL core. SDL core
doesn't know
!! anything about rotating, so it would pad one of dimensions incorrectly.
I understand that some of my claims (or code) might seem unbacked, but you can
always grab the POWDER binary, compile your own libsdl with one or more of
those fixes turned off, and see how weird it would misbehave. I can even supply
you with those custom builds of libsdl if you don't want to set up the build
environment for windows ce, you'll just need a PDA or a smartphone with it.
I plan to take care of SDL on Windows CE as long as I maintain the POWDER port.
POWDER is good for that because it:
Employs both padded (with centered image, black bars) and unpadded
(image occupies full screen) graphics; initializes video more than
once; uses both 320x240 and 640x480 video; uses both stylus and
buttons.
There's still a list of unresolved issues which I'm planning to fix:
1) Arrow buttons on PDA return weird scancodes compared to PC, this
caused the game to misbehave before I've fixed that. You can see it on
those diagrams:
http://wrar.name/upload/powder-htc.png
http://wrar.name/upload/powder-pda.png
2) SDL (or underlying windows) doesn't care to rotate arrow presses
when we're in a low-res GAPI mode, but it will rotate them in VGA mode
(because of different screen orientations, the same arrow buttons can
suddently mean different directions). Solution: we should stick to
GAPI user orientation (the orientation the program supposedly wants)
and rotate the keys on our own.
_______________________________________________
SDL mailing list
SDL@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 07 Nov 2008 04:15:36 +0000 |
parents | 0b4ebec67cad |
children | a1b03ba2fcd0 |
rev | line source |
---|---|
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1310
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1310
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1310
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1310
diff
changeset
|
13 Lesser General Public License for more details. |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1310
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1310
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1310
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
22 #include "SDL_config.h" |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 /* |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 * GEM SDL video driver implementation |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 * inspired from the Dummy SDL driver |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 * |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 * Patrice Mandin |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 * and work from |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 * Olivier Landemarre, Johan Klockars, Xavier Joubert, Claude Attard |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 #include <gem.h> |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
35 #include "../../events/SDL_sysevents.h" |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
36 #include "../../events/SDL_events_c.h" |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 #include "SDL_gemvideo.h" |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 #include "SDL_gemevents_c.h" |
1412 | 39 #include "../ataricommon/SDL_atarikeys.h" /* for keyboard scancodes */ |
40 #include "../ataricommon/SDL_atarievents_c.h" | |
41 #include "../ataricommon/SDL_xbiosevents_c.h" | |
1420
2405517b5eab
Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
1412
diff
changeset
|
42 #include "../ataricommon/SDL_ataridevmouse_c.h" |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 /* Variables */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 static unsigned char gem_currentkeyboard[ATARIBIOS_MAXKEYS]; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 static unsigned char gem_previouskeyboard[ATARIBIOS_MAXKEYS]; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 /* Functions prototypes */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 static int do_messages(_THIS, short *message); |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 static void do_keyboard(short kc, short ks); |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
53 static void do_mouse(_THIS, short mx, short my, short mb, short ks); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 /* Functions */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 void GEM_InitOSKeymap(_THIS) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 { |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
59 SDL_memset(gem_currentkeyboard, 0, sizeof(gem_currentkeyboard)); |
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
60 SDL_memset(gem_previouskeyboard, 0, sizeof(gem_previouskeyboard)); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 /* Mouse init */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 GEM_mouse_relative = SDL_FALSE; |
3861
c3625a895caf
Use new keyboard mapping routines
Patrice Mandin <patmandin@gmail.com>
parents:
3854
diff
changeset
|
64 |
c3625a895caf
Use new keyboard mapping routines
Patrice Mandin <patmandin@gmail.com>
parents:
3854
diff
changeset
|
65 SDL_Atari_InitInternalKeymap(this); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 void GEM_PumpEvents(_THIS) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 { |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
70 short mousex, mousey, mouseb, dummy; |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
71 short kstate, prevkc, prevks; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 int i; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 SDL_keysym keysym; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
75 SDL_memset(gem_currentkeyboard,0,sizeof(gem_currentkeyboard)); |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
76 prevkc = prevks = 0; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 for (;;) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 { |
1092
1f37386ef508
Forgot variable declaration
Patrice Mandin <patmandin@gmail.com>
parents:
1091
diff
changeset
|
80 int quit, resultat, event_mask, mouse_event; |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
81 short buffer[8], kc; |
1067
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
82 short x2,y2,w2,h2; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 |
1089
b3f7c4af00e0
Don't use both mouse events for the same task
Patrice Mandin <patmandin@gmail.com>
parents:
1088
diff
changeset
|
84 quit = |
b3f7c4af00e0
Don't use both mouse events for the same task
Patrice Mandin <patmandin@gmail.com>
parents:
1088
diff
changeset
|
85 mouse_event = |
b3f7c4af00e0
Don't use both mouse events for the same task
Patrice Mandin <patmandin@gmail.com>
parents:
1088
diff
changeset
|
86 x2=y2=w2=h2 = 0; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 |
1067
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
88 event_mask = MU_MESAG|MU_TIMER|MU_KEYBD; |
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
89 if (!GEM_fullscreen && (GEM_handle>=0)) { |
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
90 wind_get (GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2); |
1089
b3f7c4af00e0
Don't use both mouse events for the same task
Patrice Mandin <patmandin@gmail.com>
parents:
1088
diff
changeset
|
91 event_mask |= MU_M1; |
4060
0b4ebec67cad
Call GEM_CheckMouseMode everytime something may change mouse form, and do it properly
Patrice Mandin <patmandin@gmail.com>
parents:
4059
diff
changeset
|
92 mouse_event = ( (SDL_GetAppState() & SDL_APPMOUSEFOCUS) |
0b4ebec67cad
Call GEM_CheckMouseMode everytime something may change mouse form, and do it properly
Patrice Mandin <patmandin@gmail.com>
parents:
4059
diff
changeset
|
93 == SDL_APPMOUSEFOCUS) ? MO_LEAVE : MO_ENTER; |
1067
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
94 } |
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
95 |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 resultat = evnt_multi( |
1067
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
97 event_mask, |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 0,0,0, |
1089
b3f7c4af00e0
Don't use both mouse events for the same task
Patrice Mandin <patmandin@gmail.com>
parents:
1088
diff
changeset
|
99 mouse_event,x2,y2,w2,h2, |
b3f7c4af00e0
Don't use both mouse events for the same task
Patrice Mandin <patmandin@gmail.com>
parents:
1088
diff
changeset
|
100 0,0,0,0,0, |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 buffer, |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 10, |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
103 &dummy,&dummy,&dummy,&kstate,&kc,&dummy |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 ); |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 /* Message event ? */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 if (resultat & MU_MESAG) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 quit = do_messages(this, buffer); |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 /* Keyboard event ? */ |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
111 if (resultat & MU_KEYBD) { |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
112 if ((prevkc != kc) || (prevks != kstate)) { |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
113 do_keyboard(kc,kstate); |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
114 } else { |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
115 /* Avoid looping, if repeating same key */ |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
116 break; |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
117 } |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
118 } |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 |
1067
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
120 /* Mouse entering/leaving window */ |
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
121 if (resultat & MU_M1) { |
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
122 if (this->input_grab == SDL_GRAB_OFF) { |
4060
0b4ebec67cad
Call GEM_CheckMouseMode everytime something may change mouse form, and do it properly
Patrice Mandin <patmandin@gmail.com>
parents:
4059
diff
changeset
|
123 /* Switch mouse focus state */ |
0b4ebec67cad
Call GEM_CheckMouseMode everytime something may change mouse form, and do it properly
Patrice Mandin <patmandin@gmail.com>
parents:
4059
diff
changeset
|
124 SDL_PrivateAppActive((mouse_event == MO_ENTER), |
0b4ebec67cad
Call GEM_CheckMouseMode everytime something may change mouse form, and do it properly
Patrice Mandin <patmandin@gmail.com>
parents:
4059
diff
changeset
|
125 SDL_APPMOUSEFOCUS); |
1067
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
126 } |
4060
0b4ebec67cad
Call GEM_CheckMouseMode everytime something may change mouse form, and do it properly
Patrice Mandin <patmandin@gmail.com>
parents:
4059
diff
changeset
|
127 GEM_CheckMouseMode(this); |
1067
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
128 } |
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
129 |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 /* Timer event ? */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 if ((resultat & MU_TIMER) || quit) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 break; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 /* Update mouse */ |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
136 graf_mkstate(&mousex, &mousey, &mouseb, &kstate); |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
137 do_mouse(this, mousex, mousey, mouseb, kstate); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
139 /* Now generate keyboard events */ |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 for (i=0; i<ATARIBIOS_MAXKEYS; i++) { |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 /* Key pressed ? */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 if (gem_currentkeyboard[i] && !gem_previouskeyboard[i]) |
1209
a55ac374271c
Added preliminary missingtranslation from Atari to Unicode charset
Patrice Mandin <patmandin@gmail.com>
parents:
1092
diff
changeset
|
143 SDL_PrivateKeyboard(SDL_PRESSED, |
3861
c3625a895caf
Use new keyboard mapping routines
Patrice Mandin <patmandin@gmail.com>
parents:
3854
diff
changeset
|
144 SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE)); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 /* Key unpressed ? */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 if (gem_previouskeyboard[i] && !gem_currentkeyboard[i]) |
1209
a55ac374271c
Added preliminary missingtranslation from Atari to Unicode charset
Patrice Mandin <patmandin@gmail.com>
parents:
1092
diff
changeset
|
148 SDL_PrivateKeyboard(SDL_RELEASED, |
3861
c3625a895caf
Use new keyboard mapping routines
Patrice Mandin <patmandin@gmail.com>
parents:
3854
diff
changeset
|
149 SDL_Atari_TranslateKey(i, &keysym, SDL_FALSE)); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
152 SDL_memcpy(gem_previouskeyboard,gem_currentkeyboard,sizeof(gem_previouskeyboard)); |
996
54bb19455081
Forgot to change window title in the normal case
Patrice Mandin <patmandin@gmail.com>
parents:
964
diff
changeset
|
153 |
54bb19455081
Forgot to change window title in the normal case
Patrice Mandin <patmandin@gmail.com>
parents:
964
diff
changeset
|
154 /* Refresh window name ? */ |
54bb19455081
Forgot to change window title in the normal case
Patrice Mandin <patmandin@gmail.com>
parents:
964
diff
changeset
|
155 if (GEM_refresh_name) { |
4059
57b017e6aebf
Simplify setting window title
Patrice Mandin <patmandin@gmail.com>
parents:
3861
diff
changeset
|
156 const char *window_name = |
57b017e6aebf
Simplify setting window title
Patrice Mandin <patmandin@gmail.com>
parents:
3861
diff
changeset
|
157 (SDL_GetAppState() & SDL_APPACTIVE) |
57b017e6aebf
Simplify setting window title
Patrice Mandin <patmandin@gmail.com>
parents:
3861
diff
changeset
|
158 ? GEM_title_name : GEM_icon_name; |
57b017e6aebf
Simplify setting window title
Patrice Mandin <patmandin@gmail.com>
parents:
3861
diff
changeset
|
159 if (window_name) { |
57b017e6aebf
Simplify setting window title
Patrice Mandin <patmandin@gmail.com>
parents:
3861
diff
changeset
|
160 wind_set(GEM_handle,WF_NAME, |
57b017e6aebf
Simplify setting window title
Patrice Mandin <patmandin@gmail.com>
parents:
3861
diff
changeset
|
161 (short)(((unsigned long)window_name)>>16), |
57b017e6aebf
Simplify setting window title
Patrice Mandin <patmandin@gmail.com>
parents:
3861
diff
changeset
|
162 (short)(((unsigned long)window_name) & 0xffff), |
57b017e6aebf
Simplify setting window title
Patrice Mandin <patmandin@gmail.com>
parents:
3861
diff
changeset
|
163 0,0); |
996
54bb19455081
Forgot to change window title in the normal case
Patrice Mandin <patmandin@gmail.com>
parents:
964
diff
changeset
|
164 } |
54bb19455081
Forgot to change window title in the normal case
Patrice Mandin <patmandin@gmail.com>
parents:
964
diff
changeset
|
165 GEM_refresh_name = SDL_FALSE; |
54bb19455081
Forgot to change window title in the normal case
Patrice Mandin <patmandin@gmail.com>
parents:
964
diff
changeset
|
166 } |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 static int do_messages(_THIS, short *message) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 { |
4060
0b4ebec67cad
Call GEM_CheckMouseMode everytime something may change mouse form, and do it properly
Patrice Mandin <patmandin@gmail.com>
parents:
4059
diff
changeset
|
171 int quit, posted, check_mouse_mode; |
922
7b920743ce57
Correctly set window size if resized or maximized
Patrice Mandin <patmandin@gmail.com>
parents:
919
diff
changeset
|
172 short x2,y2,w2,h2; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 |
4060
0b4ebec67cad
Call GEM_CheckMouseMode everytime something may change mouse form, and do it properly
Patrice Mandin <patmandin@gmail.com>
parents:
4059
diff
changeset
|
174 quit = check_mouse_mode = 0; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 switch (message[0]) { |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 case WM_CLOSED: |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 case AP_TERM: |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 posted = SDL_PrivateQuit(); |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 quit=1; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 break; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 case WM_MOVED: |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 wind_set(message[3],WF_CURRXYWH,message[4],message[5],message[6],message[7]); |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 break; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 case WM_TOPPED: |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 wind_set(message[3],WF_TOP,message[4],0,0,0); |
1091
67b7f0f410a2
Correctly process top/bottom event messages
Patrice Mandin <patmandin@gmail.com>
parents:
1090
diff
changeset
|
186 /* Continue with TOP event processing */ |
67b7f0f410a2
Correctly process top/bottom event messages
Patrice Mandin <patmandin@gmail.com>
parents:
1090
diff
changeset
|
187 case WM_ONTOP: |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); |
1074
936da0056ed3
Save/restore system palette when application topped/untopped
Patrice Mandin <patmandin@gmail.com>
parents:
1073
diff
changeset
|
189 if (VDI_setpalette) { |
936da0056ed3
Save/restore system palette when application topped/untopped
Patrice Mandin <patmandin@gmail.com>
parents:
1073
diff
changeset
|
190 VDI_setpalette(this, VDI_curpalette); |
936da0056ed3
Save/restore system palette when application topped/untopped
Patrice Mandin <patmandin@gmail.com>
parents:
1073
diff
changeset
|
191 } |
4060
0b4ebec67cad
Call GEM_CheckMouseMode everytime something may change mouse form, and do it properly
Patrice Mandin <patmandin@gmail.com>
parents:
4059
diff
changeset
|
192 check_mouse_mode = 1; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 break; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 case WM_REDRAW: |
964
d9209754ebee
Prevent redraws till internal buffers are correctly setup
Patrice Mandin <patmandin@gmail.com>
parents:
928
diff
changeset
|
195 if (!GEM_lock_redraw) { |
d9209754ebee
Prevent redraws till internal buffers are correctly setup
Patrice Mandin <patmandin@gmail.com>
parents:
928
diff
changeset
|
196 GEM_wind_redraw(this, message[3],&message[4]); |
d9209754ebee
Prevent redraws till internal buffers are correctly setup
Patrice Mandin <patmandin@gmail.com>
parents:
928
diff
changeset
|
197 } |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 break; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 case WM_ICONIFY: |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 case WM_ALLICONIFY: |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 wind_set(message[3],WF_ICONIFY,message[4],message[5],message[6],message[7]); |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 /* If we're active, make ourselves inactive */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 if ( SDL_GetAppState() & SDL_APPACTIVE ) { |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 /* Send an internal deactivate event */ |
1088
6091b9ca1a97
Don't generate multiple mouse focus events
Patrice Mandin <patmandin@gmail.com>
parents:
1074
diff
changeset
|
205 SDL_PrivateAppActive(0, SDL_APPACTIVE); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 } |
736
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
319
diff
changeset
|
207 /* Update window title */ |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
319
diff
changeset
|
208 if (GEM_refresh_name && GEM_icon_name) { |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
319
diff
changeset
|
209 wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_icon_name)>>16),(short)(((unsigned long)GEM_icon_name) & 0xffff),0,0); |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
319
diff
changeset
|
210 GEM_refresh_name = SDL_FALSE; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
319
diff
changeset
|
211 } |
4060
0b4ebec67cad
Call GEM_CheckMouseMode everytime something may change mouse form, and do it properly
Patrice Mandin <patmandin@gmail.com>
parents:
4059
diff
changeset
|
212 check_mouse_mode = 1; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 break; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 case WM_UNICONIFY: |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 wind_set(message[3],WF_UNICONIFY,message[4],message[5],message[6],message[7]); |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 /* If we're not active, make ourselves active */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 if ( !(SDL_GetAppState() & SDL_APPACTIVE) ) { |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 /* Send an internal activate event */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 SDL_PrivateAppActive(1, SDL_APPACTIVE); |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 } |
736
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
319
diff
changeset
|
221 if (GEM_refresh_name && GEM_title_name) { |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
319
diff
changeset
|
222 wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_title_name)>>16),(short)(((unsigned long)GEM_title_name) & 0xffff),0,0); |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
319
diff
changeset
|
223 GEM_refresh_name = SDL_FALSE; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
319
diff
changeset
|
224 } |
4060
0b4ebec67cad
Call GEM_CheckMouseMode everytime something may change mouse form, and do it properly
Patrice Mandin <patmandin@gmail.com>
parents:
4059
diff
changeset
|
225 check_mouse_mode = 1; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 break; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 case WM_SIZED: |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 wind_set (message[3], WF_CURRXYWH, message[4], message[5], message[6], message[7]); |
964
d9209754ebee
Prevent redraws till internal buffers are correctly setup
Patrice Mandin <patmandin@gmail.com>
parents:
928
diff
changeset
|
229 wind_get (message[3], WF_WORKXYWH, &x2, &y2, &w2, &h2); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 GEM_win_fulled = SDL_FALSE; /* Cancel maximized flag */ |
964
d9209754ebee
Prevent redraws till internal buffers are correctly setup
Patrice Mandin <patmandin@gmail.com>
parents:
928
diff
changeset
|
231 GEM_lock_redraw = SDL_TRUE; /* Prevent redraw till buffers resized */ |
922
7b920743ce57
Correctly set window size if resized or maximized
Patrice Mandin <patmandin@gmail.com>
parents:
919
diff
changeset
|
232 SDL_PrivateResize(w2, h2); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 break; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 case WM_FULLED: |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 { |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 short x,y,w,h; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 if (GEM_win_fulled) { |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 wind_get (message[3], WF_PREVXYWH, &x, &y, &w, &h); |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 GEM_win_fulled = SDL_FALSE; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 } else { |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 x = GEM_desk_x; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 y = GEM_desk_y; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 w = GEM_desk_w; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 h = GEM_desk_h; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 GEM_win_fulled = SDL_TRUE; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 wind_set (message[3], WF_CURRXYWH, x, y, w, h); |
922
7b920743ce57
Correctly set window size if resized or maximized
Patrice Mandin <patmandin@gmail.com>
parents:
919
diff
changeset
|
249 wind_get (message[3], WF_WORKXYWH, &x2, &y2, &w2, &h2); |
964
d9209754ebee
Prevent redraws till internal buffers are correctly setup
Patrice Mandin <patmandin@gmail.com>
parents:
928
diff
changeset
|
250 GEM_lock_redraw = SDL_TRUE; /* Prevent redraw till buffers resized */ |
922
7b920743ce57
Correctly set window size if resized or maximized
Patrice Mandin <patmandin@gmail.com>
parents:
919
diff
changeset
|
251 SDL_PrivateResize(w2, h2); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 break; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 case WM_BOTTOMED: |
1091
67b7f0f410a2
Correctly process top/bottom event messages
Patrice Mandin <patmandin@gmail.com>
parents:
1090
diff
changeset
|
255 wind_set(message[3],WF_BOTTOM,0,0,0,0); |
67b7f0f410a2
Correctly process top/bottom event messages
Patrice Mandin <patmandin@gmail.com>
parents:
1090
diff
changeset
|
256 /* Continue with BOTTOM event processing */ |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 case WM_UNTOPPED: |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); |
1074
936da0056ed3
Save/restore system palette when application topped/untopped
Patrice Mandin <patmandin@gmail.com>
parents:
1073
diff
changeset
|
259 if (VDI_setpalette) { |
936da0056ed3
Save/restore system palette when application topped/untopped
Patrice Mandin <patmandin@gmail.com>
parents:
1073
diff
changeset
|
260 VDI_setpalette(this, VDI_oldpalette); |
936da0056ed3
Save/restore system palette when application topped/untopped
Patrice Mandin <patmandin@gmail.com>
parents:
1073
diff
changeset
|
261 } |
4060
0b4ebec67cad
Call GEM_CheckMouseMode everytime something may change mouse form, and do it properly
Patrice Mandin <patmandin@gmail.com>
parents:
4059
diff
changeset
|
262 check_mouse_mode = 1; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 break; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 } |
4060
0b4ebec67cad
Call GEM_CheckMouseMode everytime something may change mouse form, and do it properly
Patrice Mandin <patmandin@gmail.com>
parents:
4059
diff
changeset
|
265 |
0b4ebec67cad
Call GEM_CheckMouseMode everytime something may change mouse form, and do it properly
Patrice Mandin <patmandin@gmail.com>
parents:
4059
diff
changeset
|
266 if (check_mouse_mode) { |
0b4ebec67cad
Call GEM_CheckMouseMode everytime something may change mouse form, and do it properly
Patrice Mandin <patmandin@gmail.com>
parents:
4059
diff
changeset
|
267 GEM_CheckMouseMode(this); |
0b4ebec67cad
Call GEM_CheckMouseMode everytime something may change mouse form, and do it properly
Patrice Mandin <patmandin@gmail.com>
parents:
4059
diff
changeset
|
268 } |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 return quit; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 static void do_keyboard(short kc, short ks) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 { |
3861
c3625a895caf
Use new keyboard mapping routines
Patrice Mandin <patmandin@gmail.com>
parents:
3854
diff
changeset
|
275 int scancode; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 if (kc) { |
3861
c3625a895caf
Use new keyboard mapping routines
Patrice Mandin <patmandin@gmail.com>
parents:
3854
diff
changeset
|
278 scancode=(kc>>8) & (ATARIBIOS_MAXKEYS-1); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 gem_currentkeyboard[scancode]=0xFF; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 /* Read special keys */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 if (ks & K_RSHIFT) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 gem_currentkeyboard[SCANCODE_RIGHTSHIFT]=0xFF; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 if (ks & K_LSHIFT) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 gem_currentkeyboard[SCANCODE_LEFTSHIFT]=0xFF; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 if (ks & K_CTRL) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 gem_currentkeyboard[SCANCODE_LEFTCONTROL]=0xFF; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 if (ks & K_ALT) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
290 gem_currentkeyboard[SCANCODE_LEFTALT]=0xFF; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
293 static void do_mouse(_THIS, short mx, short my, short mb, short ks) |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 { |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
295 static short prevmousex=0, prevmousey=0, prevmouseb=0; |
926
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
296 short x2, y2, w2, h2; |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
297 |
1067
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
298 /* Don't return mouse events if out of window */ |
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
299 if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS)==0) { |
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
300 return; |
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
301 } |
f73b199bcd75
Better mouse lose/gain focus
Patrice Mandin <patmandin@gmail.com>
parents:
1065
diff
changeset
|
302 |
926
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
303 /* Retrieve window coords, and generate mouse events accordingly */ |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
304 x2 = y2 = 0; |
928
6c87754f324c
Forgot to initialize maximum position for mouse
Patrice Mandin <patmandin@gmail.com>
parents:
927
diff
changeset
|
305 w2 = VDI_w; |
6c87754f324c
Forgot to initialize maximum position for mouse
Patrice Mandin <patmandin@gmail.com>
parents:
927
diff
changeset
|
306 h2 = VDI_h; |
926
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
307 if ((!GEM_fullscreen) && (GEM_handle>=0)) { |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
308 wind_get (GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2); |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
309 |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
310 /* Do not generate mouse button event if out of window working area */ |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
311 if ((mx<x2) || (mx>=x2+w2) || (my<y2) || (my>=y2+h2)) { |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
312 mb=prevmouseb; |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
313 } |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
314 } |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
315 |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
316 /* Mouse motion ? */ |
1267
fdc7ef6ecab4
Correctly manage mouse relative motion
Patrice Mandin <patmandin@gmail.com>
parents:
1237
diff
changeset
|
317 if (GEM_mouse_relative) { |
1420
2405517b5eab
Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
1412
diff
changeset
|
318 if (GEM_usedevmouse) { |
2405517b5eab
Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
1412
diff
changeset
|
319 SDL_AtariDevMouse_PostMouseEvents(this, SDL_FALSE); |
2405517b5eab
Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
1412
diff
changeset
|
320 } else { |
2405517b5eab
Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
1412
diff
changeset
|
321 SDL_AtariXbios_PostMouseEvents(this, SDL_FALSE); |
2405517b5eab
Added preliminary support for MiNT /dev/mouse driver (disabled atm)
Patrice Mandin <patmandin@gmail.com>
parents:
1412
diff
changeset
|
322 } |
1267
fdc7ef6ecab4
Correctly manage mouse relative motion
Patrice Mandin <patmandin@gmail.com>
parents:
1237
diff
changeset
|
323 } else { |
fdc7ef6ecab4
Correctly manage mouse relative motion
Patrice Mandin <patmandin@gmail.com>
parents:
1237
diff
changeset
|
324 if ((prevmousex!=mx) || (prevmousey!=my)) { |
926
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
325 int posx, posy; |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
326 |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
327 /* Give mouse position relative to window position */ |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
328 posx = mx - x2; |
927
c5689bd09eaa
Wrong check for minimum mouse position
Patrice Mandin <patmandin@gmail.com>
parents:
926
diff
changeset
|
329 if (posx<0) posx = 0; |
926
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
330 if (posx>w2) posx = w2-1; |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
331 posy = my - y2; |
927
c5689bd09eaa
Wrong check for minimum mouse position
Patrice Mandin <patmandin@gmail.com>
parents:
926
diff
changeset
|
332 if (posy<0) posy = 0; |
926
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
333 if (posy>h2) posy = h2-1; |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
334 |
83db694556eb
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
Patrice Mandin <patmandin@gmail.com>
parents:
922
diff
changeset
|
335 SDL_PrivateMouseMotion(0, 0, posx, posy); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 prevmousex = mx; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
338 prevmousey = my; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 /* Mouse button ? */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 if (prevmouseb!=mb) { |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 int i; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
345 for (i=0;i<2;i++) { |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
346 int curbutton, prevbutton; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 curbutton = mb & (1<<i); |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 prevbutton = prevmouseb & (1<<i); |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
350 |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
351 if (curbutton && !prevbutton) { |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
352 SDL_PrivateMouseButton(SDL_PRESSED, i+1, 0, 0); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 } |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
354 if (!curbutton && prevbutton) { |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
355 SDL_PrivateMouseButton(SDL_RELEASED, i+1, 0, 0); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
356 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
357 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
358 prevmouseb = mb; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
359 } |
319
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
360 |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
361 /* Read special keys */ |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
362 if (ks & K_RSHIFT) |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
363 gem_currentkeyboard[SCANCODE_RIGHTSHIFT]=0xFF; |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
364 if (ks & K_LSHIFT) |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
365 gem_currentkeyboard[SCANCODE_LEFTSHIFT]=0xFF; |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
366 if (ks & K_CTRL) |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
367 gem_currentkeyboard[SCANCODE_LEFTCONTROL]=0xFF; |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
368 if (ks & K_ALT) |
189a6a3416c7
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
369 gem_currentkeyboard[SCANCODE_LEFTALT]=0xFF; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
370 } |