src/video/windows/SDL_windowsevents.c
author Ryan C. Gordon <icculus@icculus.org>
Thu, 05 Jun 2014 00:54:43 -0400
changeset 8948 3ed9a59efda1
parent 8942 3d84839c97b2
child 8949 9738e8208dd5
permissions -rw-r--r--
Wired up Windows resize hit testing.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5421
diff changeset
     2
  Simple DirectMedia Layer
8149
681eb46b8ac4 Fixed bug 2374 - Update copyright for 2014...
Sam Lantinga <slouken@libsdl.org>
parents: 8143
diff changeset
     3
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5421
diff changeset
     5
  This software is provided 'as-is', without any express or implied
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5421
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5421
diff changeset
     7
  arising from the use of this software.
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5421
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5421
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5421
diff changeset
    11
  freely, subject to the following restrictions:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5421
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5421
diff changeset
    14
     claim that you wrote the original software. If you use this software
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5421
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5421
diff changeset
    16
     appreciated but is not required.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5421
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5421
diff changeset
    18
     misrepresented as being the original software.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5421
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
*/
8093
b43765095a6f Make internal SDL sources include SDL_internal.h instead of SDL_config.h
Ryan C. Gordon <icculus@icculus.org>
parents: 8084
diff changeset
    21
#include "../../SDL_internal.h"
2710
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2324
diff changeset
    22
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 5889
diff changeset
    23
#if SDL_VIDEO_DRIVER_WINDOWS
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
5062
e8916fe9cfc8 Fixed bug #925
Sam Lantinga <slouken@libsdl.org>
parents: 5056
diff changeset
    25
#include "SDL_windowsvideo.h"
e8916fe9cfc8 Fixed bug #925
Sam Lantinga <slouken@libsdl.org>
parents: 5056
diff changeset
    26
#include "SDL_windowsshape.h"
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
#include "SDL_syswm.h"
8218
cf153cc95173 Make sure we don't stay in the windows event loop forever if there are lots of events coming in quickly.
Sam Lantinga <slouken@libsdl.org>
parents: 8212
diff changeset
    28
#include "SDL_timer.h"
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
#include "SDL_vkeys.h"
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
#include "../../events/SDL_events_c.h"
4919
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
    31
#include "../../events/SDL_touch_c.h"
6938
b272d47f70a7 Cleaned up and fixed the Windows keyboard mapping code.
Sam Lantinga <slouken@libsdl.org>
parents: 6931
diff changeset
    32
#include "../../events/scancodes_windows.h"
8942
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
    33
#include "SDL_assert.h"
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
6523
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
    35
/* Dropfile support */
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
    36
#include <shellapi.h>
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
    37
7276
37814e7eeff3 Win32: Fix issue with SetCapture & negative values.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 7275
diff changeset
    38
/* For GET_X_LPARAM, GET_Y_LPARAM. */
37814e7eeff3 Win32: Fix issue with SetCapture & negative values.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 7275
diff changeset
    39
#include <windowsx.h>
6523
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
    40
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
    41
/* #define WMMSG_DEBUG */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
#ifdef WMMSG_DEBUG
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
    43
#include <stdio.h>
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
#include "wmmsg.h"
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    45
#endif
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    46
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
/* Masks for processing the windows KEYDOWN and KEYUP messages */
2317
f537a293b3da Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents: 2313
diff changeset
    48
#define REPEATED_KEYMASK    (1<<30)
f537a293b3da Windows also remaps the numeric keypad... grrr
Sam Lantinga <slouken@libsdl.org>
parents: 2313
diff changeset
    49
#define EXTENDED_KEYMASK    (1<<24)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    50
2324
3202e4826c57 more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents: 2317
diff changeset
    51
#define VK_ENTER    10          /* Keypad Enter ... no VKEY defined? */
6931
843f9c1b16b8 Fixed cygwin compile
Sam Lantinga <slouken@libsdl.org>
parents: 6929
diff changeset
    52
#ifndef VK_OEM_NEC_EQUAL
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
    53
#define VK_OEM_NEC_EQUAL 0x92
6931
843f9c1b16b8 Fixed cygwin compile
Sam Lantinga <slouken@libsdl.org>
parents: 6929
diff changeset
    54
#endif
2313
012ec5192dfa Added support for keypad enter
Sam Lantinga <slouken@libsdl.org>
parents: 2312
diff changeset
    55
2127
3bcc26b74e42 Merged r3087:3089 from branches/SDL-1.2: WM_XBUTTON support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1951
diff changeset
    56
/* Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... */
3bcc26b74e42 Merged r3087:3089 from branches/SDL-1.2: WM_XBUTTON support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1951
diff changeset
    57
#ifndef WM_XBUTTONDOWN
3bcc26b74e42 Merged r3087:3089 from branches/SDL-1.2: WM_XBUTTON support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1951
diff changeset
    58
#define WM_XBUTTONDOWN 0x020B
3bcc26b74e42 Merged r3087:3089 from branches/SDL-1.2: WM_XBUTTON support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1951
diff changeset
    59
#endif
3bcc26b74e42 Merged r3087:3089 from branches/SDL-1.2: WM_XBUTTON support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1951
diff changeset
    60
#ifndef WM_XBUTTONUP
3bcc26b74e42 Merged r3087:3089 from branches/SDL-1.2: WM_XBUTTON support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1951
diff changeset
    61
#define WM_XBUTTONUP 0x020C
3bcc26b74e42 Merged r3087:3089 from branches/SDL-1.2: WM_XBUTTON support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1951
diff changeset
    62
#endif
3bcc26b74e42 Merged r3087:3089 from branches/SDL-1.2: WM_XBUTTON support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1951
diff changeset
    63
#ifndef GET_XBUTTON_WPARAM
3bcc26b74e42 Merged r3087:3089 from branches/SDL-1.2: WM_XBUTTON support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1951
diff changeset
    64
#define GET_XBUTTON_WPARAM(w) (HIWORD(w))
3bcc26b74e42 Merged r3087:3089 from branches/SDL-1.2: WM_XBUTTON support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1951
diff changeset
    65
#endif
2733
264037dd3c7a Fix for mingw compilation by Alam.
Edgar Simo <bobbens@gmail.com>
parents: 2726
diff changeset
    66
#ifndef WM_INPUT
264037dd3c7a Fix for mingw compilation by Alam.
Edgar Simo <bobbens@gmail.com>
parents: 2726
diff changeset
    67
#define WM_INPUT 0x00ff
264037dd3c7a Fix for mingw compilation by Alam.
Edgar Simo <bobbens@gmail.com>
parents: 2726
diff changeset
    68
#endif
4932
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
    69
#ifndef WM_TOUCH
4868
d6adaafcfb10 Fixed compiling with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 4862
diff changeset
    70
#define WM_TOUCH 0x0240
4932
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
    71
#endif
7911
a9135f92ddba Horizontal wheel support in windows
Sam Lantinga <slouken@libsdl.org>
parents: 7816
diff changeset
    72
#ifndef WM_MOUSEHWHEEL
a9135f92ddba Horizontal wheel support in windows
Sam Lantinga <slouken@libsdl.org>
parents: 7816
diff changeset
    73
#define WM_MOUSEHWHEEL 0x020E
a9135f92ddba Horizontal wheel support in windows
Sam Lantinga <slouken@libsdl.org>
parents: 7816
diff changeset
    74
#endif
8624
c87db33e4cae Fixed bug 2450 - Crosscompiling for Win32 with MinGW fails due to WM_UNICHAR undeclared
Sam Lantinga <slouken@libsdl.org>
parents: 8253
diff changeset
    75
#ifndef WM_UNICHAR
c87db33e4cae Fixed bug 2450 - Crosscompiling for Win32 with MinGW fails due to WM_UNICHAR undeclared
Sam Lantinga <slouken@libsdl.org>
parents: 8253
diff changeset
    76
#define WM_UNICHAR 0x0109
c87db33e4cae Fixed bug 2450 - Crosscompiling for Win32 with MinGW fails due to WM_UNICHAR undeclared
Sam Lantinga <slouken@libsdl.org>
parents: 8253
diff changeset
    77
#endif
4919
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
    78
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
    79
static SDL_Scancode
6973
ae30ec97694a Fixed 64-bit compile warnings on Visual C++
Sam Lantinga <slouken@libsdl.org>
parents: 6951
diff changeset
    80
WindowsScanCodeToSDLScanCode( LPARAM lParam, WPARAM wParam )
6922
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
    81
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
    82
    SDL_Scancode code;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
    83
    char bIsExtended;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
    84
    int nScanCode = ( lParam >> 16 ) & 0xFF;
6922
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
    85
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
    86
    /* 0x45 here to work around both pause and numlock sharing the same scancode, so use the VK key to tell them apart */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
    87
    if ( nScanCode == 0 || nScanCode == 0x45 )
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
    88
    {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
    89
        switch( wParam )
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
    90
        {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
    91
        case VK_CLEAR: return SDL_SCANCODE_CLEAR;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
    92
        case VK_MODECHANGE: return SDL_SCANCODE_MODE;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
    93
        case VK_SELECT: return SDL_SCANCODE_SELECT;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
    94
        case VK_EXECUTE: return SDL_SCANCODE_EXECUTE;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
    95
        case VK_HELP: return SDL_SCANCODE_HELP;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
    96
        case VK_PAUSE: return SDL_SCANCODE_PAUSE;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
    97
        case VK_NUMLOCK: return SDL_SCANCODE_NUMLOCKCLEAR;
6922
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
    98
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
    99
        case VK_F13: return SDL_SCANCODE_F13;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   100
        case VK_F14: return SDL_SCANCODE_F14;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   101
        case VK_F15: return SDL_SCANCODE_F15;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   102
        case VK_F16: return SDL_SCANCODE_F16;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   103
        case VK_F17: return SDL_SCANCODE_F17;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   104
        case VK_F18: return SDL_SCANCODE_F18;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   105
        case VK_F19: return SDL_SCANCODE_F19;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   106
        case VK_F20: return SDL_SCANCODE_F20;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   107
        case VK_F21: return SDL_SCANCODE_F21;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   108
        case VK_F22: return SDL_SCANCODE_F22;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   109
        case VK_F23: return SDL_SCANCODE_F23;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   110
        case VK_F24: return SDL_SCANCODE_F24;
6922
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   111
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   112
        case VK_OEM_NEC_EQUAL: return SDL_SCANCODE_KP_EQUALS;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   113
        case VK_BROWSER_BACK: return SDL_SCANCODE_AC_BACK;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   114
        case VK_BROWSER_FORWARD: return SDL_SCANCODE_AC_FORWARD;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   115
        case VK_BROWSER_REFRESH: return SDL_SCANCODE_AC_REFRESH;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   116
        case VK_BROWSER_STOP: return SDL_SCANCODE_AC_STOP;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   117
        case VK_BROWSER_SEARCH: return SDL_SCANCODE_AC_SEARCH;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   118
        case VK_BROWSER_FAVORITES: return SDL_SCANCODE_AC_BOOKMARKS;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   119
        case VK_BROWSER_HOME: return SDL_SCANCODE_AC_HOME;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   120
        case VK_VOLUME_MUTE: return SDL_SCANCODE_AUDIOMUTE;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   121
        case VK_VOLUME_DOWN: return SDL_SCANCODE_VOLUMEDOWN;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   122
        case VK_VOLUME_UP: return SDL_SCANCODE_VOLUMEUP;
6922
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   123
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   124
        case VK_MEDIA_NEXT_TRACK: return SDL_SCANCODE_AUDIONEXT;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   125
        case VK_MEDIA_PREV_TRACK: return SDL_SCANCODE_AUDIOPREV;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   126
        case VK_MEDIA_STOP: return SDL_SCANCODE_AUDIOSTOP;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   127
        case VK_MEDIA_PLAY_PAUSE: return SDL_SCANCODE_AUDIOPLAY;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   128
        case VK_LAUNCH_MAIL: return SDL_SCANCODE_MAIL;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   129
        case VK_LAUNCH_MEDIA_SELECT: return SDL_SCANCODE_MEDIASELECT;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   130
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   131
        case VK_OEM_102: return SDL_SCANCODE_NONUSBACKSLASH;
6922
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   132
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   133
        case VK_ATTN: return SDL_SCANCODE_SYSREQ;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   134
        case VK_CRSEL: return SDL_SCANCODE_CRSEL;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   135
        case VK_EXSEL: return SDL_SCANCODE_EXSEL;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   136
        case VK_OEM_CLEAR: return SDL_SCANCODE_CLEAR;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   137
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   138
        case VK_LAUNCH_APP1: return SDL_SCANCODE_APP1;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   139
        case VK_LAUNCH_APP2: return SDL_SCANCODE_APP2;
6922
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   140
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   141
        default: return SDL_SCANCODE_UNKNOWN;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   142
        }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   143
    }
6922
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   144
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   145
    if ( nScanCode > 127 )
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   146
        return SDL_SCANCODE_UNKNOWN;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   147
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   148
    code = windows_scancode_table[nScanCode];
6922
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   149
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   150
    bIsExtended = ( lParam & ( 1 << 24 ) ) != 0;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   151
    if ( !bIsExtended )
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   152
    {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   153
        switch ( code )
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   154
        {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   155
        case SDL_SCANCODE_HOME:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   156
            return SDL_SCANCODE_KP_7;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   157
        case SDL_SCANCODE_UP:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   158
            return SDL_SCANCODE_KP_8;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   159
        case SDL_SCANCODE_PAGEUP:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   160
            return SDL_SCANCODE_KP_9;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   161
        case SDL_SCANCODE_LEFT:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   162
            return SDL_SCANCODE_KP_4;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   163
        case SDL_SCANCODE_RIGHT:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   164
            return SDL_SCANCODE_KP_6;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   165
        case SDL_SCANCODE_END:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   166
            return SDL_SCANCODE_KP_1;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   167
        case SDL_SCANCODE_DOWN:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   168
            return SDL_SCANCODE_KP_2;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   169
        case SDL_SCANCODE_PAGEDOWN:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   170
            return SDL_SCANCODE_KP_3;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   171
        case SDL_SCANCODE_INSERT:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   172
            return SDL_SCANCODE_KP_0;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   173
        case SDL_SCANCODE_DELETE:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   174
            return SDL_SCANCODE_KP_PERIOD;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   175
        case SDL_SCANCODE_PRINTSCREEN:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   176
            return SDL_SCANCODE_KP_MULTIPLY;
7029
377cc88f3dc8 Fixed compiler warning with Cygwin
Sam Lantinga <slouken@libsdl.org>
parents: 6973
diff changeset
   177
        default:
377cc88f3dc8 Fixed compiler warning with Cygwin
Sam Lantinga <slouken@libsdl.org>
parents: 6973
diff changeset
   178
            break;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   179
        }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   180
    }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   181
    else
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   182
    {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   183
        switch ( code )
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   184
        {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   185
        case SDL_SCANCODE_RETURN:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   186
            return SDL_SCANCODE_KP_ENTER;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   187
        case SDL_SCANCODE_LALT:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   188
            return SDL_SCANCODE_RALT;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   189
        case SDL_SCANCODE_LCTRL:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   190
            return SDL_SCANCODE_RCTRL;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   191
        case SDL_SCANCODE_SLASH:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   192
            return SDL_SCANCODE_KP_DIVIDE;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   193
        case SDL_SCANCODE_CAPSLOCK:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   194
            return SDL_SCANCODE_KP_PLUS;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   195
        default:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   196
            break;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   197
        }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   198
    }
6922
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   199
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   200
    return code;
6922
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   201
}
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   202
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6885
diff changeset
   203
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   204
void
6943
ce87e12970f5 sdl - use the wParam and rawinput data for mouse state rather than just the message type, fixes missing mouse up events when alt-tabing out of the window
Sam Lantinga <slouken@libsdl.org>
parents: 6931
diff changeset
   205
WIN_CheckWParamMouseButton( SDL_bool bwParamMousePressed, SDL_bool bSDLMousePressed, SDL_WindowData *data, Uint8 button )
ce87e12970f5 sdl - use the wParam and rawinput data for mouse state rather than just the message type, fixes missing mouse up events when alt-tabing out of the window
Sam Lantinga <slouken@libsdl.org>
parents: 6931
diff changeset
   206
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   207
    if ( bwParamMousePressed && !bSDLMousePressed )
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   208
    {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   209
        SDL_SendMouseButton(data->window, 0, SDL_PRESSED, button);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   210
    }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   211
    else if ( !bwParamMousePressed && bSDLMousePressed )
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   212
    {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   213
        SDL_SendMouseButton(data->window, 0, SDL_RELEASED, button);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   214
    }
6943
ce87e12970f5 sdl - use the wParam and rawinput data for mouse state rather than just the message type, fixes missing mouse up events when alt-tabing out of the window
Sam Lantinga <slouken@libsdl.org>
parents: 6931
diff changeset
   215
}
ce87e12970f5 sdl - use the wParam and rawinput data for mouse state rather than just the message type, fixes missing mouse up events when alt-tabing out of the window
Sam Lantinga <slouken@libsdl.org>
parents: 6931
diff changeset
   216
ce87e12970f5 sdl - use the wParam and rawinput data for mouse state rather than just the message type, fixes missing mouse up events when alt-tabing out of the window
Sam Lantinga <slouken@libsdl.org>
parents: 6931
diff changeset
   217
/*
ce87e12970f5 sdl - use the wParam and rawinput data for mouse state rather than just the message type, fixes missing mouse up events when alt-tabing out of the window
Sam Lantinga <slouken@libsdl.org>
parents: 6931
diff changeset
   218
* Some windows systems fail to send a WM_LBUTTONDOWN sometimes, but each mouse move contains the current button state also
ce87e12970f5 sdl - use the wParam and rawinput data for mouse state rather than just the message type, fixes missing mouse up events when alt-tabing out of the window
Sam Lantinga <slouken@libsdl.org>
parents: 6931
diff changeset
   219
*  so this funciton reconciles our view of the world with the current buttons reported by windows
ce87e12970f5 sdl - use the wParam and rawinput data for mouse state rather than just the message type, fixes missing mouse up events when alt-tabing out of the window
Sam Lantinga <slouken@libsdl.org>
parents: 6931
diff changeset
   220
*/
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   221
void
6943
ce87e12970f5 sdl - use the wParam and rawinput data for mouse state rather than just the message type, fixes missing mouse up events when alt-tabing out of the window
Sam Lantinga <slouken@libsdl.org>
parents: 6931
diff changeset
   222
WIN_CheckWParamMouseButtons( WPARAM wParam, SDL_WindowData *data )
ce87e12970f5 sdl - use the wParam and rawinput data for mouse state rather than just the message type, fixes missing mouse up events when alt-tabing out of the window
Sam Lantinga <slouken@libsdl.org>
parents: 6931
diff changeset
   223
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   224
    if ( wParam != data->mouse_button_flags )
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   225
    {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   226
        Uint32 mouseFlags = SDL_GetMouseState( NULL, NULL );
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   227
        WIN_CheckWParamMouseButton(  (wParam & MK_LBUTTON), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT );
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   228
        WIN_CheckWParamMouseButton(  (wParam & MK_MBUTTON), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE );
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   229
        WIN_CheckWParamMouseButton(  (wParam & MK_RBUTTON), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT );
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   230
        WIN_CheckWParamMouseButton(  (wParam & MK_XBUTTON1), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1 );
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   231
        WIN_CheckWParamMouseButton(  (wParam & MK_XBUTTON2), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2 );
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   232
        data->mouse_button_flags = wParam;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   233
    }
6943
ce87e12970f5 sdl - use the wParam and rawinput data for mouse state rather than just the message type, fixes missing mouse up events when alt-tabing out of the window
Sam Lantinga <slouken@libsdl.org>
parents: 6931
diff changeset
   234
}
ce87e12970f5 sdl - use the wParam and rawinput data for mouse state rather than just the message type, fixes missing mouse up events when alt-tabing out of the window
Sam Lantinga <slouken@libsdl.org>
parents: 6931
diff changeset
   235
ce87e12970f5 sdl - use the wParam and rawinput data for mouse state rather than just the message type, fixes missing mouse up events when alt-tabing out of the window
Sam Lantinga <slouken@libsdl.org>
parents: 6931
diff changeset
   236
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   237
void
6943
ce87e12970f5 sdl - use the wParam and rawinput data for mouse state rather than just the message type, fixes missing mouse up events when alt-tabing out of the window
Sam Lantinga <slouken@libsdl.org>
parents: 6931
diff changeset
   238
WIN_CheckRawMouseButtons( ULONG rawButtons, SDL_WindowData *data )
ce87e12970f5 sdl - use the wParam and rawinput data for mouse state rather than just the message type, fixes missing mouse up events when alt-tabing out of the window
Sam Lantinga <slouken@libsdl.org>
parents: 6931
diff changeset
   239
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   240
    if ( rawButtons != data->mouse_button_flags )
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   241
    {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   242
        Uint32 mouseFlags = SDL_GetMouseState( NULL, NULL );
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   243
        if ( (rawButtons & RI_MOUSE_BUTTON_1_DOWN) )
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   244
            WIN_CheckWParamMouseButton(  (rawButtons & RI_MOUSE_BUTTON_1_DOWN), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT );
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   245
        if ( (rawButtons & RI_MOUSE_BUTTON_1_UP) )
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   246
            WIN_CheckWParamMouseButton(  !(rawButtons & RI_MOUSE_BUTTON_1_UP), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT );
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   247
        if ( (rawButtons & RI_MOUSE_BUTTON_2_DOWN) )
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   248
            WIN_CheckWParamMouseButton(  (rawButtons & RI_MOUSE_BUTTON_2_DOWN), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT );
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   249
        if ( (rawButtons & RI_MOUSE_BUTTON_2_UP) )
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   250
            WIN_CheckWParamMouseButton(  !(rawButtons & RI_MOUSE_BUTTON_2_UP), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT );
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   251
        if ( (rawButtons & RI_MOUSE_BUTTON_3_DOWN) )
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   252
            WIN_CheckWParamMouseButton(  (rawButtons & RI_MOUSE_BUTTON_3_DOWN), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE );
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   253
        if ( (rawButtons & RI_MOUSE_BUTTON_3_UP) )
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   254
            WIN_CheckWParamMouseButton(  !(rawButtons & RI_MOUSE_BUTTON_3_UP), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE );
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   255
        if ( (rawButtons & RI_MOUSE_BUTTON_4_DOWN) )
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   256
            WIN_CheckWParamMouseButton(  (rawButtons & RI_MOUSE_BUTTON_4_DOWN), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1 );
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   257
        if ( (rawButtons & RI_MOUSE_BUTTON_4_UP) )
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   258
            WIN_CheckWParamMouseButton(  !(rawButtons & RI_MOUSE_BUTTON_4_UP), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1 );
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   259
        if ( (rawButtons & RI_MOUSE_BUTTON_5_DOWN) )
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   260
            WIN_CheckWParamMouseButton(  (rawButtons & RI_MOUSE_BUTTON_5_DOWN), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2 );
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   261
        if ( (rawButtons & RI_MOUSE_BUTTON_5_UP) )
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   262
            WIN_CheckWParamMouseButton(  !(rawButtons & RI_MOUSE_BUTTON_5_UP), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2 );
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   263
        data->mouse_button_flags = rawButtons;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   264
    }
6943
ce87e12970f5 sdl - use the wParam and rawinput data for mouse state rather than just the message type, fixes missing mouse up events when alt-tabing out of the window
Sam Lantinga <slouken@libsdl.org>
parents: 6931
diff changeset
   265
}
ce87e12970f5 sdl - use the wParam and rawinput data for mouse state rather than just the message type, fixes missing mouse up events when alt-tabing out of the window
Sam Lantinga <slouken@libsdl.org>
parents: 6931
diff changeset
   266
8212
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   267
void
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   268
WIN_CheckAsyncMouseRelease( SDL_WindowData *data )
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   269
{
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   270
    Uint32 mouseFlags;
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   271
    SHORT keyState;
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   272
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   273
    /* mouse buttons may have changed state here, we need to resync them,
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   274
       but we will get a WM_MOUSEMOVE right away which will fix things up if in non raw mode also
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   275
    */
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   276
    mouseFlags = SDL_GetMouseState( NULL, NULL );
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   277
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   278
    keyState = GetAsyncKeyState( VK_LBUTTON );
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   279
    WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), ( mouseFlags & SDL_BUTTON_LMASK ), data, SDL_BUTTON_LEFT );
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   280
    keyState = GetAsyncKeyState( VK_RBUTTON );
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   281
    WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), ( mouseFlags & SDL_BUTTON_RMASK ), data, SDL_BUTTON_RIGHT );
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   282
    keyState = GetAsyncKeyState( VK_MBUTTON );
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   283
    WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), ( mouseFlags & SDL_BUTTON_MMASK ), data, SDL_BUTTON_MIDDLE );
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   284
    keyState = GetAsyncKeyState( VK_XBUTTON1 );
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   285
    WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), ( mouseFlags & SDL_BUTTON_X1MASK ), data, SDL_BUTTON_X1 );
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   286
    keyState = GetAsyncKeyState( VK_XBUTTON2 );
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   287
    WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), ( mouseFlags & SDL_BUTTON_X2MASK ), data, SDL_BUTTON_X2 );
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   288
    data->mouse_button_flags = 0;
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   289
}
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   290
7647
832a72fc1c94 Fixed windows build
Sam Lantinga <slouken@libsdl.org>
parents: 7646
diff changeset
   291
SDL_FORCE_INLINE BOOL
7645
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   292
WIN_ConvertUTF32toUTF8(UINT32 codepoint, char * text)
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   293
{
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   294
    if (codepoint <= 0x7F) {
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   295
        text[0] = (char) codepoint;
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   296
        text[1] = '\0';
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   297
    } else if (codepoint <= 0x7FF) {
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   298
        text[0] = 0xC0 | (char) ((codepoint >> 6) & 0x1F);
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   299
        text[1] = 0x80 | (char) (codepoint & 0x3F);
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   300
        text[2] = '\0';
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   301
    } else if (codepoint <= 0xFFFF) {
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   302
        text[0] = 0xE0 | (char) ((codepoint >> 12) & 0x0F);
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   303
        text[1] = 0x80 | (char) ((codepoint >> 6) & 0x3F);
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   304
        text[2] = 0x80 | (char) (codepoint & 0x3F);
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   305
        text[3] = '\0';
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   306
    } else if (codepoint <= 0x10FFFF) {
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   307
        text[0] = 0xF0 | (char) ((codepoint >> 18) & 0x0F);
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   308
        text[1] = 0x80 | (char) ((codepoint >> 12) & 0x3F);
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   309
        text[2] = 0x80 | (char) ((codepoint >> 6) & 0x3F);
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   310
        text[3] = 0x80 | (char) (codepoint & 0x3F);
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   311
        text[4] = '\0';
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   312
    } else {
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   313
        return SDL_FALSE;
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   314
    }
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   315
    return SDL_TRUE;
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   316
}
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   317
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   318
LRESULT CALLBACK
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   319
WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   320
{
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   321
    SDL_WindowData *data;
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   322
    LRESULT returnCode = -1;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   323
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
   324
    /* Send a SDL_SYSWMEVENT if the application wants them */
4429
faa9fc8e7f67 General improvements for user custom event registration
Sam Lantinga <slouken@libsdl.org>
parents: 3700
diff changeset
   325
    if (SDL_GetEventState(SDL_SYSWMEVENT) == SDL_ENABLE) {
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
   326
        SDL_SysWMmsg wmmsg;
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
   327
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
   328
        SDL_VERSION(&wmmsg.version);
4900
69d9db65f248 Merged the Windows custom window system hooks into the union used by X11.
Sam Lantinga <slouken@libsdl.org>
parents: 4868
diff changeset
   329
        wmmsg.subsystem = SDL_SYSWM_WINDOWS;
5056
8b7988f42fcb Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents: 5049
diff changeset
   330
        wmmsg.msg.win.hwnd = hwnd;
8b7988f42fcb Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents: 5049
diff changeset
   331
        wmmsg.msg.win.msg = msg;
8b7988f42fcb Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents: 5049
diff changeset
   332
        wmmsg.msg.win.wParam = wParam;
8b7988f42fcb Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents: 5049
diff changeset
   333
        wmmsg.msg.win.lParam = lParam;
1951
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
   334
        SDL_SendSysWMEvent(&wmmsg);
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
   335
    }
7177581dc9fa Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents: 1913
diff changeset
   336
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   337
    /* Get the window data for the window */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   338
    data = (SDL_WindowData *) GetProp(hwnd, TEXT("SDL_WindowData"));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   339
    if (!data) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   340
        return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   341
    }
4650
7ad7a473b086 More fixes for windows. Disabled tablet code.
jimtla
parents: 4429
diff changeset
   342
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   343
#ifdef WMMSG_DEBUG
7941
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   344
    {
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   345
        char message[1024];
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   346
        if (msg > MAX_WMMSG) {
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   347
            SDL_snprintf(message, sizeof(message), "Received windows message: %p UNKNOWN (%d) -- 0x%X, 0x%X\n", hwnd, msg, wParam, lParam);
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   348
        } else {
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   349
            SDL_snprintf(message, sizeof(message), "Received windows message: %p %s -- 0x%X, 0x%X\n", hwnd, wmtab[msg], wParam, lParam);
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   350
        }
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   351
        OutputDebugStringA(message);
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   352
    }
7816
f16e342b167a Fixed the windows message debug output so it works without HAVE_LIBC
Sam Lantinga <slouken@libsdl.org>
parents: 7813
diff changeset
   353
#endif /* WMMSG_DEBUG */
2710
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2324
diff changeset
   354
4752
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4746
diff changeset
   355
    if (IME_HandleMessage(hwnd, msg, wParam, &lParam, data->videodata))
dc7bdcf06367 Initial IMM implementation.
dewyatt
parents: 4746
diff changeset
   356
        return 0;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   357
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   358
    switch (msg) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   359
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   360
    case WM_SHOWWINDOW:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   361
        {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   362
            if (wParam) {
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3566
diff changeset
   363
                SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   364
            } else {
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3566
diff changeset
   365
                SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_HIDDEN, 0, 0);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   366
            }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   367
        }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   368
        break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   369
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   370
    case WM_ACTIVATE:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   371
        {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   372
            BOOL minimized;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   373
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   374
            minimized = HIWORD(wParam);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   375
            if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) {
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3566
diff changeset
   376
                SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0);
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
   377
                if (SDL_GetKeyboardFocus() != data->window) {
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
   378
                    SDL_SetKeyboardFocus(data->window);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   379
                }
8036
d485906bd74a Fixed bug 2260 - SDL_SetCursorGrab() is buggy on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 8035
diff changeset
   380
                WIN_UpdateClipCursor(data->window);
8212
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   381
                WIN_CheckAsyncMouseRelease(data);
6350
19545983ac76 Patrick Baggett implemented relative mouse mode on Win32
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   382
4504
9faebccfefb3 Amazingly the Windows code is almost identical to the Mac OS X code. :)
Sam Lantinga <slouken@libsdl.org>
parents: 4500
diff changeset
   383
                /*
9faebccfefb3 Amazingly the Windows code is almost identical to the Mac OS X code. :)
Sam Lantinga <slouken@libsdl.org>
parents: 4500
diff changeset
   384
                 * FIXME: Update keyboard state
9faebccfefb3 Amazingly the Windows code is almost identical to the Mac OS X code. :)
Sam Lantinga <slouken@libsdl.org>
parents: 4500
diff changeset
   385
                 */
9faebccfefb3 Amazingly the Windows code is almost identical to the Mac OS X code. :)
Sam Lantinga <slouken@libsdl.org>
parents: 4500
diff changeset
   386
                WIN_CheckClipboardUpdate(data->videodata);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   387
            } else {
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
   388
                if (SDL_GetKeyboardFocus() == data->window) {
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
   389
                    SDL_SetKeyboardFocus(NULL);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   390
                }
8050
be19dbc5ff4e Added code missed in the resolve
Sam Lantinga <slouken@libsdl.org>
parents: 8036
diff changeset
   391
be19dbc5ff4e Added code missed in the resolve
Sam Lantinga <slouken@libsdl.org>
parents: 8036
diff changeset
   392
                ClipCursor(NULL);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   393
            }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   394
        }
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   395
        returnCode = 0;
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   396
        break;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   397
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   398
    case WM_MOUSEMOVE:
