Removed ResetFeedback + small fixes
This commit is contained in:
parent
bde3edf024
commit
33b2805f89
@ -25,9 +25,7 @@ EnableRumble=0
|
|||||||
ReverseRumble=0
|
ReverseRumble=0
|
||||||
; Set to 1 to generate log.txt, else 0. Logs will be appended and not cleared.
|
; Set to 1 to generate log.txt, else 0. Logs will be appended and not cleared.
|
||||||
Logging=0
|
Logging=0
|
||||||
; When a command is set that contradicts a prior command, clear the prior command. Probably should stay as 1.
|
; Length of a feedback command. While a long period works fine, some games may still require shorter ones.
|
||||||
ResetFeedback=0
|
|
||||||
; Length of a feedback command. While a long period works fine (as long as ResetFeedback=1), some games may still require shorter ones.
|
|
||||||
FeedbackLength=500
|
FeedbackLength=500
|
||||||
; If a game does not specify its own Centering or Friction forces (e.g. only specifies roll left/right),
|
; If a game does not specify its own Centering or Friction forces (e.g. only specifies roll left/right),
|
||||||
; then a default centering and friction force can be applied here. If a game has any of its own such forces,
|
; then a default centering and friction force can be applied here. If a game has any of its own such forces,
|
||||||
|
91
DllMain.cpp
91
DllMain.cpp
@ -854,7 +854,6 @@ int EnableRumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableRumble"),
|
|||||||
int ReverseRumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("ReverseRumble"), 0, settingsFilename);
|
int ReverseRumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("ReverseRumble"), 0, settingsFilename);
|
||||||
wchar_t *deviceGUIDString = new wchar_t[256];
|
wchar_t *deviceGUIDString = new wchar_t[256];
|
||||||
int DeviceGUID = GetPrivateProfileString(TEXT("Settings"), TEXT("DeviceGUID"), NULL, deviceGUIDString, 256, settingsFilename);
|
int DeviceGUID = GetPrivateProfileString(TEXT("Settings"), TEXT("DeviceGUID"), NULL, deviceGUIDString, 256, settingsFilename);
|
||||||
int configResetFeedback = GetPrivateProfileInt(TEXT("Settings"), TEXT("ResetFeedback"), 1, settingsFilename);
|
|
||||||
int configFeedbackLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("FeedbackLength"), 120, settingsFilename);
|
int configFeedbackLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("FeedbackLength"), 120, settingsFilename);
|
||||||
int configGameId = GetPrivateProfileInt(TEXT("Settings"), TEXT("GameId"), 0, settingsFilename);
|
int configGameId = GetPrivateProfileInt(TEXT("Settings"), TEXT("GameId"), 0, settingsFilename);
|
||||||
int configDefaultCentering = GetPrivateProfileInt(TEXT("Settings"), TEXT("DefaultCentering"), 0, settingsFilename);
|
int configDefaultCentering = GetPrivateProfileInt(TEXT("Settings"), TEXT("DefaultCentering"), 0, settingsFilename);
|
||||||
@ -925,7 +924,7 @@ void Initialize(int device_index)
|
|||||||
hlp.log("in initialize");
|
hlp.log("in initialize");
|
||||||
SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC | SDL_INIT_TIMER);
|
SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC | SDL_INIT_TIMER);
|
||||||
SDL_JoystickEventState(SDL_ENABLE);
|
SDL_JoystickEventState(SDL_ENABLE);
|
||||||
SDL_JoystickUpdate;
|
SDL_JoystickUpdate();
|
||||||
char joystick_guid[256];
|
char joystick_guid[256];
|
||||||
sprintf(joystick_guid, "%S", deviceGUIDString);
|
sprintf(joystick_guid, "%S", deviceGUIDString);
|
||||||
SDL_JoystickGUID guid, dev_guid;
|
SDL_JoystickGUID guid, dev_guid;
|
||||||
@ -940,7 +939,7 @@ void Initialize(int device_index)
|
|||||||
SDL_Joystick* js = SDL_JoystickOpen(i);
|
SDL_Joystick* js = SDL_JoystickOpen(i);
|
||||||
const char* name = SDL_JoystickName(js);
|
const char* name = SDL_JoystickName(js);
|
||||||
joystick_index1 = SDL_JoystickInstanceID(js);
|
joystick_index1 = SDL_JoystickInstanceID(js);
|
||||||
SDL_JoystickGUID guid = SDL_JoystickGetGUID(js);
|
guid = SDL_JoystickGetGUID(js);
|
||||||
if (ForceShowDeviceGUIDMessageBox == 1)
|
if (ForceShowDeviceGUIDMessageBox == 1)
|
||||||
{
|
{
|
||||||
char text[256];
|
char text[256];
|
||||||
@ -985,7 +984,6 @@ void Initialize(int device_index)
|
|||||||
haptic = ControllerHaptic;
|
haptic = ControllerHaptic;
|
||||||
if ((SDL_HapticRumbleSupported(haptic) == SDL_TRUE && EnableRumble == 1))
|
if ((SDL_HapticRumbleSupported(haptic) == SDL_TRUE && EnableRumble == 1))
|
||||||
{
|
{
|
||||||
SDL_HapticRumbleInit;
|
|
||||||
SDL_HapticRumbleInit(ControllerHaptic);
|
SDL_HapticRumbleInit(ControllerHaptic);
|
||||||
hlp.log("Rumble Init");
|
hlp.log("Rumble Init");
|
||||||
}
|
}
|
||||||
@ -1078,27 +1076,11 @@ void Initialize(int device_index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
std::chrono::milliseconds timeOfLastConstantEffect = duration_cast<milliseconds>(system_clock::now().time_since_epoch());
|
|
||||||
std::chrono::milliseconds timeOfLastFrictionEffect = duration_cast<milliseconds>(system_clock::now().time_since_epoch());
|
|
||||||
std::chrono::milliseconds timeOfLastSineEffect = duration_cast<milliseconds>(system_clock::now().time_since_epoch());
|
std::chrono::milliseconds timeOfLastSineEffect = duration_cast<milliseconds>(system_clock::now().time_since_epoch());
|
||||||
std::chrono::milliseconds timeOfLastSpringEffect = duration_cast<milliseconds>(system_clock::now().time_since_epoch());
|
|
||||||
std::string lastConstantEffectHash = "";
|
|
||||||
std::string lastFrictionEffectHash = "";
|
|
||||||
double lastSineEffectStrength = 0;
|
double lastSineEffectStrength = 0;
|
||||||
double lastSineEffectPeriod = 0;
|
double lastSineEffectPeriod = 0;
|
||||||
std::string lastSpringEffectHash = "";
|
|
||||||
void TriggerConstantEffect(int direction, double strength)
|
void TriggerConstantEffect(int direction, double strength)
|
||||||
{
|
{
|
||||||
// if no strength, we do nothing
|
|
||||||
if (strength <= 0.001) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// stop previous effect if not completed
|
|
||||||
if (configResetFeedback) {
|
|
||||||
SDL_HapticStopEffect(haptic, effects.effect_constant_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_HapticEffect tempEffect;
|
SDL_HapticEffect tempEffect;
|
||||||
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
||||||
tempEffect.type = SDL_HAPTIC_CONSTANT;
|
tempEffect.type = SDL_HAPTIC_CONSTANT;
|
||||||
@ -1144,36 +1126,15 @@ void TriggerConstantEffect(int direction, double strength)
|
|||||||
SDL_HapticRunEffect(haptic, effects.effect_constant_id, 1);
|
SDL_HapticRunEffect(haptic, effects.effect_constant_id, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerFrictionEffectWithDefaultOption(double strength, bool isDefault) {
|
void TriggerFrictionEffectWithDefaultOption(double strength, bool isDefault)
|
||||||
std::chrono::milliseconds now = duration_cast<milliseconds>(system_clock::now().time_since_epoch());
|
{
|
||||||
long long elapsedTime = (std::chrono::duration_cast<std::chrono::milliseconds>(now - timeOfLastFrictionEffect)).count();
|
|
||||||
std::string effectHash = std::to_string(effects.effect_friction_id) + "_" + std::to_string(strength);
|
|
||||||
|
|
||||||
if (!isDefault) {
|
|
||||||
// if the effect is the same as the last effect that was sent AND enough time hasn't elapsed, do nothing
|
|
||||||
if (effectHash.compare(lastFrictionEffectHash) == 0 && elapsedTime < configFeedbackLength) {
|
|
||||||
return; // same effect, do nothing.
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: investigate if we need this
|
|
||||||
if (configResetFeedback || strength <= 0.001) {
|
|
||||||
SDL_HapticStopEffect(haptic, effects.effect_friction_id);
|
|
||||||
if (strength <= 0.01) {
|
|
||||||
timeOfLastFrictionEffect = now;
|
|
||||||
lastFrictionEffectHash = effectHash;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_HapticEffect tempEffect;
|
SDL_HapticEffect tempEffect;
|
||||||
|
|
||||||
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
||||||
tempEffect.type = SDL_HAPTIC_FRICTION;
|
tempEffect.type = SDL_HAPTIC_FRICTION;
|
||||||
tempEffect.condition.type = SDL_HAPTIC_FRICTION;
|
tempEffect.condition.type = SDL_HAPTIC_FRICTION;
|
||||||
tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN;
|
tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN;
|
||||||
tempEffect.condition.delay = 0;
|
tempEffect.condition.delay = 0;
|
||||||
tempEffect.condition.length = isDefault ? 0xFFFFFFFF : configFeedbackLength;
|
tempEffect.condition.length = isDefault ? SDL_HAPTIC_INFINITY : configFeedbackLength;
|
||||||
tempEffect.condition.left_sat[0] = 0xFFFF;
|
tempEffect.condition.left_sat[0] = 0xFFFF;
|
||||||
tempEffect.condition.right_sat[0] = 0xFFFF;
|
tempEffect.condition.right_sat[0] = 0xFFFF;
|
||||||
|
|
||||||
@ -1190,10 +1151,6 @@ void TriggerFrictionEffectWithDefaultOption(double strength, bool isDefault) {
|
|||||||
tempEffect.condition.right_coeff[0] = (short)(coeff);
|
tempEffect.condition.right_coeff[0] = (short)(coeff);
|
||||||
SDL_HapticUpdateEffect(haptic, effects.effect_friction_id, &tempEffect);
|
SDL_HapticUpdateEffect(haptic, effects.effect_friction_id, &tempEffect);
|
||||||
SDL_HapticRunEffect(haptic, effects.effect_friction_id, 1);
|
SDL_HapticRunEffect(haptic, effects.effect_friction_id, 1);
|
||||||
if (!isDefault) {
|
|
||||||
timeOfLastFrictionEffect = now;
|
|
||||||
lastFrictionEffectHash = effectHash;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerInertiaEffect(double strength)
|
void TriggerInertiaEffect(double strength)
|
||||||
@ -1415,11 +1372,6 @@ void TriggerSineEffect(UINT16 period, UINT16 fadePeriod, double strength)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// stop previous effect if not completed
|
|
||||||
if (configResetFeedback) {
|
|
||||||
SDL_HapticStopEffect(haptic, effects.effect_sine_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_HapticEffect tempEffect;
|
SDL_HapticEffect tempEffect;
|
||||||
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
||||||
hlp.log("Doing sine...");
|
hlp.log("Doing sine...");
|
||||||
@ -1473,35 +1425,15 @@ void TriggerSineEffect(UINT16 period, UINT16 fadePeriod, double strength)
|
|||||||
lastSineEffectPeriod = period;
|
lastSineEffectPeriod = period;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerSpringEffectWithDefaultOption(double strength, bool isDefault) {
|
void TriggerSpringEffectWithDefaultOption(double strength, bool isDefault)
|
||||||
/*std::chrono::milliseconds now = duration_cast<milliseconds>(system_clock::now().time_since_epoch());
|
{
|
||||||
long long elapsedTime = (std::chrono::duration_cast<std::chrono::milliseconds>(now - timeOfLastSpringEffect)).count();
|
|
||||||
std::string effectHash = std::to_string(effects.effect_spring_id) + "_" + std::to_string(strength);
|
|
||||||
|
|
||||||
if (!isDefault) {
|
|
||||||
// if the effect is the same as the last effect that was sent AND enough time hasn't elapsed, do nothing
|
|
||||||
if (effectHash.compare(lastSpringEffectHash) == 0 && elapsedTime < configFeedbackLength) {
|
|
||||||
return; // same effect, do nothing.
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: investigate if we need this
|
|
||||||
if (configResetFeedback || strength <= 0.001) {
|
|
||||||
SDL_HapticStopEffect(haptic, effects.effect_spring_id);
|
|
||||||
if (strength <= 0.01) {
|
|
||||||
timeOfLastSpringEffect = now;
|
|
||||||
lastSpringEffectHash = effectHash;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
SDL_HapticEffect tempEffect;
|
SDL_HapticEffect tempEffect;
|
||||||
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect));
|
||||||
tempEffect.type = SDL_HAPTIC_SPRING;
|
tempEffect.type = SDL_HAPTIC_SPRING;
|
||||||
tempEffect.condition.type = SDL_HAPTIC_SPRING;
|
tempEffect.condition.type = SDL_HAPTIC_SPRING;
|
||||||
tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN;
|
tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN;
|
||||||
tempEffect.condition.delay = 0;
|
tempEffect.condition.delay = 0;
|
||||||
tempEffect.condition.length = isDefault ? 0xFFFFFFFF : configFeedbackLength;
|
tempEffect.condition.length = isDefault ? SDL_HAPTIC_INFINITY : configFeedbackLength;
|
||||||
tempEffect.condition.direction.dir[0] = 1;
|
tempEffect.condition.direction.dir[0] = 1;
|
||||||
tempEffect.constant.direction.dir[1] = 0; //Y Position
|
tempEffect.constant.direction.dir[1] = 0; //Y Position
|
||||||
|
|
||||||
@ -1522,11 +1454,6 @@ void TriggerSpringEffectWithDefaultOption(double strength, bool isDefault) {
|
|||||||
|
|
||||||
SDL_HapticUpdateEffect(haptic, effects.effect_spring_id, &tempEffect);
|
SDL_HapticUpdateEffect(haptic, effects.effect_spring_id, &tempEffect);
|
||||||
SDL_HapticRunEffect(haptic, effects.effect_spring_id, 1);
|
SDL_HapticRunEffect(haptic, effects.effect_spring_id, 1);
|
||||||
|
|
||||||
/*if (!isDefault) {
|
|
||||||
timeOfLastSpringEffect = now;
|
|
||||||
lastSpringEffectHash = effectHash;
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerSpringEffectInfinite(double strength)
|
void TriggerSpringEffectInfinite(double strength)
|
||||||
@ -1542,7 +1469,6 @@ void TriggerSpringEffectInfinite(double strength)
|
|||||||
tempEffect.condition.direction.dir[0] = 1;
|
tempEffect.condition.direction.dir[0] = 1;
|
||||||
tempEffect.constant.direction.dir[1] = 1; //Y Position
|
tempEffect.constant.direction.dir[1] = 1; //Y Position
|
||||||
|
|
||||||
|
|
||||||
SHORT minForce = (SHORT)(strength > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0.
|
SHORT minForce = (SHORT)(strength > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0.
|
||||||
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0);
|
||||||
SHORT range = maxForce - minForce;
|
SHORT range = maxForce - minForce;
|
||||||
@ -1648,7 +1574,6 @@ void TriggerRumbleEffect(double strength, double length)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TriggerSpringEffect(double strength)
|
void TriggerSpringEffect(double strength)
|
||||||
{
|
{
|
||||||
TriggerSpringEffectWithDefaultOption(strength, false);
|
TriggerSpringEffectWithDefaultOption(strength, false);
|
||||||
|
@ -414,8 +414,6 @@ EnableRumble= **Turn Off (0) if your wheel supports rumble effect. For controlle
|
|||||||
|
|
||||||
Logging= **Turn On (1) to allow log.txt to be made to log plugin. Device GUID is given in here**
|
Logging= **Turn On (1) to allow log.txt to be made to log plugin. Device GUID is given in here**
|
||||||
|
|
||||||
ResetFeedback= **When a command is set that contradicts a prior command, clear the prior command.**
|
|
||||||
|
|
||||||
FeedbackLength= **Length of a feedback command**
|
FeedbackLength= **Length of a feedback command**
|
||||||
|
|
||||||
DefaultCentering= **If a game does not specify its own Centering force then a default centering can be applied here.
|
DefaultCentering= **If a game does not specify its own Centering force then a default centering can be applied here.
|
||||||
|
Loading…
Reference in New Issue
Block a user