Joystick programming with X11

Started by
5 comments, last by Bregma 13 years, 4 months ago
hi

how can i use and program joystick under X11? (any sample code or tutorial can help me)

Advertisement
You could always try something like glfw. If nothing else it is open source and you can check out its code for an example. Hope it helps anyway. Here is the site.
http://www.glfw.org/
Would be strange to use something made for OpenGL when he use DirectX as the rendering. It would work but still.

Currently XInput is used for most games, but it pretty much support only the xbox360 gamepad. DirectInput8 still works for every gamepad/joystick (minus the xinput bonus). Or, you can simply catch Win32 messages or use Win32 async input pooling functions.

http://msdn.microsoft.com/en-us/library/ee417014%28v=vs.85%29.aspx
Quote:Original post by Pooya65
how can i use and program joystick under X11? (any sample code or tutorial can help me)

SDL handles joysticks nicely, so if you want some sample code, look at how SDL does it.

Or, you could just use SDL.

Stephen M. Webb
Professional Free Software Developer

hi and thanks for your helps

I'm know how to work with SDL or direct input for programming joystick. but i want to work directly with x11 not any other 3rd party library like as SDL

Quote:Original post by Dunge
Would be strange to use something made for OpenGL when he use DirectX as the rendering. It would work but still.

Currently XInput is used for most games, but it pretty much support only the xbox360 gamepad. DirectInput8 still works for every gamepad/joystick (minus the xinput bonus). Or, you can simply catch Win32 messages or use Win32 async input pooling functions.

http://msdn.microsoft.com/en-us/library/ee417014%28v=vs.85%29.aspx


You do know what X11 is, right?
Amateurs practice until they do it right.Professionals practice until they never do it wrong.
Quote:Original post by Pooya65
I'm know how to work with SDL or direct input for programming joystick. but i want to work directly with x11 not any other 3rd party library like as SDL


I suggested looking at the SDL code because SDL does what you want to do, so it is a source you can learn from. It's surprising how much you can learn about wheels from people who have already invented them once.

If you want to use X11 input directly, you will need to enumerate the available input devices using the XI (XInput) extension, find a device that is known to be a joystick, and subscribe to events on its valuators. You will then need to translate from device coordinates into coordinates appropriate for your own use, and you will need to write your own X11 event loop. It's not a lot of code.

If you're on a newer version of X, you may have access to XI2 which has different calls and structures and gives you a finer level of detail for the devices and events.

You can use Xlib calls or the newer XCB interface.

Stephen M. Webb
Professional Free Software Developer

This topic is closed to new replies.

Advertisement