8071
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   399
        {
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   400
            SDL_Mouse *mouse = SDL_GetMouse();
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   401
            if (!mouse->relative_mode || mouse->relative_mode_warp) {
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   402
                SDL_SendMouseMotion(data->window, 0, 0, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   403
            }
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   404
        }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   405
        /* don't break here, fall through to check the wParam like the button presses */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   406
    case WM_LBUTTONUP:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   407
    case WM_RBUTTONUP:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   408
    case WM_MBUTTONUP:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   409
    case WM_XBUTTONUP:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   410
    case WM_LBUTTONDOWN:
8713
e3a80970cf0b Fixed bug 2496 - mouse left button double click event issue
Sam Lantinga <slouken@libsdl.org>
parents: 8624
diff changeset
   411
    case WM_LBUTTONDBLCLK:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   412
    case WM_RBUTTONDOWN:
8713
e3a80970cf0b Fixed bug 2496 - mouse left button double click event issue
Sam Lantinga <slouken@libsdl.org>
parents: 8624
diff changeset
   413
    case WM_RBUTTONDBLCLK:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   414
    case WM_MBUTTONDOWN:
8713
e3a80970cf0b Fixed bug 2496 - mouse left button double click event issue
Sam Lantinga <slouken@libsdl.org>
parents: 8624
diff changeset
   415
    case WM_MBUTTONDBLCLK:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   416
    case WM_XBUTTONDOWN:
8713
e3a80970cf0b Fixed bug 2496 - mouse left button double click event issue
Sam Lantinga <slouken@libsdl.org>
parents: 8624
diff changeset
   417
    case WM_XBUTTONDBLCLK:
8071
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   418
        {
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   419
            SDL_Mouse *mouse = SDL_GetMouse();
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   420
            if (!mouse->relative_mode || mouse->relative_mode_warp) {
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   421
                WIN_CheckWParamMouseButtons(wParam, data);
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   422
            }
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   423
        }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   424
        break;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3102
diff changeset
   425
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   426
    case WM_INPUT:
8071
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   427
        {
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   428
            SDL_Mouse *mouse = SDL_GetMouse();
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   429
            HRAWINPUT hRawInput = (HRAWINPUT)lParam;
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   430
            RAWINPUT inp;
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   431
            UINT size = sizeof(inp);
8942
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   432
            const SDL_bool isRelative = mouse->relative_mode || mouse->relative_mode_warp;
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   433
            const SDL_bool isCapture = ((data->window->flags & SDL_WINDOW_MOUSE_CAPTURE) != 0);
6782
582d35419e8a Improvements from Alfred:
Sam Lantinga <slouken@libsdl.org>
parents: 6682
diff changeset
   434
8942
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   435
            if (!isRelative || mouse->focus != data->window) {
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   436
                if (!isCapture) {
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   437
                    break;
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   438
                }
8071
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   439
            }
6782
582d35419e8a Improvements from Alfred:
Sam Lantinga <slouken@libsdl.org>
parents: 6682
diff changeset
   440
8071
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   441
            GetRawInputData(hRawInput, RID_INPUT, &inp, &size, sizeof(RAWINPUTHEADER));
6350
19545983ac76 Patrick Baggett implemented relative mouse mode on Win32
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   442
8071
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   443
            /* Mouse data */
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   444
            if (inp.header.dwType == RIM_TYPEMOUSE) {
8942
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   445
                if (isRelative) {
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   446
                    RAWMOUSE* mouse = &inp.data.mouse;
6350
19545983ac76 Patrick Baggett implemented relative mouse mode on Win32
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   447
8942
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   448
                    if ((mouse->usFlags & 0x01) == MOUSE_MOVE_RELATIVE) {
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   449
                        SDL_SendMouseMotion(data->window, 0, 1, (int)mouse->lLastX, (int)mouse->lLastY);
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   450
                    } else {
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   451
                        /* synthesize relative moves from the abs position */
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   452
                        static SDL_Point initialMousePoint;
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   453
                        if (initialMousePoint.x == 0 && initialMousePoint.y == 0) {
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   454
                            initialMousePoint.x = mouse->lLastX;
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   455
                            initialMousePoint.y = mouse->lLastY;
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   456
                        }
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   457
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   458
                        SDL_SendMouseMotion(data->window, 0, 1, (int)(mouse->lLastX-initialMousePoint.x), (int)(mouse->lLastY-initialMousePoint.y) );
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   459
8071
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   460
                        initialMousePoint.x = mouse->lLastX;
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   461
                        initialMousePoint.y = mouse->lLastY;
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   462
                    }
8942
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   463
                    WIN_CheckRawMouseButtons( mouse->usButtonFlags, data );
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   464
                } else if (isCapture) {
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   465
                    /* we check for where Windows thinks the system cursor lives in this case, so we don't really lose mouse accel, etc. */
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   466
                    POINT pt;
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   467
                    HWND hwnd = data->hwnd;
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   468
                    GetCursorPos(&pt);
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   469
                    if (WindowFromPoint(pt) != hwnd) {  /* if in the window, WM_MOUSEMOVE, etc, will cover it. */
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   470
                        ScreenToClient(data->hwnd, &pt);
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   471
                        SDL_SendMouseMotion(data->window, 0, 0, (int) pt.x, (int) pt.y);
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   472
                        SDL_SendMouseButton(data->window, 0, GetKeyState(VK_LBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_LEFT);
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   473
                        SDL_SendMouseButton(data->window, 0, GetKeyState(VK_RBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_RIGHT);
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   474
                        SDL_SendMouseButton(data->window, 0, GetKeyState(VK_MBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_MIDDLE);
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   475
                        SDL_SendMouseButton(data->window, 0, GetKeyState(VK_XBUTTON1) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_X1);
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   476
                        SDL_SendMouseButton(data->window, 0, GetKeyState(VK_XBUTTON2) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_X2);
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   477
                    }
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   478
                } else {
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   479
                    SDL_assert(0 && "Shouldn't happen");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   480
                }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   481
            }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   482
        }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   483
        break;
6350
19545983ac76 Patrick Baggett implemented relative mouse mode on Win32
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   484
5049
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
   485
    case WM_MOUSEWHEEL:
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
   486
        {
7813
d8fb783475d5 Fixed accumulating mouse wheel motion for the Microsoft Wireless Mouse 5000
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   487
            static short s_AccumulatedMotion;
5049
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
   488
7813
d8fb783475d5 Fixed accumulating mouse wheel motion for the Microsoft Wireless Mouse 5000
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   489
            s_AccumulatedMotion += GET_WHEEL_DELTA_WPARAM(wParam);
d8fb783475d5 Fixed accumulating mouse wheel motion for the Microsoft Wireless Mouse 5000
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   490
            if (s_AccumulatedMotion > 0) {
d8fb783475d5 Fixed accumulating mouse wheel motion for the Microsoft Wireless Mouse 5000
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   491
                while (s_AccumulatedMotion >= WHEEL_DELTA) {
d8fb783475d5 Fixed accumulating mouse wheel motion for the Microsoft Wireless Mouse 5000
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   492
                    SDL_SendMouseWheel(data->window, 0, 0, 1);
d8fb783475d5 Fixed accumulating mouse wheel motion for the Microsoft Wireless Mouse 5000
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   493
                    s_AccumulatedMotion -= WHEEL_DELTA;
d8fb783475d5 Fixed accumulating mouse wheel motion for the Microsoft Wireless Mouse 5000
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   494
                }
d8fb783475d5 Fixed accumulating mouse wheel motion for the Microsoft Wireless Mouse 5000
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   495
            } else {
d8fb783475d5 Fixed accumulating mouse wheel motion for the Microsoft Wireless Mouse 5000
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   496
                while (s_AccumulatedMotion <= -WHEEL_DELTA) {
d8fb783475d5 Fixed accumulating mouse wheel motion for the Microsoft Wireless Mouse 5000
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   497
                    SDL_SendMouseWheel(data->window, 0, 0, -1);
d8fb783475d5 Fixed accumulating mouse wheel motion for the Microsoft Wireless Mouse 5000
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   498
                    s_AccumulatedMotion += WHEEL_DELTA;
d8fb783475d5 Fixed accumulating mouse wheel motion for the Microsoft Wireless Mouse 5000
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   499
                }
d8fb783475d5 Fixed accumulating mouse wheel motion for the Microsoft Wireless Mouse 5000
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   500
            }
5049
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
   501
        }
8071
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   502
        break;
5049
28003ba91f57 John Wilson 2010-08-17 17:09:16 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 4932
diff changeset
   503
7911
a9135f92ddba Horizontal wheel support in windows
Sam Lantinga <slouken@libsdl.org>
parents: 7816
diff changeset
   504
    case WM_MOUSEHWHEEL:
a9135f92ddba Horizontal wheel support in windows
Sam Lantinga <slouken@libsdl.org>
parents: 7816
diff changeset
   505
        {
a9135f92ddba Horizontal wheel support in windows
Sam Lantinga <slouken@libsdl.org>
parents: 7816
diff changeset
   506
            static short s_AccumulatedMotion;
a9135f92ddba Horizontal wheel support in windows
Sam Lantinga <slouken@libsdl.org>
parents: 7816
diff changeset
   507
a9135f92ddba Horizontal wheel support in windows
Sam Lantinga <slouken@libsdl.org>
parents: 7816
diff changeset
   508
            s_AccumulatedMotion += GET_WHEEL_DELTA_WPARAM(wParam);
a9135f92ddba Horizontal wheel support in windows
Sam Lantinga <slouken@libsdl.org>
parents: 7816
diff changeset
   509
            if (s_AccumulatedMotion > 0) {
a9135f92ddba Horizontal wheel support in windows
Sam Lantinga <slouken@libsdl.org>
parents: 7816
diff changeset
   510
                while (s_AccumulatedMotion >= WHEEL_DELTA) {
7912
10eff60470b3 Fixed Windows compile error
Sam Lantinga <slouken@libsdl.org>
parents: 7911
diff changeset
   511
                    SDL_SendMouseWheel(data->window, 0, 1, 0);
7911
a9135f92ddba Horizontal wheel support in windows
Sam Lantinga <slouken@libsdl.org>
parents: 7816
diff changeset
   512
                    s_AccumulatedMotion -= WHEEL_DELTA;
a9135f92ddba Horizontal wheel support in windows
Sam Lantinga <slouken@libsdl.org>
parents: 7816
diff changeset
   513
                }
a9135f92ddba Horizontal wheel support in windows
Sam Lantinga <slouken@libsdl.org>
parents: 7816
diff changeset
   514
            } else {
a9135f92ddba Horizontal wheel support in windows
Sam Lantinga <slouken@libsdl.org>
parents: 7816
diff changeset
   515
                while (s_AccumulatedMotion <= -WHEEL_DELTA) {
7912
10eff60470b3 Fixed Windows compile error
Sam Lantinga <slouken@libsdl.org>
parents: 7911
diff changeset
   516
                    SDL_SendMouseWheel(data->window, 0, -1, 0);
7911
a9135f92ddba Horizontal wheel support in windows
Sam Lantinga <slouken@libsdl.org>
parents: 7816
diff changeset
   517
                    s_AccumulatedMotion += WHEEL_DELTA;
a9135f92ddba Horizontal wheel support in windows
Sam Lantinga <slouken@libsdl.org>
parents: 7816
diff changeset
   518
                }
a9135f92ddba Horizontal wheel support in windows
Sam Lantinga <slouken@libsdl.org>
parents: 7816
diff changeset
   519
            }
a9135f92ddba Horizontal wheel support in windows
Sam Lantinga <slouken@libsdl.org>
parents: 7816
diff changeset
   520
        }
8071
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   521
        break;
7911
a9135f92ddba Horizontal wheel support in windows
Sam Lantinga <slouken@libsdl.org>
parents: 7816
diff changeset
   522
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   523
#ifdef WM_MOUSELEAVE
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   524
    case WM_MOUSELEAVE:
8942
3d84839c97b2 Fixed up SDL_CaptureMouse() on Windows to work like I expected.
Ryan C. Gordon <icculus@icculus.org>
parents: 8941
diff changeset
   525
        if (SDL_GetMouseFocus() == data->window && !SDL_GetMouse()->relative_mode && !(data->window->flags & SDL_WINDOW_MOUSE_CAPTURE)) {
8035
2cc220c7e899 Fixed large relative mouse motion when iconifying the SDL window.
Sam Lantinga <slouken@libsdl.org>
parents: 7975
diff changeset
   526
            if (!IsIconic(hwnd)) {
2cc220c7e899 Fixed large relative mouse motion when iconifying the SDL window.
Sam Lantinga <slouken@libsdl.org>
parents: 7975
diff changeset
   527
                POINT cursorPos;
2cc220c7e899 Fixed large relative mouse motion when iconifying the SDL window.
Sam Lantinga <slouken@libsdl.org>
parents: 7975
diff changeset
   528
                GetCursorPos(&cursorPos);
2cc220c7e899 Fixed large relative mouse motion when iconifying the SDL window.
Sam Lantinga <slouken@libsdl.org>
parents: 7975
diff changeset
   529
                ScreenToClient(hwnd, &cursorPos);
2cc220c7e899 Fixed large relative mouse motion when iconifying the SDL window.
Sam Lantinga <slouken@libsdl.org>
parents: 7975
diff changeset
   530
                SDL_SendMouseMotion(data->window, 0, 0, cursorPos.x, cursorPos.y);
2cc220c7e899 Fixed large relative mouse motion when iconifying the SDL window.
Sam Lantinga <slouken@libsdl.org>
parents: 7975
diff changeset
   531
            }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   532
            SDL_SetMouseFocus(NULL);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   533
        }
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   534
        returnCode = 0;
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   535
        break;
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   536
#endif /* WM_MOUSELEAVE */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   537
7645
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   538
    case WM_KEYDOWN:
7646
42c3b0c24c6c The keyboard text events should be sent after the key down events
Sam Lantinga <slouken@libsdl.org>
parents: 7645
diff changeset
   539
    case WM_SYSKEYDOWN:
7645
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   540
        {
7646
42c3b0c24c6c The keyboard text events should be sent after the key down events
Sam Lantinga <slouken@libsdl.org>
parents: 7645
diff changeset
   541
            SDL_Scancode code = WindowsScanCodeToSDLScanCode( lParam, wParam );
42c3b0c24c6c The keyboard text events should be sent after the key down events
Sam Lantinga <slouken@libsdl.org>
parents: 7645
diff changeset
   542
            if ( code != SDL_SCANCODE_UNKNOWN ) {
42c3b0c24c6c The keyboard text events should be sent after the key down events
Sam Lantinga <slouken@libsdl.org>
parents: 7645
diff changeset
   543
                SDL_SendKeyboardKey(SDL_PRESSED, code );
42c3b0c24c6c The keyboard text events should be sent after the key down events
Sam Lantinga <slouken@libsdl.org>
parents: 7645
diff changeset
   544
            }
42c3b0c24c6c The keyboard text events should be sent after the key down events
Sam Lantinga <slouken@libsdl.org>
parents: 7645
diff changeset
   545
        }
42c3b0c24c6c The keyboard text events should be sent after the key down events
Sam Lantinga <slouken@libsdl.org>
parents: 7645
diff changeset
   546
        if (msg == WM_KEYDOWN) {
7645
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   547
            BYTE keyboardState[256];
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   548
            char text[5];
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   549
            UINT32 utf32 = 0;
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   550
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   551
            GetKeyboardState(keyboardState);
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   552
            if (ToUnicode(wParam, (lParam >> 16) & 0xff, keyboardState, (LPWSTR)&utf32, 1, 0) > 0) {
8071
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   553
                WORD repetition;
1ac2db4abe11 Added a relative mouse mode that uses mouse warping instead of raw input.
Sam Lantinga <slouken@libsdl.org>
parents: 8050
diff changeset
   554
                for (repetition = lParam & 0xffff; repetition > 0; repetition--) {
7645
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   555
                    WIN_ConvertUTF32toUTF8(utf32, text);
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   556
                    SDL_SendKeyboardText(text);
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   557
                }
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   558
            }
cc775832d501 Fixed bug 1876 - SDL_TEXTINPUT only returns '?' (0x3F) in event.text.text with Khmer language input
Sam Lantinga <slouken@libsdl.org>
parents: 7631
diff changeset
   559
        }
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   560
        returnCode = 0;
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   561
        break;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   562
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   563
    case WM_SYSKEYUP:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   564
    case WM_KEYUP:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   565
        {
6938
b272d47f70a7 Cleaned up and fixed the Windows keyboard mapping code.
Sam Lantinga <slouken@libsdl.org>
parents: 6931
diff changeset
   566
            SDL_Scancode code = WindowsScanCodeToSDLScanCode( lParam, wParam );
7975
1b49b680f319 [Windows] Fixes bug #1555, handle ALT+F4 on Windows
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7941
diff changeset
   567
            const Uint8 *keyboardState = SDL_GetKeyboardState(NULL);
1b49b680f319 [Windows] Fixes bug #1555, handle ALT+F4 on Windows
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7941
diff changeset
   568
1b49b680f319 [Windows] Fixes bug #1555, handle ALT+F4 on Windows
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7941
diff changeset
   569
            /* Detect relevant keyboard shortcuts */
1b49b680f319 [Windows] Fixes bug #1555, handle ALT+F4 on Windows
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7941
diff changeset
   570
            if (keyboardState[SDL_SCANCODE_LALT] == SDL_PRESSED || keyboardState[SDL_SCANCODE_RALT] == SDL_PRESSED ) {
8218
cf153cc95173 Make sure we don't stay in the windows event loop forever if there are lots of events coming in quickly.
Sam Lantinga <slouken@libsdl.org>
parents: 8212
diff changeset
   571
                /* ALT+F4: Close window */
cf153cc95173 Make sure we don't stay in the windows event loop forever if there are lots of events coming in quickly.
Sam Lantinga <slouken@libsdl.org>
parents: 8212
diff changeset
   572
                if (code == SDL_SCANCODE_F4) {
cf153cc95173 Make sure we don't stay in the windows event loop forever if there are lots of events coming in quickly.
Sam Lantinga <slouken@libsdl.org>
parents: 8212
diff changeset
   573
                    SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0);
cf153cc95173 Make sure we don't stay in the windows event loop forever if there are lots of events coming in quickly.
Sam Lantinga <slouken@libsdl.org>
parents: 8212
diff changeset
   574
                }
7975
1b49b680f319 [Windows] Fixes bug #1555, handle ALT+F4 on Windows
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7941
diff changeset
   575
            }
1b49b680f319 [Windows] Fixes bug #1555, handle ALT+F4 on Windows
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7941
diff changeset
   576
6938
b272d47f70a7 Cleaned up and fixed the Windows keyboard mapping code.
Sam Lantinga <slouken@libsdl.org>
parents: 6931
diff changeset
   577
            if ( code != SDL_SCANCODE_UNKNOWN ) {
b272d47f70a7 Cleaned up and fixed the Windows keyboard mapping code.
Sam Lantinga <slouken@libsdl.org>
parents: 6931
diff changeset
   578
                if (code == SDL_SCANCODE_PRINTSCREEN &&
7975
1b49b680f319 [Windows] Fixes bug #1555, handle ALT+F4 on Windows
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7941
diff changeset
   579
                    keyboardState[code] == SDL_RELEASED) {
6938
b272d47f70a7 Cleaned up and fixed the Windows keyboard mapping code.
Sam Lantinga <slouken@libsdl.org>
parents: 6931
diff changeset
   580
                    SDL_SendKeyboardKey(SDL_PRESSED, code);
b272d47f70a7 Cleaned up and fixed the Windows keyboard mapping code.
Sam Lantinga <slouken@libsdl.org>
parents: 6931
diff changeset
   581
                }
b272d47f70a7 Cleaned up and fixed the Windows keyboard mapping code.
Sam Lantinga <slouken@libsdl.org>
parents: 6931
diff changeset
   582
                SDL_SendKeyboardKey(SDL_RELEASED, code);
2308
514f7c1651fc Untested Win32 keyboard scancode code.
Sam Lantinga <slouken@libsdl.org>
parents: 2284
diff changeset
   583
            }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   584
        }
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   585
        returnCode = 0;
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   586
        break;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   587
8143
ce90b743882a Document Michael's changes adding TranslateMessage() back to the SDL message loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8142
diff changeset
   588
    case WM_UNICHAR:
ce90b743882a Document Michael's changes adding TranslateMessage() back to the SDL message loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8142
diff changeset
   589
    case WM_CHAR:
ce90b743882a Document Michael's changes adding TranslateMessage() back to the SDL message loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8142
diff changeset
   590
        /* Ignore WM_CHAR messages that come from TranslateMessage(), since we handle WM_KEY* messages directly */
ce90b743882a Document Michael's changes adding TranslateMessage() back to the SDL message loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8142
diff changeset
   591
        returnCode = 0;
ce90b743882a Document Michael's changes adding TranslateMessage() back to the SDL message loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8142
diff changeset
   592
        break;
ce90b743882a Document Michael's changes adding TranslateMessage() back to the SDL message loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8142
diff changeset
   593
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   594
#ifdef WM_INPUTLANGCHANGE
2311
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2310
diff changeset
   595
    case WM_INPUTLANGCHANGE:
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2310
diff changeset
   596
        {
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 4429
diff changeset
   597
            WIN_UpdateKeymap();
2311
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2310
diff changeset
   598
        }
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   599
        returnCode = 1;
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   600
        break;
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   601
#endif /* WM_INPUTLANGCHANGE */
2311
54e21acfec5a Friggin' Windows remaps alphabetic keys based on keyboard layout.
Sam Lantinga <slouken@libsdl.org>
parents: 2310
diff changeset
   602
8253
75ad8ebb3768 Make sure we don't clip the cursor while clicking on the window title bar
Sam Lantinga <slouken@libsdl.org>
parents: 8218
diff changeset
   603
    case WM_NCLBUTTONDOWN:
75ad8ebb3768 Make sure we don't clip the cursor while clicking on the window title bar
Sam Lantinga <slouken@libsdl.org>
parents: 8218
diff changeset
   604
        {
75ad8ebb3768 Make sure we don't clip the cursor while clicking on the window title bar
Sam Lantinga <slouken@libsdl.org>
parents: 8218
diff changeset
   605
            data->in_title_click = SDL_TRUE;
75ad8ebb3768 Make sure we don't clip the cursor while clicking on the window title bar
Sam Lantinga <slouken@libsdl.org>
parents: 8218
diff changeset
   606
            WIN_UpdateClipCursor(data->window);
75ad8ebb3768 Make sure we don't clip the cursor while clicking on the window title bar
Sam Lantinga <slouken@libsdl.org>
parents: 8218
diff changeset
   607
        }
75ad8ebb3768 Make sure we don't clip the cursor while clicking on the window title bar
Sam Lantinga <slouken@libsdl.org>
parents: 8218
diff changeset
   608
        break;
75ad8ebb3768 Make sure we don't clip the cursor while clicking on the window title bar
Sam Lantinga <slouken@libsdl.org>
parents: 8218
diff changeset
   609
75ad8ebb3768 Make sure we don't clip the cursor while clicking on the window title bar
Sam Lantinga <slouken@libsdl.org>
parents: 8218
diff changeset
   610
    case WM_NCMOUSELEAVE:
75ad8ebb3768 Make sure we don't clip the cursor while clicking on the window title bar
Sam Lantinga <slouken@libsdl.org>
parents: 8218
diff changeset
   611
        {
75ad8ebb3768 Make sure we don't clip the cursor while clicking on the window title bar
Sam Lantinga <slouken@libsdl.org>
parents: 8218
diff changeset
   612
            data->in_title_click = SDL_FALSE;
75ad8ebb3768 Make sure we don't clip the cursor while clicking on the window title bar
Sam Lantinga <slouken@libsdl.org>
parents: 8218
diff changeset
   613
            WIN_UpdateClipCursor(data->window);
75ad8ebb3768 Make sure we don't clip the cursor while clicking on the window title bar
Sam Lantinga <slouken@libsdl.org>
parents: 8218
diff changeset
   614
        }
75ad8ebb3768 Make sure we don't clip the cursor while clicking on the window title bar
Sam Lantinga <slouken@libsdl.org>
parents: 8218
diff changeset
   615
        break;
75ad8ebb3768 Make sure we don't clip the cursor while clicking on the window title bar
Sam Lantinga <slouken@libsdl.org>
parents: 8218
diff changeset
   616
8036
d485906bd74a Fixed bug 2260 - SDL_SetCursorGrab() is buggy on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 8035
diff changeset
   617
    case WM_ENTERSIZEMOVE:
d485906bd74a Fixed bug 2260 - SDL_SetCursorGrab() is buggy on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 8035
diff changeset
   618
    case WM_ENTERMENULOOP:
d485906bd74a Fixed bug 2260 - SDL_SetCursorGrab() is buggy on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 8035
diff changeset
   619
        {
d485906bd74a Fixed bug 2260 - SDL_SetCursorGrab() is buggy on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 8035
diff changeset
   620
            data->in_modal_loop = SDL_TRUE;
d485906bd74a Fixed bug 2260 - SDL_SetCursorGrab() is buggy on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 8035
diff changeset
   621
            WIN_UpdateClipCursor(data->window);
d485906bd74a Fixed bug 2260 - SDL_SetCursorGrab() is buggy on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 8035
diff changeset
   622
        }
d485906bd74a Fixed bug 2260 - SDL_SetCursorGrab() is buggy on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 8035
diff changeset
   623
        break;
d485906bd74a Fixed bug 2260 - SDL_SetCursorGrab() is buggy on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 8035
diff changeset
   624
d485906bd74a Fixed bug 2260 - SDL_SetCursorGrab() is buggy on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 8035
diff changeset
   625
    case WM_EXITSIZEMOVE:
d485906bd74a Fixed bug 2260 - SDL_SetCursorGrab() is buggy on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 8035
diff changeset
   626
    case WM_EXITMENULOOP:
d485906bd74a Fixed bug 2260 - SDL_SetCursorGrab() is buggy on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 8035
diff changeset
   627
        {
d485906bd74a Fixed bug 2260 - SDL_SetCursorGrab() is buggy on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 8035
diff changeset
   628
            data->in_modal_loop = SDL_FALSE;
d485906bd74a Fixed bug 2260 - SDL_SetCursorGrab() is buggy on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 8035
diff changeset
   629
            WIN_UpdateClipCursor(data->window);
8212
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   630
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   631
            /* The mouse may have been released during the modal loop */
d278747da408 Fixed lost mouse button when in relative mouse warp mode and you click on the title bar, entering a modal move/resize loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   632
            WIN_CheckAsyncMouseRelease(data);
8036
d485906bd74a Fixed bug 2260 - SDL_SetCursorGrab() is buggy on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 8035
diff changeset
   633
        }
d485906bd74a Fixed bug 2260 - SDL_SetCursorGrab() is buggy on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 8035
diff changeset
   634
        break;
d485906bd74a Fixed bug 2260 - SDL_SetCursorGrab() is buggy on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 8035
diff changeset
   635
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   636
#ifdef WM_GETMINMAXINFO
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   637
    case WM_GETMINMAXINFO:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   638
        {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   639
            MINMAXINFO *info;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   640
            RECT size;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   641
            int x, y;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   642
            int w, h;
6682
a0cbe4e5a07a SetWindowMinimumSize Windows implementation
stopiccot
parents: 6523
diff changeset
   643
            int min_w, min_h;
6788
036f53f2f5aa Added SDL_SetWindowMaximumSize() and SDL_GetWindowMaximumSize()
Sam Lantinga <slouken@libsdl.org>
parents: 6782
diff changeset
   644
            int max_w, max_h;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   645
            int style;
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   646
            BOOL menu;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   647
            BOOL constrain_max_size;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   648
6682
a0cbe4e5a07a SetWindowMinimumSize Windows implementation
stopiccot
parents: 6523
diff changeset
   649
            if (SDL_IsShapedWindow(data->window))
4815
93402b9dd20c Added Andreas's patch to fix my silly C++-style errors.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4788
diff changeset
   650
                Win32_ResizeWindowShape(data->window);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   651
7941
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   652
            /* If this is an expected size change, allow it */
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   653
            if (data->expected_resize) {
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   654
                break;
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   655
            }
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   656
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   657
            /* Get the current position of our window */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   658
            GetWindowRect(hwnd, &size);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   659
            x = size.left;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   660
            y = size.top;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   661
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   662
            /* Calculate current size of our window */
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3566
diff changeset
   663
            SDL_GetWindowSize(data->window, &w, &h);
6682
a0cbe4e5a07a SetWindowMinimumSize Windows implementation
stopiccot
parents: 6523
diff changeset
   664
            SDL_GetWindowMinimumSize(data->window, &min_w, &min_h);
6788
036f53f2f5aa Added SDL_SetWindowMaximumSize() and SDL_GetWindowMaximumSize()
Sam Lantinga <slouken@libsdl.org>
parents: 6782
diff changeset
   665
            SDL_GetWindowMaximumSize(data->window, &max_w, &max_h);
6682
a0cbe4e5a07a SetWindowMinimumSize Windows implementation
stopiccot
parents: 6523
diff changeset
   666
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   667
            /* Store in min_w and min_h difference between current size and minimal
6682
a0cbe4e5a07a SetWindowMinimumSize Windows implementation
stopiccot
parents: 6523
diff changeset
   668
               size so we don't need to call AdjustWindowRectEx twice */
a0cbe4e5a07a SetWindowMinimumSize Windows implementation
stopiccot
parents: 6523
diff changeset
   669
            min_w -= w;
a0cbe4e5a07a SetWindowMinimumSize Windows implementation
stopiccot
parents: 6523
diff changeset
   670
            min_h -= h;
6837
a69e10925a58 Fixed bug 1682 - Resize collapses window instantly to a size of 0 x 124.
Sam Lantinga <slouken@libsdl.org>
parents: 6788
diff changeset
   671
            if (max_w && max_h) {
a69e10925a58 Fixed bug 1682 - Resize collapses window instantly to a size of 0 x 124.
Sam Lantinga <slouken@libsdl.org>
parents: 6788
diff changeset
   672
                max_w -= w;
a69e10925a58 Fixed bug 1682 - Resize collapses window instantly to a size of 0 x 124.
Sam Lantinga <slouken@libsdl.org>
parents: 6788
diff changeset
   673
                max_h -= h;
6862
d189a1e771fe Fixed increasing the size of resizable windows
Sam Lantinga <slouken@libsdl.org>
parents: 6861
diff changeset
   674
                constrain_max_size = TRUE;
d189a1e771fe Fixed increasing the size of resizable windows
Sam Lantinga <slouken@libsdl.org>
parents: 6861
diff changeset
   675
            } else {
d189a1e771fe Fixed increasing the size of resizable windows
Sam Lantinga <slouken@libsdl.org>
parents: 6861
diff changeset
   676
                constrain_max_size = FALSE;
6837
a69e10925a58 Fixed bug 1682 - Resize collapses window instantly to a size of 0 x 124.
Sam Lantinga <slouken@libsdl.org>
parents: 6788
diff changeset
   677
            }
6682
a0cbe4e5a07a SetWindowMinimumSize Windows implementation
stopiccot
parents: 6523
diff changeset
   678
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   679
            size.top = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   680
            size.left = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   681
            size.bottom = h;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   682
            size.right = w;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   683
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   684
            style = GetWindowLong(hwnd, GWL_STYLE);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   685
            /* DJM - according to the docs for GetMenu(), the
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   686
               return value is undefined if hwnd is a child window.
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   687
               Aparently it's too difficult for MS to check
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   688
               inside their function, so I have to do it here.
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   689
             */
3168
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   690
            menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
   691
            AdjustWindowRectEx(&size, style, menu, 0);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   692
            w = size.right - size.left;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   693
            h = size.bottom - size.top;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   694
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   695
            /* Fix our size to the current size */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   696
            info = (MINMAXINFO *) lParam;
6682
a0cbe4e5a07a SetWindowMinimumSize Windows implementation
stopiccot
parents: 6523
diff changeset
   697
            if (SDL_GetWindowFlags(data->window) & SDL_WINDOW_RESIZABLE) {
a0cbe4e5a07a SetWindowMinimumSize Windows implementation
stopiccot
parents: 6523
diff changeset
   698
                info->ptMinTrackSize.x = w + min_w;
a0cbe4e5a07a SetWindowMinimumSize Windows implementation
stopiccot
parents: 6523
diff changeset
   699
                info->ptMinTrackSize.y = h + min_h;
6862
d189a1e771fe Fixed increasing the size of resizable windows
Sam Lantinga <slouken@libsdl.org>
parents: 6861
diff changeset
   700
                if (constrain_max_size) {
d189a1e771fe Fixed increasing the size of resizable windows
Sam Lantinga <slouken@libsdl.org>
parents: 6861
diff changeset
   701
                    info->ptMaxTrackSize.x = w + max_w;
d189a1e771fe Fixed increasing the size of resizable windows
Sam Lantinga <slouken@libsdl.org>
parents: 6861
diff changeset
   702
                    info->ptMaxTrackSize.y = h + max_h;
d189a1e771fe Fixed increasing the size of resizable windows
Sam Lantinga <slouken@libsdl.org>
parents: 6861
diff changeset
   703
                }
6682
a0cbe4e5a07a SetWindowMinimumSize Windows implementation
stopiccot
parents: 6523
diff changeset
   704
            } else {
a0cbe4e5a07a SetWindowMinimumSize Windows implementation
stopiccot
parents: 6523
diff changeset
   705
                info->ptMaxSize.x = w;
a0cbe4e5a07a SetWindowMinimumSize Windows implementation
stopiccot
parents: 6523
diff changeset
   706
                info->ptMaxSize.y = h;
a0cbe4e5a07a SetWindowMinimumSize Windows implementation
stopiccot
parents: 6523
diff changeset
   707
                info->ptMaxPosition.x = x;
a0cbe4e5a07a SetWindowMinimumSize Windows implementation
stopiccot
parents: 6523
diff changeset
   708
                info->ptMaxPosition.y = y;
a0cbe4e5a07a SetWindowMinimumSize Windows implementation
stopiccot
parents: 6523
diff changeset
   709
                info->ptMinTrackSize.x = w;
a0cbe4e5a07a SetWindowMinimumSize Windows implementation
stopiccot
parents: 6523
diff changeset
   710
                info->ptMinTrackSize.y = h;
a0cbe4e5a07a SetWindowMinimumSize Windows implementation
stopiccot
parents: 6523
diff changeset
   711
                info->ptMaxTrackSize.x = w;
a0cbe4e5a07a SetWindowMinimumSize Windows implementation
stopiccot
parents: 6523
diff changeset
   712
                info->ptMaxTrackSize.y = h;
a0cbe4e5a07a SetWindowMinimumSize Windows implementation
stopiccot
parents: 6523
diff changeset
   713
            }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   714
        }
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   715
        returnCode = 0;
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   716
        break;
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   717
#endif /* WM_GETMINMAXINFO */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   718
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   719
    case WM_WINDOWPOSCHANGED:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   720
        {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   721
            RECT rect;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   722
            int x, y;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   723
            int w, h;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   724
8036
d485906bd74a Fixed bug 2260 - SDL_SetCursorGrab() is buggy on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 8035
diff changeset
   725
            if (!GetClientRect(hwnd, &rect) || IsRectEmpty(&rect)) {
3256
83c87f2b2aab Fixed bug where minimized windows get zero width/height
Sam Lantinga <slouken@libsdl.org>
parents: 3253
diff changeset
   726
                break;
83c87f2b2aab Fixed bug where minimized windows get zero width/height
Sam Lantinga <slouken@libsdl.org>
parents: 3253
diff changeset
   727
            }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   728
            ClientToScreen(hwnd, (LPPOINT) & rect);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   729
            ClientToScreen(hwnd, (LPPOINT) & rect + 1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   730
8036
d485906bd74a Fixed bug 2260 - SDL_SetCursorGrab() is buggy on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 8035
diff changeset
   731
            WIN_UpdateClipCursor(data->window);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   732
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   733
            x = rect.left;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   734
            y = rect.top;
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3566
diff changeset
   735
            SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MOVED, x, y);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   736
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   737
            w = rect.right - rect.left;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   738
            h = rect.bottom - rect.top;
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3566
diff changeset
   739
            SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESIZED, w,
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   740
                                h);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   741
        }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   742
        break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   743
7941
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   744
    case WM_SIZE:
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   745
        {
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   746
            switch (wParam)
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   747
            {
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   748
            case SIZE_MAXIMIZED:
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   749
                SDL_SendWindowEvent(data->window,
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   750
                    SDL_WINDOWEVENT_MAXIMIZED, 0, 0);
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   751
                break;
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   752
            case SIZE_MINIMIZED:
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   753
                SDL_SendWindowEvent(data->window,
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   754
                    SDL_WINDOWEVENT_MINIMIZED, 0, 0);
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   755
                break;
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   756
            default:
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   757
                SDL_SendWindowEvent(data->window,
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   758
                    SDL_WINDOWEVENT_RESTORED, 0, 0);
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   759
                break;
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   760
            }
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   761
        }
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   762
        break;
7c249ca44069 Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 7912
diff changeset
   763
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   764
    case WM_SETCURSOR:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   765
        {
3076
085e46423377 Use the default arrow cursor until we implement the cursor API
Sam Lantinga <slouken@libsdl.org>
parents: 3032
diff changeset
   766
            Uint16 hittest;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   767
3076
085e46423377 Use the default arrow cursor until we implement the cursor API
Sam Lantinga <slouken@libsdl.org>
parents: 3032
diff changeset
   768
            hittest = LOWORD(lParam);
085e46423377 Use the default arrow cursor until we implement the cursor API
Sam Lantinga <slouken@libsdl.org>
parents: 3032
diff changeset
   769
            if (hittest == HTCLIENT) {
5421
f8588afb6486 Added support for Windows cursors
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   770
                SetCursor(SDL_cursor);
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   771
                returnCode = TRUE;
3076
085e46423377 Use the default arrow cursor until we implement the cursor API
Sam Lantinga <slouken@libsdl.org>
parents: 3032
diff changeset
   772
            }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   773
        }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   774
        break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   775
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   776
        /* We were occluded, refresh our display */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   777
    case WM_PAINT:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   778
        {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   779
            RECT rect;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   780
            if (GetUpdateRect(hwnd, &rect, FALSE)) {
7295
737cc5bad795 Fixed bug 1897 - CPU spike on Windows with WM_EVENT and OpenGL
Sam Lantinga <slouken@libsdl.org>
parents: 7276
diff changeset
   781
                ValidateRect(hwnd, NULL);
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3566
diff changeset
   782
                SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_EXPOSED,
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   783
                                    0, 0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   784
            }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   785
        }
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   786
        returnCode = 0;
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   787
        break;
3095
75483112b97f Date: Sat, 21 Mar 2009 19:41:52 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 3076
diff changeset
   788
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   789
        /* We'll do our own drawing, prevent flicker */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   790
    case WM_ERASEBKGND:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   791
        {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   792
        }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   793
        return (1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   794
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   795
#if defined(SC_SCREENSAVE) || defined(SC_MONITORPOWER)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   796
    case WM_SYSCOMMAND:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   797
        {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   798
            /* Don't start the screensaver or blank the monitor in fullscreen apps */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   799
            if ((wParam & 0xFFF0) == SC_SCREENSAVE ||
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   800
                (wParam & 0xFFF0) == SC_MONITORPOWER) {
3032
77c3e67f0740 Fixed Visual C++ build
Sam Lantinga <slouken@libsdl.org>
parents: 3025
diff changeset
   801
                if (SDL_GetVideoDevice()->suspend_screensaver) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   802
                    return (0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   803
                }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   804
            }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   805
        }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   806
        break;
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   807
#endif /* System has screensaver support */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   808
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   809
    case WM_CLOSE:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   810
        {
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3566
diff changeset
   811
            SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   812
        }
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   813
        returnCode = 0;
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   814
        break;
4919
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
   815
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   816
    case WM_TOUCH:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   817
        {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   818
            UINT i, num_inputs = LOWORD(wParam);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   819
            PTOUCHINPUT inputs = SDL_stack_alloc(TOUCHINPUT, num_inputs);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   820
            if (data->videodata->GetTouchInputInfo((HTOUCHINPUT)lParam, num_inputs, inputs, sizeof(TOUCHINPUT))) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   821
                RECT rect;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   822
                float x, y;
4919
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
   823
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   824
                if (!GetClientRect(hwnd, &rect) ||
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   825
                    (rect.right == rect.left && rect.bottom == rect.top)) {
7631
9fcda7425ccc Added missing call to SDL_stack_free().
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7561
diff changeset
   826
                    if (inputs) {
9fcda7425ccc Added missing call to SDL_stack_free().
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7561
diff changeset
   827
                        SDL_stack_free(inputs);
9fcda7425ccc Added missing call to SDL_stack_free().
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7561
diff changeset
   828
                    }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   829
                    break;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   830
                }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   831
                ClientToScreen(hwnd, (LPPOINT) & rect);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   832
                ClientToScreen(hwnd, (LPPOINT) & rect + 1);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   833
                rect.top *= 100;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   834
                rect.left *= 100;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   835
                rect.bottom *= 100;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   836
                rect.right *= 100;
4932
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
   837
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   838
                for (i = 0; i < num_inputs; ++i) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   839
                    PTOUCHINPUT input = &inputs[i];
4919
716b2cbf4c9e First pass at Windows multi-touch gesture support
Sam Lantinga <slouken@libsdl.org>
parents: 4902
diff changeset
   840
7543
a96f309059a1 Attempt to fix compiler warning.
Ryan C. Gordon <icculus@icculus.org>
parents: 7295
diff changeset
   841
                    const SDL_TouchID touchId = (SDL_TouchID)((size_t)input->hSource);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   842
                    if (!SDL_GetTouch(touchId)) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   843
                        if (SDL_AddTouch(touchId, "") < 0) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   844
                            continue;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   845
                        }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   846
                    }
4932
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
   847
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   848
                    /* Get the normalized coordinates for the window */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   849
                    x = (float)(input->x - rect.left)/(rect.right - rect.left);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   850
                    y = (float)(input->y - rect.top)/(rect.bottom - rect.top);
4932
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
   851
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   852
                    if (input->dwFlags & TOUCHEVENTF_DOWN) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   853
                        SDL_SendTouch(touchId, input->dwID, SDL_TRUE, x, y, 1.0f);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   854
                    }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   855
                    if (input->dwFlags & TOUCHEVENTF_MOVE) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   856
                        SDL_SendTouchMotion(touchId, input->dwID, x, y, 1.0f);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   857
                    }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   858
                    if (input->dwFlags & TOUCHEVENTF_UP) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   859
                        SDL_SendTouch(touchId, input->dwID, SDL_FALSE, x, y, 1.0f);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   860
                    }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   861
                }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   862
            }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   863
            SDL_stack_free(inputs);
4932
0d1bb1ce9d15 Removed carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4919
diff changeset
   864
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   865
            data->videodata->CloseTouchInputHandle((HTOUCHINPUT)lParam);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   866
            return 0;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   867
        }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7089
diff changeset
   868
        break;
6523
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
   869
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
   870
    case WM_DROPFILES:
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
   871
        {
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
   872
            UINT i;
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
   873
            HDROP drop = (HDROP) wParam;
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
   874
            UINT count = DragQueryFile(drop, 0xFFFFFFFF, NULL, 0);
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
   875
            for (i = 0; i < count; ++i) {
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
   876
                UINT size = DragQueryFile(drop, i, NULL, 0) + 1;
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
   877
                LPTSTR buffer = SDL_stack_alloc(TCHAR, size);
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
   878
                if (buffer) {
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
   879
                    if (DragQueryFile(drop, i, buffer, size)) {
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
   880
                        char *file = WIN_StringToUTF8(buffer);
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
   881
                        SDL_SendDropFile(file);
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
   882
                        SDL_free(file);
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
   883
                    }
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
   884
                    SDL_stack_free(buffer);
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
   885
                }
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
   886
            }
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
   887
            DragFinish(drop);
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
   888
            return 0;
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
   889
        }
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
   890
        break;
8938
c73bac338b90 First shot (not even compiled) at Windows hit-testing support.
Ryan C. Gordon <icculus@icculus.org>
parents: 8713
diff changeset
   891
c73bac338b90 First shot (not even compiled) at Windows hit-testing support.
Ryan C. Gordon <icculus@icculus.org>
parents: 8713
diff changeset
   892
    case WM_NCHITTEST:
c73bac338b90 First shot (not even compiled) at Windows hit-testing support.
Ryan C. Gordon <icculus@icculus.org>
parents: 8713
diff changeset
   893
        {
c73bac338b90 First shot (not even compiled) at Windows hit-testing support.
Ryan C. Gordon <icculus@icculus.org>
parents: 8713
diff changeset
   894
            SDL_Window *window = data->window;
c73bac338b90 First shot (not even compiled) at Windows hit-testing support.
Ryan C. Gordon <icculus@icculus.org>
parents: 8713
diff changeset
   895
            if (window->hit_test) {
8941
9229a54e4952 Fixed hit-testing on Windows.
Ryan C. Gordon <icculus@icculus.org>
parents: 8938
diff changeset
   896
                POINT winpoint = { (int) LOWORD(lParam), (int) HIWORD(lParam) };
9229a54e4952 Fixed hit-testing on Windows.
Ryan C. Gordon <icculus@icculus.org>
parents: 8938
diff changeset
   897
                if (ScreenToClient(data->hwnd, &winpoint)) {
9229a54e4952 Fixed hit-testing on Windows.
Ryan C. Gordon <icculus@icculus.org>
parents: 8938
diff changeset
   898
                    const SDL_Point point = { (int) winpoint.x, (int) winpoint.y };
9229a54e4952 Fixed hit-testing on Windows.
Ryan C. Gordon <icculus@icculus.org>
parents: 8938
diff changeset
   899
                    const SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data);
8948
3ed9a59efda1 Wired up Windows resize hit testing.
Ryan C. Gordon <icculus@icculus.org>
parents: 8942
diff changeset
   900
                    switch (rc) {
3ed9a59efda1 Wired up Windows resize hit testing.
Ryan C. Gordon <icculus@icculus.org>
parents: 8942
diff changeset
   901
                        case SDL_HITTEST_DRAGGABLE: return HTCAPTION;
3ed9a59efda1 Wired up Windows resize hit testing.
Ryan C. Gordon <icculus@icculus.org>
parents: 8942
diff changeset
   902
                        case SDL_HITTEST_RESIZE_TOPLEFT: return HTTOPLEFT;
3ed9a59efda1 Wired up Windows resize hit testing.
Ryan C. Gordon <icculus@icculus.org>
parents: 8942
diff changeset
   903
                        case SDL_HITTEST_RESIZE_TOP: return HTTOP;
3ed9a59efda1 Wired up Windows resize hit testing.
Ryan C. Gordon <icculus@icculus.org>
parents: 8942
diff changeset
   904
                        case SDL_HITTEST_RESIZE_TOPRIGHT: return HTTOPRIGHT;
3ed9a59efda1 Wired up Windows resize hit testing.
Ryan C. Gordon <icculus@icculus.org>
parents: 8942
diff changeset
   905
                        case SDL_HITTEST_RESIZE_RIGHT: return HTRIGHT;
3ed9a59efda1 Wired up Windows resize hit testing.
Ryan C. Gordon <icculus@icculus.org>
parents: 8942
diff changeset
   906
                        case SDL_HITTEST_RESIZE_BOTTOMRIGHT: return HTBOTTOMRIGHT;
3ed9a59efda1 Wired up Windows resize hit testing.
Ryan C. Gordon <icculus@icculus.org>
parents: 8942
diff changeset
   907
                        case SDL_HITTEST_RESIZE_BOTTOM: return HTBOTTOM;
3ed9a59efda1 Wired up Windows resize hit testing.
Ryan C. Gordon <icculus@icculus.org>
parents: 8942
diff changeset
   908
                        case SDL_HITTEST_RESIZE_BOTTOMLEFT: return HTBOTTOMLEFT;
3ed9a59efda1 Wired up Windows resize hit testing.
Ryan C. Gordon <icculus@icculus.org>
parents: 8942
diff changeset
   909
                        case SDL_HITTEST_RESIZE_LEFT: return HTLEFT;
8941
9229a54e4952 Fixed hit-testing on Windows.
Ryan C. Gordon <icculus@icculus.org>
parents: 8938
diff changeset
   910
                    }
8938
c73bac338b90 First shot (not even compiled) at Windows hit-testing support.
Ryan C. Gordon <icculus@icculus.org>
parents: 8713
diff changeset
   911
                }
8948
3ed9a59efda1 Wired up Windows resize hit testing.
Ryan C. Gordon <icculus@icculus.org>
parents: 8942
diff changeset
   912
                /* If we didn't return, this will call DefWindowProc below. */
8938
c73bac338b90 First shot (not even compiled) at Windows hit-testing support.
Ryan C. Gordon <icculus@icculus.org>
parents: 8713
diff changeset
   913
            }
