Skip to content

Instantly share code, notes, and snippets.

@Ape
Created January 26, 2014 10:29
Show Gist options
  • Save Ape/8630957 to your computer and use it in GitHub Desktop.
Save Ape/8630957 to your computer and use it in GitHub Desktop.
DualShock 4 driver test using python
import os
device_path = '/dev/hidraw7'
fd = os.open(device_path, os.O_RDWR)
report = bytearray(78)
report[0] = 0x11
report[1] = 128
report[3] = 255
# Rumble
report[6] = 0
report[7] = 0
# LED (red, green, blue)
report[8] = 0
report[9] = 0
report[10] = 255
# Time to flash bright (255 = 2.5 seconds)
report[11] = 0
# Time to flash dark (255 = 2.5 seconds)
report[12] = 0
os.write(fd, report)
while True:
report = os.read(fd, 78)
print(report)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment