Skip to content
This repository was archived by the owner on Dec 3, 2024. It is now read-only.

Commit aaf8c29

Browse files
committed
Infinite vibration. #105
1 parent 93a893b commit aaf8c29

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

XOutput/Devices/Input/DirectInput/DirectDevice.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ public void Dispose()
209209
{
210210
disposed = true;
211211
inputRefresher?.Abort();
212+
foreach (var effect in actuators.Values.Where(effect => effect != null))
213+
{
214+
effect.Dispose();
215+
}
212216
joystick.Dispose();
213217
}
214218
}
@@ -267,10 +271,11 @@ public void SetForceFeedback(double big, double small)
267271
var values = new Dictionary<DeviceObjectInstance, Effect>(actuators);
268272
foreach (var pair in values)
269273
{
274+
var actuator = pair.Key;
270275
var oldEffect = pair.Value;
271276
oldEffect?.Dispose();
277+
actuators[actuator] = null;
272278

273-
var actuator = pair.Key;
274279
var isSmall = actuator.ObjectType == ObjectGuid.YAxis;
275280
// All available axes will be added.
276281
var axes = new List<int> { (int)actuator.ObjectId };
@@ -287,7 +292,7 @@ public void SetForceFeedback(double big, double small)
287292
effectParams.Duration = int.MaxValue;
288293
effectParams.TriggerButton = -1;
289294
effectParams.TriggerRepeatInterval = int.MaxValue;
290-
effectParams.Gain = 10000;
295+
effectParams.Gain = joystick.Properties.ForceFeedbackGain;
291296
effectParams.SetAxes(axes.ToArray(), directions);
292297
var cf = new ConstantForce();
293298
cf.Magnitude = CalculateMagnitude(isSmall ? small : big);

0 commit comments

Comments
 (0)