From e988a7487c8e0124e1d8c04008a743028dd9c6c9 Mon Sep 17 00:00:00 2001 From: ayuanx Date: Tue, 26 Jan 2010 05:43:00 +0000 Subject: [PATCH] Adapts emulated trigger range to Gamecube trigger range git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4963 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Plugins/Plugin_GCPad/Src/GCPad.cpp | 14 ++++++++++++++ Source/Plugins/Plugin_GCPad/Src/GCPad.h | 1 + 2 files changed, 15 insertions(+) diff --git a/Source/Plugins/Plugin_GCPad/Src/GCPad.cpp b/Source/Plugins/Plugin_GCPad/Src/GCPad.cpp index 21146d1837..bf417abf5b 100644 --- a/Source/Plugins/Plugin_GCPad/Src/GCPad.cpp +++ b/Source/Plugins/Plugin_GCPad/Src/GCPad.cpp @@ -364,6 +364,7 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus) { _pPADStatus->triggerLeft = GCMapping[_numPAD].AxisState.Lx; _pPADStatus->triggerRight = GCMapping[_numPAD].AxisState.Ly; + EmulateAnalogTrigger(_pPADStatus->triggerLeft, _pPADStatus->triggerRight); if (_pPADStatus->triggerLeft > DEF_TRIGGER_THRESHOLD) _pPADStatus->button |= PAD_TRIGGER_L; if (_pPADStatus->triggerRight > DEF_TRIGGER_THRESHOLD) @@ -373,6 +374,7 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus) { _pPADStatus->triggerLeft = GCMapping[_numPAD].AxisState.Rx; _pPADStatus->triggerRight = GCMapping[_numPAD].AxisState.Ry; + EmulateAnalogTrigger(_pPADStatus->triggerLeft, _pPADStatus->triggerRight); if (_pPADStatus->triggerLeft > DEF_TRIGGER_THRESHOLD) _pPADStatus->button |= PAD_TRIGGER_L; if (_pPADStatus->triggerRight > DEF_TRIGGER_THRESHOLD) @@ -382,6 +384,7 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus) { _pPADStatus->triggerLeft = GCMapping[_numPAD].AxisState.Tl; _pPADStatus->triggerRight = GCMapping[_numPAD].AxisState.Tr; + EmulateAnalogTrigger(_pPADStatus->triggerLeft, _pPADStatus->triggerRight); if (_pPADStatus->triggerLeft > DEF_TRIGGER_THRESHOLD) _pPADStatus->button |= PAD_TRIGGER_L; if (_pPADStatus->triggerRight > DEF_TRIGGER_THRESHOLD) @@ -424,6 +427,17 @@ void EmulateAnalogStick(unsigned char &stickX, unsigned char &stickY, bool butto } } +void EmulateAnalogTrigger(unsigned char &trL, unsigned char &trR) +{ + if (GCMapping[g_ID].TriggerType == InputCommon::CTL_TRIGGER_SDL) + { + int triggerL = abs((int)trL - 0x80) * 2; + int triggerR = abs((int)trR - 0x80) * 2; + trL = (triggerL > 0xFF) ? 0xFF : triggerL; + trR = (triggerR > 0xFF) ? 0xFF : triggerR; + } +} + void Close_Devices() { PAD_RumbleClose(); diff --git a/Source/Plugins/Plugin_GCPad/Src/GCPad.h b/Source/Plugins/Plugin_GCPad/Src/GCPad.h index f50b93e34c..625e653bb2 100644 --- a/Source/Plugins/Plugin_GCPad/Src/GCPad.h +++ b/Source/Plugins/Plugin_GCPad/Src/GCPad.h @@ -155,6 +155,7 @@ extern Display* WMdisplay; // Custom Functions // ---------------- void EmulateAnalogStick(unsigned char &stickX, unsigned char &stickY, bool buttonUp, bool buttonDown, bool buttonLeft, bool buttonRight, int magnitude); +void EmulateAnalogTrigger(unsigned char &trL, unsigned char &trR); void Close_Devices(); bool Search_Devices(std::vector &_joyinfo, int &_NumPads, int &_NumGoodPads); void GetAxisState(CONTROLLER_MAPPING_GC &_GCMapping);