?
Solved

Game Port programming

Posted on 2004-09-24
2
Medium Priority
?
377 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
davidcausse earned 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

764 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