- DirectInput cleanup

Removing ancient code that's only useful on pre-XP OSs.
This commit is contained in:
Christoph Oelckers 2022-07-20 14:41:06 +02:00
parent f13e95ccbe
commit d2454d4b3b
4 changed files with 11 additions and 79 deletions

View file

@ -169,7 +169,7 @@ void M_SaveJoystickConfig(IJoystickConfig *joy)
char key[32], value[32]; char key[32], value[32];
int axislen, numaxes; int axislen, numaxes;
if (M_SetJoystickConfigSection(joy, true)) if (GameConfig != NULL && M_SetJoystickConfigSection(joy, true))
{ {
GameConfig->ClearCurrentSection(); GameConfig->ClearCurrentSection();
if (!joy->IsSensitivityDefault()) if (!joy->IsSensitivityDefault())

View file

@ -93,7 +93,6 @@ FJoystickCollection *JoyDevices[NUM_JOYDEVICES];
extern HINSTANCE g_hInst; extern HINSTANCE g_hInst;
static HMODULE DInputDLL;
bool GUICapture; bool GUICapture;
extern FMouse *Mouse; extern FMouse *Mouse;
@ -116,7 +115,6 @@ extern BOOL paused;
static bool noidle = false; static bool noidle = false;
LPDIRECTINPUT8 g_pdi; LPDIRECTINPUT8 g_pdi;
LPDIRECTINPUT g_pdi3;
extern bool AppActive; extern bool AppActive;
@ -523,58 +521,12 @@ bool I_InitInput (void *hwnd)
noidle = !!Args->CheckParm ("-noidle"); noidle = !!Args->CheckParm ("-noidle");
g_pdi = NULL; g_pdi = NULL;
g_pdi3 = NULL;
// Try for DirectInput 8 first, then DirectInput 3 for NT 4's benefit. hr = DirectInput8Create(g_hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&g_pdi, NULL);
DInputDLL = LoadLibraryA("dinput8.dll"); if (FAILED(hr))
if (DInputDLL != NULL)
{ {
typedef HRESULT (WINAPI *blah)(HINSTANCE, DWORD, REFIID, LPVOID *, LPUNKNOWN); Printf(TEXTCOLOR_ORANGE "DirectInput8Create failed: %08lx\n", hr);
blah di8c = (blah)GetProcAddress(DInputDLL, "DirectInput8Create"); g_pdi = NULL; // Just to be sure DirectInput8Create didn't change it
if (di8c != NULL)
{
hr = di8c(g_hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&g_pdi, NULL);
if (FAILED(hr))
{
Printf(TEXTCOLOR_ORANGE "DirectInput8Create failed: %08lx\n", hr);
g_pdi = NULL; // Just to be sure DirectInput8Create didn't change it
}
}
else
{
Printf(TEXTCOLOR_ORANGE "Could not find DirectInput8Create in dinput8.dll\n");
}
}
if (g_pdi == NULL)
{
if (DInputDLL != NULL)
{
FreeLibrary(DInputDLL);
}
DInputDLL = LoadLibraryA ("dinput.dll");
if (DInputDLL == NULL)
{
I_FatalError ("Could not load dinput.dll: %08lx", GetLastError());
}
typedef HRESULT (WINAPI *blah)(HINSTANCE, DWORD, LPDIRECTINPUT*, LPUNKNOWN);
#ifdef UNICODE
blah dic = (blah)GetProcAddress (DInputDLL, "DirectInputCreateW");
#else
blah dic = (blah)GetProcAddress(DInputDLL, "DirectInputCreateA");
#endif
if (dic == NULL)
{
I_FatalError ("dinput.dll is corrupt");
}
hr = dic (g_hInst, 0x0300, &g_pdi3, NULL);
if (FAILED(hr))
{
I_FatalError ("DirectInputCreate failed: %08lx", hr);
}
} }
Printf ("I_StartupMouse\n"); Printf ("I_StartupMouse\n");
@ -622,16 +574,6 @@ void I_ShutdownInput ()
g_pdi->Release (); g_pdi->Release ();
g_pdi = NULL; g_pdi = NULL;
} }
if (g_pdi3)
{
g_pdi3->Release ();
g_pdi3 = NULL;
}
if (DInputDLL != NULL)
{
FreeLibrary (DInputDLL);
DInputDLL = NULL;
}
} }
void I_GetEvent () void I_GetEvent ()

