From 7fe210a51647948460e8e263ac54dc8e4504649a Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Mon, 9 Jan 2006 01:10:37 +0000 Subject: [PATCH] silence warning spew if no hid devices plugged in --- .../InputHandler/InputHandler_DirectInput.cpp | 25 +++++++++++++++++-- .../src/archutils/Win32/RegistryAccess.cpp | 9 ++++--- .../src/archutils/Win32/RegistryAccess.h | 2 +- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/stepmania/src/arch/InputHandler/InputHandler_DirectInput.cpp b/stepmania/src/arch/InputHandler/InputHandler_DirectInput.cpp index ed7d9e3f8b..151f6a213c 100644 --- a/stepmania/src/arch/InputHandler/InputHandler_DirectInput.cpp +++ b/stepmania/src/arch/InputHandler/InputHandler_DirectInput.cpp @@ -65,7 +65,7 @@ static int GetNumUsbHidDevices() // The "Enum" key doesn't exist if no hid devices are attached, so it's expected that GetRegValue will sometimes fail. // TODO: Does this work in Win98 and Win2K? int i = 0; - RegistryAccess::GetRegValue( "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\HidUsb\\Enum", "Count", i ); + RegistryAccess::GetRegValue( "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\HidUsb\\Enum", "Count", i, false ); // don't warn on error return i; } @@ -384,7 +384,28 @@ void InputHandler_DInput::UpdateBuffered( DIDevice &device, const RageTimer &tm switch( in.type ) { case in.KEY: - ButtonPressed( DeviceInput(dev, (DeviceButton) in.num, -1, tm), !!(evtbuf[i].dwData & 0x80)) ; + /* // "Joystick with keyboard" hack + switch( in.num ) + { + case 115: //s + ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_UP, -1, tm), !!(evtbuf[i].dwData & 0x80) ); + break; + case 120: //x + ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_DOWN, -1, tm), !!(evtbuf[i].dwData & 0x80) ); + break; + case 122: //z + ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_LEFT, -1, tm), !!(evtbuf[i].dwData & 0x80) ); + break; + case 99: //c + ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_RIGHT, -1, tm), !!(evtbuf[i].dwData & 0x80) ); + break; + default: + */ + ButtonPressed( DeviceInput(dev, (DeviceButton) in.num, -1, tm), !!(evtbuf[i].dwData & 0x80)) ; + /* + break; + } + */ break; case in.BUTTON: diff --git a/stepmania/src/archutils/Win32/RegistryAccess.cpp b/stepmania/src/archutils/Win32/RegistryAccess.cpp index 5f99e445b2..00f3424a85 100644 --- a/stepmania/src/archutils/Win32/RegistryAccess.cpp +++ b/stepmania/src/archutils/Win32/RegistryAccess.cpp @@ -36,7 +36,7 @@ static bool GetRegKeyType( const RString &sIn, RString &sOut, HKEY &key ) /* Given a full key, eg. "HKEY_LOCAL_MACHINE\hardware\foo", open it and return it. * On error, return NULL. */ -static HKEY OpenRegKey( const RString &sKey ) +static HKEY OpenRegKey( const RString &sKey, bool bWarnOnError = true ) { RString sSubkey; HKEY hType; @@ -47,7 +47,8 @@ static HKEY OpenRegKey( const RString &sKey ) LONG retval = RegOpenKeyEx( hType, sSubkey, 0, KEY_READ, &hRetKey ); if ( retval != ERROR_SUCCESS ) { - LOG->Warn( werr_ssprintf(retval, "RegOpenKeyEx(%x,%s) error", hType, sSubkey.c_str()) ); + if( bWarnOnError ) + LOG->Warn( werr_ssprintf(retval, "RegOpenKeyEx(%x,%s) error", hType, sSubkey.c_str()) ); return NULL; } @@ -80,9 +81,9 @@ bool RegistryAccess::GetRegValue( const RString &sKey, const RString &sName, RSt return true; } -bool RegistryAccess::GetRegValue( const RString &sKey, const RString &sName, int &iVal ) +bool RegistryAccess::GetRegValue( const RString &sKey, const RString &sName, int &iVal, bool bWarnOnError ) { - HKEY hKey = OpenRegKey( sKey ); + HKEY hKey = OpenRegKey( sKey, bWarnOnError ); if( hKey == NULL ) return false; diff --git a/stepmania/src/archutils/Win32/RegistryAccess.h b/stepmania/src/archutils/Win32/RegistryAccess.h index 49dddba42d..4680174c79 100644 --- a/stepmania/src/archutils/Win32/RegistryAccess.h +++ b/stepmania/src/archutils/Win32/RegistryAccess.h @@ -6,7 +6,7 @@ namespace RegistryAccess { bool GetRegValue( const RString &sKey, const RString &sName, RString &val ); - bool GetRegValue( const RString &sKey, const RString &sName, int &val ); + bool GetRegValue( const RString &sKey, const RString &sName, int &val, bool bWarnOnError = true ); bool GetRegValue( const RString &sKey, const RString &sName, bool &val ); bool GetRegSubKeys( const RString &sKey, vector &asList, const RString &sRegex = ".*", bool bReturnPathToo = true );