Solved

Game Port programming

Posted on 2004-09-24
2
367 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
Comment Utility
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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

15 Experts available now in Live!

Get 1:1 Help Now