Coordinate work for Sixaxis support in Linux
Coordinate work for Sixaxis support in Linux
Hi,
Here’s a summary about what’s needed to integrate the sixaxis support in GNU/Linux systems: http://wiki.ps2dev.org/ps3:linux:sixaxis
Fell free to comment/correct it.
there have been other posts about that in past:
http://forums.ps2dev.org/viewtopic.php?t=7097
http://forums.ps2dev.org/viewtopic.php?t=8274
but I am now aiming to integrate the support in mainline linux/udev/bluez with your collaboration.
Thanks,
Antonio
Here’s a summary about what’s needed to integrate the sixaxis support in GNU/Linux systems: http://wiki.ps2dev.org/ps3:linux:sixaxis
Fell free to comment/correct it.
there have been other posts about that in past:
http://forums.ps2dev.org/viewtopic.php?t=7097
http://forums.ps2dev.org/viewtopic.php?t=8274
but I am now aiming to integrate the support in mainline linux/udev/bluez with your collaboration.
Thanks,
Antonio
Well if you do not believe me, then i guess you can believe terrasoft.. (well actually they were bought by Fixstars and they released this new version)
as they posted this:
Yellow Dog Linux v6.1 supports:
- Sony PS3.
- Apple PowerPC G4, G5.
- YDL PowerStation.
- IBM System p (JS2x, 510, 520, 540).
Yellow Dog Linux v6.1 offers these updates over v6.0:
- Kernel 2.6.27
- GCC 4.1.2
- Cell SDK 3.1
- Firefox 3.0
- OpenOffice 2.3 (v3.0 coming to YDL.net Enhanced soon!)
- X.org 1.4.999 with xrandr 1.2.2
- Dramatically improved, automated wireless config.
- GUI configuration tool for YDL.net.
- Bluetooth support for the PS3 Sixaxis controller.
- Barcelona Supercomputing Center CellSs.
- ps3vram for fast, temp file storage or swap using PS3 video RAM.
this is the link to the webpage
www.terrasoftsolutions.com/news/2008/2008-11-19.shtml
another link with useful info and resources for development about cell
http://us.fixstars.com/showcase/cellebration/
another comment i read, was that they will shift the development a little more to support cell..
That are good news!
as they posted this:
Yellow Dog Linux v6.1 supports:
- Sony PS3.
- Apple PowerPC G4, G5.
- YDL PowerStation.
- IBM System p (JS2x, 510, 520, 540).
Yellow Dog Linux v6.1 offers these updates over v6.0:
- Kernel 2.6.27
- GCC 4.1.2
- Cell SDK 3.1
- Firefox 3.0
- OpenOffice 2.3 (v3.0 coming to YDL.net Enhanced soon!)
- X.org 1.4.999 with xrandr 1.2.2
- Dramatically improved, automated wireless config.
- GUI configuration tool for YDL.net.
- Bluetooth support for the PS3 Sixaxis controller.
- Barcelona Supercomputing Center CellSs.
- ps3vram for fast, temp file storage or swap using PS3 video RAM.
this is the link to the webpage
www.terrasoftsolutions.com/news/2008/2008-11-19.shtml
another link with useful info and resources for development about cell
http://us.fixstars.com/showcase/cellebration/
another comment i read, was that they will shift the development a little more to support cell..
That are good news!
BT is supported only because bluez-utils i.e. the bluetooth stack is supporting it :) so it is the same support like everywhere else.ao2 wrote:are accelerometer values exposed? If anyone tries it out, please report.speedxl wrote: - Bluetooth support for the PS3 Sixaxis controller.
Thanks.
And I bet USB is not working, as just a few days ago I had submitted a patch fixing it.
But this will give you far superior :) support of sixaxis:
Accelerometers are working fine :)
Just need to dive into PID specification for rumble
and LED :)
And the best part is: I have written it :)
http://forums.ps2dev.org/viewtopic.php?t=11488
Worst case scenario: I've seen it working so with a little bit of feedback
YOU may se it working too :)
Last edited by tolysz on Mon Jan 05, 2009 1:46 am, edited 1 time in total.
tolysz, have you asked linux-input for feedback?tolysz wrote:BT is supported only because bluez-utils i.e. the bluetooth stack is supporting it :) so it is the same support like everywhere else.ao2 wrote:are accelerometer values exposed? If anyone tries it out, please report.speedxl wrote: - Bluetooth support for the PS3 Sixaxis controller.
Thanks.
But this will give you far superior :) support of sixaxis:
Accelerometers are working fine :)
Just need to dive into PID specification for rumble
and LED :)
And the best part is: I have written it :)
http://forums.ps2dev.org/viewtopic.php?t=11488
Worst case scenario: I've seen it working so with a little bit of feedback
YOU may se it working too :)
I don't know if your approach will be accepted mainline, you are remapping the descriptor, while other joypad drivers I've seen around just _decode_ it and generate input events.
What about asking to linux-input what is the way to go before putting further effort in this?
About setting the joypad _fully_ operational for bluetooth, I thougth we can use a sysfs custom interface, and a udev rule that set the BT controller address for the joypad, something like this (for older kernels):
Code: Select all
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 27fe4d8..4787465 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -676,14 +676,127 @@ static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid)
}
/*
+ * Show and set the master bdaddr for PS3 controller, without disconnecting
+ * the device.
+ */
+static ssize_t show_sixaxis_master_bdaddr(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ int ret;
+ unsigned char *mbuf = kzalloc(9, GFP_KERNEL);
+ struct usb_device *udev = to_usb_device(dev);
+ int len = 18; /* "00:00:00:00:00:00\n" */
+ /*
+ * FIXME, ifnum should be obtained with something like:
+ *
+ * struct usb_interface *intf = to_usb_interface(dev);
+ * int ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
+ *
+ * but I must be doing something wrong because this doesn't work, so:
+ */
+ int ifnum = 0;
+
+ if (!mbuf)
+ return -ENOMEM;
+
+ ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
+ HID_REQ_GET_REPORT,
+ USB_DIR_IN | USB_TYPE_CLASS |
+ USB_RECIP_INTERFACE,
+ (3 << 8) | 0xf5, ifnum, mbuf, 8,
+ USB_CTRL_GET_TIMEOUT);
+ if (ret < 0) {
+ err_hid("%s failed: %d\n", __func__, ret);
+ printk(KERN_DEBUG "%02x:%02x:%02x:%02x:%02x:%02x\n",
+ mbuf[2], mbuf[3], mbuf[4], mbuf[5], mbuf[6], mbuf[7]);
+
+ kfree(mbuf);
+ return -EINVAL;
+ }
+
+ ret = snprintf(buf, len, "%02x:%02x:%02x:%02x:%02x:%02x\n",
+ mbuf[2], mbuf[3], mbuf[4], mbuf[5], mbuf[6], mbuf[7]);
+
+ kfree(mbuf);
+
+ return ret;
+}
+
+static ssize_t store_sixaxis_master_bdaddr(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t count)
+{
+ int ret;
+ int mac[6];
+ unsigned char *mbuf = kzalloc(9, GFP_KERNEL);
+ struct usb_device *udev = to_usb_device(dev);
+ /*
+ * FIXME, ifnum should be obtained with something like:
+ *
+ * struct usb_interface *intf = to_usb_interface(dev);
+ * int ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
+ *
+ * but I must be doing something wrong because this doesn't work, so:
+ */
+ int ifnum = 0;
+
+ ret = sscanf(buf, "%02x:%02x:%02x:%02x:%02x:%02x",
+ &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
+ if (ret != 6) {
+ printk(KERN_DEBUG "%s: failed, ret: %d\n", __func__, ret);
+ return -EINVAL;
+ }
+
+ mbuf[0] = 0x01;
+ mbuf[1] = 0x00;
+ mbuf[2] = mac[0];
+ mbuf[3] = mac[1];
+ mbuf[4] = mac[2];
+ mbuf[5] = mac[3];
+ mbuf[6] = mac[4];
+ mbuf[7] = mac[5];
+
+ printk(KERN_DEBUG "%s: %02x:%02x:%02x:%02x:%02x:%02x\n", __func__,
+ mbuf[2], mbuf[3], mbuf[4], mbuf[5], mbuf[6], mbuf[7]);
+
+ ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
+ HID_REQ_SET_REPORT,
+ USB_DIR_OUT | USB_TYPE_CLASS |
+ USB_RECIP_INTERFACE,
+ (3 << 8) | 0xf5, ifnum, mbuf, 8,
+ USB_CTRL_GET_TIMEOUT);
+
+ kfree(mbuf);
+
+ if (ret < 0) {
+ err_hid("%s failed: %d\n", __func__, ret);
+ return ret;
+ }
+
+ return count;
+}
+
+static DEVICE_ATTR(sixaxis_master_bdaddr, S_IWUSR|S_IRUGO,
+ show_sixaxis_master_bdaddr, store_sixaxis_master_bdaddr);
+
+static struct attribute *sixaxis_attributes[] = {
+ &dev_attr_sixaxis_master_bdaddr.attr,
+ NULL
+};
+
+static const struct attribute_group sixaxis_attr_group = {
+ .attrs = sixaxis_attributes,
+};
+
+/*
* Sending HID_REQ_GET_REPORT changes the operation mode of the ps3 controller
* to "operational". Without this, the ps3 controller will not report any
* events.
*/
+
static void hid_fixup_sony_ps3_controller(struct usb_device *dev, int ifnum)
{
int result;
- char *buf = kmalloc(18, GFP_KERNEL);
+ unsigned char *buf = kmalloc(18, GFP_KERNEL);
if (!buf)
return;
@@ -697,6 +810,9 @@ static void hid_fixup_sony_ps3_controller(struct usb_device *dev, int ifnum)
if (result < 0)
err_hid("%s failed: %d\n", __func__, result);
+ else
+ printk(KERN_INFO "Sony PS3 Controller bdaddr: %02x:%02x:%02x:%02x:%02x:%02x\n",
+ buf[4], buf[5], buf[6], buf[7], buf[8], buf[9]);
kfree(buf);
}
@@ -951,6 +1067,10 @@ static void hid_disconnect(struct usb_interface *intf)
del_timer_sync(&usbhid->io_retry);
cancel_work_sync(&usbhid->reset_work);
+ if (hid->quirks & HID_QUIRK_SONY_PS3_CONTROLLER)
+ sysfs_remove_group(&interface_to_usbdev(intf)->dev.kobj,
+ &sixaxis_attr_group);
+
if (hid->claimed & HID_CLAIMED_INPUT)
hidinput_disconnect(hid);
if (hid->claimed & HID_CLAIMED_HIDDEV)
@@ -1003,10 +1123,19 @@ static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id)
if ((hid->claimed & HID_CLAIMED_INPUT))
hid_ff_init(hid);
- if (hid->quirks & HID_QUIRK_SONY_PS3_CONTROLLER)
+ if (hid->quirks & HID_QUIRK_SONY_PS3_CONTROLLER) {
hid_fixup_sony_ps3_controller(interface_to_usbdev(intf),
intf->cur_altsetting->desc.bInterfaceNumber);
+ /* Register sysfs hooks */
+ i = sysfs_create_group(&interface_to_usbdev(intf)->dev.kobj,
+ &sixaxis_attr_group);
+ if (i < 0){
+ printk(KERN_DEBUG "%s: cannot register sixaxis sysfs hooks\n",
+ __func__);
+ }
+ }
+
printk(KERN_INFO);
if (hid->claimed & HID_CLAIMED_INPUT)
Regards, ao2
I just need to wait for regression tests :) as I do not want to make silly posts on: linux-input; linux-bluetooth; linux-usb; (as Linus might see it :p)ao2 wrote: tolysz, have you asked linux-input for feedback?
I don't know if your approach will be accepted mainline, you are remapping the descriptor, while other joypad drivers I've seen around just _decode_ it and generate input events.
What about asking to linux-input what is the way to go before putting further effort in this?
About setting the joypad _fully_ operational for bluetooth, I thougth we can use a sysfs custom interface, and a udev rule that set the BT controller address for the joypad, something like this (for older kernels):
If we want to discuss all this on linux-input, please tell me and I'll subcribe.
Regards, ao2
I have patched all devices using that code so I am covered :) However regression is very important.
My solution is very general, it will apply to any device, even not a native HID one. Only if we had a fake driver and some user land. It would speed-up development as you would just design a descriptor.
I was thinking about sysfs myself - but you know - it is to much for one patch and is dangerous.
I wanted to be able to remap descriptor "on line" almost on per application basis :) using sysfs of course :)
I have written this driver overnight - it works for me :) but is it working for you?
And that code of yours seams to: just embeding sixpair.c :) as rest is already in mainline. and does not support DS3 :( [as this guy requires BT equivalent of make operational]
Happy Hacking
BTW. Yesterday, I had something similar but much less mature as yours is, but I decided to make only small changes with big implications and left it out.