mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-09-10 12:02:53 +02:00
Add GetAsyncKeyState
This commit is contained in:
parent
46f485a50a
commit
80e9291978
3 changed files with 24 additions and 1 deletions
|
@ -63,6 +63,7 @@ MiniFFI_GetFunctionHandle(void *libhandle, const char *func)
|
||||||
CAPTURE(RtlMoveMemory);
|
CAPTURE(RtlMoveMemory);
|
||||||
CAPTURE(LoadLibrary);
|
CAPTURE(LoadLibrary);
|
||||||
CAPTURE(FreeLibrary);
|
CAPTURE(FreeLibrary);
|
||||||
|
CAPTURE(GetAsyncKeyState);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
if (!libhandle) return 0;
|
if (!libhandle) return 0;
|
||||||
|
|
|
@ -55,7 +55,6 @@
|
||||||
// ===============================================================
|
// ===============================================================
|
||||||
#ifndef __WIN32__
|
#ifndef __WIN32__
|
||||||
#define m(vk,sc) { vk, SDL_SCANCODE_##sc }
|
#define m(vk,sc) { vk, SDL_SCANCODE_##sc }
|
||||||
#define n(vk) m(vk,-1)
|
|
||||||
std::map<int, int> vKeyToScancode{
|
std::map<int, int> vKeyToScancode{
|
||||||
// 0x01 LEFT MOUSE
|
// 0x01 LEFT MOUSE
|
||||||
// 0x02 RIGHT MOUSE
|
// 0x02 RIGHT MOUSE
|
||||||
|
@ -411,4 +410,23 @@ MKXP_FreeLibrary(HMODULE hLibModule)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Luckily, Essentials only cares about the high-order bit,
|
||||||
|
// so SDL's keystates will work perfectly fine
|
||||||
|
|
||||||
|
// Doesn't handle mouse clicks yet, but I'll do it later
|
||||||
|
|
||||||
|
PREFABI SHORT
|
||||||
|
MKXP_GetAsyncKeyState(int vKey)
|
||||||
|
{
|
||||||
|
SHORT result;
|
||||||
|
try {
|
||||||
|
result = shState->eThread().keyStates[vKeyToScancode[vKey]] << 15;
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
result = 0;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#ifndef __WIN32__
|
#ifndef __WIN32__
|
||||||
typedef unsigned int DWORD, UINT, *LPDWORD;
|
typedef unsigned int DWORD, UINT, *LPDWORD;
|
||||||
typedef char *LPCSTR, *PBYTE;
|
typedef char *LPCSTR, *PBYTE;
|
||||||
|
typedef short SHORT;
|
||||||
typedef int LONG;
|
typedef int LONG;
|
||||||
typedef bool BOOL;
|
typedef bool BOOL;
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -104,4 +105,7 @@ MKXP_LoadLibrary(LPCSTR lpLibFileName);
|
||||||
PREFABI BOOL
|
PREFABI BOOL
|
||||||
MKXP_FreeLibrary(HMODULE hLibModule);
|
MKXP_FreeLibrary(HMODULE hLibModule);
|
||||||
|
|
||||||
|
PREFABI SHORT
|
||||||
|
MKXP_GetAsyncKeyState(int vKey);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue