File style cleanup for the SDL 2.0 release

This commit is contained in:
Sam Lantinga 2013-05-18 14:17:52 -07:00
parent 2ac8624930
commit 0cb6385637
376 changed files with 17562 additions and 17773 deletions

View file

@ -20,57 +20,57 @@
*/
#ifndef VK_0
#define VK_0 '0'
#define VK_1 '1'
#define VK_2 '2'
#define VK_3 '3'
#define VK_4 '4'
#define VK_5 '5'
#define VK_6 '6'
#define VK_7 '7'
#define VK_8 '8'
#define VK_9 '9'
#define VK_A 'A'
#define VK_B 'B'
#define VK_C 'C'
#define VK_D 'D'
#define VK_E 'E'
#define VK_F 'F'
#define VK_G 'G'
#define VK_H 'H'
#define VK_I 'I'
#define VK_J 'J'
#define VK_K 'K'
#define VK_L 'L'
#define VK_M 'M'
#define VK_N 'N'
#define VK_O 'O'
#define VK_P 'P'
#define VK_Q 'Q'
#define VK_R 'R'
#define VK_S 'S'
#define VK_T 'T'
#define VK_U 'U'
#define VK_V 'V'
#define VK_W 'W'
#define VK_X 'X'
#define VK_Y 'Y'
#define VK_Z 'Z'
#define VK_0 '0'
#define VK_1 '1'
#define VK_2 '2'
#define VK_3 '3'
#define VK_4 '4'
#define VK_5 '5'
#define VK_6 '6'
#define VK_7 '7'
#define VK_8 '8'
#define VK_9 '9'
#define VK_A 'A'
#define VK_B 'B'
#define VK_C 'C'
#define VK_D 'D'
#define VK_E 'E'
#define VK_F 'F'
#define VK_G 'G'
#define VK_H 'H'
#define VK_I 'I'
#define VK_J 'J'
#define VK_K 'K'
#define VK_L 'L'
#define VK_M 'M'
#define VK_N 'N'
#define VK_O 'O'
#define VK_P 'P'
#define VK_Q 'Q'
#define VK_R 'R'
#define VK_S 'S'
#define VK_T 'T'
#define VK_U 'U'
#define VK_V 'V'
#define VK_W 'W'
#define VK_X 'X'
#define VK_Y 'Y'
#define VK_Z 'Z'
#endif /* VK_0 */
/* These keys haven't been defined, but were experimentally determined */
#define VK_SEMICOLON 0xBA
#define VK_EQUALS 0xBB
#define VK_COMMA 0xBC
#define VK_MINUS 0xBD
#define VK_PERIOD 0xBE
#define VK_SLASH 0xBF
#define VK_GRAVE 0xC0
#define VK_LBRACKET 0xDB
#define VK_BACKSLASH 0xDC
#define VK_RBRACKET 0xDD
#define VK_APOSTROPHE 0xDE
#define VK_BACKTICK 0xDF
#define VK_OEM_102 0xE2
#define VK_SEMICOLON 0xBA
#define VK_EQUALS 0xBB
#define VK_COMMA 0xBC
#define VK_MINUS 0xBD
#define VK_PERIOD 0xBE
#define VK_SLASH 0xBF
#define VK_GRAVE 0xC0
#define VK_LBRACKET 0xDB
#define VK_BACKSLASH 0xDC
#define VK_RBRACKET 0xDD
#define VK_APOSTROPHE 0xDE
#define VK_BACKTICK 0xDF
#define VK_OEM_102 0xE2
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -137,7 +137,7 @@ WIN_HasClipboardText(_THIS)
if (text) {
result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE;
SDL_free(text);
}
}
return result;
}

View file

