Solved

Game Port programming

Posted on 2004-09-24
2
372 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

730 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