#!/usr/bin/python # # Small script to test the rumble on a PS3 gamepad # import usb import time rumble = 0 busses = usb.busses() for bus in busses: devices = bus.devices for dev in devices: if dev.idVendor == 0x054c and dev.idProduct == 0x0268: print "Found RumblePad" rumble = dev if rumble == 0: print "RumblePad not found" exit(0) # Get a device handler for the usb device and detach it from the kernel dh = rumble.open() dh.detachKernelDriver(0) dh.claimInterface(0) #command='\x52\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1E\xff\x27\x10\x00\x32\xff\x27\x10\x00\x32\xff\x27\x10\x00\x32\xff\x27\x10\x00\x32\x00\x00\x00\x00\x00' # \x01 Header # \x00\x00\x00\x00\x00 ForceFeedback (\x00\xfe\x00+ # \x00\x00\x00\x00\x1E Which LED to enable(LED1..4 << 1, 0x20=none) # \xff\x27\x10\x00\x32 LED 1 (rate,duty factor # \xff\x27\x10\x00\x32 LED 2 # \xff\x27\x10\x00\x32 LED 3 # \xff\x27\x10\x00\x32 LED 4 # \x00\x00\x00\x00\x00 Footer # * the total time the led is active (0xff means forever) # * | duty_length: how long a cycle is in deciseconds (0 means "blink really fast") # * | | ??? (Some form of phase shift or duty_length multiplier?) # * | | | % of duty_length the led is off (0xff means 100%) # * | | | | % of duty_length the led is on (0xff mean 100%) # * | | | | | # * 0xff, 0x27, 0x10, 0x00, 0x32, print "LED3 + LED0" command='\x01' + \ '\x00\xfe\x00\xfe\x00' + \ '\x00\x00\x00\x00\x12' + \ '\xff\x00\x00\x00\x80' + \ '\xff\x00\x00\x00\x80' + \ '\xff\x00\x00\x00\x00' + \ '\xff\x00\x00\x00\x00' + \ '\x00\x00\x00\x00\x00' dh.bulkWrite(0x02, command, len(command)) time.sleep(3) print "LED2 + LED1" command='\x01' + \ '\x00\xfe\x00\xfe\x00' + \ '\x00\x00\x00\x00\x0C' + \ '\xff\x27\x10\x80\x32' + \ '\xff\x27\x10\x80\x32' + \ '\xff\x27\x10\x00\x32' + \ '\xff\x27\x10\x00\x32' + \ '\x00\x00\x00\x00\x00' dh.bulkWrite(0x02, command, len(command)) time.sleep(3) print "no LEDs" command='\x01' + \ '\x00\x00\x00\x00\x00' + \ '\x00\x00\x00\x00\x20' + \ '\xff\x07\x10\xff\x00' + \ '\xff\x07\x10\xff\x00' + \ '\xff\x07\x10\xff\x00' + \ '\xff\x07\x10\xff\x00' + \ '\x00\x00\x00\x00\x00' dh.bulkWrite(0x02, command, len(command))