From de3ad372998f3c0c7fb4fb47fde8d3b2edd79759 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Mon, 11 Oct 2010 22:19:47 +0000 Subject: [PATCH] WiimoteNew: Made emulated wiimote return read error when motion plus register area is read.(Fixes "Sonic the Hedgehog 4" input, perhaps others) GCPad/WiimoteNew: Made DirectInput use the Dolphin window hwnd for SetCoopLevel instead of GetForegroundWindow.(attempt to fix issue where gamepads sometimes don't work until "Refresh" is pressed) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6269 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../InputCommon/Src/ControllerInterface/DInput/DInput.cpp | 2 +- .../Src/ControllerInterface/DInput/DInputJoystick.cpp | 5 ++--- .../Src/ControllerInterface/DInput/DInputJoystick.h | 2 +- .../Plugin_WiimoteNew/Src/WiimoteEmu/EmuSubroutines.cpp | 4 ++++ 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInput.cpp b/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInput.cpp index 806fd31f3d..e09bd2fdd9 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInput.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInput.cpp @@ -71,7 +71,7 @@ void Init(std::vector& devices, HWND hwnd) InitKeyboardMouse(idi8, devices, hwnd); #endif #ifdef CIFACE_USE_DINPUT_JOYSTICK - InitJoystick(idi8, devices/*, hwnd*/); + InitJoystick(idi8, devices, hwnd); #endif idi8->Release(); diff --git a/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp b/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp index 337936f3a4..40823d617d 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp @@ -142,7 +142,7 @@ LCleanup: } #endif -void InitJoystick( IDirectInput8* const idi8, std::vector& devices/*, HWND hwnd*/ ) +void InitJoystick(IDirectInput8* const idi8, std::vector& devices, HWND hwnd) { std::list joysticks; idi8->EnumDevices( DI8DEVCLASS_GAMECTRL, DIEnumDevicesCallback, (LPVOID)&joysticks, DIEDFL_ATTACHEDONLY ); @@ -171,8 +171,7 @@ void InitJoystick( IDirectInput8* const idi8, std::vectorSetDataFormat(&c_dfDIJoystick))) { - // using foregroundwindow seems like a hack - if (FAILED(js_device->SetCooperativeLevel(GetForegroundWindow(), DISCL_BACKGROUND | DISCL_EXCLUSIVE))) + if (FAILED(js_device->SetCooperativeLevel(GetAncestor(hwnd, GA_ROOT), DISCL_BACKGROUND | DISCL_EXCLUSIVE))) { //PanicAlert("SetCooperativeLevel(DISCL_EXCLUSIVE) failed!"); // fall back to non-exclusive mode, with no rumble diff --git a/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.h b/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.h index 35faf2ee95..a1bdcde0e8 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.h +++ b/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.h @@ -21,7 +21,7 @@ namespace ciface namespace DInput { -void InitJoystick( IDirectInput8* const idi8, std::vector& devices/*, HWND hwnd*/ ); +void InitJoystick(IDirectInput8* const idi8, std::vector& devices, HWND hwnd); class Joystick : public ControllerInterface::Device { diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/EmuSubroutines.cpp b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/EmuSubroutines.cpp index fe457477e6..6f89016c09 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/EmuSubroutines.cpp +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/EmuSubroutines.cpp @@ -434,6 +434,10 @@ void Wiimote::ReadData(const wm_read_data* const rd) // motion plus case 0xa6 : { + // emulated motion plus is not yet supported + // return read error + size = 0; + // motion plus crap copied from old wiimote plugin //block[0xFC] = 0xA6; //block[0xFD] = 0x20;