1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 18:53:28 +01:00

Resets sleep timer on button press

Adds windows sleep timer reset on ds4 button input

Refactoring

Shorter version
This commit is contained in:
RipleyTom 2017-08-07 14:33:07 +02:00 committed by Ivan
parent a38182b967
commit db9618ac2f
2 changed files with 24 additions and 0 deletions

View File

@ -5,6 +5,10 @@
#include <thread>
#include <cmath>
#ifdef _WIN32
#include <Windows.h>
#endif
namespace
{
const auto THREAD_SLEEP = 1ms; //ds4 has new data every ~4ms,
@ -394,6 +398,17 @@ void ds4_pad_handler::ProcessData()
pad.m_buttons[12 + i - 4].m_value = pressed ? 255 : 0;
}
#ifdef _WIN32
for (int i = 6; i < 16; i++)
{
if (pad.m_buttons[i].m_pressed)
{
SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
break;
}
}
#endif
// these values come already calibrated from our ds4Thread,
// all we need to do is convert to ds3 range

View File

@ -215,6 +215,15 @@ DWORD xinput_pad_handler::ThreadProcedure()
pad.m_buttons[j].m_value = pressed ? 255 : 0;
}
for (int i = 6; i < 16; i++)
{
if (pad.m_buttons[i].m_pressed)
{
SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
break;
}
}
pad.m_buttons[XINPUT_GAMEPAD_BUTTONS].m_pressed = state.Gamepad.bLeftTrigger > 0;
pad.m_buttons[XINPUT_GAMEPAD_BUTTONS].m_value = state.Gamepad.bLeftTrigger;
pad.m_buttons[XINPUT_GAMEPAD_BUTTONS + 1].m_pressed = state.Gamepad.bRightTrigger > 0;