File: joystick_getaxis.3

package info (click to toggle)
svgalib 1%3A1.4.3-33
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 8,012 kB
  • sloc: ansic: 60,381; makefile: 1,138; asm: 630; sh: 86; perl: 54; pascal: 49
file content (139 lines) | stat: -rw-r--r-- 3,246 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
.TH joystick_getaxis 3 "14 April 1998" "Svgalib 1.3.0" "Svgalib User Manual"
.SH NAME
joystick_getaxis, joystick_getbutton \- query the current state of a joystick.
.SH SYNOPSIS

.B "#include <vgajoystick.h>"

.BI "char joystick_getaxis(int " joydev ", int " a );
.br
.BI "char joystick_getbutton(int " joydev ", int " b );

.SH DESCRIPTION
These functions query the current state of the joystick
.IR joydev .
Actually this is the state found during the last call
to
.BR joystick_update (3)
with the default joystick event handler active.

.BI "joystick_getaxis(" joydev ", " a )
return the current state of the given axis (usually it is
.BR "x - 0" ", " "y - 1" ", " "z - 1" ", ...)"
in range
.BR "-128 .. 127" .
Some effort is made such that the center position is close to
.BR 0 .

Note that especially the version 0.* protocol joystick calibration is very bad. You won't usually
see the extrem values on the extreme position. Also, the center position will be close to zero but
often not be exactly zero and return values will also vary slightly from call to call even when
the user did not move the joystick.

.BI "joystick_getbutton(" joydev ", " b )
returns the state of a button. It returns 1 for pressed button and 0 else. Note that no hardware
checks for button clicks. The button press is only detected during a call to
.BR joystick_update (3)
(at least in the 0.* protocol).

.B NOTE:
The functions simply return the data passed to the default joystick event handler!

For your convenience, the following stortcuts have been established by use of the preprocessor:

.RS
.BI joystick_button1( i )
for
.BI joystick_getbutton( i ,
.BR 0) .
.br
.BI joystick_button2( i )
for
.BI joystick_getbutton( i ,
.BR 1) .
.br
.BI joystick_button3( i )
for
.BI joystick_getbutton( i ,
.BR 2) .
.br
.BI joystick_button4( i )
for
.BI joystick_getbutton( i ,
.BR 3) .
.RE

.RS
.BI joystick_x( i )
for
.BI joystick_getaxis( i ,
.BR 0) .
.br
.BI joystick_y( i )
for
.BI joystick_getaxis( i ,
.BR 1) .
.br
.BI joystick_z( i )
for
.BI joystick_getaxis( i ,
.BR 2) .
.RE

.RS
.B joystick_getb1()
for
.BR "joystick_getbutton(0, 0)" .
.br
.B joystick_getb2()
for
.BR "joystick_getbutton(0, 1)" .
.br
.B joystick_getb3()
for
.BR "joystick_getbutton(0, 2)" .
.br
.B joystick_getb4()
for
.BR "joystick_getbutton(0, 3)" .
.RE

.RS
.B joystick_getx()
for
.BR "joystick_getaxis(0, 0)" .
.br
.B joystick_gety()
for
.BR "joystick_getaxis(0, 1)" .
.br
.B joystick_getz()
for
.BR "joystick_getaxis(0, 2)" .
.RE

.SH CAVEATS
This function is only available in ELF versions of svgalib. Due to backwards
compatibility issues it cannot be used with shared a.out libs.

.SH SEE ALSO

.BR svgalib (7),
.BR vgagl (7),
.BR libvga.config (5),
.BR joytest (6),
.BR mjoytest (6),
.BR joystick_init (3),
.BR joystick_close (3),
.BR joystick_update (3),
.BR joystick_sethandler (3),
.BR joystick_setdefaulthandler (3),
.BR joystick_getnumaxes (3),
.BR joystick_getnumbuttons (3).

.SH AUTHOR

The svgalib joystick handler was mostly done by Daniel Engstr\\"om <daniel.engstrom@riksnett.no>.
Multiple joystick, VC switching support and code to glue it into svgalib by Michael Weller
<eowmob@exp-math.uni-essen.de>. Part of the code is based on code from C. Smith and
Vojtech Pavlik.