DXINPUT_SetupMouse

This commit is contained in:
krystalgamer 2024-09-06 19:00:50 +02:00
parent 1c5ee2f70f
commit f163afa884
3 changed files with 55 additions and 8 deletions

View File

@ -109,7 +109,7 @@ void displayD3DError(long,char *,i32)
}
// @SMALLTODO
void displayDIError(long,char *,i32)
void displayDIError(HRESULT error, char* buf, i32 line)
{
printf("displayDIError(long,char *,i32)");
}

View File

@ -42,4 +42,6 @@ EXPORT void shutdownDirectInput8(void);
EXPORT void shutdownDirectSound8(void);
EXPORT void gsub_5027A0(void);
#define DISPLAY_DI_ERROR(x) displayDIError(x, __FILE__, __LINE__)
#endif

View File

@ -1,10 +1,12 @@
#include "DXsound.h"
#include "DXinit.h"
#include "SpideyDX.h"
#include "validate.h"
#include <cstring>
EXPORT i32 gKeyBoardRelated;
EXPORT i32 gMouseRelated;
EXPORT LPDIRECTINPUTDEVICEA g_pMouse;
EXPORT i32 gControllerRelated;
EXPORT i32 gForceFeedbackRelated;
@ -14,6 +16,18 @@ EXPORT u8 gKeyState[0x100];
EXPORT u8 gControllerButtonState[0x20];
EXPORT u8 gMouseButtonState[3];
#define DI_ERROR_LOG_AND_QUIT(x) {\
if (x)\
{\
DISPLAY_DI_ERROR(x);\
if (FAILED(hr))\
{\
DXINIT_ShutDown();\
exit(hr);\
}\
}\
}
EXPORT char* gDxKeyNames[0x100] =
{
"NULL",
@ -322,7 +336,7 @@ void DXINPUT_Initialize(IDirectInputA* a1, HWND a2)
gDxInputHwnd = a2;
gKeyBoardRelated = 0;
gMouseRelated = 0;
g_pMouse = 0;
gControllerRelated = 0;
gForceFeedbackRelated = 0;
@ -396,12 +410,43 @@ i32 DXINPUT_SetupKeyboard(i32,i32)
return 0x23082024;
}
// @MEDIUMTODO
i32 DXINPUT_SetupMouse(i32)
// @Ok
i32 DXINPUT_SetupMouse(i32 exclusive)
{
g_pDI->CreateDevice(GUID_SysMouse, NULL, NULL);
printf("DXINPUT_SetupMouse(i32)");
return 0x23082024;
HRESULT hr = g_pDI->CreateDevice(GUID_SysMouse, &g_pMouse, NULL);
DI_ERROR_LOG_AND_QUIT(hr);
DIPROPDWORD v12;
v12.diph.dwHeaderSize = 16;
v12.dwData = 16;
v12.diph.dwSize = 20;
v12.diph.dwObj = 0;
v12.diph.dwHow = 0;
hr = g_pMouse->SetProperty(DIPROP_BUFFERSIZE, &v12.diph);
DI_ERROR_LOG_AND_QUIT(hr);
hr = g_pMouse->SetDataFormat(&c_dfDIMouse);
DI_ERROR_LOG_AND_QUIT(hr);
hr = g_pMouse->SetCooperativeLevel(gDxInputHwnd,
exclusive ?
DISCL_FOREGROUND | DISCL_EXCLUSIVE :
DISCL_FOREGROUND | DISCL_NONEXCLUSIVE);
DI_ERROR_LOG_AND_QUIT(hr);
hr = g_pMouse->Acquire();
if (hr == DIERR_OTHERAPPHASPRIO)
{
DXERR_printf("Other application has priority when attempting to acquire mouse\n");
}
else
{
DI_ERROR_LOG_AND_QUIT(hr);
}
return 1;
}
// @SMALLTODO