mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-06-04 02:51:03 +00:00
Vibrations can start now
This commit is contained in:
parent
50feeaa758
commit
a0362edefb
1 changed files with 29 additions and 1 deletions
|
@ -46,6 +46,8 @@
|
|||
#include "cmdlib.h"
|
||||
#include "keydef.h"
|
||||
|
||||
#pragma comment(lib, "Xinput.lib")
|
||||
|
||||
// MACROS ------------------------------------------------------------------
|
||||
|
||||
// This macro is defined by newer versions of xinput.h. In case we are
|
||||
|
@ -107,6 +109,8 @@ public:
|
|||
bool GetEnabled();
|
||||
void SetEnabled(bool enabled);
|
||||
|
||||
void Rumble();
|
||||
|
||||
bool AllowsEnabledInBackground() { return true; }
|
||||
bool GetEnabledInBackground() { return EnabledInBackground; }
|
||||
void SetEnabledInBackground(bool enabled) { EnabledInBackground = enabled; }
|
||||
|
@ -129,6 +133,7 @@ protected:
|
|||
EJoyAxis GameAxis;
|
||||
float Multiplier;
|
||||
};
|
||||
XINPUT_VIBRATION Vibration;
|
||||
enum
|
||||
{
|
||||
AXIS_ThumbLX,
|
||||
|
@ -170,6 +175,8 @@ public:
|
|||
void GetDevices(TArray<IJoystickConfig *> &sticks);
|
||||
IJoystickConfig *Rescan();
|
||||
|
||||
void Rumble();
|
||||
|
||||
protected:
|
||||
HMODULE XInputDLL;
|
||||
FXInputController *Devices[XUSER_MAX_COUNT];
|
||||
|
@ -379,6 +386,15 @@ void FXInputController::Attached()
|
|||
UpdateJoystickMenu(this);
|
||||
}
|
||||
|
||||
#include <iostream>
|
||||
|
||||
void FXInputController::Rumble() {
|
||||
std::cout << "rumble" << std::endl;
|
||||
Vibration.wLeftMotorSpeed = -1;
|
||||
Vibration.wRightMotorSpeed = -1;
|
||||
XInputSetState(Index, &Vibration);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FXInputController :: Detached
|
||||
|
@ -821,6 +837,17 @@ bool FXInputManager::WndProcHook(HWND hWnd, uint32_t message, WPARAM wParam, LPA
|
|||
return false;
|
||||
}
|
||||
|
||||
void FXInputManager::Rumble() {
|
||||
|
||||
for (int i = 0; i < XUSER_MAX_COUNT; ++i)
|
||||
{
|
||||
if (Devices[i] && Devices[i]->IsConnected())
|
||||
{
|
||||
Devices[i]->Rumble();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// FXInputManager :: Rescan
|
||||
|
@ -867,7 +894,8 @@ void I_StartupXInput()
|
|||
}
|
||||
|
||||
void I_RumbleRaw(uint32_t duration_ms, uint16_t high_freq, uint16_t low_freq, uint16_t left_trig, uint16_t right_trig) {
|
||||
Printf("stub\n");
|
||||
FXInputManager* XInputManager = & static_cast<FXInputManager&> (*JoyDevices[INPUT_XInput]);
|
||||
if (XInputManager != NULL) XInputManager->Rumble();
|
||||
}
|
||||
void I_Rumble(unsigned int duration_ms, double high_freq, double low_freq, double left_trig, double right_trig) {
|
||||
I_RumbleRaw(0, 0, 0, 0, 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue