- 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];
int axislen, numaxes;
if (M_SetJoystickConfigSection(joy, true))
if (GameConfig != NULL && M_SetJoystickConfigSection(joy, true))
{
GameConfig->ClearCurrentSection();
if (!joy->IsSensitivityDefault())

View File

@ -93,7 +93,6 @@ FJoystickCollection *JoyDevices[NUM_JOYDEVICES];
extern HINSTANCE g_hInst;
static HMODULE DInputDLL;
bool GUICapture;
extern FMouse *Mouse;
@ -116,7 +115,6 @@ extern BOOL paused;
static bool noidle = false;
LPDIRECTINPUT8 g_pdi;
LPDIRECTINPUT g_pdi3;
extern bool AppActive;
@ -523,59 +521,13 @@ bool I_InitInput (void *hwnd)
noidle = !!Args->CheckParm ("-noidle");
g_pdi = NULL;
g_pdi3 = NULL;
// Try for DirectInput 8 first, then DirectInput 3 for NT 4's benefit.
DInputDLL = LoadLibraryA("dinput8.dll");
if (DInputDLL != NULL)
{
typedef HRESULT (WINAPI *blah)(HINSTANCE, DWORD, REFIID, LPVOID *, LPUNKNOWN);
blah di8c = (blah)GetProcAddress(DInputDLL, "DirectInput8Create");
if (di8c != NULL)
{
hr = di8c(g_hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&g_pdi, NULL);
hr = DirectInput8Create(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");
I_StartupMouse();
@ -622,16 +574,6 @@ void I_ShutdownInput ()
g_pdi->Release ();
g_pdi = NULL;
}
if (g_pdi3)
{
g_pdi3->Release ();
g_pdi3 = NULL;
}
if (DInputDLL != NULL)
{
FreeLibrary (DInputDLL);
DInputDLL = NULL;
}
}
void I_GetEvent ()

View File

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