emGetController.3p 1.22 KB
.TH emGetController 3P local "Silicon Graphics, Inc."
.SH NAME
emGetController \- Get current state of the game controller
.SH C SPECIFICATION
#include "em.h"
.br
.sp
int emGetController(int port, GamePad *pad)
.SH PARAMETERS
.TP 10
.I port
tty port number
.TP
.I pad
Pointer to Gamepad structure
.SH DESCRIPTION
Poll the current state of the game controller that is connected to the 
specified port.
The contents of the GamePad structure is as follows:
.sp
.nf
	typedef struct {
	    unsigned short button;          /* all of the 14 buttons */
	    unsigned char stick_x;
	    unsigned char stick_y;
	} GamePad;
.fi
.sp
The bit positions of the 14 buttons are listed in em.h.
A value of one means the button is pressed.
.sp
The joystick x and y values range from 0 to 255.
(0,0) is up and to the right.  (255,255) is down and to the left.
.sp
.I emInitController
must be called before
.I emGetController
is used.
.SH NOTES
The current joystick has a range from 0 to 255.
The final joystick will have a range from 0 to 127.
The current joystick doesn't return to the mid point of the range.
The bit positions of the buttons may change.
.SH RETURN VALUE
Returns 0 on success and -1 on failure.
.SH SEE ALSO
.TP 10
emulate(1P), emInitController(3P)