1joystick_getaxis(3)           Svgalib User Manual          joystick_getaxis(3)
2
3
4

NAME

6       joystick_getaxis,  joystick_getbutton  -  query  the current state of a
7       joystick.
8

SYNOPSIS

10       #include <vgajoystick.h>
11
12       char joystick_getaxis(int joydev, int a);
13       char joystick_getbutton(int joydev, int b);
14
15

DESCRIPTION

17       These functions query the current state of the joystick joydev.   Actu‐
18       ally this is the state found during the last call to joystick_update(3)
19       with the default joystick event handler active.
20
21       joystick_getaxis(joydev, a) return the current state of the given  axis
22       (usually  it  is x - 0, y - 1, z - 1, ...)  in range -128 .. 127.  Some
23       effort is made such that the center position is close to 0.
24
25       Note that especially the version 0.* protocol joystick  calibration  is
26       very  bad. You won't usually see the extrem values on the extreme posi‐
27       tion. Also, the center position will be close to zero but often not  be
28       exactly  zero  and  return  values will also vary slightly from call to
29       call even when the user did not move the joystick.
30
31       joystick_getbutton(joydev, b) returns the state of a button. It returns
32       1  for pressed button and 0 else. Note that no hardware checks for but‐
33       ton clicks. The button press is only detected during  a  call  to  joy‐
34       stick_update(3) (at least in the 0.* protocol).
35
36       NOTE:  The  functions simply return the data passed to the default joy‐
37       stick event handler!
38
39       For your convenience, the following stortcuts have been established  by
40       use of the preprocessor:
41
42              joystick_button1(i) for joystick_getbutton(i, 0).
43              joystick_button2(i) for joystick_getbutton(i, 1).
44              joystick_button3(i) for joystick_getbutton(i, 2).
45              joystick_button4(i) for joystick_getbutton(i, 3).
46
47              joystick_x(i) for joystick_getaxis(i, 0).
48              joystick_y(i) for joystick_getaxis(i, 1).
49              joystick_z(i) for joystick_getaxis(i, 2).
50
51              joystick_getb1() for joystick_getbutton(0, 0).
52              joystick_getb2() for joystick_getbutton(0, 1).
53              joystick_getb3() for joystick_getbutton(0, 2).
54              joystick_getb4() for joystick_getbutton(0, 3).
55
56              joystick_getx() for joystick_getaxis(0, 0).
57              joystick_gety() for joystick_getaxis(0, 1).
58              joystick_getz() for joystick_getaxis(0, 2).
59
60

CAVEATS

62       This  function  is  only  available  in ELF versions of svgalib. Due to
63       backwards compatibility issues it cannot  be  used  with  shared  a.out
64       libs.
65
66

SEE ALSO

68       svgalib(7),  vgagl(7),  libvga.config(5), joytest(6), mjoytest(6), joy‐
69       stick_init(3),     joystick_close(3),     joystick_update(3),      joy‐
70       stick_sethandler(3),   joystick_setdefaulthandler(3),   joystick_getnu‐
71       maxes(3), joystick_getnumbuttons(3).
72
73

AUTHOR

75       The svgalib joystick handler  was  mostly  done  by  Daniel  Engstr\"om
76       <daniel.engstrom@riksnett.no>.  Multiple joystick, VC switching support
77       and code to  glue  it  into  svgalib  by  Michael  Weller  <eowmob@exp-
78       math.uni-essen.de>. Part of the code is based on code from C. Smith and
79       Vojtech Pavlik.
80
81
82
83Svgalib 1.3.0                    14 April 1998             joystick_getaxis(3)
Impressum