LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 01-28-2007, 03:31 PM   #1
ma1069
LQ Newbie
 
Registered: Aug 2006
Distribution: ubuntu
Posts: 24

Rep: Reputation: 15
Post xbox 360 controller programming


Hello,

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 */
could you give me some advices?

Thanks
 
Old 01-30-2007, 03:38 AM   #2
Mega Man X
Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 63
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.

Regards!
 
Old 01-30-2007, 06:54 AM   #3
ma1069
LQ Newbie
 
Registered: Aug 2006
Distribution: ubuntu
Posts: 24

Original Poster
Rep: Reputation: 15
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...

Thanks anyway
 
Old 01-30-2007, 07:47 AM   #4
Mega Man X
Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 63
Quote:
Originally Posted by ma1069
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 ^_^
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
xbox 360 suavecu Linux - Software 7 07-24-2006 09:15 PM
Xbox 360 controller for windows...errrr....linux hkl8324 Linux - Hardware 1 03-01-2006 12:49 PM
Linux fo xbox 360 randyvalpobb Linux - General 2 01-20-2006 04:15 PM
Xbox 360 stabile007 General 112 05-28-2005 09:23 PM


All times are GMT -5. The time now is 01:57 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration