Solved

Game Port programming

Posted on 2004-09-24
2
370 Views
Last Modified: 2006-11-17
Does anyone know where I can find some good example code for reading a joystick input through the PC game port?

I have a SideWinder 3D pro, I need to be able read the up/down and left/right movement as well as when the fire button is pressed.  I know how to access the game port using ioperm(), I just would like to look at some example's to get some ideas.

I am writing the application in C, then I will be writing a basic Qt GUI to display the results.
0
Comment
Question by:sabrE7
2 Comments
 
LVL 1

Accepted Solution

by:
davidcausse earned 500 total points
ID: 12170076
Hi,

Joystick is a character device in Linux so you do not need to use complicated io* stuff. You can just access data sent by joystick by reading the character device /dev/js[0-9] or /dev/input/js[0-9] depends if you use devfs. You can make a simple test by doing "cat /dev/[input/]js0" and move your joystick.
[NOTE: reading a character device is like reading a regular file, except you cannot seek]

However it isn't a good idea to read directly through this device, you'd better implement a game library like SDL for convenient/portable access methods.

Have look here : http://www.libsdl.org/

Good luck.

PS. ioperm is very lowlevel syscall and needs the super-user permissions, I must recommend to not develop as super-user.
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 12185701
Use libsdl, I fixed a few joystick problems in libsdl a few years ago, and I can tell you: You don't want to program the joystick directly :-) So take David's advice and learn about how to use libsdl.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
please append a correct root= boot option HELP! cant boot up linux server! 22 682
Identify Linux loader 67 177
Linux Search 3 67
Help with a backup script in Linux 4 76
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now