View file

@ -89,7 +89,6 @@ protected:
// EXTERNAL DATA DECLARATIONS ---------------------------------------------- // EXTERNAL DATA DECLARATIONS ----------------------------------------------
extern LPDIRECTINPUT8 g_pdi; extern LPDIRECTINPUT8 g_pdi;
extern LPDIRECTINPUT g_pdi3;
extern bool GUICapture; extern bool GUICapture;
// PRIVATE DATA DEFINITIONS ------------------------------------------------ // PRIVATE DATA DEFINITIONS ------------------------------------------------
@ -320,17 +319,13 @@ bool FDInputKeyboard::GetDevice()
{ {
HRESULT hr; HRESULT hr;
if (g_pdi3 != NULL) if (g_pdi != NULL)
{ // DirectInput3 interface
hr = g_pdi3->CreateDevice(GUID_SysKeyboard, (LPDIRECTINPUTDEVICE*)&Device, NULL);
}
else if (g_pdi != NULL)
{ // DirectInput8 interface { // DirectInput8 interface
hr = g_pdi->CreateDevice(GUID_SysKeyboard, &Device, NULL); hr = g_pdi->CreateDevice(GUID_SysKeyboard, &Device, NULL);
} }
else else
{ {
hr = -1; hr = E_FAIL;
} }
if (FAILED(hr)) if (FAILED(hr))
{ {
@ -383,7 +378,7 @@ void FDInputKeyboard::ProcessInput()
for (;;) for (;;)
{ {
DWORD cbObjectData = g_pdi3 ? sizeof(DIDEVICEOBJECTDATA_DX3) : sizeof(DIDEVICEOBJECTDATA); DWORD cbObjectData = sizeof(DIDEVICEOBJECTDATA);
dwElements = 1; dwElements = 1;
hr = Device->GetDeviceData(cbObjectData, &od, &dwElements, 0); hr = Device->GetDeviceData(cbObjectData, &od, &dwElements, 0);
if (hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED) if (hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED)

View file

@ -140,7 +140,6 @@ static void CenterMouse(int x, int y, LONG *centx, LONG *centy);
// EXTERNAL DATA DECLARATIONS ---------------------------------------------- // EXTERNAL DATA DECLARATIONS ----------------------------------------------
extern LPDIRECTINPUT8 g_pdi; extern LPDIRECTINPUT8 g_pdi;
extern LPDIRECTINPUT g_pdi3;
extern bool GUICapture; extern bool GUICapture;
extern int BlockMouseMove; extern int BlockMouseMove;
@ -680,17 +679,13 @@ bool FDInputMouse::GetDevice()
{ {
HRESULT hr; HRESULT hr;
if (g_pdi3 != NULL) if (g_pdi != NULL)
{ // DirectInput3 interface
hr = g_pdi3->CreateDevice(GUID_SysMouse, (LPDIRECTINPUTDEVICE*)&Device, NULL);
}
else if (g_pdi != NULL)
{ // DirectInput8 interface { // DirectInput8 interface
hr = g_pdi->CreateDevice(GUID_SysMouse, &Device, NULL); hr = g_pdi->CreateDevice(GUID_SysMouse, &Device, NULL);
} }
else else
{ {
hr = -1; hr = E_FAIL;
} }
if (FAILED(hr)) if (FAILED(hr))
{ {
@ -783,7 +778,7 @@ void FDInputMouse::ProcessInput()
event_t ev = { 0 }; event_t ev = { 0 };
for (;;) for (;;)
{ {
DWORD cbObjectData = g_pdi3 ? sizeof(DIDEVICEOBJECTDATA_DX3) : sizeof(DIDEVICEOBJECTDATA); DWORD cbObjectData = sizeof(DIDEVICEOBJECTDATA);
dwElements = 1; dwElements = 1;
hr = Device->GetDeviceData(cbObjectData, &od, &dwElements, 0); hr = Device->GetDeviceData(cbObjectData, &od, &dwElements, 0);
if (hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED) if (hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED)