XInput Rumble

This commit is contained in:
nastys
2019-09-11 02:25:01 +02:00
parent b2d5311d79
commit 8d02025254
5 changed files with 21 additions and 6 deletions
@@ -19,8 +19,11 @@ namespace TLAC::Components
{
const std::string KEY_CONFIG_FILE_NAME = "keyconfig.ini";
TouchSliderEmulator* TouchSliderEmulator::LatestInstance;
TouchSliderEmulator::TouchSliderEmulator()
{
LatestInstance = this;
}
TouchSliderEmulator::~TouchSliderEmulator()
@@ -17,6 +17,8 @@ namespace TLAC::Components
class TouchSliderEmulator : public EmulatorComponent
{
public:
static TouchSliderEmulator* LatestInstance;
Input::Binding* LeftSideSlideLeft;
Input::Binding* LeftSideSlideRight;
@@ -34,6 +36,14 @@ namespace TLAC::Components
virtual void OnFocusLost() override;
bool isSliderTouched()
{
for (int i = 0; i < 32; i++)
if (sliderState->SensorTouched[i].IsTouched) return true;
return false;
}
private:
ComponentsManager* componentsManager;
float sliderSpeed = 750.0f;
@@ -5,7 +5,7 @@
namespace TLAC::Input
{
// DualShock 4 Controller Product GUIDs:
// Controller GUIDs:
const GUID GUID_Ds4[] =
{
// First Generation: {05C4054C-0000-0000-0000-504944564944}
@@ -15,9 +15,9 @@ namespace TLAC::Input
// GAMO2 DIVALLER: {11140E8F-0000-0000-0000-504944564944}
{ 0x11140E8F, 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } },
// Hori HATSUNE MIKU X: {00A50F0D-0000-0000-0000-504944564944}
{ 0x00A50F0D, 0x0000, 0x0000,{ 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } },
{ 0x00A50F0D, 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } },
// Hori F2nd Miniboard (Hatsune Miku Sho): {00490F0D-0000-0000-0000-504944564944}
{ 0x00490F0D, 0x0000, 0x0000,{ 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } },
{ 0x00490F0D, 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } }
};
class DualShock4 : public Controller, public IInputDevice
@@ -4,6 +4,7 @@
#include "../../FileSystem/ConfigFile.h"
#include "../../framework.h"
#include "../../Components/GameTargets/TargetInspector.h"
#include "../../Components/Input/TouchSliderEmulator.h"
namespace TLAC::Input
{
@@ -232,8 +233,7 @@ namespace TLAC::Input
ZeroMemory(&vibration, sizeof(XINPUT_VIBRATION));
vibration.wLeftMotorSpeed = 8000; // use any value between 0-65535 here
vibration.wRightMotorSpeed = 4000; // use any value between 0-65535 here
//XInputSetState(xc_pref, &vibration);
//printf("1");
if (TLAC::Components::TouchSliderEmulator::LatestInstance->isSliderTouched()) XInputSetState(xc_pref, &vibration);
}
else
{
@@ -241,7 +241,7 @@ namespace TLAC::Input
ZeroMemory(&vibration, sizeof(XINPUT_VIBRATION));
vibration.wLeftMotorSpeed = 0; // use any value between 0-65535 here
vibration.wRightMotorSpeed = 0; // use any value between 0-65535 here
//XInputSetState(xc_pref, &vibration);
XInputSetState(xc_pref, &vibration);
//printf("0");
}