www.riscos.com Technical Support:
The Joystick module provides a SWI interface for reading the state of a joystick. When the module initialises it tests for the existence of built-in joystick hardware and if it does not find any then it will not initialise. Third parties can replace this module to provide different hardware. It is recommended that any such modules have version numbers greater than 2.00 so that Acorn can upgrade its own module without preventing its replacement.
Returns the state of a joystick
R0 = joystick number
R0 = joystick state
Interrupt status is unaltered
Fast interrupts are enabled
Processor is in SVC mode
This SWI is used to obtain the state of the requested joystick. The state is returned in the following format, which supports both digital and analogue devices:
|0||Signed Y value in the range -127 to 127. For a single switch joystick, -64 DOWN_ 0 REST_ AND 64 Up.|
|1||Signed Y value in the range -127 to 127. For a single switch joystick, -64 LEFT_ 0 REST_ AND 64 Right.|
|2||Switches (eg fire buttons) starting in bit 0; unimplemented switches return 0.|
Applications which are only interested in state (up, down, left, right) should not simply test the bytes for positive, negative or zero. We recommend that the 'at rest' state should span a middle range, say from -32 to 32, since analogue joysticks cannot be relied upon to produce 0 when at rest.