From 8f9f07d99df6a3414dadbed149681ff9c0e1a0b1 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Thu, 16 Oct 2003 04:44:36 +0000 Subject: [PATCH] zomby changes (sliders, etc) --- Doc/Changelog.txt | 3 +++ Include/Cxbx.h | 4 +-- Source/Win32/XBController.cpp | 51 +++++++++++++++++++++++++++-------- 3 files changed, 45 insertions(+), 13 deletions(-) diff --git a/Doc/Changelog.txt b/Doc/Changelog.txt index 20813b8c0..37210b3b8 100644 --- a/Doc/Changelog.txt +++ b/Doc/Changelog.txt @@ -8,6 +8,9 @@ version: 0.7.9 (??/??/??) - Added auto-pause functionality when window loses focus +- Fixes to slider device input, some more robust error handling + in input configuration (thanks Zomby!) + - Fixed start/back mapping problem :) - Fixed a glitch in EmuExe that was outputting some bad Exes diff --git a/Include/Cxbx.h b/Include/Cxbx.h index 6824ca0de..ff37319a5 100644 --- a/Include/Cxbx.h +++ b/Include/Cxbx.h @@ -55,10 +55,10 @@ typedef signed short sint16; typedef signed long sint32; // define this to trace intercepted function calls -//#define _DEBUG_TRACE +#define _DEBUG_TRACE // define this to trace warnings -//#define _DEBUG_WARNINGS +#define _DEBUG_WARNINGS // version information #ifndef _DEBUG_TRACE diff --git a/Source/Win32/XBController.cpp b/Source/Win32/XBController.cpp index c5d0900d8..c80b9d945 100644 --- a/Source/Win32/XBController.cpp +++ b/Source/Win32/XBController.cpp @@ -328,14 +328,32 @@ bool XBController::ConfigPoll(char *szStatus) dwFlags |= (JoyState.lRz > 0) ? (DEVICE_FLAG_AXIS | DEVICE_FLAG_POSITIVE) : (DEVICE_FLAG_AXIS | DEVICE_FLAG_NEGATIVE); } else + { for(int b=0;b<2;b++) + { if(abs(JoyState.rglSlider[b]) > DETECT_SENSITIVITY_JOYSTICK) + { dwHow = FIELD_OFFSET(XTL::DIJOYSTATE, rglSlider[b]); - else + dwFlags |= (JoyState.rglSlider[b] > 0) ? (DEVICE_FLAG_AXIS | DEVICE_FLAG_POSITIVE) : (DEVICE_FLAG_AXIS | DEVICE_FLAG_NEGATIVE); + } + } + } + + /* temporarily disabled + if(dwHow == -1) + { for(int b=0;b<4;b++) + { if(abs(JoyState.rgdwPOV[b]) > DETECT_SENSITIVITY_POV) + { dwHow = FIELD_OFFSET(XTL::DIJOYSTATE, rgdwPOV[b]); - else + } + } + } + //*/ + + if(dwHow == -1) + { for(int b=0;b<32;b++) { if(JoyState.rgbButtons[b] > DETECT_SENSITIVITY_BUTTON) @@ -344,6 +362,7 @@ bool XBController::ConfigPoll(char *szStatus) dwFlags |= DEVICE_FLAG_BUTTON; } } + } // ****************************************************************** // * Retrieve Object Info @@ -950,6 +969,12 @@ void XBController::DInputInit(HWND hwnd) } } + // ****************************************************************** + // * Enumerate Controller objects + // ****************************************************************** + for(m_dwCurObject=0;m_dwCurObjectEnumObjects(WrapEnumObjectsCallback, this, DIDFT_ALL); + // ****************************************************************** // * Set cooperative level and acquire // ****************************************************************** @@ -973,12 +998,6 @@ void XBController::DInputInit(HWND hwnd) } } } - - // ****************************************************************** - // * Enumerate Controller objects - // ****************************************************************** - for(m_dwCurObject=0;m_dwCurObjectEnumObjects(WrapEnumObjectsCallback, this, DIDFT_ALL); } // ****************************************************************** @@ -1014,7 +1033,7 @@ void XBController::Map(XBCtrlObject object, const char *szDeviceName, int dwInfo m_ObjectConfig[object].dwInfo = dwInfo; m_ObjectConfig[object].dwFlags = dwFlags; - // Purse unused device slots + // Purge unused device slots for(int v=0;vSetProperty(DIPROP_RANGE, &diprg.diph); if(FAILED(hRet)) - return DIENUM_STOP; + { + if(hRet == E_NOTIMPL) + return DIENUM_CONTINUE; + else + return DIENUM_STOP; + } } else if(lpddoi->dwType & DIDFT_BUTTON) { @@ -1152,7 +1176,12 @@ BOOL XBController::EnumObjectsCallback(XTL::LPCDIDEVICEOBJECTINSTANCE lpddoi) HRESULT hRet = m_InputDevice[m_dwCurObject].m_Device->SetProperty(DIPROP_RANGE, &diprg.diph); if(FAILED(hRet)) - return DIENUM_STOP; + { + if(hRet == E_NOTIMPL) + return DIENUM_CONTINUE; + else + return DIENUM_STOP; + } } return DIENUM_CONTINUE;