Merge branch 'develop' into develop-win-sdl1-async-hack-201802

Conflicts:
	vs2015/sdl/src/video/windib/SDL_dibevents.c
This commit is contained in:
Jonathan Campbell
2018-02-20 16:02:47 -08:00
2 changed files with 21 additions and 48 deletions

View File

@@ -105,6 +105,8 @@ bool OpenGL_using(void);
using namespace std;
bool window_was_maximized = false;
Bitu userResizeWindowWidth = 0, userResizeWindowHeight = 0;
Bitu currentWindowWidth = 640, currentWindowHeight = 480;
@@ -1741,9 +1743,13 @@ static LRESULT CALLBACK WinExtHookKeyboardHookProc(int nCode,WPARAM wParam,LPARA
wParam = WM_USER + 0x101;
}
DWORD lParam =
(st_hook->scanCode << 8U) +
((st_hook->flags & LLKHF_EXTENDED) ? 0x01000000 : 0) +
((wParam == WM_KEYUP || wParam == WM_SYSKEYUP) ? 0xC0000000 : 0);
// catch the keystroke, post it to ourself, do not pass it on
PostMessage(myHwnd, wParam, st_hook->vkCode,
(st_hook->flags & 0x80/*transition state*/) ? 0x0000 : 0xA000/*bits 13&15 are set*/);
PostMessage(myHwnd, wParam, st_hook->vkCode, lParam);
return TRUE;
}
}
@@ -3067,7 +3073,7 @@ static void HandleVideoResize(void * event) {
/* assume the resize comes from user preference UNLESS the window
* is fullscreen or maximized */
if (!menu.maxwindow && !sdl.desktop.fullscreen && !sdl.init_ignore && NonUserResizeCounter == 0) {
if (!menu.maxwindow && !sdl.desktop.fullscreen && !sdl.init_ignore && NonUserResizeCounter == 0 && !window_was_maximized) {
UpdateWindowDimensions();
UpdateWindowDimensions(ResizeEvent->w, ResizeEvent->h);
@@ -3084,6 +3090,7 @@ static void HandleVideoResize(void * event) {
UpdateWindowDimensions();
}
window_was_maximized = menu.maxwindow;
if (NonUserResizeCounter > 0)
NonUserResizeCounter--;

View File

@@ -50,6 +50,8 @@
#define NO_GETKEYBOARDSTATE
#endif
static HKL hLayout = NULL;
/* The translation table from a Microsoft VK keysym to a SDL keysym */
static SDLKey VK_keymap[SDLK_LAST];
static SDL_keysym *TranslateKey(WPARAM vkey, UINT scancode, SDL_keysym *keysym, int pressed);
@@ -192,6 +194,13 @@ LRESULT DIB_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
ShowWindow(ParentWindowHWND, SW_RESTORE);
}
break;
/* FIXME: I like how Microsoft defines a perfectly reasonable message but does not send it to us
when the user selects a different language from the language bar. >:( */
case WM_INPUTLANGCHANGE:
hLayout = (HKL)wParam;
return(1);
case WM_INPUTLANGCHANGEREQUEST: /* We must use DefWindowProc() or else Windows will not notify us of input layout changes */
return DefWindowProc(hwnd, msg, wParam, lParam);
case WM_SYSKEYDOWN:
case WM_KEYDOWN: {
@@ -460,40 +469,12 @@ void DIB_CheckMouse(void) {
last_dib_mouse_motion = SDL_GetTicks();
}
static HKL hLayoutUS = NULL;
void DIB_InitOSKeymap(_THIS)
{
int i;
#ifndef _WIN32_WCE
char current_layout[KL_NAMELENGTH];
GetKeyboardLayoutName(current_layout);
//printf("Initial Keyboard Layout Name: '%s'\n", current_layout);
hLayout = GetKeyboardLayout(0);
hLayoutUS = LoadKeyboardLayout("00000409", KLF_NOTELLSHELL);
if (!hLayoutUS) {
//printf("Failed to load US keyboard layout. Using current.\n");
hLayoutUS = GetKeyboardLayout(0);
}
LoadKeyboardLayout(current_layout, KLF_ACTIVATE);
#else
#if _WIN32_WCE >=420
TCHAR current_layout[KL_NAMELENGTH];
GetKeyboardLayoutName(current_layout);
//printf("Initial Keyboard Layout Name: '%s'\n", current_layout);
hLayoutUS = LoadKeyboardLayout(L"00000409", 0);
if (!hLayoutUS) {
//printf("Failed to load US keyboard layout. Using current.\n");
hLayoutUS = GetKeyboardLayout(0);
}
LoadKeyboardLayout(current_layout, 0);
#endif // _WIN32_WCE >=420
#endif
/* Map the VK keysyms */
for ( i=0; i<SDL_arraysize(VK_keymap); ++i )
VK_keymap[i] = SDLK_UNKNOWN;
@@ -629,7 +610,7 @@ void DIB_InitOSKeymap(_THIS)
static int SDL_MapVirtualKey(int scancode, int vkey)
{
#ifndef _WIN32_WCE
int mvke = MapVirtualKeyEx(scancode & 0xFF, 1, hLayoutUS);
int mvke = MapVirtualKeyEx(scancode & 0xFF, 1, hLayout);
#else
int mvke = MapVirtualKey(scancode & 0xFF, 1);
#endif
@@ -709,21 +690,6 @@ static SDL_keysym *TranslateKey(WPARAM vkey, UINT scancode, SDL_keysym *keysym,
#endif /* NO_GETKEYBOARDSTATE */
}
#if 0
{
HKL hLayoutCurrent = GetKeyboardLayout(0);
int sc = scancode & 0xFF;
printf("SYM:%d, VK:0x%02X, SC:0x%04X, US:(1:0x%02X, 3:0x%02X), "
"Current:(1:0x%02X, 3:0x%02X)\n",
keysym->sym, vkey, scancode,
MapVirtualKeyEx(sc, 1, hLayoutUS),
MapVirtualKeyEx(sc, 3, hLayoutUS),
MapVirtualKeyEx(sc, 1, hLayoutCurrent),
MapVirtualKeyEx(sc, 3, hLayoutCurrent)
);
}
#endif
return(keysym);
}