c73bac338b90 First shot (not even compiled) at Windows hit-testing support.
Ryan C. Gordon <icculus@icculus.org>
parents: 8713
diff changeset
   914
        }
c73bac338b90 First shot (not even compiled) at Windows hit-testing support.
Ryan C. Gordon <icculus@icculus.org>
parents: 8713
diff changeset
   915
        break;
c73bac338b90 First shot (not even compiled) at Windows hit-testing support.
Ryan C. Gordon <icculus@icculus.org>
parents: 8713
diff changeset
   916
6523
62d0193a7a02 Fixed bug 1593 - SDL_DROPFILE event doesn't work on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6430
diff changeset
   917
    }
3566
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   918
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   919
    /* If there's a window proc, assume it's going to handle messages */
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   920
    if (data->wndproc) {
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   921
        return CallWindowProc(data->wndproc, hwnd, msg, wParam, lParam);
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   922
    } else if (returnCode >= 0) {
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   923
        return returnCode;
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   924
    } else {
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   925
        return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam);
07c8339c95c6 Fixed bug #905
Sam Lantinga <slouken@libsdl.org>
parents: 3565
diff changeset
   926
    }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   927
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   928
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   929
void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   930
WIN_PumpEvents(_THIS)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   931
{
7561
65f2b183e2aa Windows: Unstick shift keys in a timely manner when the OS loses a KEYUP event.
Ryan C. Gordon <icculus@icculus.org>
parents: 7543
diff changeset
   932
    const Uint8 *keystate;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   933
    MSG msg;
8218
cf153cc95173 Make sure we don't stay in the windows event loop forever if there are lots of events coming in quickly.
Sam Lantinga <slouken@libsdl.org>
parents: 8212
diff changeset
   934
    DWORD start_ticks = GetTickCount();
cf153cc95173 Make sure we don't stay in the windows event loop forever if there are lots of events coming in quickly.
Sam Lantinga <slouken@libsdl.org>
parents: 8212
diff changeset
   935
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   936
    while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
8143
ce90b743882a Document Michael's changes adding TranslateMessage() back to the SDL message loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8142
diff changeset
   937
        /* Always translate the message in case it's a non-SDL window (e.g. with Qt integration) */
ce90b743882a Document Michael's changes adding TranslateMessage() back to the SDL message loop.
Sam Lantinga <slouken@libsdl.org>
parents: 8142
diff changeset
   938
        TranslateMessage(&msg);
8218
cf153cc95173 Make sure we don't stay in the windows event loop forever if there are lots of events coming in quickly.
Sam Lantinga <slouken@libsdl.org>
parents: 8212
diff changeset
   939
        DispatchMessage( &msg );
cf153cc95173 Make sure we don't stay in the windows event loop forever if there are lots of events coming in quickly.
Sam Lantinga <slouken@libsdl.org>
parents: 8212
diff changeset
   940
cf153cc95173 Make sure we don't stay in the windows event loop forever if there are lots of events coming in quickly.
Sam Lantinga <slouken@libsdl.org>
parents: 8212
diff changeset
   941
        /* Make sure we don't busy loop here forever if there are lots of events coming in */
cf153cc95173 Make sure we don't stay in the windows event loop forever if there are lots of events coming in quickly.
Sam Lantinga <slouken@libsdl.org>
parents: 8212
diff changeset
   942
        if (SDL_TICKS_PASSED(msg.time, start_ticks)) {
cf153cc95173 Make sure we don't stay in the windows event loop forever if there are lots of events coming in quickly.
Sam Lantinga <slouken@libsdl.org>
parents: 8212
diff changeset
   943
            break;
cf153cc95173 Make sure we don't stay in the windows event loop forever if there are lots of events coming in quickly.
Sam Lantinga <slouken@libsdl.org>
parents: 8212
diff changeset
   944
        }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   945
    }