@ -36,7 +36,7 @@
/*#define WMMSG_DEBUG*/
#ifdef WMMSG_DEBUG
#include <stdio.h>
#include <stdio.h>
#include "wmmsg.h"
#endif
@ -46,7 +46,7 @@
#define VK_ENTER 10 /* Keypad Enter ... no VKEY defined? */
#ifndef VK_OEM_NEC_EQUAL
#define VK_OEM_NEC_EQUAL 0x92
#define VK_OEM_NEC_EQUAL 0x92
#endif
/* Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... */
@ -66,192 +66,192 @@
#define WM_TOUCH 0x0240
#endif
static SDL_Scancode
static SDL_Scancode
WindowsScanCodeToSDLScanCode( LPARAM lParam, WPARAM wParam )
{
SDL_Scancode code;
char bIsExtended;
int nScanCode = ( lParam >> 16 ) & 0xFF;
SDL_Scancode code;
char bIsExtended;
int nScanCode = ( lParam >> 16 ) & 0xFF;
/* 0x45 here to work around both pause and numlock sharing the same scancode, so use the VK key to tell them apart */
if ( nScanCode == 0 || nScanCode == 0x45 )
{
switch( wParam )
{
case VK_CLEAR: return SDL_SCANCODE_CLEAR;
case VK_MODECHANGE: return SDL_SCANCODE_MODE;
case VK_SELECT: return SDL_SCANCODE_SELECT;
case VK_EXECUTE: return SDL_SCANCODE_EXECUTE;
case VK_HELP: return SDL_SCANCODE_HELP;
case VK_PAUSE: return SDL_SCANCODE_PAUSE;
case VK_NUMLOCK: return SDL_SCANCODE_NUMLOCKCLEAR;
/* 0x45 here to work around both pause and numlock sharing the same scancode, so use the VK key to tell them apart */
if ( nScanCode == 0 || nScanCode == 0x45 )
{
switch( wParam )
{
case VK_CLEAR: return SDL_SCANCODE_CLEAR;
case VK_MODECHANGE: return SDL_SCANCODE_MODE;
case VK_SELECT: return SDL_SCANCODE_SELECT;
case VK_EXECUTE: return SDL_SCANCODE_EXECUTE;
case VK_HELP: return SDL_SCANCODE_HELP;
case VK_PAUSE: return SDL_SCANCODE_PAUSE;
case VK_NUMLOCK: return SDL_SCANCODE_NUMLOCKCLEAR;
case VK_F13: return SDL_SCANCODE_F13;
case VK_F14: return SDL_SCANCODE_F14;
case VK_F15: return SDL_SCANCODE_F15;
case VK_F16: return SDL_SCANCODE_F16;
case VK_F17: return SDL_SCANCODE_F17;
case VK_F18: return SDL_SCANCODE_F18;
case VK_F19: return SDL_SCANCODE_F19;
case VK_F20: return SDL_SCANCODE_F20;
case VK_F21: return SDL_SCANCODE_F21;
case VK_F22: return SDL_SCANCODE_F22;
case VK_F23: return SDL_SCANCODE_F23;
case VK_F24: return SDL_SCANCODE_F24;
case VK_F13: return SDL_SCANCODE_F13;
case VK_F14: return SDL_SCANCODE_F14;
case VK_F15: return SDL_SCANCODE_F15;
case VK_F16: return SDL_SCANCODE_F16;
case VK_F17: return SDL_SCANCODE_F17;
case VK_F18: return SDL_SCANCODE_F18;
case VK_F19: return SDL_SCANCODE_F19;
case VK_F20: return SDL_SCANCODE_F20;
case VK_F21: return SDL_SCANCODE_F21;
case VK_F22: return SDL_SCANCODE_F22;
case VK_F23: return SDL_SCANCODE_F23;
case VK_F24: return SDL_SCANCODE_F24;
case VK_OEM_NEC_EQUAL: return SDL_SCANCODE_KP_EQUALS;
case VK_BROWSER_BACK: return SDL_SCANCODE_AC_BACK;
case VK_BROWSER_FORWARD: return SDL_SCANCODE_AC_FORWARD;
case VK_BROWSER_REFRESH: return SDL_SCANCODE_AC_REFRESH;
case VK_BROWSER_STOP: return SDL_SCANCODE_AC_STOP;
case VK_BROWSER_SEARCH: return SDL_SCANCODE_AC_SEARCH;
case VK_BROWSER_FAVORITES: return SDL_SCANCODE_AC_BOOKMARKS;
case VK_BROWSER_HOME: return SDL_SCANCODE_AC_HOME;
case VK_VOLUME_MUTE: return SDL_SCANCODE_AUDIOMUTE;
case VK_VOLUME_DOWN: return SDL_SCANCODE_VOLUMEDOWN;
case VK_VOLUME_UP: return SDL_SCANCODE_VOLUMEUP;
case VK_MEDIA_NEXT_TRACK: return SDL_SCANCODE_AUDIONEXT;
case VK_MEDIA_PREV_TRACK: return SDL_SCANCODE_AUDIOPREV;
case VK_MEDIA_STOP: return SDL_SCANCODE_AUDIOSTOP;
case VK_MEDIA_PLAY_PAUSE: return SDL_SCANCODE_AUDIOPLAY;
case VK_LAUNCH_MAIL: return SDL_SCANCODE_MAIL;
case VK_LAUNCH_MEDIA_SELECT: return SDL_SCANCODE_MEDIASELECT;
case VK_OEM_102: return SDL_SCANCODE_NONUSBACKSLASH;
case VK_OEM_NEC_EQUAL: return SDL_SCANCODE_KP_EQUALS;
case VK_BROWSER_BACK: return SDL_SCANCODE_AC_BACK;
case VK_BROWSER_FORWARD: return SDL_SCANCODE_AC_FORWARD;
case VK_BROWSER_REFRESH: return SDL_SCANCODE_AC_REFRESH;
case VK_BROWSER_STOP: return SDL_SCANCODE_AC_STOP;
case VK_BROWSER_SEARCH: return SDL_SCANCODE_AC_SEARCH;
case VK_BROWSER_FAVORITES: return SDL_SCANCODE_AC_BOOKMARKS;
case VK_BROWSER_HOME: return SDL_SCANCODE_AC_HOME;
case VK_VOLUME_MUTE: return SDL_SCANCODE_AUDIOMUTE;
case VK_VOLUME_DOWN: return SDL_SCANCODE_VOLUMEDOWN;
case VK_VOLUME_UP: return SDL_SCANCODE_VOLUMEUP;
case VK_ATTN: return SDL_SCANCODE_SYSREQ;
case VK_CRSEL: return SDL_SCANCODE_CRSEL;
case VK_EXSEL: return SDL_SCANCODE_EXSEL;
case VK_OEM_CLEAR: return SDL_SCANCODE_CLEAR;
case VK_MEDIA_NEXT_TRACK: return SDL_SCANCODE_AUDIONEXT;
case VK_MEDIA_PREV_TRACK: return SDL_SCANCODE_AUDIOPREV;
case VK_MEDIA_STOP: return SDL_SCANCODE_AUDIOSTOP;
case VK_MEDIA_PLAY_PAUSE: return SDL_SCANCODE_AUDIOPLAY;
case VK_LAUNCH_MAIL: return SDL_SCANCODE_MAIL;
case VK_LAUNCH_MEDIA_SELECT: return SDL_SCANCODE_MEDIASELECT;
case VK_LAUNCH_APP1: return SDL_SCANCODE_APP1;
case VK_LAUNCH_APP2: return SDL_SCANCODE_APP2;
case VK_OEM_102: return SDL_SCANCODE_NONUSBACKSLASH;
default: return SDL_SCANCODE_UNKNOWN;
}
}
case VK_ATTN: return SDL_SCANCODE_SYSREQ;
case VK_CRSEL: return SDL_SCANCODE_CRSEL;
case VK_EXSEL: return SDL_SCANCODE_EXSEL;
case VK_OEM_CLEAR: return SDL_SCANCODE_CLEAR;
if ( nScanCode > 127 )
return SDL_SCANCODE_UNKNOWN;
case VK_LAUNCH_APP1: return SDL_SCANCODE_APP1;
case VK_LAUNCH_APP2: return SDL_SCANCODE_APP2;
code = windows_scancode_table[nScanCode];
default: return SDL_SCANCODE_UNKNOWN;
}
}
bIsExtended = ( lParam & ( 1 << 24 ) ) != 0;
if ( !bIsExtended )
{
switch ( code )
{
case SDL_SCANCODE_HOME:
return SDL_SCANCODE_KP_7;
case SDL_SCANCODE_UP:
return SDL_SCANCODE_KP_8;
case SDL_SCANCODE_PAGEUP:
return SDL_SCANCODE_KP_9;
case SDL_SCANCODE_LEFT:
return SDL_SCANCODE_KP_4;
case SDL_SCANCODE_RIGHT:
return SDL_SCANCODE_KP_6;
case SDL_SCANCODE_END:
return SDL_SCANCODE_KP_1;
case SDL_SCANCODE_DOWN:
return SDL_SCANCODE_KP_2;
case SDL_SCANCODE_PAGEDOWN:
return SDL_SCANCODE_KP_3;
case SDL_SCANCODE_INSERT:
return SDL_SCANCODE_KP_0;
case SDL_SCANCODE_DELETE:
return SDL_SCANCODE_KP_PERIOD;
case SDL_SCANCODE_PRINTSCREEN:
return SDL_SCANCODE_KP_MULTIPLY;
default:
break;
}
}
else
{
switch ( code )
{
case SDL_SCANCODE_RETURN:
return SDL_SCANCODE_KP_ENTER;
case SDL_SCANCODE_LALT:
return SDL_SCANCODE_RALT;
case SDL_SCANCODE_LCTRL:
return SDL_SCANCODE_RCTRL;
case SDL_SCANCODE_SLASH:
return SDL_SCANCODE_KP_DIVIDE;
case SDL_SCANCODE_CAPSLOCK:
return SDL_SCANCODE_KP_PLUS;
if ( nScanCode > 127 )
return SDL_SCANCODE_UNKNOWN;
code = windows_scancode_table[nScanCode];
bIsExtended = ( lParam & ( 1 << 24 ) ) != 0;
if ( !bIsExtended )
{
switch ( code )
{
case SDL_SCANCODE_HOME:
return SDL_SCANCODE_KP_7;
case SDL_SCANCODE_UP:
return SDL_SCANCODE_KP_8;
case SDL_SCANCODE_PAGEUP:
return SDL_SCANCODE_KP_9;
case SDL_SCANCODE_LEFT:
return SDL_SCANCODE_KP_4;
case SDL_SCANCODE_RIGHT:
return SDL_SCANCODE_KP_6;
case SDL_SCANCODE_END:
return SDL_SCANCODE_KP_1;
case SDL_SCANCODE_DOWN:
return SDL_SCANCODE_KP_2;
case SDL_SCANCODE_PAGEDOWN:
return SDL_SCANCODE_KP_3;
case SDL_SCANCODE_INSERT:
return SDL_SCANCODE_KP_0;
case SDL_SCANCODE_DELETE:
return SDL_SCANCODE_KP_PERIOD;
case SDL_SCANCODE_PRINTSCREEN:
return SDL_SCANCODE_KP_MULTIPLY;
default:
break;
}
}
}
}
else
{
switch ( code )
{
case SDL_SCANCODE_RETURN:
return SDL_SCANCODE_KP_ENTER;
case SDL_SCANCODE_LALT:
return SDL_SCANCODE_RALT;
case SDL_SCANCODE_LCTRL:
return SDL_SCANCODE_RCTRL;
case SDL_SCANCODE_SLASH:
return SDL_SCANCODE_KP_DIVIDE;
case SDL_SCANCODE_CAPSLOCK:
return SDL_SCANCODE_KP_PLUS;
default:
break;
}
}
return code;
return code;
}
void
void
WIN_CheckWParamMouseButton( SDL_bool bwParamMousePressed, SDL_bool bSDLMousePressed, SDL_WindowData *data, Uint8 button )
{
if ( bwParamMousePressed && !bSDLMousePressed )
{
SDL_SendMouseButton(data->window, 0, SDL_PRESSED, button);
}
else if ( !bwParamMousePressed && bSDLMousePressed )
{
SDL_SendMouseButton(data->window, 0, SDL_RELEASED, button);
}
if ( bwParamMousePressed && !bSDLMousePressed )
{
SDL_SendMouseButton(data->window, 0, SDL_PRESSED, button);
}
else if ( !bwParamMousePressed && bSDLMousePressed )
{
SDL_SendMouseButton(data->window, 0, SDL_RELEASED, button);
}
}
/*
* Some windows systems fail to send a WM_LBUTTONDOWN sometimes, but each mouse move contains the current button state also
* so this funciton reconciles our view of the world with the current buttons reported by windows
*/
void
void
WIN_CheckWParamMouseButtons( WPARAM wParam, SDL_WindowData *data )
{
if ( wParam != data->mouse_button_flags )
{
Uint32 mouseFlags = SDL_GetMouseState( NULL, NULL );
WIN_CheckWParamMouseButton( (wParam & MK_LBUTTON), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT );
WIN_CheckWParamMouseButton( (wParam & MK_MBUTTON), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE );
WIN_CheckWParamMouseButton( (wParam & MK_RBUTTON), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT );
WIN_CheckWParamMouseButton( (wParam & MK_XBUTTON1), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1 );
WIN_CheckWParamMouseButton( (wParam & MK_XBUTTON2), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2 );
data->mouse_button_flags = wParam;
}
if ( wParam != data->mouse_button_flags )
{
Uint32 mouseFlags = SDL_GetMouseState( NULL, NULL );
WIN_CheckWParamMouseButton( (wParam & MK_LBUTTON), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT );
WIN_CheckWParamMouseButton( (wParam & MK_MBUTTON), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE );
WIN_CheckWParamMouseButton( (wParam & MK_RBUTTON), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT );
WIN_CheckWParamMouseButton( (wParam & MK_XBUTTON1), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1 );
WIN_CheckWParamMouseButton( (wParam & MK_XBUTTON2), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2 );
data->mouse_button_flags = wParam;
}
}
void
void
WIN_CheckRawMouseButtons( ULONG rawButtons, SDL_WindowData *data )
{
if ( rawButtons != data->mouse_button_flags )
{
Uint32 mouseFlags = SDL_GetMouseState( NULL, NULL );
if ( (rawButtons & RI_MOUSE_BUTTON_1_DOWN) )
WIN_CheckWParamMouseButton( (rawButtons & RI_MOUSE_BUTTON_1_DOWN), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT );
if ( (rawButtons & RI_MOUSE_BUTTON_1_UP) )
WIN_CheckWParamMouseButton( !(rawButtons & RI_MOUSE_BUTTON_1_UP), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT );
if ( (rawButtons & RI_MOUSE_BUTTON_2_DOWN) )
WIN_CheckWParamMouseButton( (rawButtons & RI_MOUSE_BUTTON_2_DOWN), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT );
if ( (rawButtons & RI_MOUSE_BUTTON_2_UP) )
WIN_CheckWParamMouseButton( !(rawButtons & RI_MOUSE_BUTTON_2_UP), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT );
if ( (rawButtons & RI_MOUSE_BUTTON_3_DOWN) )
WIN_CheckWParamMouseButton( (rawButtons & RI_MOUSE_BUTTON_3_DOWN), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE );
if ( (rawButtons & RI_MOUSE_BUTTON_3_UP) )
WIN_CheckWParamMouseButton( !(rawButtons & RI_MOUSE_BUTTON_3_UP), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE );
if ( (rawButtons & RI_MOUSE_BUTTON_4_DOWN) )
WIN_CheckWParamMouseButton( (rawButtons & RI_MOUSE_BUTTON_4_DOWN), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1 );
if ( (rawButtons & RI_MOUSE_BUTTON_4_UP) )
WIN_CheckWParamMouseButton( !(rawButtons & RI_MOUSE_BUTTON_4_UP), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1 );
if ( (rawButtons & RI_MOUSE_BUTTON_5_DOWN) )
WIN_CheckWParamMouseButton( (rawButtons & RI_MOUSE_BUTTON_5_DOWN), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2 );
if ( (rawButtons & RI_MOUSE_BUTTON_5_UP) )
WIN_CheckWParamMouseButton( !(rawButtons & RI_MOUSE_BUTTON_5_UP), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2 );
data->mouse_button_flags = rawButtons;
}
if ( rawButtons != data->mouse_button_flags )
{
Uint32 mouseFlags = SDL_GetMouseState( NULL, NULL );
if ( (rawButtons & RI_MOUSE_BUTTON_1_DOWN) )
WIN_CheckWParamMouseButton( (rawButtons & RI_MOUSE_BUTTON_1_DOWN), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT );
if ( (rawButtons & RI_MOUSE_BUTTON_1_UP) )
WIN_CheckWParamMouseButton( !(rawButtons & RI_MOUSE_BUTTON_1_UP), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT );
if ( (rawButtons & RI_MOUSE_BUTTON_2_DOWN) )
WIN_CheckWParamMouseButton( (rawButtons & RI_MOUSE_BUTTON_2_DOWN), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT );
if ( (rawButtons & RI_MOUSE_BUTTON_2_UP) )
WIN_CheckWParamMouseButton( !(rawButtons & RI_MOUSE_BUTTON_2_UP), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT );
if ( (rawButtons & RI_MOUSE_BUTTON_3_DOWN) )
WIN_CheckWParamMouseButton( (rawButtons & RI_MOUSE_BUTTON_3_DOWN), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE );
if ( (rawButtons & RI_MOUSE_BUTTON_3_UP) )
WIN_CheckWParamMouseButton( !(rawButtons & RI_MOUSE_BUTTON_3_UP), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE );
if ( (rawButtons & RI_MOUSE_BUTTON_4_DOWN) )
WIN_CheckWParamMouseButton( (rawButtons & RI_MOUSE_BUTTON_4_DOWN), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1 );
if ( (rawButtons & RI_MOUSE_BUTTON_4_UP) )
WIN_CheckWParamMouseButton( !(rawButtons & RI_MOUSE_BUTTON_4_UP), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1 );
if ( (rawButtons & RI_MOUSE_BUTTON_5_DOWN) )
WIN_CheckWParamMouseButton( (rawButtons & RI_MOUSE_BUTTON_5_DOWN), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2 );
if ( (rawButtons & RI_MOUSE_BUTTON_5_UP) )
WIN_CheckWParamMouseButton( !(rawButtons & RI_MOUSE_BUTTON_5_UP), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2 );
data->mouse_button_flags = rawButtons;
}
}
LRESULT CALLBACK
@ -280,8 +280,8 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
#ifdef WMMSG_DEBUG
{
FILE *log = fopen("wmmsg.txt", "a");
{
FILE *log = fopen("wmmsg.txt", "a");
fprintf(log, "Received windows message: %p ", hwnd);
if (msg > MAX_WMMSG) {
fprintf(log, "%d", msg);
@ -314,8 +314,8 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
minimized = HIWORD(wParam);
if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) {
Uint32 mouseFlags;
SHORT keyState;
Uint32 mouseFlags;
SHORT keyState;
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0);
SDL_SendWindowEvent(data->window,
@ -327,40 +327,40 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
if (SDL_GetKeyboardFocus() != data->window) {
SDL_SetKeyboardFocus(data->window);
}
/* mouse buttons may have changed state here, we need
to resync them, but we will get a WM_MOUSEMOVE right away which will fix
things up if in non raw mode also
*/
mouseFlags = SDL_GetMouseState( NULL, NULL );
/* mouse buttons may have changed state here, we need
to resync them, but we will get a WM_MOUSEMOVE right away which will fix
things up if in non raw mode also
*/
mouseFlags = SDL_GetMouseState( NULL, NULL );
keyState = GetAsyncKeyState( VK_LBUTTON );
WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT );
keyState = GetAsyncKeyState( VK_RBUTTON );
WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT );
keyState = GetAsyncKeyState( VK_MBUTTON );
WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE );
keyState = GetAsyncKeyState( VK_XBUTTON1 );
WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1 );
keyState = GetAsyncKeyState( VK_XBUTTON2 );
WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2 );
data->mouse_button_flags = 0;
keyState = GetAsyncKeyState( VK_LBUTTON );
WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT );
keyState = GetAsyncKeyState( VK_RBUTTON );
WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT );
keyState = GetAsyncKeyState( VK_MBUTTON );
WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE );
keyState = GetAsyncKeyState( VK_XBUTTON1 );
WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1 );
keyState = GetAsyncKeyState( VK_XBUTTON2 );
WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2 );
data->mouse_button_flags = 0;
if(SDL_GetMouse()->relative_mode) {
LONG cx, cy;
RECT rect;
GetWindowRect(hwnd, &rect);
if(SDL_GetMouse()->relative_mode) {
LONG cx, cy;
RECT rect;
GetWindowRect(hwnd, &rect);
cx = (rect.left + rect.right) / 2;
cy = (rect.top + rect.bottom) / 2;
cx = (rect.left + rect.right) / 2;
cy = (rect.top + rect.bottom) / 2;
/* Make an absurdly small clip rect */
rect.left = cx-1;
rect.right = cx+1;
rect.top = cy-1;
rect.bottom = cy+1;
/* Make an absurdly small clip rect */
rect.left = cx-1;
rect.right = cx+1;
rect.top = cy-1;
rect.bottom = cy+1;
ClipCursor(&rect);
}
ClipCursor(&rect);
}
/*
* FIXME: Update keyboard state
@ -379,65 +379,65 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
returnCode = 0;
break;
case WM_MOUSEMOVE:
if( !SDL_GetMouse()->relative_mode )
SDL_SendMouseMotion(data->window, 0, 0, LOWORD(lParam), HIWORD(lParam));
/* don't break here, fall through to check the wParam like the button presses */
case WM_LBUTTONUP:
case WM_RBUTTONUP:
case WM_MBUTTONUP:
case WM_XBUTTONUP:
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_XBUTTONDOWN:
if( !SDL_GetMouse()->relative_mode )
WIN_CheckWParamMouseButtons( wParam, data );
break;
case WM_MOUSEMOVE:
if( !SDL_GetMouse()->relative_mode )
SDL_SendMouseMotion(data->window, 0, 0, LOWORD(lParam), HIWORD(lParam));
/* don't break here, fall through to check the wParam like the button presses */
case WM_LBUTTONUP:
case WM_RBUTTONUP:
case WM_MBUTTONUP:
case WM_XBUTTONUP:
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_XBUTTONDOWN:
if( !SDL_GetMouse()->relative_mode )
WIN_CheckWParamMouseButtons( wParam, data );
break;
case WM_INPUT:
{
HRAWINPUT hRawInput = (HRAWINPUT)lParam;
RAWINPUT inp;
UINT size = sizeof(inp);
case WM_INPUT:
{
HRAWINPUT hRawInput = (HRAWINPUT)lParam;
RAWINPUT inp;
UINT size = sizeof(inp);
if(!SDL_GetMouse()->relative_mode)
break;
if(!SDL_GetMouse()->relative_mode)
break;
GetRawInputData(hRawInput, RID_INPUT, &inp, &size, sizeof(RAWINPUTHEADER));
GetRawInputData(hRawInput, RID_INPUT, &inp, &size, sizeof(RAWINPUTHEADER));
/* Mouse data */
if(inp.header.dwType == RIM_TYPEMOUSE)
{
RAWMOUSE* mouse = &inp.data.mouse;
/* Mouse data */
if(inp.header.dwType == RIM_TYPEMOUSE)
{
RAWMOUSE* mouse = &inp.data.mouse;
if((mouse->usFlags & 0x01) == MOUSE_MOVE_RELATIVE)
{
SDL_SendMouseMotion(data->window, 0, 1, (int)mouse->lLastX, (int)mouse->lLastY);
}
else
{
// synthesize relative moves from the abs position
static SDL_Point initialMousePoint;
if ( initialMousePoint.x == 0 && initialMousePoint.y == 0 )
{
initialMousePoint.x = mouse->lLastX;
initialMousePoint.y = mouse->lLastY;
}
if((mouse->usFlags & 0x01) == MOUSE_MOVE_RELATIVE)
{
SDL_SendMouseMotion(data->window, 0, 1, (int)mouse->lLastX, (int)mouse->lLastY);
}
else
{
/* synthesize relative moves from the abs position */
static SDL_Point initialMousePoint;
if ( initialMousePoint.x == 0 && initialMousePoint.y == 0 )
{
initialMousePoint.x = mouse->lLastX;
initialMousePoint.y = mouse->lLastY;
}
SDL_SendMouseMotion(data->window, 0, 1, (int)(mouse->lLastX-initialMousePoint.x), (int)(mouse->lLastY-initialMousePoint.y) );
SDL_SendMouseMotion(data->window, 0, 1, (int)(mouse->lLastX-initialMousePoint.x), (int)(mouse->lLastY-initialMousePoint.y) );
initialMousePoint.x = mouse->lLastX;
initialMousePoint.y = mouse->lLastY;
}
WIN_CheckRawMouseButtons( mouse->usButtonFlags, data );
}
break;
}
initialMousePoint.x = mouse->lLastX;
initialMousePoint.y = mouse->lLastY;
}
WIN_CheckRawMouseButtons( mouse->usButtonFlags, data );
}
break;
}
case WM_MOUSEWHEEL:
{
// FIXME: This may need to accumulate deltas up to WHEEL_DELTA
/* FIXME: This may need to accumulate deltas up to WHEEL_DELTA */
short motion = GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA;
SDL_SendMouseWheel(data->window, 0, 0, motion);
@ -447,14 +447,14 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
#ifdef WM_MOUSELEAVE
case WM_MOUSELEAVE:
if (SDL_GetMouseFocus() == data->window) {
if (!SDL_GetMouse()->relative_mode) {
POINT cursorPos;
GetCursorPos(&cursorPos);
ScreenToClient(hwnd, &cursorPos);
SDL_SendMouseMotion(data->window, 0, 0, cursorPos.x, cursorPos.y);
}
if (!SDL_GetMouse()->relative_mode) {
POINT cursorPos;
GetCursorPos(&cursorPos);
ScreenToClient(hwnd, &cursorPos);
SDL_SendMouseMotion(data->window, 0, 0, cursorPos.x, cursorPos.y);
}
SDL_SetMouseFocus(NULL);
SDL_SetMouseFocus(NULL);
}
returnCode = 0;
break;
@ -463,8 +463,8 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_SYSKEYDOWN:
case WM_KEYDOWN:
{
SDL_Scancode code = WindowsScanCodeToSDLScanCode( lParam, wParam );
if ( code != SDL_SCANCODE_UNKNOWN ) {
SDL_Scancode code = WindowsScanCodeToSDLScanCode( lParam, wParam );
if ( code != SDL_SCANCODE_UNKNOWN ) {
SDL_SendKeyboardKey(SDL_PRESSED, code );
}
}
@ -529,7 +529,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
int max_w, max_h;
int style;
BOOL menu;
BOOL constrain_max_size;
BOOL constrain_max_size;
/* If we allow resizing, let the resize happen naturally */
if (SDL_IsShapedWindow(data->window))
@ -545,7 +545,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
SDL_GetWindowMinimumSize(data->window, &min_w, &min_h);
SDL_GetWindowMaximumSize(data->window, &max_w, &max_h);
/* Store in min_w and min_h difference between current size and minimal
/* Store in min_w and min_h difference between current size and minimal
size so we don't need to call AdjustWindowRectEx twice */
min_w -= w;
min_h -= h;
@ -680,56 +680,56 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
returnCode = 0;
break;
case WM_TOUCH:
{
UINT i, num_inputs = LOWORD(wParam);
PTOUCHINPUT inputs = SDL_stack_alloc(TOUCHINPUT, num_inputs);
if (data->videodata->GetTouchInputInfo((HTOUCHINPUT)lParam, num_inputs, inputs, sizeof(TOUCHINPUT))) {
RECT rect;
float x, y;
case WM_TOUCH:
{
UINT i, num_inputs = LOWORD(wParam);
PTOUCHINPUT inputs = SDL_stack_alloc(TOUCHINPUT, num_inputs);
if (data->videodata->GetTouchInputInfo((HTOUCHINPUT)lParam, num_inputs, inputs, sizeof(TOUCHINPUT))) {
RECT rect;
float x, y;
if (!GetClientRect(hwnd, &rect) ||
(rect.right == rect.left && rect.bottom == rect.top)) {
break;
}
ClientToScreen(hwnd, (LPPOINT) & rect);
ClientToScreen(hwnd, (LPPOINT) & rect + 1);
rect.top *= 100;
rect.left *= 100;
rect.bottom *= 100;
rect.right *= 100;
if (!GetClientRect(hwnd, &rect) ||
(rect.right == rect.left && rect.bottom == rect.top)) {
break;
}
ClientToScreen(hwnd, (LPPOINT) & rect);
ClientToScreen(hwnd, (LPPOINT) & rect + 1);
rect.top *= 100;
rect.left *= 100;
rect.bottom *= 100;
rect.right *= 100;
for (i = 0; i < num_inputs; ++i) {
PTOUCHINPUT input = &inputs[i];
for (i = 0; i < num_inputs; ++i) {
PTOUCHINPUT input = &inputs[i];
const SDL_TouchID touchId = (SDL_TouchID)input->hSource;
if (!SDL_GetTouch(touchId)) {
if (SDL_AddTouch(touchId, "") < 0) {
continue;
}
}
const SDL_TouchID touchId = (SDL_TouchID)input->hSource;
if (!SDL_GetTouch(touchId)) {
if (SDL_AddTouch(touchId, "") < 0) {
continue;
}
}
// Get the normalized coordinates for the window
x = (float)(input->x - rect.left)/(rect.right - rect.left);
y = (float)(input->y - rect.top)/(rect.bottom - rect.top);
/* Get the normalized coordinates for the window */
x = (float)(input->x - rect.left)/(rect.right - rect.left);
y = (float)(input->y - rect.top)/(rect.bottom - rect.top);
if (input->dwFlags & TOUCHEVENTF_DOWN) {
SDL_SendTouch(touchId, input->dwID, SDL_TRUE, x, y, 1.0f);
}
if (input->dwFlags & TOUCHEVENTF_MOVE) {
SDL_SendTouchMotion(touchId, input->dwID, x, y, 1.0f);
}
if (input->dwFlags & TOUCHEVENTF_UP) {
SDL_SendTouch(touchId, input->dwID, SDL_FALSE, x, y, 1.0f);
}
}
}
SDL_stack_free(inputs);
if (input->dwFlags & TOUCHEVENTF_DOWN) {
SDL_SendTouch(touchId, input->dwID, SDL_TRUE, x, y, 1.0f);
}
if (input->dwFlags & TOUCHEVENTF_MOVE) {
SDL_SendTouchMotion(touchId, input->dwID, x, y, 1.0f);
}
if (input->dwFlags & TOUCHEVENTF_UP) {
SDL_SendTouch(touchId, input->dwID, SDL_FALSE, x, y, 1.0f);
}
}
}
SDL_stack_free(inputs);
data->videodata->CloseTouchInputHandle((HTOUCHINPUT)lParam);
return 0;
}
break;
data->videodata->CloseTouchInputHandle((HTOUCHINPUT)lParam);
return 0;
}
break;
case WM_DROPFILES:
{

View file

@ -77,7 +77,7 @@ int WIN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, voi
/* Fill in the size information */
*pitch = (((window->w * SDL_BYTESPERPIXEL(*format)) + 3) & ~3);
info->bmiHeader.biWidth = window->w;
info->bmiHeader.biHeight = -window->h; /* negative for topdown bitmap */
info->bmiHeader.biHeight = -window->h; /* negative for topdown bitmap */
info->bmiHeader.biSizeImage = window->h * (*pitch);
data->mdc = CreateCompatibleDC(data->hdc);

View file

@ -187,12 +187,12 @@ void
WIN_SetTextInputRect(_THIS, SDL_Rect *rect)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
if (!rect) {
SDL_InvalidParamError("rect");
return;
}
videodata->ime_rect = *rect;
}
@ -1031,7 +1031,7 @@ STDMETHODIMP UIElementSink_BeginUIElement(TSFSink *sink, DWORD dwUIElementId, BO
}
preading->lpVtbl->Release(preading);
}
else if (SUCCEEDED(element->lpVtbl->QueryInterface(element, &IID_ITfCandidateListUIElement, (LPVOID *)&pcandlist))) {
else if (SUCCEEDED(element->lpVtbl->QueryInterface(element, &IID_ITfCandidateListUIElement, (LPVOID *)&pcandlist))) {
videodata->ime_candref++;
UILess_GetCandidateList(videodata, pcandlist);
pcandlist->lpVtbl->Release(pcandlist);
@ -1058,7 +1058,7 @@ STDMETHODIMP UIElementSink_UpdateUIElement(TSFSink *sink, DWORD dwUIElementId)
}
preading->lpVtbl->Release(preading);
}
else if (SUCCEEDED(element->lpVtbl->QueryInterface(element, &IID_ITfCandidateListUIElement, (LPVOID *)&pcandlist))) {
else if (SUCCEEDED(element->lpVtbl->QueryInterface(element, &IID_ITfCandidateListUIElement, (LPVOID *)&pcandlist))) {
UILess_GetCandidateList(videodata, pcandlist);
pcandlist->lpVtbl->Release(pcandlist);
}
@ -1512,7 +1512,7 @@ void IME_Present(SDL_VideoData *videodata)
if (videodata->ime_dirty)
IME_Render(videodata);
// FIXME: Need to show the IME bitmap
/* FIXME: Need to show the IME bitmap */
}
#endif /* SDL_DISABLE_WINDOWS_IME */

View file

@ -36,28 +36,28 @@
typedef struct
{
WORD dlgVer;
WORD signature;
DWORD helpID;
DWORD exStyle;
DWORD style;
WORD cDlgItems;
short x;
short y;
short cx;
short cy;
WORD dlgVer;
WORD signature;
DWORD helpID;
DWORD exStyle;
DWORD style;
WORD cDlgItems;
short x;
short y;
short cx;
short cy;
} DLGTEMPLATEEX;
typedef struct
{
DWORD helpID;
DWORD exStyle;
DWORD style;
short x;
short y;
short cx;
short cy;
DWORD id;
DWORD helpID;
DWORD exStyle;
DWORD style;
short x;
short y;
short cx;
short cy;
DWORD id;
} DLGITEMTEMPLATEEX;
#pragma pack(pop)
@ -76,7 +76,7 @@ static INT_PTR MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPA
switch ( iMessage ) {
case WM_COMMAND:
/* Return the ID of the button that was pushed */
EndDialog(hDlg, LOWORD(wParam));
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
default:
@ -108,7 +108,7 @@ static SDL_bool ExpandDialogSpace(WIN_DialogData *dialog, size_t space)
}
return SDL_TRUE;
}
static SDL_bool AlignDialogData(WIN_DialogData *dialog, size_t size)
{
size_t padding = (dialog->used % size);
@ -166,7 +166,7 @@ static int s_BaseUnitsX;
static int s_BaseUnitsY;
static void Vec2ToDLU(short *x, short *y)
{
SDL_assert(s_BaseUnitsX != 0); // we init in WIN_ShowMessageBox(), which is the only public function...
SDL_assert(s_BaseUnitsX != 0); /* we init in WIN_ShowMessageBox(), which is the only public function... */
*x = MulDiv(*x, 4, s_BaseUnitsX);
*y = MulDiv(*y, 8, s_BaseUnitsY);
@ -265,37 +265,37 @@ static WIN_DialogData *CreateDialogData(int w, int h, const char *caption)
return NULL;
}
// No menu
/* No menu */
WordToPass = 0;
if (!AddDialogData(dialog, &WordToPass, 2)) {
FreeDialogData(dialog);
return NULL;
}
// No custom class
/* No custom class */
if (!AddDialogData(dialog, &WordToPass, 2)) {
FreeDialogData(dialog);
return NULL;
}
// title
/* title */
if (!AddDialogString(dialog, caption)) {
FreeDialogData(dialog);
return NULL;
}
// Font stuff
/* Font stuff */
{
//
// We want to use the system messagebox font.
//
/*
* We want to use the system messagebox font.
*/
BYTE ToPass;
NONCLIENTMETRICSA NCM;
NCM.cbSize = sizeof(NCM);
SystemParametersInfoA(SPI_GETNONCLIENTMETRICS, 0, &NCM, 0);
// Font size - convert to logical font size for dialog parameter.
/* Font size - convert to logical font size for dialog parameter. */
{
HDC ScreenDC = GetDC(0);
WordToPass = (WORD)(-72 * NCM.lfMessageFont.lfHeight / GetDeviceCaps(ScreenDC, LOGPIXELSY));
@ -307,28 +307,28 @@ static WIN_DialogData *CreateDialogData(int w, int h, const char *caption)
return NULL;
}
// Font weight
/* Font weight */
WordToPass = (WORD)NCM.lfMessageFont.lfWeight;
if (!AddDialogData(dialog, &WordToPass, 2)) {
FreeDialogData(dialog);
return NULL;
}
// italic?
/* italic? */
ToPass = NCM.lfMessageFont.lfItalic;
if (!AddDialogData(dialog, &ToPass, 1)) {
FreeDialogData(dialog);
return NULL;
}
// charset?
/* charset? */
ToPass = NCM.lfMessageFont.lfCharSet;
if (!AddDialogData(dialog, &ToPass, 1)) {
FreeDialogData(dialog);
return NULL;
}
// font typeface.
/* font typeface. */
if (!AddDialogString(dialog, NCM.lfMessageFont.lfFaceName)) {
FreeDialogData(dialog);
return NULL;
@ -355,44 +355,44 @@ WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
const int ButtonHeight = 26;
const int TextMargin = 16;
const int ButtonMargin = 12;
// Jan 25th, 2013 - dant@fleetsa.com
//
//
// I've tried to make this more reasonable, but I've run in to a lot
// of nonsense.
//
// The original issue is the code was written in pixels and not
// dialog units (DLUs). All DialogBox functions use DLUs, which
// vary based on the selected font (yay).
//
// According to MSDN, the most reliable way to convert is via
// MapDialogUnits, which requires an HWND, which we don't have
// at time of template creation.
//
// We do however have:
// The system font (DLU width 8 for me)
// The font we select for the dialog (DLU width 6 for me)
//
// Based on experimentation, *neither* of these return the value
// actually used. Stepping in to MapDialogUnits(), the conversion
// is fairly clear, and uses 7 for me.
//
// As a result, some of this is hacky to ensure the sizing is
// somewhat correct.
//
// Honestly, a long term solution is to use CreateWindow, not CreateDialog.
//
//
// In order to get text dimensions we need to have a DC with the desired font.
// I'm assuming a dialog box in SDL is rare enough we can to the create.
//
/* Jan 25th, 2013 - dant@fleetsa.com
*
*
* I've tried to make this more reasonable, but I've run in to a lot
* of nonsense.
*
* The original issue is the code was written in pixels and not
* dialog units (DLUs). All DialogBox functions use DLUs, which
* vary based on the selected font (yay).
*
* According to MSDN, the most reliable way to convert is via
* MapDialogUnits, which requires an HWND, which we don't have
* at time of template creation.
*
* We do however have:
* The system font (DLU width 8 for me)
* The font we select for the dialog (DLU width 6 for me)
*
* Based on experimentation, *neither* of these return the value
* actually used. Stepping in to MapDialogUnits(), the conversion
* is fairly clear, and uses 7 for me.
*
* As a result, some of this is hacky to ensure the sizing is
* somewhat correct.
*
* Honestly, a long term solution is to use CreateWindow, not CreateDialog.
*
*
* In order to get text dimensions we need to have a DC with the desired font.
* I'm assuming a dialog box in SDL is rare enough we can to the create.
*/
HDC FontDC = CreateCompatibleDC(0);
{
// Create a duplicate of the font used in system message boxes.
/* Create a duplicate of the font used in system message boxes. */
LOGFONT lf;
NONCLIENTMETRICS NCM;
NCM.cbSize = sizeof(NCM);
@ -401,40 +401,40 @@ WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
DialogFont = CreateFontIndirect(&lf);
}
// Select the font in to our DC
/* Select the font in to our DC */
SelectObject(FontDC, DialogFont);
{
// Get the metrics to try and figure our DLU conversion.
/* Get the metrics to try and figure our DLU conversion. */
GetTextMetrics(FontDC, &TM);
s_BaseUnitsX = TM.tmAveCharWidth + 1;
s_BaseUnitsY = TM.tmHeight;
}
// Measure the *pixel* size of the string.
/* Measure the *pixel* size of the string. */
wmessage = WIN_UTF8ToString(messageboxdata->message);
SDL_zero(TextSize);
Size.cx = DrawText(FontDC, wmessage, -1, &TextSize, DT_CALCRECT);
// Add some padding for hangs, etc.
/* Add some padding for hangs, etc. */
TextSize.right += 2;
TextSize.bottom += 2;
// Done with the DC, and the string
/* Done with the DC, and the string */
DeleteDC(FontDC);
SDL_free(wmessage);
// Increase the size of the dialog by some border spacing around the text.
/* Increase the size of the dialog by some border spacing around the text. */
Size.cx = TextSize.right - TextSize.left;
Size.cy = TextSize.bottom - TextSize.top;
Size.cx += TextMargin * 2;
Size.cy += TextMargin * 2;
// Ensure the size is wide enough for all of the buttons.
/* Ensure the size is wide enough for all of the buttons. */
if (Size.cx < messageboxdata->numbuttons * (ButtonWidth + ButtonMargin) + ButtonMargin)
Size.cx = messageboxdata->numbuttons * (ButtonWidth + ButtonMargin) + ButtonMargin;
// Add vertical space for the buttons and border.
/* Add vertical space for the buttons and border. */
Size.cy += ButtonHeight + TextMargin;
dialog = CreateDialogData(Size.cx, Size.cy, messageboxdata->title);
@ -447,7 +447,7 @@ WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
return -1;
}
// Align the buttons to the right/bottom.
/* Align the buttons to the right/bottom. */
x = Size.cx - ButtonWidth - ButtonMargin;
y = Size.cy - ButtonHeight - ButtonMargin;
for (i = 0; i < messageboxdata->numbuttons; ++i) {

View file

@ -180,44 +180,44 @@ static int
WIN_SetRelativeMouseMode(SDL_bool enabled)
{
RAWINPUTDEVICE rawMouse = { 0x01, 0x02, 0, NULL }; /* Mouse: UsagePage = 1, Usage = 2 */
HWND hWnd;
hWnd = GetActiveWindow();
HWND hWnd;
hWnd = GetActiveWindow();
rawMouse.hwndTarget = hWnd;
if(!enabled) {
rawMouse.dwFlags |= RIDEV_REMOVE;
rawMouse.hwndTarget = NULL;
}
rawMouse.hwndTarget = hWnd;
if(!enabled) {
rawMouse.dwFlags |= RIDEV_REMOVE;
rawMouse.hwndTarget = NULL;
}
/* (Un)register raw input for mice */
if(RegisterRawInputDevices(&rawMouse, 1, sizeof(RAWINPUTDEVICE)) == FALSE) {
/* (Un)register raw input for mice */
if(RegisterRawInputDevices(&rawMouse, 1, sizeof(RAWINPUTDEVICE)) == FALSE) {
/* Only return an error when registering. If we unregister and fail, then
it's probably that we unregistered twice. That's OK. */
if(enabled) {
return SDL_Unsupported();
}
}
/* Only return an error when registering. If we unregister and fail, then
it's probably that we unregistered twice. That's OK. */
if(enabled) {
return SDL_Unsupported();
}
}
if(enabled) {
LONG cx, cy;
RECT rect;
GetWindowRect(hWnd, &rect);
if(enabled) {
LONG cx, cy;
RECT rect;
GetWindowRect(hWnd, &rect);
cx = (rect.left + rect.right) / 2;
cy = (rect.top + rect.bottom) / 2;
cx = (rect.left + rect.right) / 2;
cy = (rect.top + rect.bottom) / 2;
/* Make an absurdly small clip rect */
rect.left = cx-1;
rect.right = cx+1;
rect.top = cy-1;
rect.bottom = cy+1;
/* Make an absurdly small clip rect */
rect.left = cx-1;
rect.right = cx+1;
rect.top = cy-1;
rect.bottom = cy+1;
ClipCursor(&rect);
}
else
ClipCursor(NULL);
ClipCursor(&rect);
}
else
ClipCursor(NULL);
return 0;
}
@ -228,7 +228,7 @@ WIN_InitMouse(_THIS)
SDL_Mouse *mouse = SDL_GetMouse();
mouse->CreateCursor = WIN_CreateCursor;
mouse->CreateSystemCursor = WIN_CreateSystemCursor;
mouse->CreateSystemCursor = WIN_CreateSystemCursor;
mouse->ShowCursor = WIN_ShowCursor;
mouse->FreeCursor = WIN_FreeCursor;
mouse->WarpMouse = WIN_WarpMouse;

View file

@ -503,7 +503,7 @@ WIN_GL_SetupWindow(_THIS, SDL_Window * window)
}
if (!pixel_format && _this->gl_config.accelerated != 1) {
iAttr[-1] = WGL_NO_ACCELERATION_ARB;
pixel_format = WIN_GL_ChoosePixelFormatARB(_this, iAttribs, fAttribs);
pixel_format = WIN_GL_ChoosePixelFormatARB(_this, iAttribs, fAttribs);
}
if (!pixel_format) {
pixel_format = WIN_GL_ChoosePixelFormat(hdc, &pfd);
@ -530,13 +530,13 @@ WIN_GL_CreateContext(_THIS, SDL_Window * window)
}
if (_this->gl_config.major_version < 3 &&
_this->gl_config.profile_mask == 0 &&
_this->gl_config.flags == 0) {
_this->gl_config.profile_mask == 0 &&
_this->gl_config.flags == 0) {
/* Create legacy context */
context = _this->gl_data->wglCreateContext(hdc);
if( share_context != 0 ) {
if( share_context != 0 ) {
_this->gl_data->wglShareLists(share_context, context);
}
}
} else {
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB;
HGLRC temp_context = _this->gl_data->wglCreateContext(hdc);
@ -558,27 +558,27 @@ WIN_GL_CreateContext(_THIS, SDL_Window * window)
SDL_SetError("GL 3.x is not supported");
context = temp_context;
} else {
/* max 8 attributes plus terminator */
/* max 8 attributes plus terminator */
int attribs[9] = {
WGL_CONTEXT_MAJOR_VERSION_ARB, _this->gl_config.major_version,
WGL_CONTEXT_MINOR_VERSION_ARB, _this->gl_config.minor_version,
0
};
int iattr = 4;
int iattr = 4;
/* SDL profile bits match WGL profile bits */
if( _this->gl_config.profile_mask != 0 ) {
attribs[iattr++] = WGL_CONTEXT_PROFILE_MASK_ARB;
attribs[iattr++] = _this->gl_config.profile_mask;
}
/* SDL profile bits match WGL profile bits */
if( _this->gl_config.profile_mask != 0 ) {
attribs[iattr++] = WGL_CONTEXT_PROFILE_MASK_ARB;
attribs[iattr++] = _this->gl_config.profile_mask;
}
/* SDL flags match WGL flags */
if( _this->gl_config.flags != 0 ) {
attribs[iattr++] = WGL_CONTEXT_FLAGS_ARB;
attribs[iattr++] = _this->gl_config.flags;
}
/* SDL flags match WGL flags */
if( _this->gl_config.flags != 0 ) {
attribs[iattr++] = WGL_CONTEXT_FLAGS_ARB;
attribs[iattr++] = _this->gl_config.flags;
}
attribs[iattr++] = 0;
attribs[iattr++] = 0;
/* Create the GL 3.x context */
context = wglCreateContextAttribsARB(hdc, share_context, attribs);

View file

@ -36,12 +36,12 @@ Win32_CreateShaper(SDL_Window * window) {
result->userx = result->usery = 0;
result->driverdata = (SDL_ShapeData*)SDL_malloc(sizeof(SDL_ShapeData));
((SDL_ShapeData*)result->driverdata)->mask_tree = NULL;
//Put some driver-data here.
/* Put some driver-data here. */
window->shaper = result;
resized_properly = Win32_ResizeWindowShape(window);
if (resized_properly != 0)
return NULL;
return result;
}
@ -49,15 +49,15 @@ void
CombineRectRegions(SDL_ShapeTree* node,void* closure) {
HRGN mask_region = *((HRGN*)closure),temp_region = NULL;
if(node->kind == OpaqueShape) {
//Win32 API regions exclude their outline, so we widen the region by one pixel in each direction to include the real outline.
/* Win32 API regions exclude their outline, so we widen the region by one pixel in each direction to include the real outline. */
temp_region = CreateRectRgn(node->data.shape.x,node->data.shape.y,node->data.shape.x + node->data.shape.w + 1,node->data.shape.y + node->data.shape.h + 1);
if(mask_region != NULL) {
CombineRgn(mask_region,mask_region,temp_region,RGN_OR);
DeleteObject(temp_region);
}
else
}
else
*((HRGN*)closure) = temp_region;
}
}
}
int
@ -77,12 +77,12 @@ Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShape
if(data->mask_tree != NULL)
SDL_FreeShapeTree(&data->mask_tree);
data->mask_tree = SDL_CalculateShapeTree(*shape_mode,shape);
SDL_TraverseShapeTree(data->mask_tree,&CombineRectRegions,&mask_region);
SDL_assert(mask_region != NULL);
SDL_assert(mask_region != NULL);
SetWindowRgn(((SDL_WindowData *)(shaper->window->driverdata))->hwnd, mask_region, TRUE);
return 0;
}
@ -95,15 +95,15 @@ Win32_ResizeWindowShape(SDL_Window *window) {
data = (SDL_ShapeData *)window->shaper->driverdata;
if (data == NULL)
return -1;
if(data->mask_tree != NULL)
SDL_FreeShapeTree(&data->mask_tree);
if(window->shaper->hasshape == SDL_TRUE) {
window->shaper->userx = window->x;
window->shaper->usery = window->y;
SDL_SetWindowPosition(window,-1000,-1000);
}
}
return 0;
}

View file

@ -30,7 +30,7 @@
#include "../SDL_shape_internals.h"
typedef struct {
SDL_ShapeTree *mask_tree;
SDL_ShapeTree *mask_tree;
} SDL_ShapeData;
extern SDL_WindowShaper* Win32_CreateShaper(SDL_Window * window);

View file

@ -51,9 +51,9 @@ WIN_DeleteDevice(SDL_VideoDevice * device)
SDL_VideoData *data = (SDL_VideoData *) device->driverdata;
SDL_UnregisterApp();
if (data->userDLL) {
SDL_UnloadObject(data->userDLL);
}
if (data->userDLL) {
SDL_UnloadObject(data->userDLL);
}
SDL_free(device->driverdata);
SDL_free(device);
@ -83,12 +83,12 @@ WIN_CreateDevice(int devindex)
}
device->driverdata = data;
data->userDLL = SDL_LoadObject("USER32.DLL");
if (data->userDLL) {
data->CloseTouchInputHandle = (BOOL (WINAPI *)( HTOUCHINPUT )) SDL_LoadFunction(data->userDLL, "CloseTouchInputHandle");
data->GetTouchInputInfo = (BOOL (WINAPI *)( HTOUCHINPUT, UINT, PTOUCHINPUT, int )) SDL_LoadFunction(data->userDLL, "GetTouchInputInfo");
data->RegisterTouchWindow = (BOOL (WINAPI *)( HWND, ULONG )) SDL_LoadFunction(data->userDLL, "RegisterTouchWindow");
}
data->userDLL = SDL_LoadObject("USER32.DLL");
if (data->userDLL) {
data->CloseTouchInputHandle = (BOOL (WINAPI *)( HTOUCHINPUT )) SDL_LoadFunction(data->userDLL, "CloseTouchInputHandle");
data->GetTouchInputInfo = (BOOL (WINAPI *)( HTOUCHINPUT, UINT, PTOUCHINPUT, int )) SDL_LoadFunction(data->userDLL, "GetTouchInputInfo");
data->RegisterTouchWindow = (BOOL (WINAPI *)( HWND, ULONG )) SDL_LoadFunction(data->userDLL, "RegisterTouchWindow");
}
/* Set the function pointers */
device->VideoInit = WIN_VideoInit;
@ -122,11 +122,11 @@ WIN_CreateDevice(int devindex)
device->UpdateWindowFramebuffer = WIN_UpdateWindowFramebuffer;
device->DestroyWindowFramebuffer = WIN_DestroyWindowFramebuffer;
device->OnWindowEnter = WIN_OnWindowEnter;
device->shape_driver.CreateShaper = Win32_CreateShaper;
device->shape_driver.SetWindowShape = Win32_SetWindowShape;
device->shape_driver.ResizeWindowShape = Win32_ResizeWindowShape;
#if SDL_VIDEO_OPENGL_WGL
device->GL_LoadLibrary = WIN_GL_LoadLibrary;
device->GL_GetProcAddress = WIN_GL_GetProcAddress;

View file

@ -51,8 +51,8 @@
#if WINVER < 0x0601
/* Touch input definitions */
#define TWF_FINETOUCH 1
#define TWF_WANTPALM 2
#define TWF_FINETOUCH 1
#define TWF_WANTPALM 2
#define TOUCHEVENTF_MOVE 0x0001
#define TOUCHEVENTF_DOWN 0x0002
@ -61,16 +61,16 @@
DECLARE_HANDLE(HTOUCHINPUT);
typedef struct _TOUCHINPUT {
LONG x;
LONG y;
HANDLE hSource;
DWORD dwID;
DWORD dwFlags;
DWORD dwMask;
DWORD dwTime;
ULONG_PTR dwExtraInfo;
DWORD cxContact;
DWORD cyContact;
LONG x;
LONG y;
HANDLE hSource;
DWORD dwID;
DWORD dwFlags;
DWORD dwMask;
DWORD dwTime;
ULONG_PTR dwExtraInfo;
DWORD cxContact;
DWORD cyContact;
} TOUCHINPUT, *PTOUCHINPUT;
#endif /* WINVER < 0x0601 */
@ -78,7 +78,7 @@ typedef struct _TOUCHINPUT {
typedef BOOL (*PFNSHFullScreen)(HWND, DWORD);
typedef void (*PFCoordTransform)(SDL_Window*, POINT*);
typedef struct
typedef struct
{
void **lpVtbl;
int refcount;
@ -115,13 +115,13 @@ typedef struct SDL_VideoData
{
int render;
DWORD clipboard_count;
DWORD clipboard_count;
/* Touch input functions */
void* userDLL;
BOOL (WINAPI *CloseTouchInputHandle)( HTOUCHINPUT );
BOOL (WINAPI *GetTouchInputInfo)( HTOUCHINPUT, UINT, PTOUCHINPUT, int );
BOOL (WINAPI *RegisterTouchWindow)( HWND, ULONG );
/* Touch input functions */
void* userDLL;
BOOL (WINAPI *CloseTouchInputHandle)( HTOUCHINPUT );
BOOL (WINAPI *GetTouchInputInfo)( HTOUCHINPUT, UINT, PTOUCHINPUT, int );
BOOL (WINAPI *RegisterTouchWindow)( HWND, ULONG );
SDL_bool ime_com_initialized;
struct ITfThreadMgr *ime_threadmgr;

View file

@ -201,7 +201,7 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
DWORD style = STYLE_BASIC;
int x, y;
int w, h;
style |= GetWindowStyle(window);
/* Figure out what the window area will be */
@ -352,7 +352,7 @@ WIN_SetWindowPositionInternal(_THIS, SDL_Window * window, UINT flags)
/* Figure out what the window area will be */
if ( SDL_ShouldAllowTopmost() && (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS)) == (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS )) {
top = HWND_TOPMOST;
top = HWND_TOPMOST;
} else {
top = HWND_NOTOPMOST;
}
@ -403,11 +403,11 @@ WIN_RaiseWindow(_THIS, SDL_Window * window)
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
HWND top;
if ( SDL_ShouldAllowTopmost() && (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS)) == (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS )) {
top = HWND_TOPMOST;
} else {
top = HWND_NOTOPMOST;
}
if ( SDL_ShouldAllowTopmost() && (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS)) == (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS )) {
top = HWND_TOPMOST;
} else {
top = HWND_NOTOPMOST;
}
SetWindowPos(hwnd, top, 0, 0, 0, 0, (SWP_NOMOVE | SWP_NOSIZE));
}
@ -464,11 +464,11 @@ WIN_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display,
int x, y;
int w, h;
if ( SDL_ShouldAllowTopmost() && (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS)) == (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS )) {
top = HWND_TOPMOST;
} else {
top = HWND_NOTOPMOST;
}
if ( SDL_ShouldAllowTopmost() && (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS)) == (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS )) {
top = HWND_TOPMOST;
} else {
top = HWND_NOTOPMOST;
}
style = GetWindowLong(hwnd, GWL_STYLE);
style &= ~STYLE_MASK;
@ -550,22 +550,22 @@ WIN_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
ClipCursor(NULL);
}
if ( window->flags & SDL_WINDOW_FULLSCREEN )
{
HWND top;
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
HWND hwnd = data->hwnd;
UINT flags = SWP_NOMOVE | SWP_NOSIZE;
if ( window->flags & SDL_WINDOW_FULLSCREEN )
{
HWND top;
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
HWND hwnd = data->hwnd;
UINT flags = SWP_NOMOVE | SWP_NOSIZE;
if ( SDL_ShouldAllowTopmost() && (window->flags & SDL_WINDOW_INPUT_FOCUS ) ) {
top = HWND_TOPMOST;
} else {
top = HWND_NOTOPMOST;
flags |= SWP_NOZORDER;
}
SetWindowPos(hwnd, top, 0, 0, 0, 0, flags);
}
if ( SDL_ShouldAllowTopmost() && (window->flags & SDL_WINDOW_INPUT_FOCUS ) ) {
top = HWND_TOPMOST;
} else {
top = HWND_NOTOPMOST;
flags |= SWP_NOZORDER;
}
SetWindowPos(hwnd, top, 0, 0, 0, 0, flags);
}
}
void

View file

@ -1,5 +1,5 @@
#define MAX_WMMSG (sizeof(wmtab)/sizeof(wmtab[0]))
#define MAX_WMMSG (sizeof(wmtab)/sizeof(wmtab[0]))
char *wmtab[] = {
"WM_NULL",