- some notes on SDL

- fixed axis inversion
This commit is contained in:
Ingo Ruhnke 2008-04-11 15:33:11 +02:00
parent 27ce5e70fc
commit 22ec4ab1ba
4 changed files with 38 additions and 5 deletions

13
README
View file

@ -35,6 +35,19 @@ and start the userspace driver:
This will create a /dev/input/js0 and allow you to access the gamepad
from any game. To exit the driver press Ctrl-c twice
[[ SDL Notes ]]
---------------
To let SDL know which axis act as a hat and which act as normal axis
you have to set an environment variable:
% SDL_LINUX_JOYSTICK="'XBox360 Gamepad (userspace driver)' 6 1 0"
% export SDL_LINUX_JOYSTICK
This will let the DPad act as Hat.
See ftp://ptah.lnf.kth.se/pub/misc/sdl-env-vars for more information.
[[ LED Commands ]]
------------------

1
TODO
View file

@ -1,6 +1,7 @@
* add support to remap keys
* add support to merge LT and RT into Z-axis
* allow mouse emulation
* allow swapping of dpad and analog axis, so that dpad is first instead of last
* ...
# EOF #

View file

@ -65,7 +65,7 @@ uInput::uInput()
struct uinput_user_dev uinp;
memset(&uinp,0,sizeof(uinp));
strncpy(uinp.name, "XBOx360 Gamepad (userspace driver)", UINPUT_MAX_NAME_SIZE);
strncpy(uinp.name, "XBox360 Gamepad (userspace driver)", UINPUT_MAX_NAME_SIZE);
uinp.id.version = 0;
uinp.id.bustype = BUS_USB;
uinp.id.vendor = 0x045e;
@ -170,11 +170,11 @@ uInput::send(XBox360Msg& msg)
if (msg.dpad_up)
{
send_axis(ABS_HAT0Y, 1);
send_axis(ABS_HAT0Y, -1);
}
else if (msg.dpad_down)
{
send_axis(ABS_HAT0Y, -1);
send_axis(ABS_HAT0Y, 1);
}
else
{
@ -183,11 +183,11 @@ uInput::send(XBox360Msg& msg)
if (msg.dpad_left)
{
send_axis(ABS_HAT0X, 1);
send_axis(ABS_HAT0X, -1);
}
else if (msg.dpad_right)
{
send_axis(ABS_HAT0X, -1);
send_axis(ABS_HAT0X, 1);
}
else
{

View file

@ -19,6 +19,25 @@
#ifndef HEADER_XBOX360_HPP
#define HEADER_XBOX360_HPP
enum XBox360Buttons {
XBOX360_DPAD_UP = (1<< 0),
XBOX360_DPAD_DOWN = (1<< 1),
XBOX360_DPAD_LEFT = (1<< 2),
XBOX360_DPAD_RIGHT = (1<< 3),
XBOX360_START = (1<< 4),
XBOX360_SELECT = (1<< 5),
XBOX360_THUMB_L = (1<< 6),
XBOX360_THUMB_R = (1<< 7),
XBOX360_LB = (1<< 8),
XBOX360_RB = (1<< 9),
XBOX360_MODE = (1<<10),
// unused = (1<<11),
XBOX360_A = (1<<12),
XBOX360_B = (1<<13),
XBOX360_X = (1<<14),
XBOX360_Y = (1<<15),
};
struct XBox360Msg
{
// --------------------------