18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  Copyright (C) 1996-2000 Vojtech Pavlik
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  Sponsored by SuSE
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci/*
88c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify
98c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License as published by
108c2ecf20Sopenharmony_ci * the Free Software Foundation; either version 2 of the License, or
118c2ecf20Sopenharmony_ci * (at your option) any later version.
128c2ecf20Sopenharmony_ci *
138c2ecf20Sopenharmony_ci * This program is distributed in the hope that it will be useful,
148c2ecf20Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
158c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
168c2ecf20Sopenharmony_ci * GNU General Public License for more details.
178c2ecf20Sopenharmony_ci *
188c2ecf20Sopenharmony_ci * You should have received a copy of the GNU General Public License
198c2ecf20Sopenharmony_ci * along with this program; if not, write to the Free Software
208c2ecf20Sopenharmony_ci * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
218c2ecf20Sopenharmony_ci */
228c2ecf20Sopenharmony_ci#ifndef _UAPI_LINUX_JOYSTICK_H
238c2ecf20Sopenharmony_ci#define _UAPI_LINUX_JOYSTICK_H
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#include <linux/types.h>
288c2ecf20Sopenharmony_ci#include <linux/input.h>
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci/*
318c2ecf20Sopenharmony_ci * Version
328c2ecf20Sopenharmony_ci */
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#define JS_VERSION		0x020100
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci/*
378c2ecf20Sopenharmony_ci * Types and constants for reading from /dev/js
388c2ecf20Sopenharmony_ci */
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci#define JS_EVENT_BUTTON		0x01	/* button pressed/released */
418c2ecf20Sopenharmony_ci#define JS_EVENT_AXIS		0x02	/* joystick moved */
428c2ecf20Sopenharmony_ci#define JS_EVENT_INIT		0x80	/* initial state of device */
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_cistruct js_event {
458c2ecf20Sopenharmony_ci	__u32 time;	/* event timestamp in milliseconds */
468c2ecf20Sopenharmony_ci	__s16 value;	/* value */
478c2ecf20Sopenharmony_ci	__u8 type;	/* event type */
488c2ecf20Sopenharmony_ci	__u8 number;	/* axis/button number */
498c2ecf20Sopenharmony_ci};
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci/*
528c2ecf20Sopenharmony_ci * IOCTL commands for joystick driver
538c2ecf20Sopenharmony_ci */
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci#define JSIOCGVERSION		_IOR('j', 0x01, __u32)				/* get driver version */
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci#define JSIOCGAXES		_IOR('j', 0x11, __u8)				/* get number of axes */
588c2ecf20Sopenharmony_ci#define JSIOCGBUTTONS		_IOR('j', 0x12, __u8)				/* get number of buttons */
598c2ecf20Sopenharmony_ci#define JSIOCGNAME(len)		_IOC(_IOC_READ, 'j', 0x13, len)			/* get identifier string */
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci#define JSIOCSCORR		_IOW('j', 0x21, struct js_corr)			/* set correction values */
628c2ecf20Sopenharmony_ci#define JSIOCGCORR		_IOR('j', 0x22, struct js_corr)			/* get correction values */
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci#define JSIOCSAXMAP		_IOW('j', 0x31, __u8[ABS_CNT])			/* set axis mapping */
658c2ecf20Sopenharmony_ci#define JSIOCGAXMAP		_IOR('j', 0x32, __u8[ABS_CNT])			/* get axis mapping */
668c2ecf20Sopenharmony_ci#define JSIOCSBTNMAP		_IOW('j', 0x33, __u16[KEY_MAX - BTN_MISC + 1])	/* set button mapping */
678c2ecf20Sopenharmony_ci#define JSIOCGBTNMAP		_IOR('j', 0x34, __u16[KEY_MAX - BTN_MISC + 1])	/* get button mapping */
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci/*
708c2ecf20Sopenharmony_ci * Types and constants for get/set correction
718c2ecf20Sopenharmony_ci */
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci#define JS_CORR_NONE		0x00	/* returns raw values */
748c2ecf20Sopenharmony_ci#define JS_CORR_BROKEN		0x01	/* broken line */
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_cistruct js_corr {
778c2ecf20Sopenharmony_ci	__s32 coef[8];
788c2ecf20Sopenharmony_ci	__s16 prec;
798c2ecf20Sopenharmony_ci	__u16 type;
808c2ecf20Sopenharmony_ci};
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci/*
838c2ecf20Sopenharmony_ci * v0.x compatibility definitions
848c2ecf20Sopenharmony_ci */
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci#define JS_RETURN		sizeof(struct JS_DATA_TYPE)
878c2ecf20Sopenharmony_ci#define JS_TRUE			1
888c2ecf20Sopenharmony_ci#define JS_FALSE		0
898c2ecf20Sopenharmony_ci#define JS_X_0			0x01
908c2ecf20Sopenharmony_ci#define JS_Y_0			0x02
918c2ecf20Sopenharmony_ci#define JS_X_1			0x04
928c2ecf20Sopenharmony_ci#define JS_Y_1			0x08
938c2ecf20Sopenharmony_ci#define JS_MAX			2
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci#define JS_DEF_TIMEOUT		0x1300
968c2ecf20Sopenharmony_ci#define JS_DEF_CORR		0
978c2ecf20Sopenharmony_ci#define JS_DEF_TIMELIMIT	10L
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci#define JS_SET_CAL		1
1008c2ecf20Sopenharmony_ci#define JS_GET_CAL		2
1018c2ecf20Sopenharmony_ci#define JS_SET_TIMEOUT		3
1028c2ecf20Sopenharmony_ci#define JS_GET_TIMEOUT		4
1038c2ecf20Sopenharmony_ci#define JS_SET_TIMELIMIT	5
1048c2ecf20Sopenharmony_ci#define JS_GET_TIMELIMIT	6
1058c2ecf20Sopenharmony_ci#define JS_GET_ALL		7
1068c2ecf20Sopenharmony_ci#define JS_SET_ALL		8
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_cistruct JS_DATA_TYPE {
1098c2ecf20Sopenharmony_ci	__s32 buttons;
1108c2ecf20Sopenharmony_ci	__s32 x;
1118c2ecf20Sopenharmony_ci	__s32 y;
1128c2ecf20Sopenharmony_ci};
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_cistruct JS_DATA_SAVE_TYPE_32 {
1158c2ecf20Sopenharmony_ci	__s32 JS_TIMEOUT;
1168c2ecf20Sopenharmony_ci	__s32 BUSY;
1178c2ecf20Sopenharmony_ci	__s32 JS_EXPIRETIME;
1188c2ecf20Sopenharmony_ci	__s32 JS_TIMELIMIT;
1198c2ecf20Sopenharmony_ci	struct JS_DATA_TYPE JS_SAVE;
1208c2ecf20Sopenharmony_ci	struct JS_DATA_TYPE JS_CORR;
1218c2ecf20Sopenharmony_ci};
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_cistruct JS_DATA_SAVE_TYPE_64 {
1248c2ecf20Sopenharmony_ci	__s32 JS_TIMEOUT;
1258c2ecf20Sopenharmony_ci	__s32 BUSY;
1268c2ecf20Sopenharmony_ci	__s64 JS_EXPIRETIME;
1278c2ecf20Sopenharmony_ci	__s64 JS_TIMELIMIT;
1288c2ecf20Sopenharmony_ci	struct JS_DATA_TYPE JS_SAVE;
1298c2ecf20Sopenharmony_ci	struct JS_DATA_TYPE JS_CORR;
1308c2ecf20Sopenharmony_ci};
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci#endif /* _UAPI_LINUX_JOYSTICK_H */
134