2 * Copyright (c) 2015 Oleksandr Tymoshenko <gonzo@freebsd.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
30 #include <sys/param.h>
31 #include <sys/systm.h>
33 #include <dev/gpio/gpiokeys.h>
34 #include <gnu/dts/include/dt-bindings/input/linux-event-codes.h>
36 struct gpiokeys_codemap_entry {
41 static struct gpiokeys_codemap_entry gpiokeys_codes_map[] = {
69 { KEY_RIGHTBRACE, 27},
83 { KEY_APOSTROPHE, 40},
98 { KEY_RIGHTSHIFT, 54},
117 { KEY_RIGHTCTRL, 90},
121 { KEY_HOME, GPIOKEY_E0(71)},
122 { KEY_UP, GPIOKEY_E0(72)},
123 { KEY_PAGEUP, GPIOKEY_E0(73)},
124 { KEY_LEFT, GPIOKEY_E0(75)},
125 { KEY_RIGHT, GPIOKEY_E0(77)},
126 { KEY_END, GPIOKEY_E0(79)},
127 { KEY_DOWN, GPIOKEY_E0(80)},
128 { KEY_PAGEDOWN, GPIOKEY_E0(81)},
129 { KEY_INSERT, GPIOKEY_E0(82)},
130 { KEY_DELETE, GPIOKEY_E0(83)},
132 { GPIOKEY_NONE, GPIOKEY_NONE}
136 gpiokey_map_linux_code(uint32_t linux_code)
140 for (i = 0; gpiokeys_codes_map[i].linux_code != GPIOKEY_NONE; i++) {
141 if (gpiokeys_codes_map[i].linux_code == linux_code)
142 return (gpiokeys_codes_map[i].bsd_code);
145 return (GPIOKEY_NONE);