Improvements to XInput vibration:

- use std::chrono to measure 20ms between XInputSetState calls, because clock() measures cpu time and not real time (so calls were made more often than intended)
- fixup data types for cached vibration values to prevent u8 values overflowing and giving false positives on m_dev->newVibrateData
This commit is contained in:
Silent 2019-07-14 17:47:06 +02:00 committed by Megamouse
parent b3aff3a1c6
commit 87ffa04a2b
2 changed files with 13 additions and 13 deletions

View file

@ -5,7 +5,7 @@
#define NOMINMAX
#include <Windows.h>
#include <Xinput.h>
#include <ctime>
#include <chrono>
namespace XINPUT_INFO
{
@ -91,9 +91,9 @@ class xinput_pad_handler final : public PadHandlerBase
{
u32 deviceNumber{ 0 };
bool newVibrateData{ true };
u8 largeVibrate{ 0 };
u8 smallVibrate{ 0 };
clock_t last_vibration{ 0 };
u16 largeVibrate{ 0 };
u16 smallVibrate{ 0 };
std::chrono::high_resolution_clock::time_point last_vibration;
pad_config* config{ nullptr };
};