Joystick to mouse

For my current project I am programming a Gravis joystick to act as a mouse. I have completed the parts involving button detection and axis calibration, but I am having trouble getting it to do perform the functions an actual mouse would. Among these, I need to be able to move the cursor in every direction, and use the left and right mouse click buttons.

I have searched Google for just about everything I could think of and asked on various IRC channels but have been unable to find what I need.

I am using Mandrake 9.1 Linux, KDE 3.1, and gcc 3.2.2 as my C compiler.

Thanks,
MikeNolan


You will need to poll the joystick and move the mouse pointer a little bit. Do this 20 times a second and you will get smooth motion for your mouse pointer. It is probably possible for an X program to move the mouse pointer and cause mouse clicks to happen. If not, then you will need to learn about XFree86 and make a "mouse" driver for it.

Is this a project or are you just doing it so you can use your joystick? I think there is already a module for XFree86 that will use the linux joystick interface. -Mike_L


This is a project. I read about joyd (joystick daemon) a little bit, but I don't think it can move the mouse cursor, just assign actions to the buttons. I'll bump the speed up to about 50 ms intervals when I do get to that point. This is a project so I can learn about joystick programming, master it, and be able to use it if I ever do get to writing 3d games. So it's not absolutely necessary that I write it myself, but I don't see any harm in doing so.

Using what you've said, I think I'll go look at the source code for some of the generic mouse drivers to figure out what's going on.

Thanks,
MikeNolan

JoystickToMouseQuestion (last edited 2008-07-09 05:47:55 by localhost)