Browse Source

Merge pull request #5309 from nounoursheureux/master

Fix the joystick vibration on Linux
Rémi Verschelde 9 years ago
parent
commit
a1a57bc369
2 changed files with 4 additions and 6 deletions
  1. 1 1
      main/input_default.cpp
  2. 3 5
      platform/x11/joystick_linux.cpp

+ 1 - 1
main/input_default.cpp

@@ -365,7 +365,7 @@ void InputDefault::stop_joy_vibration(int p_device) {
 	vibration.weak_magnitude = 0;
 	vibration.weak_magnitude = 0;
 	vibration.strong_magnitude = 0;
 	vibration.strong_magnitude = 0;
 	vibration.duration = 0;
 	vibration.duration = 0;
-	vibration.timestamp = OS::get_singleton()->get_unix_time();
+	vibration.timestamp = OS::get_singleton()->get_ticks_usec();
 	joy_vibration[p_device] = vibration;
 	joy_vibration[p_device] = vibration;
 }
 }
 
 

+ 3 - 5
platform/x11/joystick_linux.cpp

@@ -439,11 +439,9 @@ void joystick_linux::joystick_vibration_stop(int p_id, uint64_t p_timestamp)
 		return;
 		return;
 	}
 	}
 
 
-	struct input_event stop;
-	stop.type = EV_FF;
-	stop.code = joy.ff_effect_id;
-	stop.value = 0;
-	write(joy.fd, (const void*)&stop, sizeof(stop));
+	if (ioctl(joy.fd, EVIOCRMFF, joy.ff_effect_id) < 0) {
+		return;
+	}
 
 
 	joy.ff_effect_id = -1;
 	joy.ff_effect_id = -1;
 	joy.ff_effect_timestamp = p_timestamp;
 	joy.ff_effect_timestamp = p_timestamp;