config:ps3-controller
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
config:ps3-controller [2019/04/22 23:46] – created Wulf Rajek | config:ps3-controller [2023/05/29 11:55] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PS3 Controller/ | ====== PS3 Controller/ | ||
- | |||
https:// | https:// | ||
- | |||
https:// | https:// | ||
Line 10: | Line 8: | ||
https:// | https:// | ||
+ | |||
+ | |||
+ | £12 Third party PS3 controller (SHANWAN) from Amazon: https:// | ||
+ | |||
+ | The DualShock 3, DualShock 4 and Sixaxis controllers work out of the box when plugged in via USB (the PS button will need to be pushed to begin). | ||
+ | |||
+ | The generic Bluetooth driver is the btusb kernel module. To load: | ||
+ | < | ||
+ | sudo modprobe btusb | ||
+ | sudo modprobe bluetooth | ||
+ | </ | ||
+ | |||
+ | check modprobe blacklist in case bluetooth was disabled | ||
+ | / | ||
+ | ##Disable Bluetooth | ||
+ | #blacklist btusb | ||
+ | #blacklist bluetooth | ||
+ | |||
+ | |||
+ | connect via USB | ||
+ | |||
+ | Install the bluez and bluez-tools packages, which includes the sixaxis plugin. Bluez v5.48 and kernel 4.15 is required which include patches for third party PS3 controllers. | ||
+ | < | ||
+ | Then start bluetooth.service, | ||
+ | < | ||
+ | plug the controller in via USB, and the plugin should program your PC's bluetooth address into the controller automatically. If not, the sixpair.c file can be compiled and used. | ||
+ | |||
+ | You can now disconnect your controller. The next time you hit the PlayStation button it will connect without asking anything else. \\ | ||
+ | Alternatively, | ||
+ | Remember to disconnect the controller when you are done as the controller will stay on when connected and drain the battery. \\ | ||
+ | Note: If the controller does not connect, make sure the bluetooth interface is turned on and the controllers have been trusted. (See Bluetooth)\\ | ||
+ | |||
+ | < | ||
+ | sudo bluetoothctl | ||
+ | scan on | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | sudo apt-get install libusb-dev libusb-0.1-4 | ||
+ | gcc -o sixpair sixpair.c -lusb | ||
+ | sudo ./sixpair | ||
+ | No controller found on USB busses. | ||
+ | |||
+ | # plug in controller via usb | ||
+ | |||
+ | sudo ./sixpair | ||
+ | Current Bluetooth master: d0: | ||
+ | Setting master bd_addr to 30: | ||
+ | |||
+ | # disconnect from usb | ||
+ | |||
+ | sudo bluetoothctl | ||
+ | power on | ||
+ | discoverable on | ||
+ | advertise on | ||
+ | scan on | ||
+ | #switch on controller via PS button | ||
+ | [NEW] Device 04: | ||
+ | trust 04: | ||
+ | connect 04: | ||
+ | pair 04: | ||
+ | </ | ||
+ | |||
+ | connect via usb, wait 15 seconds\\ | ||
+ | disconnect from usb\\ | ||
+ | press select button while all leds flashing\\ | ||
+ | paired up, one led flashing only\\ | ||
+ | |||
+ | |||
+ | |||
+ | <code - sixpair.c> | ||
+ | /* | ||
+ | * sixpair.c version 2007-04-18 | ||
+ | * Compile with: gcc -o sixpair sixpair.c -lusb | ||
+ | */ | ||
+ | |||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | #define VENDOR 0x054c | ||
+ | #define PRODUCT 0x0268 | ||
+ | |||
+ | #define USB_DIR_IN 0x80 | ||
+ | #define USB_DIR_OUT 0 | ||
+ | |||
+ | void fatal(char *msg) { perror(msg); | ||
+ | |||
+ | void show_master(usb_dev_handle *devh, int itfnum) { | ||
+ | printf(" | ||
+ | unsigned char msg[8]; | ||
+ | int res = usb_control_msg | ||
+ | (devh, USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, | ||
+ | 0x01, 0x03f5, itfnum, (void*)msg, sizeof(msg), | ||
+ | if ( res < 0 ) { perror(" | ||
+ | printf(" | ||
+ | msg[2], msg[3], msg[4], msg[5], msg[6], msg[7]); | ||
+ | } | ||
+ | |||
+ | void set_master(usb_dev_handle *devh, int itfnum, int mac[6]) { | ||
+ | printf(" | ||
+ | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); | ||
+ | char msg[8]= { 0x01, 0x00, mac[0], | ||
+ | int res = usb_control_msg | ||
+ | (devh, | ||
+ | | ||
+ | 0x09, | ||
+ | | ||
+ | | ||
+ | if ( res < 0 ) fatal(" | ||
+ | } | ||
+ | |||
+ | void process_device(int argc, char **argv, struct usb_device *dev, | ||
+ | struct usb_config_descriptor *cfg, int itfnum) { | ||
+ | int mac[6], have_mac=0; | ||
+ | |||
+ | usb_dev_handle *devh = usb_open(dev); | ||
+ | if ( ! devh ) fatal(" | ||
+ | |||
+ | usb_detach_kernel_driver_np(devh, | ||
+ | |||
+ | int res = usb_claim_interface(devh, | ||
+ | if ( res < 0 ) fatal(" | ||
+ | |||
+ | show_master(devh, | ||
+ | |||
+ | if ( argc >= 2 ) { | ||
+ | if ( sscanf(argv[1], | ||
+ | & | ||
+ | |||
+ | printf(" | ||
+ | exit(1); | ||
+ | } | ||
+ | } else { | ||
+ | FILE *f = popen(" | ||
+ | if ( !f || | ||
+ | fscanf(f, " | ||
+ | & | ||
+ | printf(" | ||
+ | printf(" | ||
+ | exit(1); | ||
+ | } | ||
+ | pclose(f); | ||
+ | } | ||
+ | | ||
+ | set_master(devh, | ||
+ | |||
+ | usb_close(devh); | ||
+ | } | ||
+ | |||
+ | int main(int argc, char *argv[]) { | ||
+ | |||
+ | usb_init(); | ||
+ | if ( usb_find_busses() < 0 ) fatal(" | ||
+ | if ( usb_find_devices() < 0 ) fatal(" | ||
+ | struct usb_bus *busses = usb_get_busses(); | ||
+ | if ( ! busses ) fatal(" | ||
+ | |||
+ | int found = 0; | ||
+ | |||
+ | struct usb_bus *bus; | ||
+ | for ( bus=busses; bus; bus=bus-> | ||
+ | struct usb_device *dev; | ||
+ | for ( dev=bus-> | ||
+ | struct usb_config_descriptor *cfg; | ||
+ | for ( cfg = dev-> | ||
+ | cfg < dev-> | ||
+ | ++cfg ) { | ||
+ | int itfnum; | ||
+ | for ( itfnum=0; itfnum< | ||
+ | struct usb_interface *itf = & | ||
+ | struct usb_interface_descriptor *alt; | ||
+ | for ( alt = itf-> | ||
+ | alt < itf-> | ||
+ | ++alt ) { | ||
+ | if ( dev-> | ||
+ | dev-> | ||
+ | alt-> | ||
+ | process_device(argc, | ||
+ | ++found; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | if ( ! found ) printf(" | ||
+ | return 0; | ||
+ | |||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | http:// | ||
+ | |||
+ | https:// | ||
+ | |||
+ | https:// | ||
+ | |||
+ | https:// | ||
+ | |||
+ | https:// |
config/ps3-controller.1555973187.txt.gz · Last modified: 2023/05/29 11:53 (external edit)