Use MKXP_SetWindowLong for Windows

This commit is contained in:
Inori 2019-08-27 10:35:56 -04:00
parent e093e3eb8f
commit db0bb632ed
4 changed files with 22 additions and 23 deletions

View file

@ -104,6 +104,7 @@ mkxp-z provides limited support for some WinAPI functions that would normally br
* `SetWindowTextA`: Sets the window title.
* `GetWindowRect`: Returns the screen coordinates of the game window's corners.
* `RegisterHotKey`: No-op. pls no disabling SDL's precious fullscreen.
* `SetWindowLong`: Only supports switching between fullscreen/windowed modes. Always returns `571`.
* `GetKeyboardState`: On Windows, adds states for Shift based on SDL's keystates. Emulated everywhere else.
#### macOS/Linux
@ -112,7 +113,6 @@ mkxp-z provides limited support for some WinAPI functions that would normally br
* `GetAsyncKeyState`: Emulated based on SDL mouse/key states.
* `GetSystemPowerStatus`: Emulated based on SDL_GetPowerInfo.
* `ShowWindow`: No-op.
* `SetWindowLong`: No-op. Always returns `571`.
* `GetSystemMetrics`: Only supports getting screen width/height.
* `SetCapture`: No-op. Always returns `571`.
* `ReleaseCapture`: No-op.

View file

@ -58,6 +58,7 @@ MiniFFI_GetFunctionHandle(void *libhandle, const char *func)
CAPTURE(SetWindowTextA);
CAPTURE(GetWindowRect);
CAPTURE(RegisterHotKey);
CAPTURE(SetWindowLong);
CAPTURE(GetKeyboardState);
#ifndef __WIN32__
// Functions only needed on Linux and macOS go here
@ -67,7 +68,6 @@ MiniFFI_GetFunctionHandle(void *libhandle, const char *func)
CAPTURE(GetAsyncKeyState);
CAPTURE(GetSystemPowerStatus);
CAPTURE(ShowWindow);
CAPTURE(SetWindowLong);
CAPTURE(GetSystemMetrics);
CAPTURE(SetCapture);
CAPTURE(ReleaseCapture);

View file

@ -334,6 +334,23 @@ MKXP_RegisterHotKey(HWND hWnd,
UINT vk)
NOP_VAL(true)
PREFABI LONG
MKXP_SetWindowLong(HWND hWnd, int nIndex, LONG dwNewLong)
{
if (nIndex == -16)
{
if (dwNewLong == 0)
{
shState->graphics().setFullscreen(true);
}
else if (dwNewLong == 0x14ca0000)
{
shState->graphics().setFullscreen(false);
}
}
return DUMMY_VAL;
};
// Shift key with GetKeyboardState doesn't work for whatever reason,
// so Windows needs this too
#define ks(sc) shState->eThread().keyStates[SDL_SCANCODE_##sc]
@ -506,24 +523,6 @@ PREFABI BOOL
MKXP_ShowWindow(HWND hWnd, int nCmdShow)
NOP_VAL(true);
PREFABI LONG
MKXP_SetWindowLong(HWND hWnd, int nIndex, LONG dwNewLong)
{
if (nIndex == -16)
{
if (dwNewLong == 0)
{
shState->graphics().setFullscreen(true);
}
else if (dwNewLong == 0x14ca0000)
{
shState->graphics().setFullscreen(false);
}
}
return DUMMY_VAL;
};
// This only currently supports getting screen width/height
// Not really motivated to do the other ones when I'll be

View file

@ -102,6 +102,9 @@ MKXP_RegisterHotKey(HWND hWnd,
UINT fsModifiers,
UINT vk);
PREFABI LONG
MKXP_SetWindowLong(HWND hWnd, int nIndex, LONG dwNewLong);
PREFABI BOOL
MKXP_GetKeyboardState(PBYTE lpKeyState);
@ -125,9 +128,6 @@ MKXP_GetSystemPowerStatus(LPSYSTEM_POWER_STATUS lpSystemPowerStatus);
PREFABI BOOL
MKXP_ShowWindow(HWND hWnd, int nCmdShow);
PREFABI LONG
MKXP_SetWindowLong(HWND hWnd, int nIndex, LONG dwNewLong);
PREFABI int
MKXP_GetSystemMetrics(int nIndex);