7561
65f2b183e2aa Windows: Unstick shift keys in a timely manner when the OS loses a KEYUP event.
Ryan C. Gordon <icculus@icculus.org>
parents: 7543
diff changeset
   946
65f2b183e2aa Windows: Unstick shift keys in a timely manner when the OS loses a KEYUP event.
Ryan C. Gordon <icculus@icculus.org>
parents: 7543
diff changeset
   947
    /* Windows loses a shift KEYUP event when you have both pressed at once and let go of one.
65f2b183e2aa Windows: Unstick shift keys in a timely manner when the OS loses a KEYUP event.
Ryan C. Gordon <icculus@icculus.org>
parents: 7543
diff changeset
   948
       You won't get a KEYUP until both are released, and that keyup will only be for the second
65f2b183e2aa Windows: Unstick shift keys in a timely manner when the OS loses a KEYUP event.
Ryan C. Gordon <icculus@icculus.org>
parents: 7543
diff changeset
   949
       key you released. Take heroic measures and check the keystate as of the last handled event,
65f2b183e2aa Windows: Unstick shift keys in a timely manner when the OS loses a KEYUP event.
Ryan C. Gordon <icculus@icculus.org>
parents: 7543
diff changeset
   950
       and if we think a key is pressed when Windows doesn't, unstick it in SDL's state. */
65f2b183e2aa Windows: Unstick shift keys in a timely manner when the OS loses a KEYUP event.
Ryan C. Gordon <icculus@icculus.org>
parents: 7543
diff changeset
   951
    keystate = SDL_GetKeyboardState(NULL);
65f2b183e2aa Windows: Unstick shift keys in a timely manner when the OS loses a KEYUP event.
Ryan C. Gordon <icculus@icculus.org>
parents: 7543
diff changeset
   952
    if ((keystate[SDL_SCANCODE_LSHIFT] == SDL_PRESSED) && !(GetKeyState(VK_LSHIFT) & 0x8000)) {
65f2b183e2aa Windows: Unstick shift keys in a timely manner when the OS loses a KEYUP event.
Ryan C. Gordon <icculus@icculus.org>
parents: 7543
diff changeset
   953
        SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
65f2b183e2aa Windows: Unstick shift keys in a timely manner when the OS loses a KEYUP event.
Ryan C. Gordon <icculus@icculus.org>
parents: 7543
diff changeset
   954
    }
65f2b183e2aa Windows: Unstick shift keys in a timely manner when the OS loses a KEYUP event.
Ryan C. Gordon <icculus@icculus.org>
parents: 7543
diff changeset
   955
    if ((keystate[SDL_SCANCODE_RSHIFT] == SDL_PRESSED) && !(GetKeyState(VK_RSHIFT) & 0x8000)) {
65f2b183e2aa Windows: Unstick shift keys in a timely manner when the OS loses a KEYUP event.
Ryan C. Gordon <icculus@icculus.org>
parents: 7543
diff changeset
   956
        SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RSHIFT);
65f2b183e2aa Windows: Unstick shift keys in a timely manner when the OS loses a KEYUP event.
Ryan C. Gordon <icculus@icculus.org>
parents: 7543
diff changeset
   957
    }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   958
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   959
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   960
static int app_registered = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   961
LPTSTR SDL_Appname = NULL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   962
Uint32 SDL_Appstyle = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   963
HINSTANCE SDL_Instance = NULL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   964
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   965
/* Register the class for this application */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   966
int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   967
SDL_RegisterApp(char *name, Uint32 style, void *hInst)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   968
{
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   969
    WNDCLASS class;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   970
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   971
    /* Only do this once... */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   972
    if (app_registered) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   973
        ++app_registered;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   974
        return (0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   975
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   976
    if (!name && !SDL_Appname) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   977
        name = "SDL_app";
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   978
#if defined(CS_BYTEALIGNCLIENT) || defined(CS_OWNDC)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   979
        SDL_Appstyle = (CS_BYTEALIGNCLIENT | CS_OWNDC);
5086
c2539ff054c8 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 5062
diff changeset
   980
#endif
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   981
        SDL_Instance = hInst ? hInst : GetModuleHandle(NULL);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   982
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   983
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   984
    if (name) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   985
        SDL_Appname = WIN_UTF8ToString(name);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   986
        SDL_Appstyle = style;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   987
        SDL_Instance = hInst ? hInst : GetModuleHandle(NULL);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   988
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   989
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   990
    /* Register the application class */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   991
    class.hCursor = NULL;
2710
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2324
diff changeset
   992
    class.hIcon =
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2324
diff changeset
   993
        LoadImage(SDL_Instance, SDL_Appname, IMAGE_ICON, 0, 0,
44e49d3fa6cf Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents: 2324
diff changeset
   994
                  LR_DEFAULTCOLOR);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   995
    class.lpszMenuName = NULL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   996
    class.lpszClassName = SDL_Appname;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   997
    class.hbrBackground = NULL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   998
    class.hInstance = SDL_Instance;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   999
    class.style = SDL_Appstyle;
4733
983eb9d5ed31 Change SDL to not use DefWindowProc as the window class' window procedure.
dewyatt
parents: 4429
diff changeset
  1000
    class.lpfnWndProc = WIN_WindowProc;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1001
    class.cbWndExtra = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1002
    class.cbClsExtra = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1003
    if (!RegisterClass(&class)) {
7037
3fedf1f25b94 Make SDL_SetError and friends unconditionally return -1.
Ryan C. Gordon <icculus@icculus.org>
parents: 7029
diff changeset
  1004
        return SDL_SetError("Couldn't register application class");
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1005
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1006
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1007
    app_registered = 1;
7037
3fedf1f25b94 Make SDL_SetError and friends unconditionally return -1.
Ryan C. Gordon <icculus@icculus.org>
parents: 7029
diff changeset
  1008
    return 0;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1009
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1010
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1011
/* Unregisters the windowclass registered in SDL_RegisterApp above. */