[SDL] SDL Joystick!

David Olofson david at olofson.net
Wed Nov 30 22:48:04 PST 2005


On Thursday 01 December 2005 00.22, Golgoth wrote:
[...]
> if (SDL_JoystickGetHat(m_joystick, SDL_HAT_UP))
> Trace("SDL: Joystick Hat UP pressed.\n");
[...]

According to the documentation, SDL_JoystickGetHat() *returns* a Uint8 
hat state. The last argument is an integer telling it which hat to 
read. (There can be several hats on one joystick. Mine has 4 IIRC; 
two on the actual stick and two on the throttle handle...)

So, the code should read something like:

	if (SDL_JoystickGetHat(m_joystick, hat) & SDL_HAT_UP)
		Trace("SDL: Joystick Hat UP pressed.\n");

where "hat" is the index of the hat you want to read.


//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
|  Free/Open Source audio engine for games and multimedia.  |
| MIDI, modular synthesis, real time effects, scripting,... |
`-----------------------------------> http://audiality.org -'
   --- http://olofson.net --- http://www.reologica.se ---




More information about the SDL mailing list