2 from ds4drv.eventloop
import EventLoop
4 from threading
import Thread
5 from distutils.version
import StrictVersion
15 BATTERY_FULL_CHARGING = 11
27 self.loop.fire_event(event, *args)
32 self.loop.add_watcher(device.report_fd, self.
read_report)
39 self.loop.remove_watcher(self.device.report_fd)
44 report = self.device.read_report()
59 if self.
device is not None:
65 def control(self, led_red=None, led_green=None, led_blue=None,
66 rumble_small=
None, rumble_big=
None,
67 flash_on=
None, flash_off=
None):
69 Similar to DS4Device.control but with None as default values 80 self.
_led[0]
if led_red
is None else led_red,
81 self.
_led[1]
if led_green
is None else led_green,
82 self.
_led[2]
if led_blue
is None else led_blue,
85 self.
_led_flash[0]
if flash_on
is None else flash_on,
86 self.
_led_flash[1]
if flash_off
is None else flash_off,
91 self.
_control(small_rumble=rumble_small
if rumble_small
is not None else 0,
92 big_rumble=rumble_big
if rumble_big
is not None else 0)
95 self.device.control(led_red=self.
_led[0],
96 led_green=self.
_led[1],
97 led_blue=self.
_led[2],
105 Sets the correct IMU data in the report 106 See: https://github.com/chrippa/ds4drv/pull/168 110 ver_with_bug = StrictVersion(
'0.5.1')
111 current = StrictVersion(ds4drv.__version__)
114 if current > ver_with_bug
or not hasattr(report,
'orientation_roll'):
117 'x': report.lin_acc_x,
118 'y': report.lin_acc_y,
119 'z': report.lin_acc_z,
122 'x': report.ang_vel_x,
123 'y': report.ang_vel_y,
124 'z': report.ang_vel_z,
131 'x': ~report.orientation_roll,
132 'y': report.orientation_yaw,
133 'z': report.orientation_pitch,
136 'x': report.motion_y,
137 'y': report.motion_x,
138 'z': report.motion_z,
def fire_event(self, event, args)
def _control(self, kwargs)
def control(self, led_red=None, led_green=None, led_blue=None, rumble_small=None, rumble_big=None, flash_on=None, flash_off=None)
def setup_device(self, device)