From 7006682250f01fd41f5112ff166ba09fe5dfb191 Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke Date: Sun, 2 Jan 2011 19:12:32 +0100 Subject: [PATCH] Some more chatpad work --- AUTHORS | 8 ++++++-- NEWS | 8 ++++++++ PROTOCOL | 40 ++++++++++++++++++++++++++++++++++++++++ TODO | 29 +++++++++++++++++++++++++---- src/chatpad.cpp | 30 ++++++++++++++++++++---------- src/chatpad.hpp | 8 ++++++++ 6 files changed, 107 insertions(+), 16 deletions(-) diff --git a/AUTHORS b/AUTHORS index 7fbd699..e3c44da 100644 --- a/AUTHORS +++ b/AUTHORS @@ -35,8 +35,12 @@ Other parts of the code are inspired or based on cwiid: * L. Donnie Smith -Chatpad USB Protocol Traces: -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Chatpad USB Reverse Engineering: +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * Jani Virta + * Andy Kirkham + * dwomac + * GAFBlizzard + # EOF # diff --git a/NEWS b/NEWS index 211ee8e..4521702 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,11 @@ +xboxdrv 0.6.3 - (??/Jan/2011) +============================= + +* chatpad support, enable with --chatpad (special thanks to Jani + Virta, Andy Kirkham, dwomac and GAFBlizzard who helped make it + possible) + + xboxdrv 0.6.2 - (31/Dec/2010) ============================= diff --git a/PROTOCOL b/PROTOCOL index 90aac6b..edfe379 100644 --- a/PROTOCOL +++ b/PROTOCOL @@ -256,6 +256,46 @@ usb_control_msg()'s Sending "0x41 0x0 0x1f 0x02" gives a reply of "0x08, 0x03, 0x01" (chatpad) or "0x08, 0x03, 0x03" (chatpad + headset) +Data from Chatpad +================= + +0xf0 0x04 +0x00 MODIFIER SCAN1 SCAN2 0x00 + + ,- active LEDs + / ,----,---- clock, counts up to 0x0f then rolls to zero +0xf0 0x04 LEDSTATUS 0x0e 0x0e +0x00 0x00 0x34 0x00 0x00 <- always zero + | | `- scan1 `scan2 + \ `--- modifier bit field + `--- input event + +LED: +10111001 + + 0 0 + +LED_STATUS_PEOPLE = (1<<0) +LED_STATUS_SHIFT = (1<<5) +LED_STATUS_ORANGE = (1<<4) +LED_STATUS_GREEN = (1<<3) +LED_STATUS_BACKLIGHT = (1<<7) + +0xa0 - shift +0x88 - green +0x81 - people +0x90 - orange +0x91 - people+orange +0x98 - orange+green +0xb0 - shift+orange +0xb9 - shift+orange+green+shift + + +Chatpad init: + +Hardware version 1.10, uses 0x01 0x02 for init. +Hardware version 1.14, uses 0x09 0x00 for init. + Xbox360 Guitar ============== diff --git a/TODO b/TODO index 2b10060..4a46891 100644 --- a/TODO +++ b/TODO @@ -17,16 +17,37 @@ Ubuntu Package: =============== $ cd ../debian/ -$ git-import-orig -u 0.6.1 ~/projects/xboxdrv/htdocs/xboxdrv-linux-0.6.1.tar.bz2 -$ dch -v "0.6.1" "New Ubuntu release" +$ git-import-orig -u 0.6.3 ~/projects/xboxdrv/htdocs/xboxdrv-linux-0.6.3.tar.bz2 +$ dch -v "0.6.3" "New xboxdrv release" $ git-buildpackage --git-tag --git-builder="debuild -S" -$ sudo pbuilder --build xboxdrv_0.6.1.dsc -$ dput my-ppa xboxdrv_0.6.1_source.changes +$ sudo pbuilder --build xboxdrv_0.6.3.dsc +$ dput my-ppa xboxdrv_0.6.3_source.changes + + +Stuff to do before 0.6.4 release: +================================= + +* integrate filters into --buttonmap and --axismap: + + --buttonmap X^toggle:autofire=B + --axismap Y1^relative + + main purpose: allow to make shift a toggle button + +* bug: when shifting the last axis state sticks even when they key was released + +Figure out a way to load custom keymaps: + +* http://madduck.net/docs/extending-xkb/ +* http://stackoverflow.com/questions/1557689/keyboard-remapping-with-more-modifiers +* http://tldp.org/HOWTO/Keyboard-and-Console-HOWTO-15.html Stuff to do before 0.6.x release: ================================= +http://www.mp3car.com/vbulletin/input-devices/108554-xbox360-chatpad-awsome-backlit-mini-keyboard-16.html#post1256444 + * change default axis/button map depending on controller type (tricky as type is only really known after the axis/buttonmap as already been build): diff --git a/src/chatpad.cpp b/src/chatpad.cpp index b02e6aa..ce2bf9b 100644 --- a/src/chatpad.cpp +++ b/src/chatpad.cpp @@ -183,17 +183,14 @@ Chatpad::read_thread() } else { - if (false) + if (true) { - if (!(data[0] == 0xf0 && data[1] == 0x04)) // ignore timing messages + std::cout << "read: " << len << "/5: data: " << std::flush; + for(int i = 0; i < len; ++i) { - std::cout << "read: " << len << "/5: data: " << std::flush; - for(int i = 0; i < len; ++i) - { - std::cout << boost::format("0x%02x ") % int(data[i]); - } - std::cout << std::endl; + std::cout << boost::format("0x%02x ") % int(data[i]); } + std::cout << std::endl; } if (data[0] == 0x00) @@ -231,6 +228,11 @@ Chatpad::process(const ChatpadKeyMsg& msg) { if (m_state[i]) { + if (i == CHATPAD_KEY_1) + { + usb_control_msg(m_handle, 0x41, 0x00, 0x0004, 0x0002, NULL, 0, 0); + } + if (i == CHATPAD_MOD_PEOPLE) { set_led(CHATPAD_LED_PEOPLE, !get_led(CHATPAD_LED_PEOPLE)); @@ -298,8 +300,16 @@ Chatpad::send_init() } else { - buf[0] = 0x01; - buf[1] = 0x02; + if (true /* old_xbox360 pad */) + { + buf[0] = 0x01; + buf[1] = 0x02; + } + else + { + buf[0] = 0x09; + buf[1] = 0x00; + } ret = usb_control_msg(m_handle, 0x40, 0xa1, 0x0000, 0xe416, buf, 2, 0); // (send 2 bytes, data must be 0x09 0x00) std::cout << "ret: " << ret << std::endl; diff --git a/src/chatpad.hpp b/src/chatpad.hpp index 872c4d1..43d4853 100644 --- a/src/chatpad.hpp +++ b/src/chatpad.hpp @@ -84,6 +84,14 @@ enum { CHATPAD_LED_BACKLIGHT = 1<<4 }; +enum { + CHATPAD_LED_STATUS_PEOPLE = (1<<0), + CHATPAD_LED_STATUS_SHIFT = (1<<5), + CHATPAD_LED_STATUS_ORANGE = (1<<4), + CHATPAD_LED_STATUS_GREEN = (1<<3), + CHATPAD_LED_STATUS_BACKLIGHT = (1<<7) +}; + class Chatpad { private: