mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-04 05:55:31 +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(SetWindowTextA);
|
||||
CAPTURE(GetWindowRect);
|
||||
CAPTURE(RegisterHotKey);
|
||||
CAPTURE(SetWindowLong);
|
||||
CAPTURE(GetKeyboardState);
|
||||
#ifndef __WIN32__
|
||||
// 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(GetUserDefaultLangID);
|
||||
CAPTURE(GetUserName);
|
||||
CAPTURE(RegisterHotKey);
|
||||
CAPTURE(SetWindowLong);
|
||||
#endif
|
||||
#endif
|
||||
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_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);
|
||||
|
||||
#ifndef __WIN32__
|
||||
|
@ -125,5 +121,9 @@ PREFABI short MKXP_GetUserDefaultLangID(void);
|
|||
|
||||
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
|
||||
|
|
|
@ -122,24 +122,6 @@ PREFABI BOOL MKXP_GetWindowRect(HWND hWnd, LPRECT lpRect) {
|
|||
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,
|
||||
// so Windows needs this too
|
||||
#define ks(sc) shState->eThread().keyStates[SDL_SCANCODE_##sc]
|
||||
|
@ -384,4 +366,18 @@ PREFABI BOOL MKXP_GetUserName(LPSTR lpBuffer, LPDWORD pcbBuffer) {
|
|||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue