xref: /linux/include/uapi/linux/joystick.h (revision aaccf3c97418f169afdbb5855e9cbcbda34e90fd)
1*e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2607ca46eSDavid Howells /*
3607ca46eSDavid Howells  *  Copyright (C) 1996-2000 Vojtech Pavlik
4607ca46eSDavid Howells  *
5607ca46eSDavid Howells  *  Sponsored by SuSE
6607ca46eSDavid Howells  */
7607ca46eSDavid Howells /*
8607ca46eSDavid Howells  * This program is free software; you can redistribute it and/or modify
9607ca46eSDavid Howells  * it under the terms of the GNU General Public License as published by
10607ca46eSDavid Howells  * the Free Software Foundation; either version 2 of the License, or
11607ca46eSDavid Howells  * (at your option) any later version.
12607ca46eSDavid Howells  *
13607ca46eSDavid Howells  * This program is distributed in the hope that it will be useful,
14607ca46eSDavid Howells  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15607ca46eSDavid Howells  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16607ca46eSDavid Howells  * GNU General Public License for more details.
17607ca46eSDavid Howells  *
18607ca46eSDavid Howells  * You should have received a copy of the GNU General Public License
19607ca46eSDavid Howells  * along with this program; if not, write to the Free Software
20607ca46eSDavid Howells  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21607ca46eSDavid Howells  */
22607ca46eSDavid Howells #ifndef _UAPI_LINUX_JOYSTICK_H
23607ca46eSDavid Howells #define _UAPI_LINUX_JOYSTICK_H
24607ca46eSDavid Howells 
25607ca46eSDavid Howells 
26607ca46eSDavid Howells 
27607ca46eSDavid Howells #include <linux/types.h>
28607ca46eSDavid Howells #include <linux/input.h>
29607ca46eSDavid Howells 
30607ca46eSDavid Howells /*
31607ca46eSDavid Howells  * Version
32607ca46eSDavid Howells  */
33607ca46eSDavid Howells 
34607ca46eSDavid Howells #define JS_VERSION		0x020100
35607ca46eSDavid Howells 
36607ca46eSDavid Howells /*
37607ca46eSDavid Howells  * Types and constants for reading from /dev/js
38607ca46eSDavid Howells  */
39607ca46eSDavid Howells 
40607ca46eSDavid Howells #define JS_EVENT_BUTTON		0x01	/* button pressed/released */
41607ca46eSDavid Howells #define JS_EVENT_AXIS		0x02	/* joystick moved */
42607ca46eSDavid Howells #define JS_EVENT_INIT		0x80	/* initial state of device */
43607ca46eSDavid Howells 
44607ca46eSDavid Howells struct js_event {
45607ca46eSDavid Howells 	__u32 time;	/* event timestamp in milliseconds */
46607ca46eSDavid Howells 	__s16 value;	/* value */
47607ca46eSDavid Howells 	__u8 type;	/* event type */
48607ca46eSDavid Howells 	__u8 number;	/* axis/button number */
49607ca46eSDavid Howells };
50607ca46eSDavid Howells 
51607ca46eSDavid Howells /*
52607ca46eSDavid Howells  * IOCTL commands for joystick driver
53607ca46eSDavid Howells  */
54607ca46eSDavid Howells 
55607ca46eSDavid Howells #define JSIOCGVERSION		_IOR('j', 0x01, __u32)				/* get driver version */
56607ca46eSDavid Howells 
57607ca46eSDavid Howells #define JSIOCGAXES		_IOR('j', 0x11, __u8)				/* get number of axes */
58607ca46eSDavid Howells #define JSIOCGBUTTONS		_IOR('j', 0x12, __u8)				/* get number of buttons */
59607ca46eSDavid Howells #define JSIOCGNAME(len)		_IOC(_IOC_READ, 'j', 0x13, len)			/* get identifier string */
60607ca46eSDavid Howells 
61607ca46eSDavid Howells #define JSIOCSCORR		_IOW('j', 0x21, struct js_corr)			/* set correction values */
62607ca46eSDavid Howells #define JSIOCGCORR		_IOR('j', 0x22, struct js_corr)			/* get correction values */
63607ca46eSDavid Howells 
64607ca46eSDavid Howells #define JSIOCSAXMAP		_IOW('j', 0x31, __u8[ABS_CNT])			/* set axis mapping */
65607ca46eSDavid Howells #define JSIOCGAXMAP		_IOR('j', 0x32, __u8[ABS_CNT])			/* get axis mapping */
66607ca46eSDavid Howells #define JSIOCSBTNMAP		_IOW('j', 0x33, __u16[KEY_MAX - BTN_MISC + 1])	/* set button mapping */
67607ca46eSDavid Howells #define JSIOCGBTNMAP		_IOR('j', 0x34, __u16[KEY_MAX - BTN_MISC + 1])	/* get button mapping */
68607ca46eSDavid Howells 
69607ca46eSDavid Howells /*
70607ca46eSDavid Howells  * Types and constants for get/set correction
71607ca46eSDavid Howells  */
72607ca46eSDavid Howells 
73607ca46eSDavid Howells #define JS_CORR_NONE		0x00	/* returns raw values */
74607ca46eSDavid Howells #define JS_CORR_BROKEN		0x01	/* broken line */
75607ca46eSDavid Howells 
76607ca46eSDavid Howells struct js_corr {
77607ca46eSDavid Howells 	__s32 coef[8];
78607ca46eSDavid Howells 	__s16 prec;
79607ca46eSDavid Howells 	__u16 type;
80607ca46eSDavid Howells };
81607ca46eSDavid Howells 
82607ca46eSDavid Howells /*
83607ca46eSDavid Howells  * v0.x compatibility definitions
84607ca46eSDavid Howells  */
85607ca46eSDavid Howells 
86607ca46eSDavid Howells #define JS_RETURN		sizeof(struct JS_DATA_TYPE)
87607ca46eSDavid Howells #define JS_TRUE			1
88607ca46eSDavid Howells #define JS_FALSE		0
89607ca46eSDavid Howells #define JS_X_0			0x01
90607ca46eSDavid Howells #define JS_Y_0			0x02
91607ca46eSDavid Howells #define JS_X_1			0x04
92607ca46eSDavid Howells #define JS_Y_1			0x08
93607ca46eSDavid Howells #define JS_MAX			2
94607ca46eSDavid Howells 
95607ca46eSDavid Howells #define JS_DEF_TIMEOUT		0x1300
96607ca46eSDavid Howells #define JS_DEF_CORR		0
97607ca46eSDavid Howells #define JS_DEF_TIMELIMIT	10L
98607ca46eSDavid Howells 
99607ca46eSDavid Howells #define JS_SET_CAL		1
100607ca46eSDavid Howells #define JS_GET_CAL		2
101607ca46eSDavid Howells #define JS_SET_TIMEOUT		3
102607ca46eSDavid Howells #define JS_GET_TIMEOUT		4
103607ca46eSDavid Howells #define JS_SET_TIMELIMIT	5
104607ca46eSDavid Howells #define JS_GET_TIMELIMIT	6
105607ca46eSDavid Howells #define JS_GET_ALL		7
106607ca46eSDavid Howells #define JS_SET_ALL		8
107607ca46eSDavid Howells 
108607ca46eSDavid Howells struct JS_DATA_TYPE {
109607ca46eSDavid Howells 	__s32 buttons;
110607ca46eSDavid Howells 	__s32 x;
111607ca46eSDavid Howells 	__s32 y;
112607ca46eSDavid Howells };
113607ca46eSDavid Howells 
114607ca46eSDavid Howells struct JS_DATA_SAVE_TYPE_32 {
115607ca46eSDavid Howells 	__s32 JS_TIMEOUT;
116607ca46eSDavid Howells 	__s32 BUSY;
117607ca46eSDavid Howells 	__s32 JS_EXPIRETIME;
118607ca46eSDavid Howells 	__s32 JS_TIMELIMIT;
119607ca46eSDavid Howells 	struct JS_DATA_TYPE JS_SAVE;
120607ca46eSDavid Howells 	struct JS_DATA_TYPE JS_CORR;
121607ca46eSDavid Howells };
122607ca46eSDavid Howells 
123607ca46eSDavid Howells struct JS_DATA_SAVE_TYPE_64 {
124607ca46eSDavid Howells 	__s32 JS_TIMEOUT;
125607ca46eSDavid Howells 	__s32 BUSY;
126607ca46eSDavid Howells 	__s64 JS_EXPIRETIME;
127607ca46eSDavid Howells 	__s64 JS_TIMELIMIT;
128607ca46eSDavid Howells 	struct JS_DATA_TYPE JS_SAVE;
129607ca46eSDavid Howells 	struct JS_DATA_TYPE JS_CORR;
130607ca46eSDavid Howells };
131607ca46eSDavid Howells 
132607ca46eSDavid Howells 
133607ca46eSDavid Howells #endif /* _UAPI_LINUX_JOYSTICK_H */
134