ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm trying to connect a xbox360 controller to my linux pc; The driver xpad.c works perfectly, but now I am wondering if it is possible to control the rumble pack and the leds of the pad. Do you know how this could be done?
I've searched through Internet and inside the source code, but the only thing that I discovered is a group of prototypes/declares that could be useful, but I really don't know how to use them
Code:
#define USB_XPAD_IOC_MAGIC 'x'
#define USB_XPAD_IOCRESET _IO( USB_XPAD_IOC_MAGIC, 0 )
#define USB_XPAD_IOCSRUMBLE _IOW( USB_XPAD_IOC_MAGIC, 3, int )
#define USB_XPAD_IOCGRUMBLE _IOR( USB_XPAD_IOC_MAGIC, 4, int )
...
#ifdef CONFIG_USB_XPAD_RUMBLE
int rumble_enabled; /* ioctl can toggle rumble */
int ep_out_adr; /* number of out endpoint */
unsigned char tx_data[XPAD_PKT_LEN_FF]; /* output data (rumble) */
int strong_rumble, play_strong; /* strong rumbling */
int weak_rumble, play_weak; /* weak rumbling */
struct timer_list rumble_timer; /* timed urb out retry */
wait_queue_head_t wait; /* wait for URBs on queue */
spinlock_t tx_lock;
struct circ_buf tx;
unsigned char tx_buf[XPAD_TX_BUFSIZE];
long tx_flags[1]; /* transmit flags */
#endif
...
/************************ rumble function stubs ***********************/
#ifndef CONFIG_USB_XPAD_RUMBLE
#define xpad_rumble_ioctl(dev, cmd, arg) -ENOTTY
#define xpad_rumble_open(xpad) {}
#define xpad_rumble_probe(udev, xpad, ifnum) 0
#define xpad_rumble_close(xpad) {}
#define xpad_rumble_disconnect(xpad) {}
#else /* CONFIG_USB_XPAD_RUMBLE */
Is rumble/force feedback supported at all in Linux? I've had several joypad/sticks with force feedback and they were never supported (though they all worked just fine under Linux). If we don't have a way to communicate with those devices (ex: using SDL API) to enable the rumble feature, the source for the joypad driver will do very little to help, as far as I'm concerned.
Do you mean that, even if the linux joystick driver also supports force feedback devices (i've seen even the Sidewinder Force Feedback in the compatible devices list) these devices are only seen as input objects in /dev/js0?
Unfortunately I don't have the SDL in my embedded linux and I can't crosscompile it
Maybe I should check inside the SDL source code...
Do you mean that, even if the linux joystick driver also supports force feedback devices (i've seen even the Sidewinder Force Feedback in the compatible devices list) these devices are only seen as input objects in /dev/js0?
Pretty much. I am not saying that SDL supports force feedback devices, but it was on their todo list, if I remember it correctly.
Just to clear that up, I'm assuming (without doing any deeper research), that Linux does not support force feedback devices. Period. What makes force feedback devices to work in Windows is the DirectX API. The only way (again, assuming) to get a force feedback device to work in Linux is through an API. The closest API to DirectX we have is the powerful SDL (used to create virtually every console emulator and video players in Linux, besides, well, games ). So unless somebody can create an interface for those devices, they won't work, regardless if the source is available or if the kernel has it's modules enabled.
Now (I can't stress this enough) I am just assuming those things. A deeper search on google would be better. Searching the SDL FAQ could also be a good approach. I unfortunately can't do that now (or today), have a meeting in 10 minutes, hihi. But I'm sure you can dig some stuff up ^_^
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.