- added some guitar support
This commit is contained in:
parent
4fbb03bee9
commit
8f18a99e66
6 changed files with 157 additions and 14 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,3 +7,4 @@ xpad.c
|
|||
xpad.h
|
||||
publish.sh
|
||||
usbcat
|
||||
macosx
|
||||
|
|
11
NEWS
11
NEWS
|
@ -1,5 +1,12 @@
|
|||
Apr 13 2008
|
||||
===========
|
||||
xboxdrv 0.2 -
|
||||
=========================
|
||||
|
||||
* switched from usb_bulk_read() to usb_interrupt_read(), this fixes
|
||||
the Guitar Hero controller
|
||||
|
||||
|
||||
xboxdrv 0.1 - Apr 13 2008
|
||||
=========================
|
||||
* initial release
|
||||
|
||||
# EOF #
|
||||
|
|
5
TODO
5
TODO
|
@ -1,3 +1,7 @@
|
|||
* Question: Firestorm Dual Power: How to get rumble to work when there is no endpoint to send data to?
|
||||
|
||||
* allow selection of controller by usb path busNr,deviceNr
|
||||
|
||||
* Guitar Hero Controller:
|
||||
- lsusb -v output looks like a XBox360 controller
|
||||
- usbcat looks like an XBox360 controller
|
||||
|
@ -7,6 +11,7 @@ http://forums.gentoo.org/viewtopic-p-5061825.html
|
|||
http://gentoo-wiki.com/HOWTO_Xbox_360_controller_on_Linux
|
||||
http://happypenguin.org/show?xboxdrv
|
||||
http://ubuntuforums.org/showthread.php?t=404577&page=16
|
||||
http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/OsxDriver
|
||||
|
||||
* add jstest, evtest into the source
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ find_usb_device(uint16_t idVendor, uint16_t idProduct)
|
|||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cat_usb_device(struct usb_device* dev, int ep)
|
||||
|
@ -74,10 +74,28 @@ cat_usb_device(struct usb_device* dev, int ep)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (usb_claim_interface(handle, 0) != 0) // FIXME: bInterfaceNumber shouldn't be hardcoded
|
||||
{
|
||||
std::cout << "Error claiming the interface: " << usb_strerror() << std::endl;
|
||||
if (usb_detach_kernel_driver_np(handle, 0) < 0)
|
||||
{
|
||||
std::cout << "Failure to kick kernel driver: " << usb_strerror() << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (usb_claim_interface(handle, 0) != 0) // FIXME: bInterfaceNumber shouldn't be hardcoded
|
||||
{
|
||||
std::cout << "Error claiming the interface: " << usb_strerror() << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool quit = false;
|
||||
|
||||
while(!quit)
|
||||
{
|
||||
uint8_t data[1024];
|
||||
uint8_t data[32];
|
||||
int ret = usb_bulk_read(handle, ep, (char*)data, sizeof(data), 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -98,6 +116,21 @@ cat_usb_device(struct usb_device* dev, int ep)
|
|||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
if (0)
|
||||
{
|
||||
int len = rand() % 10;
|
||||
char rumblecmd[len];
|
||||
for (int i = 0; i < len; ++i)
|
||||
{
|
||||
rumblecmd[i] = rand() % 255;
|
||||
}
|
||||
|
||||
std::cout << "Writing random data" << std::endl;
|
||||
if (usb_bulk_write(handle, 0, rumblecmd, len, 0) < 0)
|
||||
{
|
||||
std::cout << "Write Error: " << usb_strerror() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
usb_close(handle);
|
||||
}
|
||||
|
@ -108,17 +141,22 @@ list_usb_devices()
|
|||
{
|
||||
struct usb_bus* busses = usb_get_busses();
|
||||
|
||||
int bus_idx = 0;
|
||||
for (struct usb_bus* bus = busses; bus; bus = bus->next)
|
||||
{
|
||||
for (struct usb_device* dev = bus->devices; dev; dev = dev->next)
|
||||
{
|
||||
std::cout << dev << std::endl;
|
||||
std::cout << boost::format("Bus %s Device %s ") % bus->dirname % dev->filename
|
||||
<< " " << dev << std::endl;
|
||||
}
|
||||
bus_idx += 1;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
srand(time(NULL));
|
||||
|
||||
if (argc == 2 && strcmp("list", argv[1]) == 0)
|
||||
{
|
||||
usb_init();
|
||||
|
|
53
xboxdrv.cpp
53
xboxdrv.cpp
|
@ -62,7 +62,7 @@ XPadDevice xpad_devices[] = {
|
|||
{ GAMEPAD_XBOX, 0x044f, 0x0f07, "Thrustmaster, Inc. Controller" },
|
||||
{ GAMEPAD_XBOX360, 0x045e, 0x028e, "Microsoft Xbox 360 Controller" },
|
||||
{ GAMEPAD_XBOX360, 0x0738, 0x4716, "Mad Catz Xbox 360 Controller" },
|
||||
{ GAMEPAD_XBOX360, 0x1430, 0x4748, "RedOctane Guitar Hero X-plorer" },
|
||||
{ GAMEPAD_XBOX360_GUITAR, 0x1430, 0x4748, "RedOctane Guitar Hero X-plorer" },
|
||||
|
||||
// Do these work?
|
||||
{ GAMEPAD_XBOX360_WIRELESS, 0x045e, 0x0291, "Microsoft Xbox 360 Wireless Controller" },
|
||||
|
@ -98,6 +98,43 @@ std::ostream& operator<<(std::ostream& out, const GamepadType& type)
|
|||
}
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const XBox360GuitarMsg& msg)
|
||||
{
|
||||
out << boost::format(" whammy:%6d tilt:%6d | up:%d down:%d left:%d right:%d | back:%d mode:%d start:%d | green:%d red:%d yellow:%d blue:%d orange:%d ")
|
||||
% int(msg.whammy)
|
||||
% int(msg.tilt)
|
||||
% int(msg.dpad_up)
|
||||
% int(msg.dpad_down)
|
||||
% int(msg.dpad_left)
|
||||
% int(msg.dpad_right)
|
||||
% int(msg.select)
|
||||
% int(msg.mode)
|
||||
% int(msg.start)
|
||||
% int(msg.green)
|
||||
% int(msg.red)
|
||||
% int(msg.yellow)
|
||||
% int(msg.blue)
|
||||
% int(msg.orange);
|
||||
|
||||
if (1)
|
||||
out << boost::format("| dummy: %d %d %d %d %02hhx %02hhx %04hx %04hx %02x %02x")
|
||||
% int(msg.thumb_l)
|
||||
% int(msg.thumb_r)
|
||||
% int(msg.rb)
|
||||
% int(msg.dummy1)
|
||||
|
||||
% int(msg.lt)
|
||||
% int(msg.rt)
|
||||
|
||||
% int16_t(msg.x1)
|
||||
% int16_t(msg.y1)
|
||||
|
||||
% int(msg.dummy2)
|
||||
% int(msg.dummy3);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const XBox360Msg& msg)
|
||||
{
|
||||
out << boost::format(" S1:(%6d, %6d)")
|
||||
|
@ -130,8 +167,8 @@ std::ostream& operator<<(std::ostream& out, const XBox360Msg& msg)
|
|||
out << boost::format(" LT:%3d RT:%3d")
|
||||
% int(msg.lt) % int(msg.rt);
|
||||
|
||||
if (0)
|
||||
out << " Dummy: " << msg.dummy3 << " " << msg.dummy4 << " " << msg.dummy5;
|
||||
if (2)
|
||||
out << " Dummy: " << msg.dummy1 << " " << msg.dummy2 << " " << msg.dummy3;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
@ -546,8 +583,14 @@ int main(int argc, char** argv)
|
|||
{
|
||||
memcpy(old_data, data, 20);
|
||||
|
||||
if (dev_type->type == GAMEPAD_XBOX360 ||
|
||||
dev_type->type == GAMEPAD_XBOX360_WIRELESS)
|
||||
if (dev_type->type == GAMEPAD_XBOX360_GUITAR)
|
||||
{
|
||||
XBox360GuitarMsg& msg = (XBox360GuitarMsg&)data;
|
||||
if (verbose)
|
||||
std::cout << msg << std::endl;
|
||||
}
|
||||
else if (dev_type->type == GAMEPAD_XBOX360 ||
|
||||
dev_type->type == GAMEPAD_XBOX360_WIRELESS)
|
||||
{
|
||||
XBox360Msg& msg = (XBox360Msg&)data;
|
||||
|
||||
|
|
57
xboxdrv.hpp
57
xboxdrv.hpp
|
@ -60,7 +60,7 @@ struct XBox360Msg
|
|||
unsigned int lb :1;
|
||||
unsigned int rb :1;
|
||||
unsigned int mode :1;
|
||||
unsigned int dummy3 :1;
|
||||
unsigned int dummy1 :1;
|
||||
|
||||
unsigned int a :1;
|
||||
unsigned int b :1;
|
||||
|
@ -80,10 +80,58 @@ struct XBox360Msg
|
|||
int y2 :16;
|
||||
|
||||
// data[14]; ----------------
|
||||
unsigned int dummy4 :32;
|
||||
unsigned int dummy5 :16;
|
||||
unsigned int dummy2 :32;
|
||||
unsigned int dummy3 :16;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
struct XBox360GuitarMsg
|
||||
{
|
||||
// -------------------------
|
||||
unsigned int type :8;
|
||||
unsigned int length :8;
|
||||
|
||||
// data[2] ------------------
|
||||
unsigned int dpad_up :1; // also strum-up
|
||||
unsigned int dpad_down :1; // also strum-down
|
||||
unsigned int dpad_left :1;
|
||||
unsigned int dpad_right :1;
|
||||
|
||||
unsigned int start :1;
|
||||
unsigned int select :1;
|
||||
|
||||
unsigned int thumb_l :1; // unused
|
||||
unsigned int thumb_r :1; // unused
|
||||
|
||||
// data[3] ------------------
|
||||
unsigned int orange :1; // 5
|
||||
unsigned int rb :1; // unused
|
||||
unsigned int mode :1;
|
||||
unsigned int dummy1 :1; // unused
|
||||
|
||||
unsigned int green :1; // 1
|
||||
unsigned int red :1; // 2
|
||||
unsigned int blue :1; // 4
|
||||
unsigned int yellow :1; // 3
|
||||
|
||||
// data[4] ------------------
|
||||
unsigned int lt :8; // unknown
|
||||
unsigned int rt :8; // unknown
|
||||
|
||||
// data[6] ------------------
|
||||
int x1 :16; // unused
|
||||
int y1 :16; // unused
|
||||
|
||||
// data[10] -----------------
|
||||
int whammy :16;
|
||||
int tilt :16;
|
||||
|
||||
// data[14]; ----------------
|
||||
unsigned int dummy2 :32; // unused
|
||||
unsigned int dummy3 :16; // unused
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
struct XBoxMsg
|
||||
{
|
||||
// --------------------------
|
||||
|
@ -126,7 +174,8 @@ enum GamepadType {
|
|||
GAMEPAD_XBOX,
|
||||
GAMEPAD_XBOX_MAT,
|
||||
GAMEPAD_XBOX360,
|
||||
GAMEPAD_XBOX360_WIRELESS
|
||||
GAMEPAD_XBOX360_WIRELESS,
|
||||
GAMEPAD_XBOX360_GUITAR
|
||||
};
|
||||
|
||||
struct XPadDevice {
|
||||
|
|
Loading…
Add table
Reference in a new issue