954,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Linux, ALSA, C++, And the Joystick

Ok, in a very simplified version ive got to write a C++ app to interface with a joystick and play various sounds depending on its position - Its a USB joystick and I will have a QT GUI.

This app already exists, for Windows/C# . I just need help porting it to C++/Linux.

Specifically, how to do the joystick and sound? Any ideas for libaries?

jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
 

A google search on alsa api returns many useful links. I am not familiar with Windows/C# audio model, so I don't know how well it is mapped onto alsa.

Regarding joystick, it is seen by the system as a serial device; you need to open it, query it with some ioctls (JSIOCGAXES and JSIOCGBUTTONS), and then just read struct js_event (see linux/joystick.h for reference).

nezachem
Posting Shark
903 posts since Dec 2009
Reputation Points: 719
Solved Threads: 194
 
jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
 

Most likely. The code is based on a fairly old kernel, but AFAIK not much has been changed since then.

nezachem
Posting Shark
903 posts since Dec 2009
Reputation Points: 719
Solved Threads: 194
 

This was quite helpful, in case anyone else has the same problem finding info,

http://www.linuxjournal.com/article/6735?page=0,1

jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
 
jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: