12b3f6d66SOleksandr Tymoshenko /*- 22b3f6d66SOleksandr Tymoshenko * Copyright (c) 2016 Oleksandr Tymoshenko <gonzo@FreeBSD.org> 3e6502802SVladimir Kondratyev * Copyright (c) 2015-2016 Vladimir Kondratyev <wulf@FreeBSD.org> 42b3f6d66SOleksandr Tymoshenko * All rights reserved. 52b3f6d66SOleksandr Tymoshenko * 62b3f6d66SOleksandr Tymoshenko * Redistribution and use in source and binary forms, with or without 72b3f6d66SOleksandr Tymoshenko * modification, are permitted provided that the following conditions 82b3f6d66SOleksandr Tymoshenko * are met: 92b3f6d66SOleksandr Tymoshenko * 1. Redistributions of source code must retain the above copyright 102b3f6d66SOleksandr Tymoshenko * notice, this list of conditions and the following disclaimer. 112b3f6d66SOleksandr Tymoshenko * 2. Redistributions in binary form must reproduce the above copyright 122b3f6d66SOleksandr Tymoshenko * notice, this list of conditions and the following disclaimer in the 132b3f6d66SOleksandr Tymoshenko * documentation and/or other materials provided with the distribution. 142b3f6d66SOleksandr Tymoshenko * 152b3f6d66SOleksandr Tymoshenko * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 162b3f6d66SOleksandr Tymoshenko * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 172b3f6d66SOleksandr Tymoshenko * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 182b3f6d66SOleksandr Tymoshenko * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 192b3f6d66SOleksandr Tymoshenko * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 202b3f6d66SOleksandr Tymoshenko * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 212b3f6d66SOleksandr Tymoshenko * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 222b3f6d66SOleksandr Tymoshenko * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 232b3f6d66SOleksandr Tymoshenko * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 242b3f6d66SOleksandr Tymoshenko * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 252b3f6d66SOleksandr Tymoshenko * SUCH DAMAGE. 262b3f6d66SOleksandr Tymoshenko */ 272b3f6d66SOleksandr Tymoshenko 282b3f6d66SOleksandr Tymoshenko #ifndef _EVDEV_UINPUT_H_ 292b3f6d66SOleksandr Tymoshenko #define _EVDEV_UINPUT_H_ 302b3f6d66SOleksandr Tymoshenko 312b3f6d66SOleksandr Tymoshenko #include <sys/types.h> 322b3f6d66SOleksandr Tymoshenko #include <dev/evdev/input.h> 332b3f6d66SOleksandr Tymoshenko 342b3f6d66SOleksandr Tymoshenko #define UINPUT_VERSION 5 352b3f6d66SOleksandr Tymoshenko #define UINPUT_MAX_NAME_SIZE 80 362b3f6d66SOleksandr Tymoshenko 372b3f6d66SOleksandr Tymoshenko struct uinput_ff_upload { 382b3f6d66SOleksandr Tymoshenko uint32_t request_id; 392b3f6d66SOleksandr Tymoshenko int32_t retval; 402b3f6d66SOleksandr Tymoshenko struct ff_effect effect; 412b3f6d66SOleksandr Tymoshenko struct ff_effect old; 422b3f6d66SOleksandr Tymoshenko }; 432b3f6d66SOleksandr Tymoshenko 442b3f6d66SOleksandr Tymoshenko struct uinput_ff_erase { 452b3f6d66SOleksandr Tymoshenko uint32_t request_id; 462b3f6d66SOleksandr Tymoshenko int32_t retval; 472b3f6d66SOleksandr Tymoshenko uint32_t effect_id; 482b3f6d66SOleksandr Tymoshenko }; 492b3f6d66SOleksandr Tymoshenko 502b3f6d66SOleksandr Tymoshenko /* ioctl */ 512b3f6d66SOleksandr Tymoshenko #define UINPUT_IOCTL_BASE 'U' 522b3f6d66SOleksandr Tymoshenko 532b3f6d66SOleksandr Tymoshenko #define UI_DEV_CREATE _IO(UINPUT_IOCTL_BASE, 1) 542b3f6d66SOleksandr Tymoshenko #define UI_DEV_DESTROY _IO(UINPUT_IOCTL_BASE, 2) 552b3f6d66SOleksandr Tymoshenko 562b3f6d66SOleksandr Tymoshenko struct uinput_setup { 572b3f6d66SOleksandr Tymoshenko struct input_id id; 582b3f6d66SOleksandr Tymoshenko char name[UINPUT_MAX_NAME_SIZE]; 592b3f6d66SOleksandr Tymoshenko uint32_t ff_effects_max; 602b3f6d66SOleksandr Tymoshenko }; 612b3f6d66SOleksandr Tymoshenko 622b3f6d66SOleksandr Tymoshenko #define UI_DEV_SETUP _IOW(UINPUT_IOCTL_BASE, 3, struct uinput_setup) 632b3f6d66SOleksandr Tymoshenko 642b3f6d66SOleksandr Tymoshenko struct uinput_abs_setup { 652b3f6d66SOleksandr Tymoshenko uint16_t code; /* axis code */ 662b3f6d66SOleksandr Tymoshenko struct input_absinfo absinfo; 672b3f6d66SOleksandr Tymoshenko }; 682b3f6d66SOleksandr Tymoshenko 692b3f6d66SOleksandr Tymoshenko #define UI_ABS_SETUP _IOW(UINPUT_IOCTL_BASE, 4, struct uinput_abs_setup) 702b3f6d66SOleksandr Tymoshenko 712b3f6d66SOleksandr Tymoshenko #define UI_GET_SYSNAME(len) _IOC(IOC_OUT, UINPUT_IOCTL_BASE, 44, len) 722b3f6d66SOleksandr Tymoshenko #define UI_GET_VERSION _IOR(UINPUT_IOCTL_BASE, 45, unsigned int) 732b3f6d66SOleksandr Tymoshenko 742b3f6d66SOleksandr Tymoshenko #define UI_SET_EVBIT _IOWINT(UINPUT_IOCTL_BASE, 100) 752b3f6d66SOleksandr Tymoshenko #define UI_SET_KEYBIT _IOWINT(UINPUT_IOCTL_BASE, 101) 762b3f6d66SOleksandr Tymoshenko #define UI_SET_RELBIT _IOWINT(UINPUT_IOCTL_BASE, 102) 772b3f6d66SOleksandr Tymoshenko #define UI_SET_ABSBIT _IOWINT(UINPUT_IOCTL_BASE, 103) 782b3f6d66SOleksandr Tymoshenko #define UI_SET_MSCBIT _IOWINT(UINPUT_IOCTL_BASE, 104) 792b3f6d66SOleksandr Tymoshenko #define UI_SET_LEDBIT _IOWINT(UINPUT_IOCTL_BASE, 105) 802b3f6d66SOleksandr Tymoshenko #define UI_SET_SNDBIT _IOWINT(UINPUT_IOCTL_BASE, 106) 812b3f6d66SOleksandr Tymoshenko #define UI_SET_FFBIT _IOWINT(UINPUT_IOCTL_BASE, 107) 822b3f6d66SOleksandr Tymoshenko #define UI_SET_PHYS _IO(UINPUT_IOCTL_BASE, 108) 832b3f6d66SOleksandr Tymoshenko #define UI_SET_SWBIT _IOWINT(UINPUT_IOCTL_BASE, 109) 842b3f6d66SOleksandr Tymoshenko #define UI_SET_PROPBIT _IOWINT(UINPUT_IOCTL_BASE, 110) 852b3f6d66SOleksandr Tymoshenko 862b3f6d66SOleksandr Tymoshenko #define UI_BEGIN_FF_UPLOAD _IOWR(UINPUT_IOCTL_BASE, 200, struct uinput_ff_upload) 872b3f6d66SOleksandr Tymoshenko #define UI_END_FF_UPLOAD _IOW(UINPUT_IOCTL_BASE, 201, struct uinput_ff_upload) 882b3f6d66SOleksandr Tymoshenko #define UI_BEGIN_FF_ERASE _IOWR(UINPUT_IOCTL_BASE, 202, struct uinput_ff_erase) 892b3f6d66SOleksandr Tymoshenko #define UI_END_FF_ERASE _IOW(UINPUT_IOCTL_BASE, 203, struct uinput_ff_erase) 902b3f6d66SOleksandr Tymoshenko 91*4b58fa12SVladimir Kondratyev /* 92*4b58fa12SVladimir Kondratyev * FreeBSD specific. Set unique identifier of input device. 93*4b58fa12SVladimir Kondratyev * Name and magic are chosen to reduce chances of clashing 94*4b58fa12SVladimir Kondratyev * with possible future Linux extensions. 95*4b58fa12SVladimir Kondratyev */ 96*4b58fa12SVladimir Kondratyev #define UI_SET_BSDUNIQ _IO(UINPUT_IOCTL_BASE, 109) 97*4b58fa12SVladimir Kondratyev 982b3f6d66SOleksandr Tymoshenko #define EV_UINPUT 0x0101 992b3f6d66SOleksandr Tymoshenko #define UI_FF_UPLOAD 1 1002b3f6d66SOleksandr Tymoshenko #define UI_FF_ERASE 2 1012b3f6d66SOleksandr Tymoshenko 1022b3f6d66SOleksandr Tymoshenko struct uinput_user_dev { 1032b3f6d66SOleksandr Tymoshenko char name[UINPUT_MAX_NAME_SIZE]; 1042b3f6d66SOleksandr Tymoshenko struct input_id id; 1052b3f6d66SOleksandr Tymoshenko uint32_t ff_effects_max; 1062b3f6d66SOleksandr Tymoshenko int32_t absmax[ABS_CNT]; 1072b3f6d66SOleksandr Tymoshenko int32_t absmin[ABS_CNT]; 1082b3f6d66SOleksandr Tymoshenko int32_t absfuzz[ABS_CNT]; 1092b3f6d66SOleksandr Tymoshenko int32_t absflat[ABS_CNT]; 1102b3f6d66SOleksandr Tymoshenko }; 1112b3f6d66SOleksandr Tymoshenko 1122b3f6d66SOleksandr Tymoshenko #endif /* _EVDEV_UINPUT_H_ */ 113