Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
port WinInReadKeyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Mar 17, 2024
1 parent 52af291 commit 861941c
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 10 deletions.
16 changes: 8 additions & 8 deletions docs/progress.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion docs/progress.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2615,7 +2615,7 @@ typedef enum GAME_OBJECT_ID {
004471C0 0000002F x sub_4471C0
004471F0 00000022 +R bool __cdecl DInputCreate(void);
00447220 0000001A +R void __cdecl DInputRelease(void);
00447240 0000005A -R void __cdecl WinInReadKeyboard(LPVOID lpInputData);
00447240 0000005A +R void __cdecl WinInReadKeyboard(LPVOID lpInputData);
004472A0 000000F3 -R DWORD __cdecl WinInReadJoystick(int32_t *x, int32_t *y);
004473A0 00000005 -R sub_4473A0
004473B0 0000007F -R bool __cdecl WinInputInit(void);
Expand Down Expand Up @@ -3234,3 +3234,4 @@ typedef enum GAME_OBJECT_ID {
00526320 - struct CAMERA_INFO g_Camera;
005263CC - struct BOX_INFO *g_Boxes;
004D855C - LPDIRECTINPUT g_DInput;
004D8560 - LPDIRECTINPUTDEVICE IDID_SysKeyboard;
16 changes: 16 additions & 0 deletions src/decomp/decomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,3 +358,19 @@ void __cdecl DInputRelease(void)
g_DInput = NULL;
}
}

void __cdecl WinInReadKeyboard(uint8_t *input_data)
{
if (SUCCEEDED(IDirectInputDevice_GetDeviceState(
IDID_SysKeyboard, 256, input_data))) {
return;
}

if (SUCCEEDED(IDirectInputDevice_Acquire(IDID_SysKeyboard))
&& SUCCEEDED(IDirectInputDevice_GetDeviceState(
IDID_SysKeyboard, 256, input_data))) {
return;
}

memset(input_data, 0, 256);
}
1 change: 1 addition & 0 deletions src/decomp/decomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ size_t __cdecl EncodePutPCX(uint8_t value, uint8_t num, uint8_t *buffer);
void __cdecl Screenshot(LPDDS screen);
bool __cdecl DInputCreate(void);
void __cdecl DInputRelease(void);
void __cdecl WinInReadKeyboard(uint8_t *input_data);
1 change: 0 additions & 1 deletion src/global/funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,6 @@
#define InsertDisplayMode ((DISPLAY_MODE *__thiscall (*)(DISPLAY_MODE_LIST *modeList, DISPLAY_MODE_NODE *before))0x00446FF0)
#define InsertDisplayModeInListHead ((DISPLAY_MODE *__thiscall (*)(DISPLAY_MODE_LIST *modeList))0x00447010)
#define InsertDisplayModeInListTail ((DISPLAY_MODE *__thiscall (*)(DISPLAY_MODE_LIST *modeList))0x00447060)
#define WinInReadKeyboard ((void __cdecl (*)(LPVOID lpInputData))0x00447240)
#define WinInReadJoystick ((DWORD __cdecl (*)(int32_t *x, int32_t *y))0x004472A0)
#define WinInputInit ((bool __cdecl (*)(void))0x004473B0)
#define DInputEnumDevices ((bool __cdecl (*)(JOYSTICK_LIST *joystickList))0x00447430)
Expand Down
1 change: 1 addition & 0 deletions src/global/vars.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
#define g_FullScreenVGA (*(int32_t*)0x004D8374)
#define g_IsGameToExit (*(uint8_t*)0x004D8378)
#define g_DInput (*(LPDIRECTINPUT*)0x004D855C)
#define IDID_SysKeyboard (*(LPDIRECTINPUTDEVICE*)0x004D8560)
#define g_ScreenSizer (*(int32_t*)0x004D8568)
#define g_IsVidSizeLock (*(int32_t*)0x004D856C)
#define g_SampleFreqs (*(DWORD(*)[256])0x004D8570)
Expand Down
1 change: 1 addition & 0 deletions src/inject_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ static void Inject_Decomp(void)
{
INJECT(1, 0x004471F0, DInputCreate);
INJECT(1, 0x00447220, DInputRelease);
INJECT(1, 0x00447240, WinInReadKeyboard);
INJECT(1, 0x004498C0, DecodeErrorMessage);
INJECT(1, 0x0044E4E0, RenderErrorBox);
INJECT(1, 0x0044E520, WinMain);
Expand Down

0 comments on commit 861941c

Please sign in to comment.