The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/evdev/evdev.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2014 Jakub Wojciech Klama <jceel@FreeBSD.org>
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   24  * SUCH DAMAGE.
   25  *
   26  * $FreeBSD$
   27  */
   28 
   29 #ifndef _DEV_EVDEV_EVDEV_H
   30 #define _DEV_EVDEV_EVDEV_H
   31 
   32 #include <sys/types.h>
   33 #include <sys/epoch.h>
   34 #include <sys/kbio.h>
   35 #include <dev/evdev/input.h>
   36 #include <dev/kbd/kbdreg.h>
   37 
   38 #define NAMELEN         80
   39 
   40 struct evdev_dev;
   41 
   42 typedef int (evdev_open_t)(struct evdev_dev *);
   43 typedef int (evdev_close_t)(struct evdev_dev *);
   44 typedef void (evdev_event_t)(struct evdev_dev *, uint16_t, uint16_t, int32_t);
   45 typedef void (evdev_keycode_t)(struct evdev_dev *,
   46     struct input_keymap_entry *);
   47 
   48 /*
   49  * Keyboard and mouse events recipient mask.
   50  * evdev_rcpt_mask variable should be respected by keyboard and mouse drivers
   51  * that are able to send events through both evdev and sysmouse/kbdmux
   52  * interfaces so user can choose prefered one to not receive one event twice.
   53  */
   54 #define EVDEV_RCPT_SYSMOUSE     (1<<0)
   55 #define EVDEV_RCPT_KBDMUX       (1<<1)
   56 #define EVDEV_RCPT_HW_MOUSE     (1<<2)
   57 #define EVDEV_RCPT_HW_KBD       (1<<3)
   58 extern int evdev_rcpt_mask;
   59 /*
   60  * Sysmouse protocol does not support horizontal wheel movement reporting.
   61  * To overcome this limitation different drivers use different sysmouse proto
   62  * extensions. Set kern.evdev.sysmouse_t_axis to tell sysmouse evdev driver
   63  * which protocol extension is used.
   64  * 0 - do not extract horizontal wheel movement (default).
   65  * 1 - ums(4) horizontal wheel encoding. T-axis is mapped to buttons 6 and 7
   66  * 2 - psm(4) wheels encoding: z = 1,-1 - vert. wheel, z = 2,-2 - horiz. wheel
   67  */
   68 enum
   69 {
   70         EVDEV_SYSMOUSE_T_AXIS_NONE = 0,
   71         EVDEV_SYSMOUSE_T_AXIS_UMS = 1,
   72         EVDEV_SYSMOUSE_T_AXIS_PSM = 2,
   73 };
   74 extern int evdev_sysmouse_t_axis;
   75 
   76 #define ABS_MT_FIRST    ABS_MT_TOUCH_MAJOR
   77 #define ABS_MT_LAST     ABS_MT_TOOL_Y
   78 #define ABS_IS_MT(x)    ((x) >= ABS_MT_FIRST && (x) <= ABS_MT_LAST)
   79 #define ABS_MT_INDEX(x) ((x) - ABS_MT_FIRST)
   80 #define MT_CNT          (ABS_MT_INDEX(ABS_MT_LAST) + 1)
   81 /* Multitouch protocol type A */
   82 #define MAX_MT_REPORTS  5
   83 /* Multitouch protocol type B interface */
   84 #define MAX_MT_SLOTS    16
   85 
   86 #define EVDEV_FLAG_SOFTREPEAT   0x00    /* use evdev to repeat keys */
   87 #define EVDEV_FLAG_MT_STCOMPAT  0x01    /* autogenerate ST-compatible events
   88                                          * for MT protocol type B reports */
   89 #define EVDEV_FLAG_MT_AUTOREL   0x02    /* Autorelease MT-slots not listed in
   90                                          * current MT protocol type B report */
   91 #define EVDEV_FLAG_EXT_EPOCH    0x03    /* evdev_push_* is allways called with
   92                                          * input (global) epoch entered */
   93 #define EVDEV_FLAG_MAX          0x1F
   94 #define EVDEV_FLAG_CNT          (EVDEV_FLAG_MAX + 1)
   95 
   96 struct evdev_methods
   97 {
   98         evdev_open_t            *ev_open;
   99         evdev_close_t           *ev_close;
  100         evdev_event_t           *ev_event;
  101         evdev_keycode_t         *ev_get_keycode;
  102         evdev_keycode_t         *ev_set_keycode;
  103 };
  104 
  105 /* Input device interface: */
  106 struct evdev_dev *evdev_alloc(void);
  107 void evdev_free(struct evdev_dev *);
  108 void evdev_set_name(struct evdev_dev *, const char *);
  109 void evdev_set_id(struct evdev_dev *, uint16_t, uint16_t, uint16_t, uint16_t);
  110 void evdev_set_phys(struct evdev_dev *, const char *);
  111 void evdev_set_serial(struct evdev_dev *, const char *);
  112 void evdev_set_methods(struct evdev_dev *, void *,
  113     const struct evdev_methods *);
  114 int evdev_register(struct evdev_dev *);
  115 int evdev_register_mtx(struct evdev_dev *, struct mtx *);
  116 int evdev_unregister(struct evdev_dev *);
  117 int evdev_push_event(struct evdev_dev *, uint16_t, uint16_t, int32_t);
  118 void evdev_support_prop(struct evdev_dev *, uint16_t);
  119 void evdev_support_event(struct evdev_dev *, uint16_t);
  120 void evdev_support_key(struct evdev_dev *, uint16_t);
  121 void evdev_support_rel(struct evdev_dev *, uint16_t);
  122 void evdev_support_abs(struct evdev_dev *, uint16_t, int32_t, int32_t, int32_t,
  123    int32_t, int32_t);
  124 void evdev_support_msc(struct evdev_dev *, uint16_t);
  125 void evdev_support_led(struct evdev_dev *, uint16_t);
  126 void evdev_support_snd(struct evdev_dev *, uint16_t);
  127 void evdev_support_sw(struct evdev_dev *, uint16_t);
  128 void evdev_set_repeat_params(struct evdev_dev *, uint16_t, int);
  129 int evdev_set_report_size(struct evdev_dev *, size_t);
  130 void evdev_set_flag(struct evdev_dev *, uint16_t);
  131 void *evdev_get_softc(struct evdev_dev *);
  132 
  133 /* Multitouch related functions: */
  134 int32_t evdev_get_mt_slot_by_tracking_id(struct evdev_dev *, int32_t);
  135 void evdev_support_nfingers(struct evdev_dev *, int32_t);
  136 void evdev_support_mt_compat(struct evdev_dev *);
  137 void evdev_push_nfingers(struct evdev_dev *, int32_t);
  138 void evdev_push_mt_compat(struct evdev_dev *);
  139 
  140 /* Utility functions: */
  141 uint16_t evdev_hid2key(int);
  142 void evdev_support_all_known_keys(struct evdev_dev *);
  143 uint16_t evdev_scancode2key(int *, int);
  144 void evdev_push_mouse_btn(struct evdev_dev *, int);
  145 void evdev_push_leds(struct evdev_dev *, int);
  146 void evdev_push_repeats(struct evdev_dev *, keyboard_t *);
  147 
  148 /* Event reporting shortcuts: */
  149 static __inline int
  150 evdev_sync(struct evdev_dev *evdev)
  151 {
  152 
  153         return (evdev_push_event(evdev, EV_SYN, SYN_REPORT, 1));
  154 }
  155 
  156 static __inline int
  157 evdev_mt_sync(struct evdev_dev *evdev)
  158 {
  159 
  160         return (evdev_push_event(evdev, EV_SYN, SYN_MT_REPORT, 1));
  161 }
  162 
  163 static __inline int
  164 evdev_push_key(struct evdev_dev *evdev, uint16_t code, int32_t value)
  165 {
  166 
  167         return (evdev_push_event(evdev, EV_KEY, code, value != 0));
  168 }
  169 
  170 static __inline int
  171 evdev_push_rel(struct evdev_dev *evdev, uint16_t code, int32_t value)
  172 {
  173 
  174         return (evdev_push_event(evdev, EV_REL, code, value));
  175 }
  176 
  177 static __inline int
  178 evdev_push_abs(struct evdev_dev *evdev, uint16_t code, int32_t value)
  179 {
  180 
  181         return (evdev_push_event(evdev, EV_ABS, code, value));
  182 }
  183 
  184 static __inline int
  185 evdev_push_msc(struct evdev_dev *evdev, uint16_t code, int32_t value)
  186 {
  187 
  188         return (evdev_push_event(evdev, EV_MSC, code, value));
  189 }
  190 
  191 static __inline int
  192 evdev_push_led(struct evdev_dev *evdev, uint16_t code, int32_t value)
  193 {
  194 
  195         return (evdev_push_event(evdev, EV_LED, code, value != 0));
  196 }
  197 
  198 static __inline int
  199 evdev_push_snd(struct evdev_dev *evdev, uint16_t code, int32_t value)
  200 {
  201 
  202         return (evdev_push_event(evdev, EV_SND, code, value));
  203 }
  204 
  205 static __inline int
  206 evdev_push_sw(struct evdev_dev *evdev, uint16_t code, int32_t value)
  207 {
  208 
  209         return (evdev_push_event(evdev, EV_SW, code, value != 0));
  210 }
  211 
  212 #endif  /* _DEV_EVDEV_EVDEV_H */

Cache object: 657a83dea19da5dde803d0097b80773a


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.