Re: xpad.c patch to make triggers report as buttons as well as analog
Jesse Guardiani <[email protected]> Mon, 02 Jan 2006 14:33:09 -0500
| Newsgroups | gmane.linux.ports.xbox.devel |
|---|---|
| Organization | WingNET Internet Services |
| Message-ID | <[email protected]> |
On Mon, 02 Jan 2006 19:20:09 +0000, Jesse Guardiani wrote:
> Hello,
>
> I've found myself wanting to use the Xbox controller's left and right triggers
> as non-analog buttons recently. All the other analog buttons support this, so
> why not the triggers?
>
> So I wrote a patch against the CVS version of xpad.c from today. I renamed the
> Xbox 360's additional triggers as TL2 and TR2, and named the xbox triggers TL
> and TR.
>
> This patch shifts the button mappings a bit, so anyone using it would have to
> reconfigure their games, but I like it as it allows me to use the triggers in
> snes9x and mame.
>
> NOTE: I've only tested this patch with xbox controllers, not xbox 360
> controllers as I don't have any 360 controllers.
Sorry, forgot the patch:
--- xpad.c.orig_abs_trig 2006-01-02 13:39:14.000000000 -0500
+++ xpad.c 2006-01-02 14:01:34.000000000 -0500
@@ -113,9 +113,10 @@
static signed short xpad_btn[] = {
BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, /* analogue buttons */
+ BTN_TL, BTN_TR, /* triggers left/right */
BTN_START, BTN_BACK, BTN_THUMBL, BTN_THUMBR, /* start/back/sticks */
BTN_0, BTN_1, BTN_2, BTN_3, /* d-pad as buttons */
- BTN_TL, BTN_TR, /* Button LB/RB */
+ BTN_TL2, BTN_TR2, /* Button LB/RB */
BTN_MODE, /* The big X */
-1 /* terminating entry */
};
@@ -189,13 +190,13 @@
/* buttons A, B, X, Y digital mode */
if(xpad->is360) {
- input_report_key(dev, BTN_A, (data[3] & 0x10) >> 4);
- input_report_key(dev, BTN_B, (data[3] & 0x20) >> 5);
- input_report_key(dev, BTN_X, (data[3] & 0x80) >> 7);
- input_report_key(dev, BTN_Y, (data[3] & 0x40) >> 6);
- input_report_key(dev, BTN_TL, data[3] & 0x01 );
- input_report_key(dev, BTN_TR, (data[3] & 0x02) >> 1);
- input_report_key(dev, BTN_MODE, (data[3] & 0x04) >> 2);
+ input_report_key(dev, BTN_A, (data[3] & 0x10) >> 4);
+ input_report_key(dev, BTN_B, (data[3] & 0x20) >> 5);
+ input_report_key(dev, BTN_X, (data[3] & 0x80) >> 7);
+ input_report_key(dev, BTN_Y, (data[3] & 0x40) >> 6);
+ input_report_key(dev, BTN_TL2, data[3] & 0x01 );
+ input_report_key(dev, BTN_TR2, (data[3] & 0x02) >> 1);
+ input_report_key(dev, BTN_MODE,(data[3] & 0x04) >> 2);
} else {
input_report_key(dev, BTN_A, data[4]);
input_report_key(dev, BTN_B, data[5]);
@@ -224,12 +225,21 @@
input_report_abs(dev, ABS_RY, (__s16)(((__s16)data[19] << 8) | (__s16)data[18]));
}
- /* triggers left/right */
if(xpad->is360) {
+ /* Trigger Left digital/analogue mode */
+ input_report_key(dev, BTN_TL, data[4]);
input_report_abs(dev, ABS_Z, data[4]);
+
+ /* Trigger Right digital/analogue mode */
+ input_report_key(dev, BTN_TR, data[5]);
input_report_abs(dev, ABS_RZ, data[5]);
} else {
+ /* Trigger Left digital/analogue mode */
+ input_report_key(dev, BTN_TL, data[10]);
input_report_abs(dev, ABS_Z, data[10]);
+
+ /* Trigger Right digital/analogue mode */
+ input_report_key(dev, BTN_TR, data[11]);
input_report_abs(dev, ABS_RZ, data[11]);
}
Exit 1
--
Jesse Guardiani
Programmer/Sys Admin
[email protected]
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click