mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-10 00:45:33 +02:00
Use native SetWindowLong+RegisterHotKey on Windows
This commit is contained in:
parent
fe1360f6b4
commit
21f75f84aa
3 changed files with 20 additions and 24 deletions
|
@ -60,8 +60,6 @@ static void *MiniFFI_GetFunctionHandle(void *libhandle, const char *func) {
|
||||||
CAPTURE(SetWindowPos);
|
CAPTURE(SetWindowPos);
|
||||||
CAPTURE(SetWindowTextA);
|
CAPTURE(SetWindowTextA);
|
||||||
CAPTURE(GetWindowRect);
|
CAPTURE(GetWindowRect);
|
||||||
CAPTURE(RegisterHotKey);
|
|
||||||
CAPTURE(SetWindowLong);
|
|
||||||
CAPTURE(GetKeyboardState);
|
CAPTURE(GetKeyboardState);
|
||||||
#ifndef __WIN32__
|
#ifndef __WIN32__
|
||||||
// Functions only needed on Linux and macOS go here
|
// Functions only needed on Linux and macOS go here
|
||||||
|
@ -78,6 +76,8 @@ static void *MiniFFI_GetFunctionHandle(void *libhandle, const char *func) {
|
||||||
CAPTURE(GetPrivateProfileString);
|
CAPTURE(GetPrivateProfileString);
|
||||||
CAPTURE(GetUserDefaultLangID);
|
CAPTURE(GetUserDefaultLangID);
|
||||||
CAPTURE(GetUserName);
|
CAPTURE(GetUserName);
|
||||||
|
CAPTURE(RegisterHotKey);
|
||||||
|
CAPTURE(SetWindowLong);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
if (!libhandle)
|
if (!libhandle)
|
||||||
|
|
|
@ -87,10 +87,6 @@ PREFABI BOOL MKXP_SetWindowTextA(HWND hWnd, LPCSTR lpString);
|
||||||
|
|
||||||
PREFABI BOOL MKXP_GetWindowRect(HWND hWnd, LPRECT lpRect);
|
PREFABI BOOL MKXP_GetWindowRect(HWND hWnd, LPRECT lpRect);
|
||||||
|
|
||||||
PREFABI BOOL MKXP_RegisterHotKey(HWND hWnd, int id, UINT fsModifiers, UINT vk);
|
|
||||||
|
|
||||||
PREFABI LONG MKXP_SetWindowLong(HWND hWnd, int nIndex, LONG dwNewLong);
|
|
||||||
|
|
||||||
PREFABI BOOL MKXP_GetKeyboardState(PBYTE lpKeyState);
|
PREFABI BOOL MKXP_GetKeyboardState(PBYTE lpKeyState);
|
||||||
|
|
||||||
#ifndef __WIN32__
|
#ifndef __WIN32__
|
||||||
|
@ -125,5 +121,9 @@ PREFABI short MKXP_GetUserDefaultLangID(void);
|
||||||
|
|
||||||
PREFABI BOOL MKXP_GetUserName(LPSTR lpBuffer, LPDWORD pcbBuffer);
|
PREFABI BOOL MKXP_GetUserName(LPSTR lpBuffer, LPDWORD pcbBuffer);
|
||||||
|
|
||||||
|
PREFABI BOOL MKXP_RegisterHotKey(HWND hWnd, int id, UINT fsModifiers, UINT vk);
|
||||||
|
|
||||||
|
PREFABI LONG MKXP_SetWindowLong(HWND hWnd, int nIndex, LONG dwNewLong);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -122,24 +122,6 @@ PREFABI BOOL MKXP_GetWindowRect(HWND hWnd, LPRECT lpRect) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PREFABI BOOL MKXP_RegisterHotKey(HWND hWnd, int id, UINT fsModifiers, UINT vk)
|
|
||||||
NOP_VAL(true)
|
|
||||||
|
|
||||||
PREFABI LONG MKXP_SetWindowLong(HWND hWnd, int nIndex, LONG dwNewLong) {
|
|
||||||
#ifdef __WIN32__
|
|
||||||
return SetWindowLong(hWnd, nIndex, dwNewLong);
|
|
||||||
#else
|
|
||||||
if (nIndex == -16) {
|
|
||||||
if (dwNewLong == 0) {
|
|
||||||
shState->eThread().requestFullscreenMode(true);
|
|
||||||
} else if (dwNewLong == 0x14ca0000) {
|
|
||||||
shState->eThread().requestFullscreenMode(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return DUMMY_VAL;
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
// Shift key with GetKeyboardState doesn't work for whatever reason,
|
// Shift key with GetKeyboardState doesn't work for whatever reason,
|
||||||
// so Windows needs this too
|
// so Windows needs this too
|
||||||
#define ks(sc) shState->eThread().keyStates[SDL_SCANCODE_##sc]
|
#define ks(sc) shState->eThread().keyStates[SDL_SCANCODE_##sc]
|
||||||
|
@ -384,4 +366,18 @@ PREFABI BOOL MKXP_GetUserName(LPSTR lpBuffer, LPDWORD pcbBuffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PREFABI BOOL MKXP_RegisterHotKey(HWND hWnd, int id, UINT fsModifiers, UINT vk)
|
||||||
|
NOP_VAL(true);
|
||||||
|
|
||||||
|
PREFABI LONG MKXP_SetWindowLong(HWND hWnd, int nIndex, LONG dwNewLong) {
|
||||||
|
if (nIndex == -16) {
|
||||||
|
if (dwNewLong == 0) {
|
||||||
|
shState->eThread().requestFullscreenMode(true);
|
||||||
|
} else if (dwNewLong == 0x14ca0000) {
|
||||||
|
shState->eThread().requestFullscreenMode(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return DUMMY_VAL;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue