Mercurial > sdl-ios-xcode
annotate src/video/wincommon/SDL_sysevents.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 | 82dab719502e |
children | a1b03ba2fcd0 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1295
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1295
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1295
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1295
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1295
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:
1295
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:
1295
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
179
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1379
diff
changeset
|
22 #include "SDL_config.h" |
0 | 23 |
1433
bb6839704ed6
SDL_windows.h is no longer necessary
Sam Lantinga <slouken@libsdl.org>
parents:
1428
diff
changeset
|
24 #define WIN32_LEAN_AND_MEAN |
bb6839704ed6
SDL_windows.h is no longer necessary
Sam Lantinga <slouken@libsdl.org>
parents:
1428
diff
changeset
|
25 #include <windows.h> |
0 | 26 |
3970
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
27 /* Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... */ |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
28 #ifndef WM_XBUTTONDOWN |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
29 #define WM_XBUTTONDOWN 0x020B |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
30 #endif |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
31 #ifndef WM_XBUTTONUP |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
32 #define WM_XBUTTONUP 0x020C |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
33 #endif |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
34 #ifndef GET_XBUTTON_WPARAM |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
35 #define GET_XBUTTON_WPARAM(w) (HIWORD(w)) |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
36 #endif |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
37 |
0 | 38 #include "SDL_events.h" |
39 #include "SDL_video.h" | |
40 #include "SDL_syswm.h" | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
41 #include "../SDL_sysvideo.h" |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
42 #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
|
43 #include "../../events/SDL_events_c.h" |
0 | 44 #include "SDL_lowvideo.h" |
45 #include "SDL_syswm_c.h" | |
46 #include "SDL_main.h" | |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
47 #include "SDL_loadso.h" |
0 | 48 |
49 #ifdef WMMSG_DEBUG | |
50 #include "wmmsg.h" | |
51 #endif | |
52 | |
53 #ifdef _WIN32_WCE | |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
54 #include "../gapi/SDL_gapivideo.h" |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
55 |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
56 #define IsZoomed(HWND) 1 |
0 | 57 #define NO_GETKEYBOARDSTATE |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
58 #if _WIN32_WCE < 420 |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
59 #define NO_CHANGEDISPLAYSETTINGS |
0 | 60 #endif |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
61 #endif |
0 | 62 |
63 /* The window we use for everything... */ | |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
64 #ifdef _WIN32_WCE |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
65 LPWSTR SDL_Appname = NULL; |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
66 #else |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
67 LPSTR SDL_Appname = NULL; |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
68 #endif |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
69 Uint32 SDL_Appstyle = 0; |
0 | 70 HINSTANCE SDL_Instance = NULL; |
71 HWND SDL_Window = NULL; | |
72 RECT SDL_bounds = {0, 0, 0, 0}; | |
833
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
829
diff
changeset
|
73 int SDL_windowX = 0; |
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
829
diff
changeset
|
74 int SDL_windowY = 0; |
0 | 75 int SDL_resizing = 0; |
76 int mouse_relative = 0; | |
77 int posted = 0; | |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
78 #ifndef NO_CHANGEDISPLAYSETTINGS |
1295
c3e36ac8a94c
Date: Sun, 6 Mar 2005 17:06:20 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1291
diff
changeset
|
79 DEVMODE SDL_desktop_mode; |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
80 DEVMODE SDL_fullscreen_mode; |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
81 #endif |
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
82 WORD *gamma_saved = NULL; |
0 | 83 |
84 | |
85 /* Functions called by the message processing function */ | |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
86 LONG (*HandleMessage)(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)=NULL; |
3992 | 87 void (*WIN_Activate)(_THIS, BOOL active, BOOL iconic); |
0 | 88 void (*WIN_RealizePalette)(_THIS); |
89 void (*WIN_PaletteChanged)(_THIS, HWND window); | |
90 void (*WIN_WinPAINT)(_THIS, HDC hdc); | |
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
91 extern void DIB_SwapGamma(_THIS); |
0 | 92 |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
93 #ifndef NO_GETKEYBOARDSTATE |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
94 /* Variables and support functions for SDL_ToUnicode() */ |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
95 static int codepage; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
96 static int Is9xME(); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
97 static int GetCodePage(); |
1428
5f52867ba65c
Update for Visual C++ 6.0
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
98 static int WINAPI ToUnicode9xME(UINT vkey, UINT scancode, BYTE *keystate, LPWSTR wchars, int wsize, UINT flags); |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
99 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
100 ToUnicodeFN SDL_ToUnicode = ToUnicode9xME; |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
101 #endif /* !NO_GETKEYBOARDSTATE */ |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
102 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
103 |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
104 #if defined(_WIN32_WCE) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
105 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
106 // dynamically load aygshell dll because we want SDL to work on HPC and be300 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
107 HINSTANCE aygshell = NULL; |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
108 BOOL (WINAPI *SHFullScreen)(HWND hwndRequester, DWORD dwState) = 0; |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
109 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
110 #define SHFS_SHOWTASKBAR 0x0001 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
111 #define SHFS_HIDETASKBAR 0x0002 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
112 #define SHFS_SHOWSIPBUTTON 0x0004 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
113 #define SHFS_HIDESIPBUTTON 0x0008 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
114 #define SHFS_SHOWSTARTICON 0x0010 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
115 #define SHFS_HIDESTARTICON 0x0020 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
116 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
117 static void LoadAygshell(void) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
118 { |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
119 if( !aygshell ) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
120 aygshell = SDL_LoadObject("aygshell.dll"); |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
121 if( (aygshell != 0) && (SHFullScreen == 0) ) |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
122 { |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
123 SHFullScreen = (int (WINAPI *)(struct HWND__ *,unsigned long)) SDL_LoadFunction(aygshell, "SHFullScreen"); |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
124 } |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
125 } |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
126 |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
127 /* for gapi landscape mode */ |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
128 static void GapiTransform(SDL_ScreenOrientation rotate, char hires, Sint16 *x, Sint16 *y) { |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
129 Sint16 rotatedX; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
130 Sint16 rotatedY; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
131 |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
132 if (hires) { |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
133 *x = *x * 2; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
134 *y = *y * 2; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
135 } |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
136 |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
137 switch(rotate) { |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
138 case SDL_ORIENTATION_UP: |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
139 { |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
140 /* this code needs testing on a real device! |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
141 So it will be enabled later */ |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
142 /* |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
143 #ifdef _WIN32_WCE |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
144 #if _WIN32_WCE >= 420 |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
145 // test device orientation |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
146 // FIXME: do not check every mouse message |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
147 DEVMODE settings; |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
148 SDL_memset(&settings, 0, sizeof(DEVMODE)); |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
149 settings.dmSize = sizeof(DEVMODE); |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
150 settings.dmFields = DM_DISPLAYORIENTATION; |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
151 ChangeDisplaySettingsEx(NULL, &settings, NULL, CDS_TEST, NULL); |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
152 if( settings.dmOrientation == DMDO_90 ) |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
153 { |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
154 rotatedX = SDL_VideoSurface->h - *x; |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
155 rotatedY = *y; |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
156 *x = rotatedX; |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
157 *y = rotatedY; |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
158 } |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
159 #endif |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
160 #endif */ |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
161 } |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
162 break; |
4157
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
163 // FIXME: Older version used just SDL_VideoSurface->(w, h) |
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
164 // w and h are "clipped" while x and y are "raw", which caused |
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
165 // x in former and y in latter case to be clipped in a wrong direction, |
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
166 // thus offsetting the coordinate on 2 x clip pixels |
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
167 // (like, 128 for 640 -> 512 clipping). |
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
168 // We will now try to extract and use raw values. |
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
169 // The way to do that RIGHT is do (orientation-dependent) clipping before |
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
170 // doing this transform, but it's hardly possible. |
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
171 |
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
172 // SEE SDL_mouse.c /ClipOffset to understand these calculations. |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
173 case SDL_ORIENTATION_RIGHT: |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
174 if (!SDL_VideoSurface) |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
175 break; |
4157
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
176 rotatedX = (2 * ((SDL_VideoSurface->offset%SDL_VideoSurface->pitch)/ |
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
177 SDL_VideoSurface->format->BytesPerPixel)) |
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
178 + SDL_VideoSurface->w - *y; |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
179 rotatedY = *x; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
180 *x = rotatedX; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
181 *y = rotatedY; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
182 break; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
183 case SDL_ORIENTATION_LEFT: |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
184 if (!SDL_VideoSurface) |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
185 break; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
186 rotatedX = *y; |
4157
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
187 rotatedY = (2 * (SDL_VideoSurface->offset/SDL_VideoSurface->pitch)) |
baf615f9f2a0
Date: Thu, 16 Oct 2008 20:27:34 +0400
Sam Lantinga <slouken@libsdl.org>
parents:
4113
diff
changeset
|
188 + SDL_VideoSurface->h - *x; |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
189 *x = rotatedX; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
190 *y = rotatedY; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
191 break; |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
192 } |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
193 } |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
194 |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
195 #endif |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
196 |
1523 | 197 /* JC 14 Mar 2006 |
198 This is used all over the place, in the windib driver and in the dx5 driver | |
199 So we may as well stick it here instead of having multiple copies scattered | |
200 about | |
201 */ | |
202 void WIN_FlushMessageQueue() | |
203 { | |
204 MSG msg; | |
205 while ( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) ) { | |
206 if ( msg.message == WM_QUIT ) break; | |
207 TranslateMessage( &msg ); | |
208 DispatchMessage( &msg ); | |
209 } | |
210 } | |
211 | |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
212 static void SDL_RestoreGameMode(void) |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
213 { |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
214 #ifdef _WIN32_WCE |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
215 SDL_VideoDevice *this = current_video; |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
216 if(SDL_strcmp(this->name, "gapi") == 0) |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
217 { |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
218 if( this->hidden->suspended ) |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
219 { |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
220 this->hidden->suspended = 0; |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
221 } |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
222 } |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
223 #else |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
224 ShowWindow(SDL_Window, SW_RESTORE); |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
225 #endif |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
226 |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
227 #ifndef NO_CHANGEDISPLAYSETTINGS |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
228 #ifndef _WIN32_WCE |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
229 ChangeDisplaySettings(&SDL_fullscreen_mode, CDS_FULLSCREEN); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
230 #endif |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
231 #endif /* NO_CHANGEDISPLAYSETTINGS */ |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
232 } |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
233 static void SDL_RestoreDesktopMode(void) |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
234 { |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
235 |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
236 #ifdef _WIN32_WCE |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
237 SDL_VideoDevice *this = current_video; |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
238 if(SDL_strcmp(this->name, "gapi") == 0) |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
239 { |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
240 if( !this->hidden->suspended ) |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
241 { |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
242 this->hidden->suspended = 1; |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
243 } |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
244 } |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
245 #else |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
246 /* WinCE does not have a taskbar, so minimizing is not convenient */ |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
247 ShowWindow(SDL_Window, SW_MINIMIZE); |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
248 #endif |
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
249 |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
250 #ifndef NO_CHANGEDISPLAYSETTINGS |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
251 #ifndef _WIN32_WCE |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
252 ChangeDisplaySettings(NULL, 0); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
253 #endif |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
254 #endif /* NO_CHANGEDISPLAYSETTINGS */ |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
255 } |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
256 |
0 | 257 #ifdef WM_MOUSELEAVE |
258 /* | |
259 Special code to handle mouse leave events - this sucks... | |
260 http://support.microsoft.com/support/kb/articles/q183/1/07.asp | |
261 | |
262 TrackMouseEvent() is only available on Win98 and WinNT. | |
263 _TrackMouseEvent() is available on Win95, but isn't yet in the mingw32 | |
264 development environment, and only works on systems that have had IE 3.0 | |
265 or newer installed on them (which is not the case with the base Win95). | |
266 Therefore, we implement our own version of _TrackMouseEvent() which | |
267 uses our own implementation if TrackMouseEvent() is not available. | |
268 */ | |
269 static BOOL (WINAPI *_TrackMouseEvent)(TRACKMOUSEEVENT *ptme) = NULL; | |
270 | |
271 static VOID CALLBACK | |
272 TrackMouseTimerProc(HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime) | |
273 { | |
274 RECT rect; | |
275 POINT pt; | |
276 | |
277 GetClientRect(hWnd, &rect); | |
278 MapWindowPoints(hWnd, NULL, (LPPOINT)&rect, 2); | |
279 GetCursorPos(&pt); | |
280 if ( !PtInRect(&rect, pt) || (WindowFromPoint(pt) != hWnd) ) { | |
281 if ( !KillTimer(hWnd, idEvent) ) { | |
282 /* Error killing the timer! */ | |
283 } | |
284 PostMessage(hWnd, WM_MOUSELEAVE, 0, 0); | |
285 } | |
286 } | |
287 static BOOL WINAPI WIN_TrackMouseEvent(TRACKMOUSEEVENT *ptme) | |
288 { | |
289 if ( ptme->dwFlags == TME_LEAVE ) { | |
290 return SetTimer(ptme->hwndTrack, ptme->dwFlags, 100, | |
1456
84de7511f79f
Fixed a bunch of 64-bit compatibility problems
Sam Lantinga <slouken@libsdl.org>
parents:
1433
diff
changeset
|
291 (TIMERPROC)TrackMouseTimerProc) != 0; |
0 | 292 } |
293 return FALSE; | |
294 } | |
295 #endif /* WM_MOUSELEAVE */ | |
296 | |
297 /* Function to retrieve the current keyboard modifiers */ | |
298 static void WIN_GetKeyboardState(void) | |
299 { | |
300 #ifndef NO_GETKEYBOARDSTATE | |
301 SDLMod state; | |
302 BYTE keyboard[256]; | |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
303 Uint8 *kstate = SDL_GetKeyState(NULL); |
0 | 304 |
305 state = KMOD_NONE; | |
306 if ( GetKeyboardState(keyboard) ) { | |
307 if ( keyboard[VK_LSHIFT] & 0x80) { | |
308 state |= KMOD_LSHIFT; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
309 kstate[SDLK_LSHIFT] = SDL_PRESSED; |
0 | 310 } |
311 if ( keyboard[VK_RSHIFT] & 0x80) { | |
312 state |= KMOD_RSHIFT; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
313 kstate[SDLK_RSHIFT] = SDL_PRESSED; |
0 | 314 } |
315 if ( keyboard[VK_LCONTROL] & 0x80) { | |
316 state |= KMOD_LCTRL; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
317 kstate[SDLK_LCTRL] = SDL_PRESSED; |
0 | 318 } |
319 if ( keyboard[VK_RCONTROL] & 0x80) { | |
320 state |= KMOD_RCTRL; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
321 kstate[SDLK_RCTRL] = SDL_PRESSED; |
0 | 322 } |
323 if ( keyboard[VK_LMENU] & 0x80) { | |
324 state |= KMOD_LALT; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
325 kstate[SDLK_LALT] = SDL_PRESSED; |
0 | 326 } |
327 if ( keyboard[VK_RMENU] & 0x80) { | |
328 state |= KMOD_RALT; | |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1280
diff
changeset
|
329 kstate[SDLK_RALT] = SDL_PRESSED; |
0 | 330 } |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
331 if ( keyboard[VK_NUMLOCK] & 0x01) { |
0 | 332 state |= KMOD_NUM; |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
333 kstate[SDLK_NUMLOCK] = SDL_PRESSED; |
0 | 334 } |
1
cf2af46e9e2a
Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
335 if ( keyboard[VK_CAPITAL] & 0x01) { |
0 | 336 state |= KMOD_CAPS; |
327
13fc64213765
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
337 kstate[SDLK_CAPSLOCK] = SDL_PRESSED; |
0 | 338 } |
339 } | |
340 SDL_SetModState(state); | |
341 #endif /* !NO_GETKEYBOARDSTATE */ | |
342 } | |
343 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
344 /* The main Win32 event handler |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
345 DJM: This is no longer static as (DX5/DIB)_CreateWindow needs it |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
346 */ |
1456
84de7511f79f
Fixed a bunch of 64-bit compatibility problems
Sam Lantinga <slouken@libsdl.org>
parents:
1433
diff
changeset
|
347 LRESULT CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) |
0 | 348 { |
349 SDL_VideoDevice *this = current_video; | |
350 static int mouse_pressed = 0; | |
351 static int in_window = 0; | |
352 #ifdef WMMSG_DEBUG | |
353 fprintf(stderr, "Received windows message: "); | |
354 if ( msg > MAX_WMMSG ) { | |
355 fprintf(stderr, "%d", msg); | |
356 } else { | |
357 fprintf(stderr, "%s", wmtab[msg]); | |
358 } | |
359 fprintf(stderr, " -- 0x%X, 0x%X\n", wParam, lParam); | |
360 #endif | |
361 switch (msg) { | |
362 | |
363 case WM_ACTIVATE: { | |
364 SDL_VideoDevice *this = current_video; | |
3992 | 365 BOOL active, minimized; |
0 | 366 Uint8 appstate; |
367 | |
368 minimized = HIWORD(wParam); | |
3992 | 369 active = (LOWORD(wParam) != WA_INACTIVE) && !minimized; |
370 if ( active ) { | |
0 | 371 /* Gain the following states */ |
372 appstate = SDL_APPACTIVE|SDL_APPINPUTFOCUS; | |
373 if ( this->input_grab != SDL_GRAB_OFF ) { | |
374 WIN_GrabInput(this, SDL_GRAB_ON); | |
375 } | |
376 if ( !(SDL_GetAppState()&SDL_APPINPUTFOCUS) ) { | |
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
377 if ( ! DDRAW_FULLSCREEN() ) { |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
378 DIB_SwapGamma(this); |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
379 } |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
380 if ( WINDIB_FULLSCREEN() ) { |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
381 SDL_RestoreGameMode(); |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
382 } |
0 | 383 } |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
384 #if defined(_WIN32_WCE) |
3992 | 385 if ( WINDIB_FULLSCREEN() ) { |
386 LoadAygshell(); | |
387 if( SHFullScreen ) | |
388 SHFullScreen(SDL_Window, SHFS_HIDESTARTICON|SHFS_HIDETASKBAR|SHFS_HIDESIPBUTTON); | |
389 else | |
390 ShowWindow(FindWindow(TEXT("HHTaskBar"),NULL),SW_HIDE); | |
391 } | |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
392 #endif |
0 | 393 posted = SDL_PrivateAppActive(1, appstate); |
394 WIN_GetKeyboardState(); | |
395 } else { | |
396 /* Lose the following states */ | |
397 appstate = SDL_APPINPUTFOCUS; | |
398 if ( minimized ) { | |
399 appstate |= SDL_APPACTIVE; | |
400 } | |
401 if ( this->input_grab != SDL_GRAB_OFF ) { | |
402 WIN_GrabInput(this, SDL_GRAB_OFF); | |
403 } | |
404 if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) { | |
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
405 if ( ! DDRAW_FULLSCREEN() ) { |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
406 DIB_SwapGamma(this); |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
335
diff
changeset
|
407 } |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
408 if ( WINDIB_FULLSCREEN() ) { |
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
409 SDL_RestoreDesktopMode(); |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
410 #if defined(_WIN32_WCE) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
411 LoadAygshell(); |
1497
420b3f47806d
Fixes from Dmitry Yakimov:
Sam Lantinga <slouken@libsdl.org>
parents:
1480
diff
changeset
|
412 if( SHFullScreen ) |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
413 SHFullScreen(SDL_Window, SHFS_SHOWSTARTICON|SHFS_SHOWTASKBAR|SHFS_SHOWSIPBUTTON); |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
414 else |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
415 ShowWindow(FindWindow(TEXT("HHTaskBar"),NULL),SW_SHOW); |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1150
diff
changeset
|
416 #endif |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
417 } |
0 | 418 } |
419 posted = SDL_PrivateAppActive(0, appstate); | |
420 } | |
3992 | 421 WIN_Activate(this, active, minimized); |
0 | 422 return(0); |
423 } | |
424 break; | |
425 | |
426 case WM_MOUSEMOVE: { | |
427 | |
428 /* Mouse is handled by DirectInput when fullscreen */ | |
13
e30a8ce27c22
Fixed double-mouse event bug on Windows using OpenGL
Sam Lantinga <slouken@lokigames.com>
parents:
1
diff
changeset
|
429 if ( SDL_VideoSurface && ! DINPUT_FULLSCREEN() ) { |
0 | 430 Sint16 x, y; |
431 | |
432 /* mouse has entered the window */ | |
433 if ( ! in_window ) { | |
434 #ifdef WM_MOUSELEAVE | |
435 TRACKMOUSEEVENT tme; | |
436 | |
437 tme.cbSize = sizeof(tme); | |
438 tme.dwFlags = TME_LEAVE; | |
439 tme.hwndTrack = SDL_Window; | |
440 _TrackMouseEvent(&tme); | |
441 #endif /* WM_MOUSELEAVE */ | |
442 in_window = TRUE; | |
443 | |
444 posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); | |
445 } | |
446 | |
447 /* mouse has moved within the window */ | |
448 x = LOWORD(lParam); | |
449 y = HIWORD(lParam); | |
450 if ( mouse_relative ) { | |
451 POINT center; | |
452 center.x = (SDL_VideoSurface->w/2); | |
453 center.y = (SDL_VideoSurface->h/2); | |
454 x -= (Sint16)center.x; | |
455 y -= (Sint16)center.y; | |
456 if ( x || y ) { | |
457 ClientToScreen(SDL_Window, ¢er); | |
458 SetCursorPos(center.x, center.y); | |
459 posted = SDL_PrivateMouseMotion(0, 1, x, y); | |
460 } | |
461 } else { | |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
462 #ifdef _WIN32_WCE |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
463 if (SDL_VideoSurface) |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
464 GapiTransform(this->hidden->userOrientation, this->hidden->hiresFix, &x, &y); |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
465 #endif |
0 | 466 posted = SDL_PrivateMouseMotion(0, 0, x, y); |
467 } | |
468 } | |
469 } | |
470 return(0); | |
471 | |
472 #ifdef WM_MOUSELEAVE | |
473 case WM_MOUSELEAVE: { | |
474 | |
475 /* Mouse is handled by DirectInput when fullscreen */ | |
13
e30a8ce27c22
Fixed double-mouse event bug on Windows using OpenGL
Sam Lantinga <slouken@lokigames.com>
parents:
1
diff
changeset
|
476 if ( SDL_VideoSurface && ! DINPUT_FULLSCREEN() ) { |
0 | 477 /* mouse has left the window */ |
478 /* or */ | |
479 /* Elvis has left the building! */ | |
480 posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); | |
481 } | |
829
77bca0665b69
Fixed mouse focus events after resetting video mode on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
565
diff
changeset
|
482 in_window = FALSE; |
0 | 483 } |
484 return(0); | |
485 #endif /* WM_MOUSELEAVE */ | |
486 | |
487 case WM_LBUTTONDOWN: | |
488 case WM_LBUTTONUP: | |
489 case WM_MBUTTONDOWN: | |
490 case WM_MBUTTONUP: | |
491 case WM_RBUTTONDOWN: | |
3970
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
492 case WM_RBUTTONUP: |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
493 case WM_XBUTTONDOWN: |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
494 case WM_XBUTTONUP: { |
0 | 495 /* Mouse is handled by DirectInput when fullscreen */ |
13
e30a8ce27c22
Fixed double-mouse event bug on Windows using OpenGL
Sam Lantinga <slouken@lokigames.com>
parents:
1
diff
changeset
|
496 if ( SDL_VideoSurface && ! DINPUT_FULLSCREEN() ) { |
3970
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
497 WORD xbuttonval = 0; |
0 | 498 Sint16 x, y; |
499 Uint8 button, state; | |
500 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
501 /* DJM: |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
502 We want the SDL window to take focus so that |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
503 it acts like a normal windows "component" |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
504 (e.g. gains keyboard focus on a mouse click). |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
505 */ |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
506 SetFocus(SDL_Window); |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
507 |
0 | 508 /* Figure out which button to use */ |
509 switch (msg) { | |
510 case WM_LBUTTONDOWN: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
511 button = SDL_BUTTON_LEFT; |
0 | 512 state = SDL_PRESSED; |
513 break; | |
514 case WM_LBUTTONUP: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
515 button = SDL_BUTTON_LEFT; |
0 | 516 state = SDL_RELEASED; |
517 break; | |
518 case WM_MBUTTONDOWN: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
519 button = SDL_BUTTON_MIDDLE; |
0 | 520 state = SDL_PRESSED; |
521 break; | |
522 case WM_MBUTTONUP: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
523 button = SDL_BUTTON_MIDDLE; |
0 | 524 state = SDL_RELEASED; |
525 break; | |
526 case WM_RBUTTONDOWN: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
527 button = SDL_BUTTON_RIGHT; |
0 | 528 state = SDL_PRESSED; |
529 break; | |
530 case WM_RBUTTONUP: | |
457
d0ab9718bf91
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
531 button = SDL_BUTTON_RIGHT; |
0 | 532 state = SDL_RELEASED; |
533 break; | |
3970
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
534 case WM_XBUTTONDOWN: |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
535 xbuttonval = GET_XBUTTON_WPARAM(wParam); |
4113 | 536 button = SDL_BUTTON_X1 + xbuttonval - 1; |
3970
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
537 state = SDL_PRESSED; |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
538 break; |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
539 case WM_XBUTTONUP: |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
540 xbuttonval = GET_XBUTTON_WPARAM(wParam); |
4113 | 541 button = SDL_BUTTON_X1 + xbuttonval - 1; |
3970
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
542 state = SDL_RELEASED; |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
543 break; |
0 | 544 default: |
545 /* Eh? Unknown button? */ | |
546 return(0); | |
547 } | |
548 if ( state == SDL_PRESSED ) { | |
549 /* Grab mouse so we get up events */ | |
550 if ( ++mouse_pressed > 0 ) { | |
551 SetCapture(hwnd); | |
552 } | |
553 } else { | |
554 /* Release mouse after all up events */ | |
555 if ( --mouse_pressed <= 0 ) { | |
556 ReleaseCapture(); | |
557 mouse_pressed = 0; | |
558 } | |
559 } | |
560 if ( mouse_relative ) { | |
561 /* RJR: March 28, 2000 | |
562 report internal mouse position if in relative mode */ | |
563 x = 0; y = 0; | |
564 } else { | |
565 x = (Sint16)LOWORD(lParam); | |
566 y = (Sint16)HIWORD(lParam); | |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
567 #ifdef _WIN32_WCE |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
568 if (SDL_VideoSurface) |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
569 GapiTransform(this->hidden->userOrientation, this->hidden->hiresFix, &x, &y); |
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
570 #endif |
0 | 571 } |
572 posted = SDL_PrivateMouseButton( | |
573 state, button, x, y); | |
3970
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
574 |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
575 /* |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
576 * MSDN says: |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
577 * "Unlike the WM_LBUTTONUP, WM_MBUTTONUP, and WM_RBUTTONUP |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
578 * messages, an application should return TRUE from [an |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
579 * XBUTTON message] if it processes it. Doing so will allow |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
580 * software that simulates this message on Microsoft Windows |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
581 * systems earlier than Windows 2000 to determine whether |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
582 * the window procedure processed the message or called |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
583 * DefWindowProc to process it. |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
584 */ |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
585 if (xbuttonval > 0) |
203695f768e0
Added support for WM_XBUTTON to the windib driver, to support more mouse
Ryan C. Gordon <icculus@icculus.org>
parents:
1523
diff
changeset
|
586 return(TRUE); |
0 | 587 } |
588 } | |
589 return(0); | |
590 | |
61
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
591 |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
592 #if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400) |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
593 case WM_MOUSEWHEEL: |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
594 if ( SDL_VideoSurface && ! DINPUT_FULLSCREEN() ) { |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
595 int move = (short)HIWORD(wParam); |
162
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
596 if ( move ) { |
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
597 Uint8 button; |
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
598 if ( move > 0 ) |
451
24edec3cafe4
Added SDL_BUTTON_WHEELUP (4) and SDL_BUTTON_WHEELDOWN (5)
Sam Lantinga <slouken@libsdl.org>
parents:
447
diff
changeset
|
599 button = SDL_BUTTON_WHEELUP; |
162
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
600 else |
451
24edec3cafe4
Added SDL_BUTTON_WHEELUP (4) and SDL_BUTTON_WHEELDOWN (5)
Sam Lantinga <slouken@libsdl.org>
parents:
447
diff
changeset
|
601 button = SDL_BUTTON_WHEELDOWN; |
61
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
602 posted = SDL_PrivateMouseButton( |
162
0a26c92c2385
Fixed mouse wheel motion position on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
603 SDL_PRESSED, button, 0, 0); |
332 | 604 posted |= SDL_PrivateMouseButton( |
605 SDL_RELEASED, button, 0, 0); | |
61
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
606 } |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
607 } |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
608 return(0); |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
609 #endif |
994ed1d668e7
Mouse wheel sends mouse button (4/5) events on Windows
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
610 |
0 | 611 #ifdef WM_GETMINMAXINFO |
612 /* This message is sent as a way for us to "check" the values | |
613 * of a position change. If we don't like it, we can adjust | |
614 * the values before they are changed. | |
615 */ | |
616 case WM_GETMINMAXINFO: { | |
617 MINMAXINFO *info; | |
618 RECT size; | |
619 int x, y; | |
565
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
620 int style; |
0 | 621 int width; |
622 int height; | |
623 | |
624 /* We don't want to clobber an internal resize */ | |
625 if ( SDL_resizing ) | |
626 return(0); | |
627 | |
628 /* We allow resizing with the SDL_RESIZABLE flag */ | |
629 if ( SDL_PublicSurface && | |
630 (SDL_PublicSurface->flags & SDL_RESIZABLE) ) { | |
631 return(0); | |
632 } | |
633 | |
634 /* Get the current position of our window */ | |
635 GetWindowRect(SDL_Window, &size); | |
636 x = size.left; | |
637 y = size.top; | |
638 | |
639 /* Calculate current width and height of our window */ | |
640 size.top = 0; | |
641 size.left = 0; | |
642 if ( SDL_PublicSurface != NULL ) { | |
643 size.bottom = SDL_PublicSurface->h; | |
644 size.right = SDL_PublicSurface->w; | |
645 } else { | |
646 size.bottom = 0; | |
647 size.right = 0; | |
648 } | |
565
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
649 |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
650 /* DJM - according to the docs for GetMenu(), the |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
651 return value is undefined if hwnd is a child window. |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
652 Aparently it's too difficult for MS to check |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
653 inside their function, so I have to do it here. |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
654 */ |
1480 | 655 style = GetWindowLong(hwnd, GWL_STYLE); |
565
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
656 AdjustWindowRect( |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
657 &size, |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
658 style, |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
659 style & WS_CHILDWINDOW ? FALSE |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
660 : GetMenu(hwnd) != NULL); |
7d7e19b59866
David MacCormack fixed a bug in window sizing with Windows menus
Sam Lantinga <slouken@libsdl.org>
parents:
459
diff
changeset
|
661 |
0 | 662 width = size.right - size.left; |
663 height = size.bottom - size.top; | |
664 | |
665 /* Fix our size to the current size */ | |
666 info = (MINMAXINFO *)lParam; | |
667 info->ptMaxSize.x = width; | |
668 info->ptMaxSize.y = height; | |
669 info->ptMaxPosition.x = x; | |
670 info->ptMaxPosition.y = y; | |
671 info->ptMinTrackSize.x = width; | |
672 info->ptMinTrackSize.y = height; | |
673 info->ptMaxTrackSize.x = width; | |
674 info->ptMaxTrackSize.y = height; | |
675 } | |
676 return(0); | |
677 #endif /* WM_GETMINMAXINFO */ | |
678 | |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
679 case WM_WINDOWPOSCHANGED: { |
0 | 680 SDL_VideoDevice *this = current_video; |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
681 int w, h; |
0 | 682 |
683 GetClientRect(SDL_Window, &SDL_bounds); | |
1290
c4a5a772c5d9
The event code was fine, and calculated the SDL_windowX/Y correctly.
Sam Lantinga <slouken@libsdl.org>
parents:
1288
diff
changeset
|
684 ClientToScreen(SDL_Window, (LPPOINT)&SDL_bounds); |
c4a5a772c5d9
The event code was fine, and calculated the SDL_windowX/Y correctly.
Sam Lantinga <slouken@libsdl.org>
parents:
1288
diff
changeset
|
685 ClientToScreen(SDL_Window, (LPPOINT)&SDL_bounds+1); |
1291
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
686 if ( !SDL_resizing && !IsZoomed(SDL_Window) && |
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
687 SDL_PublicSurface && |
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
688 !(SDL_PublicSurface->flags & SDL_FULLSCREEN) ) { |
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
689 SDL_windowX = SDL_bounds.left; |
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
690 SDL_windowY = SDL_bounds.top; |
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
691 } |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
692 w = SDL_bounds.right-SDL_bounds.left; |
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
693 h = SDL_bounds.bottom-SDL_bounds.top; |
0 | 694 if ( this->input_grab != SDL_GRAB_OFF ) { |
695 ClipCursor(&SDL_bounds); | |
696 } | |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
697 if ( SDL_PublicSurface && |
0 | 698 (SDL_PublicSurface->flags & SDL_RESIZABLE) ) { |
447
16d0449891b8
Fixed mouse grab going fullscreen to windowed in Windows
Sam Lantinga <slouken@libsdl.org>
parents:
338
diff
changeset
|
699 SDL_PrivateResize(w, h); |
0 | 700 } |
701 } | |
702 break; | |
703 | |
704 /* We need to set the cursor */ | |
705 case WM_SETCURSOR: { | |
706 Uint16 hittest; | |
707 | |
708 hittest = LOWORD(lParam); | |
709 if ( hittest == HTCLIENT ) { | |
710 SetCursor(SDL_hcursor); | |
711 return(TRUE); | |
712 } | |
713 } | |
714 break; | |
715 | |
716 /* We are about to get palette focus! */ | |
717 case WM_QUERYNEWPALETTE: { | |
718 WIN_RealizePalette(current_video); | |
719 return(TRUE); | |
720 } | |
721 break; | |
722 | |
723 /* Another application changed the palette */ | |
724 case WM_PALETTECHANGED: { | |
725 WIN_PaletteChanged(current_video, (HWND)wParam); | |
726 } | |
727 break; | |
728 | |
729 /* We were occluded, refresh our display */ | |
730 case WM_PAINT: { | |
731 HDC hdc; | |
732 PAINTSTRUCT ps; | |
733 | |
734 hdc = BeginPaint(SDL_Window, &ps); | |
735 if ( current_video->screen && | |
736 !(current_video->screen->flags & SDL_OPENGL) ) { | |
737 WIN_WinPAINT(current_video, hdc); | |
738 } | |
739 EndPaint(SDL_Window, &ps); | |
740 } | |
741 return(0); | |
742 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
743 /* DJM: Send an expose event in this case */ |
0 | 744 case WM_ERASEBKGND: { |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
745 posted = SDL_PrivateExpose(); |
0 | 746 } |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
747 return(0); |
0 | 748 |
749 case WM_CLOSE: { | |
750 if ( (posted = SDL_PrivateQuit()) ) | |
751 PostQuitMessage(0); | |
752 } | |
753 return(0); | |
754 | |
755 case WM_DESTROY: { | |
756 PostQuitMessage(0); | |
757 } | |
758 return(0); | |
759 | |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
760 #ifndef NO_GETKEYBOARDSTATE |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
761 case WM_INPUTLANGCHANGE: { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
762 codepage = GetCodePage(); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
763 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
764 return(TRUE); |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
765 #endif |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
766 |
0 | 767 default: { |
768 /* Special handling by the video driver */ | |
769 if (HandleMessage) { | |
770 return(HandleMessage(current_video, | |
771 hwnd, msg, wParam, lParam)); | |
772 } | |
773 } | |
774 break; | |
775 } | |
776 return(DefWindowProc(hwnd, msg, wParam, lParam)); | |
777 } | |
778 | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
779 /* Allow the application handle to be stored and retrieved later */ |
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
780 static void *SDL_handle = NULL; |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
781 |
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
782 void SDL_SetModuleHandle(void *handle) |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
783 { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
784 SDL_handle = handle; |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
785 } |
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
786 void *SDL_GetModuleHandle(void) |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
787 { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
788 void *handle; |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
789 |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
790 if ( SDL_handle ) { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
791 handle = SDL_handle; |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
792 } else { |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
793 handle = GetModuleHandle(NULL); |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
794 } |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
795 return(handle); |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
796 } |
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
61
diff
changeset
|
797 |
0 | 798 /* This allows the SDL_WINDOWID hack */ |
1280
f61f045343d3
Re-query the SDL_WINDOWID each time we initialize the video
Sam Lantinga <slouken@libsdl.org>
parents:
1272
diff
changeset
|
799 BOOL SDL_windowid = FALSE; |
0 | 800 |
1145
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
801 static int app_registered = 0; |
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
802 |
0 | 803 /* Register the class for this application -- exported for winmain.c */ |
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
804 int SDL_RegisterApp(char *name, Uint32 style, void *hInst) |
0 | 805 { |
806 WNDCLASS class; | |
807 #ifdef WM_MOUSELEAVE | |
808 HMODULE handle; | |
809 #endif | |
810 | |
811 /* Only do this once... */ | |
1145
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
812 if ( app_registered ) { |
1498 | 813 ++app_registered; |
0 | 814 return(0); |
815 } | |
816 | |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
817 #ifndef CS_BYTEALIGNCLIENT |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
818 #define CS_BYTEALIGNCLIENT 0 |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
819 #endif |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
820 if ( ! name && ! SDL_Appname ) { |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
821 name = "SDL_app"; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
822 SDL_Appstyle = CS_BYTEALIGNCLIENT; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
823 SDL_Instance = hInst ? hInst : SDL_GetModuleHandle(); |
0 | 824 } |
825 | |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
826 if ( name ) { |
0 | 827 #ifdef _WIN32_WCE |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
828 /* WinCE uses the UNICODE version */ |
1505 | 829 SDL_Appname = SDL_iconv_utf8_ucs2(name); |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
830 #else |
4007 | 831 SDL_Appname = SDL_iconv_utf8_locale(name); |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
832 #endif /* _WIN32_WCE */ |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
833 SDL_Appstyle = style; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
834 SDL_Instance = hInst ? hInst : SDL_GetModuleHandle(); |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
835 } |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
836 |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
837 /* Register the application class */ |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
838 class.hCursor = NULL; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
839 class.hIcon = LoadImage(SDL_Instance, SDL_Appname, |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
840 IMAGE_ICON, |
0 | 841 0, 0, LR_DEFAULTCOLOR); |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
13
diff
changeset
|
842 class.lpszMenuName = NULL; |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
451
diff
changeset
|
843 class.lpszClassName = SDL_Appname; |
0 | 844 class.hbrBackground = NULL; |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
845 class.hInstance = SDL_Instance; |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
846 class.style = SDL_Appstyle; |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
847 #if SDL_VIDEO_OPENGL |
0 | 848 class.style |= CS_OWNDC; |
849 #endif | |
850 class.lpfnWndProc = WinMessage; | |
851 class.cbWndExtra = 0; | |
852 class.cbClsExtra = 0; | |
853 if ( ! RegisterClass(&class) ) { | |
854 SDL_SetError("Couldn't register application class"); | |
855 return(-1); | |
856 } | |
857 | |
858 #ifdef WM_MOUSELEAVE | |
859 /* Get the version of TrackMouseEvent() we use */ | |
860 _TrackMouseEvent = NULL; | |
861 handle = GetModuleHandle("USER32.DLL"); | |
862 if ( handle ) { | |
863 _TrackMouseEvent = (BOOL (WINAPI *)(TRACKMOUSEEVENT *))GetProcAddress(handle, "TrackMouseEvent"); | |
864 } | |
865 if ( _TrackMouseEvent == NULL ) { | |
866 _TrackMouseEvent = WIN_TrackMouseEvent; | |
867 } | |
868 #endif /* WM_MOUSELEAVE */ | |
869 | |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
870 #ifndef NO_GETKEYBOARDSTATE |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
871 /* Initialise variables for SDL_ToUnicode() */ |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
872 codepage = GetCodePage(); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
873 SDL_ToUnicode = Is9xME() ? ToUnicode9xME : ToUnicode; |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
874 #endif |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
875 |
1145
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
876 app_registered = 1; |
0 | 877 return(0); |
878 } | |
879 | |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
880 /* Unregisters the windowclass registered in SDL_RegisterApp above. */ |
1150
7d8e1925f35b
Typo that broke Windows builds.
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
881 void SDL_UnregisterApp() |
1145
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
882 { |
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
883 WNDCLASS class; |
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
884 |
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
885 /* SDL_RegisterApp might not have been called before */ |
1498 | 886 if ( !app_registered ) { |
887 return; | |
888 } | |
889 --app_registered; | |
890 if ( app_registered == 0 ) { | |
1288
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
891 /* Check for any registered window classes. */ |
ea3888b472bf
Cleaned up the app registration stuff a bit
Sam Lantinga <slouken@libsdl.org>
parents:
1287
diff
changeset
|
892 if ( GetClassInfo(SDL_Instance, SDL_Appname, &class) ) { |
1145
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
893 UnregisterClass(SDL_Appname, SDL_Instance); |
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
894 } |
1498 | 895 SDL_free(SDL_Appname); |
896 SDL_Appname = NULL; | |
1145
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
897 } |
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
898 } |
d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
Ryan C. Gordon <icculus@icculus.org>
parents:
833
diff
changeset
|
899 |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
900 #ifndef NO_GETKEYBOARDSTATE |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
901 /* JFP: Implementation of ToUnicode() that works on 9x/ME/2K/XP */ |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
902 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
903 static int Is9xME() |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
904 { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
905 OSVERSIONINFO info; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
906 |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
907 SDL_memset(&info, 0, sizeof(info)); |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
908 info.dwOSVersionInfoSize = sizeof(info); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
909 if (!GetVersionEx(&info)) { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
910 return 0; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
911 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
912 return (info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
913 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
914 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
915 static int GetCodePage() |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
916 { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
917 char buff[8]; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
918 int lcid = MAKELCID(LOWORD(GetKeyboardLayout(0)), SORT_DEFAULT); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
919 int cp = GetACP(); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
920 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
921 if (GetLocaleInfo(lcid, LOCALE_IDEFAULTANSICODEPAGE, buff, sizeof(buff))) { |
1341
d02b552e5304
Configure dynamically generates SDL_config.h
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
922 cp = SDL_atoi(buff); |
1253
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
923 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
924 return cp; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
925 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
926 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
927 static int WINAPI ToUnicode9xME(UINT vkey, UINT scancode, PBYTE keystate, LPWSTR wchars, int wsize, UINT flags) |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
928 { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
929 BYTE chars[2]; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
930 |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
931 if (ToAsciiEx(vkey, scancode, keystate, (WORD*)chars, 0, GetKeyboardLayout(0)) == 1) { |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
932 return MultiByteToWideChar(codepage, 0, chars, 1, wchars, wsize); |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
933 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
934 return 0; |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
935 } |
7c7ddaf195bf
Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
936 |
1272
94c0709f8856
Compile fix for Window CE
Sam Lantinga <slouken@libsdl.org>
parents:
1253
diff
changeset
|
937 #endif /* !NO_GETKEYBOARDSTATE */ |