Skip to main content
GameDev.net gamedev.net
🔒 Locked

Global Joystick Hook...

Started by Xorcist Jan 16, 2004 at 7:06 PM 2 replies 1.9k views
Original Post
Xorcist
Xorcist
I want to write a program to globally catch various activities from an attached Joystick, so I can then bind keyboard keys to each button/axis, and emulate the keypresses through the Joystick. Programs like RB-Joy and JoyToKey are working examples, but their source is not available. I assume I could use SDL or DirectX to capture these actions, however each has it''s own quirks, and require alot of setup for each individual device attached (SDL can''t handle more that two under Windows). Not to mention how I would go about creating the global Joystick hook after the fact. So does anyone have any ideas? or better yet any links to tutorials or examples...
Extrarius
Extrarius
As far as I know, you can''t really hook a joystick. The reason is that under windows (AFAIK)joysticks don''t create any events. To get input from a joystick, you have to poll it and react to the state you get. Your program would essentially just be an infinite loop that polls the joystick and sends a keypress to the active application if needed. You''d probably want some amount of sleeping so your program doesn''t waste CPU (and take it from other programs that could use it better, like a game), but of course you need to balance the amount of delay so that the joystick is still usable as a realtime controller.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.