RISCOS.com

www.riscos.com Technical Support:
Programmer's Reference Manual

 

Joystick module


Introduction and Overview

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.

SWI Calls


Joystick_Read
(SWI &43F40)

Returns the state of a joystick

On entry

R0 = joystick number

On exit

R0 = joystick state

Interrupts

Interrupt status is unaltered
Fast interrupts are enabled

Processor mode

Processor is in SVC mode

Re-entrancy

Not defined

Use

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:

Byte Value
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.
3 Reserved.

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.

Related SWIs

None

Related vectors

None

This edition Copyright © 3QD Developments Ltd 2015
Last Edit: Tue,03 Nov 2015