2019-05-27 06:55:01 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2008-06-18 21:36:49 +00:00
|
|
|
/*
|
|
|
|
* USB HID quirks support for Linux
|
|
|
|
*
|
|
|
|
* Copyright (c) 1999 Andreas Gal
|
|
|
|
* Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
|
|
|
|
* Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
|
|
|
|
* Copyright (c) 2006-2007 Jiri Kosina
|
|
|
|
* Copyright (c) 2008 Jiri Slaby <jirislaby@gmail.com>
|
2022-02-03 12:21:13 +00:00
|
|
|
* Copyright (c) 2019 Paul Pawlowski <paul@mrarm.io>
|
2008-06-18 21:36:49 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
|
|
|
|
2010-12-10 03:29:03 +00:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2008-06-18 21:36:49 +00:00
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/hid.h>
|
2021-11-18 07:29:55 +00:00
|
|
|
#include <linux/jiffies.h>
|
2008-06-18 21:36:49 +00:00
|
|
|
#include <linux/module.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2021-11-18 07:29:55 +00:00
|
|
|
#include <linux/timer.h>
|
2022-05-05 19:12:21 +00:00
|
|
|
#include <linux/string.h>
|
2023-02-15 01:03:37 +00:00
|
|
|
#include <linux/leds.h>
|
2008-06-18 21:36:49 +00:00
|
|
|
|
|
|
|
#include "hid-ids.h"
|
|
|
|
|
2021-11-18 07:29:54 +00:00
|
|
|
#define APPLE_RDESC_JIS BIT(0)
|
|
|
|
#define APPLE_IGNORE_MOUSE BIT(1)
|
|
|
|
#define APPLE_HAS_FN BIT(2)
|
|
|
|
/* BIT(3) reserved, was: APPLE_HIDDEV */
|
|
|
|
#define APPLE_ISO_TILDE_QUIRK BIT(4)
|
|
|
|
#define APPLE_MIGHTYMOUSE BIT(5)
|
|
|
|
#define APPLE_INVERT_HWHEEL BIT(6)
|
|
|
|
/* BIT(7) reserved, was: APPLE_IGNORE_HIDINPUT */
|
|
|
|
#define APPLE_NUMLOCK_EMULATION BIT(8)
|
2021-11-18 07:29:55 +00:00
|
|
|
#define APPLE_RDESC_BATTERY BIT(9)
|
2022-02-03 12:21:13 +00:00
|
|
|
#define APPLE_BACKLIGHT_CTL BIT(10)
|
2022-06-02 08:12:19 +00:00
|
|
|
#define APPLE_IS_NON_APPLE BIT(11)
|
2008-06-18 21:36:49 +00:00
|
|
|
|
|
|
|
#define APPLE_FLAG_FKEY 0x01
|
|
|
|
|
2017-06-02 15:28:39 +00:00
|
|
|
#define HID_COUNTRY_INTERNATIONAL_ISO 13
|
2021-11-18 07:29:55 +00:00
|
|
|
#define APPLE_BATTERY_TIMEOUT_MS 60000
|
2017-06-02 15:28:39 +00:00
|
|
|
|
2022-05-05 19:12:21 +00:00
|
|
|
static unsigned int fnmode = 3;
|
2008-06-18 21:36:49 +00:00
|
|
|
module_param(fnmode, uint, 0644);
|
|
|
|
MODULE_PARM_DESC(fnmode, "Mode of fn key on Apple keyboards (0 = disabled, "
|
2022-05-05 19:12:21 +00:00
|
|
|
"1 = fkeyslast, 2 = fkeysfirst, [3] = auto)");
|
2008-06-18 21:36:49 +00:00
|
|
|
|
2021-10-19 07:12:32 +00:00
|
|
|
static int iso_layout = -1;
|
|
|
|
module_param(iso_layout, int, 0644);
|
|
|
|
MODULE_PARM_DESC(iso_layout, "Swap the backtick/tilde and greater-than/less-than keys. "
|
|
|
|
"([-1] = auto, 0 = disabled, 1 = enabled)");
|
2010-01-05 22:30:30 +00:00
|
|
|
|
2013-10-14 14:07:42 +00:00
|
|
|
static unsigned int swap_opt_cmd;
|
2013-10-14 14:07:15 +00:00
|
|
|
module_param(swap_opt_cmd, uint, 0644);
|
|
|
|
MODULE_PARM_DESC(swap_opt_cmd, "Swap the Option (\"Alt\") and Command (\"Flag\") keys. "
|
|
|
|
"(For people who want to keep Windows PC keyboard muscle memory. "
|
2023-05-22 18:40:12 +00:00
|
|
|
"[0] = as-is, Mac layout. 1 = swapped, Windows layout., 2 = swapped, Swap only left side)");
|
2013-10-14 14:07:15 +00:00
|
|
|
|
2022-11-04 11:55:35 +00:00
|
|
|
static unsigned int swap_ctrl_cmd;
|
|
|
|
module_param(swap_ctrl_cmd, uint, 0644);
|
|
|
|
MODULE_PARM_DESC(swap_ctrl_cmd, "Swap the Control (\"Ctrl\") and Command (\"Flag\") keys. "
|
|
|
|
"(For people who are used to Mac shortcuts involving Command instead of Control. "
|
|
|
|
"[0] = No change. 1 = Swapped.)");
|
|
|
|
|
2020-05-15 06:14:00 +00:00
|
|
|
static unsigned int swap_fn_leftctrl;
|
|
|
|
module_param(swap_fn_leftctrl, uint, 0644);
|
|
|
|
MODULE_PARM_DESC(swap_fn_leftctrl, "Swap the Fn and left Control keys. "
|
|
|
|
"(For people who want to keep PC keyboard muscle memory. "
|
|
|
|
"[0] = as-is, Mac layout, 1 = swapped, PC layout)");
|
|
|
|
|
2022-06-02 08:12:19 +00:00
|
|
|
struct apple_non_apple_keyboard {
|
|
|
|
char *name;
|
|
|
|
};
|
|
|
|
|
2022-02-03 12:21:13 +00:00
|
|
|
struct apple_sc_backlight {
|
|
|
|
struct led_classdev cdev;
|
|
|
|
struct hid_device *hdev;
|
|
|
|
unsigned short backlight_off, backlight_on_min, backlight_on_max;
|
|
|
|
};
|
|
|
|
|
2008-06-18 21:36:49 +00:00
|
|
|
struct apple_sc {
|
2021-11-18 07:29:55 +00:00
|
|
|
struct hid_device *hdev;
|
2008-06-18 21:36:49 +00:00
|
|
|
unsigned long quirks;
|
|
|
|
unsigned int fn_on;
|
2020-06-20 12:32:29 +00:00
|
|
|
unsigned int fn_found;
|
2008-06-18 21:36:49 +00:00
|
|
|
DECLARE_BITMAP(pressed_numlock, KEY_CNT);
|
2021-11-18 07:29:55 +00:00
|
|
|
struct timer_list battery_timer;
|
2022-02-03 12:21:13 +00:00
|
|
|
struct apple_sc_backlight *backlight;
|
2008-06-18 21:36:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct apple_key_translation {
|
|
|
|
u16 from;
|
|
|
|
u16 to;
|
|
|
|
u8 flags;
|
|
|
|
};
|
|
|
|
|
2022-02-08 18:37:03 +00:00
|
|
|
static const struct apple_key_translation magic_keyboard_alu_fn_keys[] = {
|
|
|
|
{ KEY_BACKSPACE, KEY_DELETE },
|
|
|
|
{ KEY_ENTER, KEY_INSERT },
|
|
|
|
{ KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F6, KEY_NUMLOCK, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_UP, KEY_PAGEUP },
|
|
|
|
{ KEY_DOWN, KEY_PAGEDOWN },
|
|
|
|
{ KEY_LEFT, KEY_HOME },
|
|
|
|
{ KEY_RIGHT, KEY_END },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2022-02-08 18:37:04 +00:00
|
|
|
static const struct apple_key_translation magic_keyboard_2015_fn_keys[] = {
|
|
|
|
{ KEY_BACKSPACE, KEY_DELETE },
|
|
|
|
{ KEY_ENTER, KEY_INSERT },
|
|
|
|
{ KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_UP, KEY_PAGEUP },
|
|
|
|
{ KEY_DOWN, KEY_PAGEDOWN },
|
|
|
|
{ KEY_LEFT, KEY_HOME },
|
|
|
|
{ KEY_RIGHT, KEY_END },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2022-02-03 12:21:13 +00:00
|
|
|
struct apple_backlight_config_report {
|
|
|
|
u8 report_id;
|
|
|
|
u8 version;
|
|
|
|
u16 backlight_off, backlight_on_min, backlight_on_max;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct apple_backlight_set_report {
|
|
|
|
u8 report_id;
|
|
|
|
u8 version;
|
|
|
|
u16 backlight;
|
|
|
|
u16 rate;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-11-08 12:50:38 +00:00
|
|
|
static const struct apple_key_translation apple2021_fn_keys[] = {
|
|
|
|
{ KEY_BACKSPACE, KEY_DELETE },
|
|
|
|
{ KEY_ENTER, KEY_INSERT },
|
|
|
|
{ KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F4, KEY_SEARCH, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F5, KEY_MICMUTE, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F6, KEY_SLEEP, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_UP, KEY_PAGEUP },
|
|
|
|
{ KEY_DOWN, KEY_PAGEDOWN },
|
|
|
|
{ KEY_LEFT, KEY_HOME },
|
|
|
|
{ KEY_RIGHT, KEY_END },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2010-11-03 14:36:18 +00:00
|
|
|
static const struct apple_key_translation macbookair_fn_keys[] = {
|
|
|
|
{ KEY_BACKSPACE, KEY_DELETE },
|
|
|
|
{ KEY_ENTER, KEY_INSERT },
|
|
|
|
{ KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F6, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F7, KEY_PLAYPAUSE, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F8, KEY_NEXTSONG, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F9, KEY_MUTE, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F10, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F11, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F12, KEY_EJECTCD, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_UP, KEY_PAGEUP },
|
|
|
|
{ KEY_DOWN, KEY_PAGEDOWN },
|
|
|
|
{ KEY_LEFT, KEY_HOME },
|
|
|
|
{ KEY_RIGHT, KEY_END },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2022-02-03 12:23:02 +00:00
|
|
|
static const struct apple_key_translation macbookpro_no_esc_fn_keys[] = {
|
|
|
|
{ KEY_BACKSPACE, KEY_DELETE },
|
|
|
|
{ KEY_ENTER, KEY_INSERT },
|
|
|
|
{ KEY_GRAVE, KEY_ESC },
|
|
|
|
{ KEY_1, KEY_F1 },
|
|
|
|
{ KEY_2, KEY_F2 },
|
|
|
|
{ KEY_3, KEY_F3 },
|
|
|
|
{ KEY_4, KEY_F4 },
|
|
|
|
{ KEY_5, KEY_F5 },
|
|
|
|
{ KEY_6, KEY_F6 },
|
|
|
|
{ KEY_7, KEY_F7 },
|
|
|
|
{ KEY_8, KEY_F8 },
|
|
|
|
{ KEY_9, KEY_F9 },
|
|
|
|
{ KEY_0, KEY_F10 },
|
|
|
|
{ KEY_MINUS, KEY_F11 },
|
|
|
|
{ KEY_EQUAL, KEY_F12 },
|
|
|
|
{ KEY_UP, KEY_PAGEUP },
|
|
|
|
{ KEY_DOWN, KEY_PAGEDOWN },
|
|
|
|
{ KEY_LEFT, KEY_HOME },
|
|
|
|
{ KEY_RIGHT, KEY_END },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct apple_key_translation macbookpro_dedicated_esc_fn_keys[] = {
|
|
|
|
{ KEY_BACKSPACE, KEY_DELETE },
|
|
|
|
{ KEY_ENTER, KEY_INSERT },
|
|
|
|
{ KEY_1, KEY_F1 },
|
|
|
|
{ KEY_2, KEY_F2 },
|
|
|
|
{ KEY_3, KEY_F3 },
|
|
|
|
{ KEY_4, KEY_F4 },
|
|
|
|
{ KEY_5, KEY_F5 },
|
|
|
|
{ KEY_6, KEY_F6 },
|
|
|
|
{ KEY_7, KEY_F7 },
|
|
|
|
{ KEY_8, KEY_F8 },
|
|
|
|
{ KEY_9, KEY_F9 },
|
|
|
|
{ KEY_0, KEY_F10 },
|
|
|
|
{ KEY_MINUS, KEY_F11 },
|
|
|
|
{ KEY_EQUAL, KEY_F12 },
|
|
|
|
{ KEY_UP, KEY_PAGEUP },
|
|
|
|
{ KEY_DOWN, KEY_PAGEDOWN },
|
|
|
|
{ KEY_LEFT, KEY_HOME },
|
|
|
|
{ KEY_RIGHT, KEY_END },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2009-03-07 04:07:15 +00:00
|
|
|
static const struct apple_key_translation apple_fn_keys[] = {
|
2008-06-18 21:36:49 +00:00
|
|
|
{ KEY_BACKSPACE, KEY_DELETE },
|
2008-11-04 12:31:38 +00:00
|
|
|
{ KEY_ENTER, KEY_INSERT },
|
2008-06-18 21:36:49 +00:00
|
|
|
{ KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
|
2008-11-04 12:31:38 +00:00
|
|
|
{ KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY },
|
2008-06-18 21:36:49 +00:00
|
|
|
{ KEY_F5, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F6, KEY_KBDILLUMUP, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_UP, KEY_PAGEUP },
|
|
|
|
{ KEY_DOWN, KEY_PAGEDOWN },
|
|
|
|
{ KEY_LEFT, KEY_HOME },
|
|
|
|
{ KEY_RIGHT, KEY_END },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2009-03-07 04:07:15 +00:00
|
|
|
static const struct apple_key_translation powerbook_fn_keys[] = {
|
2008-06-18 21:36:49 +00:00
|
|
|
{ KEY_BACKSPACE, KEY_DELETE },
|
|
|
|
{ KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F3, KEY_MUTE, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F4, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F5, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F6, KEY_NUMLOCK, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F7, KEY_SWITCHVIDEOMODE, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F8, KEY_KBDILLUMTOGGLE, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F9, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_F10, KEY_KBDILLUMUP, APPLE_FLAG_FKEY },
|
|
|
|
{ KEY_UP, KEY_PAGEUP },
|
|
|
|
{ KEY_DOWN, KEY_PAGEDOWN },
|
|
|
|
{ KEY_LEFT, KEY_HOME },
|
|
|
|
{ KEY_RIGHT, KEY_END },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2009-03-07 04:07:15 +00:00
|
|
|
static const struct apple_key_translation powerbook_numlock_keys[] = {
|
2008-06-18 21:36:49 +00:00
|
|
|
{ KEY_J, KEY_KP1 },
|
|
|
|
{ KEY_K, KEY_KP2 },
|
|
|
|
{ KEY_L, KEY_KP3 },
|
|
|
|
{ KEY_U, KEY_KP4 },
|
|
|
|
{ KEY_I, KEY_KP5 },
|
|
|
|
{ KEY_O, KEY_KP6 },
|
|
|
|
{ KEY_7, KEY_KP7 },
|
|
|
|
{ KEY_8, KEY_KP8 },
|
|
|
|
{ KEY_9, KEY_KP9 },
|
|
|
|
{ KEY_M, KEY_KP0 },
|
|
|
|
{ KEY_DOT, KEY_KPDOT },
|
|
|
|
{ KEY_SLASH, KEY_KPPLUS },
|
|
|
|
{ KEY_SEMICOLON, KEY_KPMINUS },
|
|
|
|
{ KEY_P, KEY_KPASTERISK },
|
|
|
|
{ KEY_MINUS, KEY_KPEQUAL },
|
|
|
|
{ KEY_0, KEY_KPSLASH },
|
|
|
|
{ KEY_F6, KEY_NUMLOCK },
|
|
|
|
{ KEY_KPENTER, KEY_KPENTER },
|
|
|
|
{ KEY_BACKSPACE, KEY_BACKSPACE },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2009-03-07 04:07:15 +00:00
|
|
|
static const struct apple_key_translation apple_iso_keyboard[] = {
|
2008-06-18 21:36:49 +00:00
|
|
|
{ KEY_GRAVE, KEY_102ND },
|
|
|
|
{ KEY_102ND, KEY_GRAVE },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2013-10-14 14:07:15 +00:00
|
|
|
static const struct apple_key_translation swapped_option_cmd_keys[] = {
|
|
|
|
{ KEY_LEFTALT, KEY_LEFTMETA },
|
|
|
|
{ KEY_LEFTMETA, KEY_LEFTALT },
|
|
|
|
{ KEY_RIGHTALT, KEY_RIGHTMETA },
|
2022-11-04 11:55:35 +00:00
|
|
|
{ KEY_RIGHTMETA, KEY_RIGHTALT },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2023-05-22 18:40:12 +00:00
|
|
|
static const struct apple_key_translation swapped_option_cmd_left_keys[] = {
|
|
|
|
{ KEY_LEFTALT, KEY_LEFTMETA },
|
|
|
|
{ KEY_LEFTMETA, KEY_LEFTALT },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2022-11-04 11:55:35 +00:00
|
|
|
static const struct apple_key_translation swapped_ctrl_cmd_keys[] = {
|
|
|
|
{ KEY_LEFTCTRL, KEY_LEFTMETA },
|
|
|
|
{ KEY_LEFTMETA, KEY_LEFTCTRL },
|
|
|
|
{ KEY_RIGHTCTRL, KEY_RIGHTMETA },
|
|
|
|
{ KEY_RIGHTMETA, KEY_RIGHTCTRL },
|
2013-10-14 14:07:15 +00:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2020-05-15 06:14:00 +00:00
|
|
|
static const struct apple_key_translation swapped_fn_leftctrl_keys[] = {
|
|
|
|
{ KEY_FN, KEY_LEFTCTRL },
|
HID: apple: fix key translations where multiple quirks attempt to translate the same key
The hid-apple driver does not support chaining translations or
dependencies on other translations. This creates two problems:
1 - In Non-English keyboards of Macs, KEY_102ND and KEY_GRAVE are
swapped and the APPLE_ISO_TILDE_QUIRK is used to work around this
problem. The quirk is not set for the Macs where these bugs happen yet
(see the 2nd patch for that), but this can be forced by setting the
iso_layout parameter. Unfortunately, this only partially works.
KEY_102ND gets translated to KEY_GRAVE, but KEY_GRAVE does not get
translated to KEY_102ND, so both of them end up functioning as
KEY_GRAVE. This is because the driver translates the keys as if Fn was
pressed and the original is sent if it is not pressed, without any
further translations happening on the key[#463]. KEY_GRAVE is present at
macbookpro_no_esc_fn_keys[#195], so this is what happens:
- KEY_GRAVE -> KEY_ESC (as if Fn is pressed)
- KEY_GRAVE is returned (Fn isn't pressed, so translation is discarded)
- KEY_GRAVE -> KEY_102ND (this part is not reached!)
...
2 - In case the touchbar does not work, the driver supports sending
Escape when Fn+KEY_GRAVE is pressed. As mentioned previously, KEY_102ND
is actually KEY_GRAVE and needs to be translated before this happens.
Normally, these are the steps that should happen:
- KEY_102ND -> KEY_GRAVE
- KEY_GRAVE -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
Though this is what happens instead, as dependencies on other
translations are not supported:
- KEY_102ND -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
This patch fixes both bugs by ordering the translations correctly and by
making the translations continue and not return immediately after
translating a key so that chained translations work and translations can
depend on other ones.
This patch also simplifies the implementation of the swap_fn_leftctrl
option a little bit, as it makes it simply use a normal translation
instead adding extra code to translate a key to KEY_FN[#381]. This change
wasn't put in another patch as the code that translates the Fn key needs
to be changed because of the changes in the patch, and those changes
would be discarded with the next patch anyway (the part that originally
translates KEY_FN to KEY_LEFTCTRL needs to be made an else-if branch of
the part that transltes KEY_LEFTCTRL to KEY_FN).
Note: Line numbers (#XYZ) are for drivers/hid/hid-apple.c at commit
20afcc462579 ("HID: apple: Add "GANSS" to the non-Apple list").
Note: These bugs are only present on Macs with a keyboard with no
dedicated escape key and a non-English layout.
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-09-24 09:53:05 +00:00
|
|
|
{ KEY_LEFTCTRL, KEY_FN },
|
2020-05-15 06:14:00 +00:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2022-06-02 08:12:19 +00:00
|
|
|
static const struct apple_non_apple_keyboard non_apple_keyboards[] = {
|
|
|
|
{ "SONiX USB DEVICE" },
|
|
|
|
{ "Keychron" },
|
2022-07-21 14:34:23 +00:00
|
|
|
{ "AONE" },
|
|
|
|
{ "GANSS" }
|
2022-06-02 08:12:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static bool apple_is_non_apple_keyboard(struct hid_device *hdev)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(non_apple_keyboards); i++) {
|
|
|
|
char *non_apple = non_apple_keyboards[i].name;
|
|
|
|
|
|
|
|
if (strncmp(hdev->name, non_apple, strlen(non_apple)) == 0)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-02-08 18:37:02 +00:00
|
|
|
static inline void apple_setup_key_translation(struct input_dev *input,
|
|
|
|
const struct apple_key_translation *table)
|
|
|
|
{
|
|
|
|
const struct apple_key_translation *trans;
|
|
|
|
|
|
|
|
for (trans = table; trans->from; trans++)
|
|
|
|
set_bit(trans->to, input->keybit);
|
|
|
|
}
|
|
|
|
|
2009-03-07 04:07:15 +00:00
|
|
|
static const struct apple_key_translation *apple_find_translation(
|
|
|
|
const struct apple_key_translation *table, u16 from)
|
2008-06-18 21:36:49 +00:00
|
|
|
{
|
2009-03-07 04:07:15 +00:00
|
|
|
const struct apple_key_translation *trans;
|
2008-06-18 21:36:49 +00:00
|
|
|
|
|
|
|
/* Look for the translation */
|
|
|
|
for (trans = table; trans->from; trans++)
|
|
|
|
if (trans->from == from)
|
|
|
|
return trans;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2021-07-22 01:25:44 +00:00
|
|
|
static void input_event_with_scancode(struct input_dev *input,
|
|
|
|
__u8 type, __u16 code, unsigned int hid, __s32 value)
|
|
|
|
{
|
|
|
|
if (type == EV_KEY &&
|
|
|
|
(!test_bit(code, input->key)) == value)
|
|
|
|
input_event(input, EV_MSC, MSC_SCAN, hid);
|
|
|
|
input_event(input, type, code, value);
|
|
|
|
}
|
|
|
|
|
2008-06-18 21:36:49 +00:00
|
|
|
static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
|
|
|
|
struct hid_usage *usage, __s32 value)
|
|
|
|
{
|
|
|
|
struct apple_sc *asc = hid_get_drvdata(hid);
|
2010-11-03 14:42:02 +00:00
|
|
|
const struct apple_key_translation *trans, *table;
|
2019-09-03 14:46:32 +00:00
|
|
|
bool do_translate;
|
HID: apple: fix key translations where multiple quirks attempt to translate the same key
The hid-apple driver does not support chaining translations or
dependencies on other translations. This creates two problems:
1 - In Non-English keyboards of Macs, KEY_102ND and KEY_GRAVE are
swapped and the APPLE_ISO_TILDE_QUIRK is used to work around this
problem. The quirk is not set for the Macs where these bugs happen yet
(see the 2nd patch for that), but this can be forced by setting the
iso_layout parameter. Unfortunately, this only partially works.
KEY_102ND gets translated to KEY_GRAVE, but KEY_GRAVE does not get
translated to KEY_102ND, so both of them end up functioning as
KEY_GRAVE. This is because the driver translates the keys as if Fn was
pressed and the original is sent if it is not pressed, without any
further translations happening on the key[#463]. KEY_GRAVE is present at
macbookpro_no_esc_fn_keys[#195], so this is what happens:
- KEY_GRAVE -> KEY_ESC (as if Fn is pressed)
- KEY_GRAVE is returned (Fn isn't pressed, so translation is discarded)
- KEY_GRAVE -> KEY_102ND (this part is not reached!)
...
2 - In case the touchbar does not work, the driver supports sending
Escape when Fn+KEY_GRAVE is pressed. As mentioned previously, KEY_102ND
is actually KEY_GRAVE and needs to be translated before this happens.
Normally, these are the steps that should happen:
- KEY_102ND -> KEY_GRAVE
- KEY_GRAVE -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
Though this is what happens instead, as dependencies on other
translations are not supported:
- KEY_102ND -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
This patch fixes both bugs by ordering the translations correctly and by
making the translations continue and not return immediately after
translating a key so that chained translations work and translations can
depend on other ones.
This patch also simplifies the implementation of the swap_fn_leftctrl
option a little bit, as it makes it simply use a normal translation
instead adding extra code to translate a key to KEY_FN[#381]. This change
wasn't put in another patch as the code that translates the Fn key needs
to be changed because of the changes in the patch, and those changes
would be discarded with the next patch anyway (the part that originally
translates KEY_FN to KEY_LEFTCTRL needs to be made an else-if branch of
the part that transltes KEY_LEFTCTRL to KEY_FN).
Note: Line numbers (#XYZ) are for drivers/hid/hid-apple.c at commit
20afcc462579 ("HID: apple: Add "GANSS" to the non-Apple list").
Note: These bugs are only present on Macs with a keyboard with no
dedicated escape key and a non-English layout.
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-09-24 09:53:05 +00:00
|
|
|
u16 code = usage->code;
|
2022-05-05 19:12:21 +00:00
|
|
|
unsigned int real_fnmode;
|
2008-06-18 21:36:49 +00:00
|
|
|
|
2022-05-05 19:12:21 +00:00
|
|
|
if (fnmode == 3) {
|
2022-06-02 08:12:19 +00:00
|
|
|
real_fnmode = (asc->quirks & APPLE_IS_NON_APPLE) ? 2 : 1;
|
2022-05-05 19:12:21 +00:00
|
|
|
} else {
|
|
|
|
real_fnmode = fnmode;
|
|
|
|
}
|
|
|
|
|
HID: apple: fix key translations where multiple quirks attempt to translate the same key
The hid-apple driver does not support chaining translations or
dependencies on other translations. This creates two problems:
1 - In Non-English keyboards of Macs, KEY_102ND and KEY_GRAVE are
swapped and the APPLE_ISO_TILDE_QUIRK is used to work around this
problem. The quirk is not set for the Macs where these bugs happen yet
(see the 2nd patch for that), but this can be forced by setting the
iso_layout parameter. Unfortunately, this only partially works.
KEY_102ND gets translated to KEY_GRAVE, but KEY_GRAVE does not get
translated to KEY_102ND, so both of them end up functioning as
KEY_GRAVE. This is because the driver translates the keys as if Fn was
pressed and the original is sent if it is not pressed, without any
further translations happening on the key[#463]. KEY_GRAVE is present at
macbookpro_no_esc_fn_keys[#195], so this is what happens:
- KEY_GRAVE -> KEY_ESC (as if Fn is pressed)
- KEY_GRAVE is returned (Fn isn't pressed, so translation is discarded)
- KEY_GRAVE -> KEY_102ND (this part is not reached!)
...
2 - In case the touchbar does not work, the driver supports sending
Escape when Fn+KEY_GRAVE is pressed. As mentioned previously, KEY_102ND
is actually KEY_GRAVE and needs to be translated before this happens.
Normally, these are the steps that should happen:
- KEY_102ND -> KEY_GRAVE
- KEY_GRAVE -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
Though this is what happens instead, as dependencies on other
translations are not supported:
- KEY_102ND -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
This patch fixes both bugs by ordering the translations correctly and by
making the translations continue and not return immediately after
translating a key so that chained translations work and translations can
depend on other ones.
This patch also simplifies the implementation of the swap_fn_leftctrl
option a little bit, as it makes it simply use a normal translation
instead adding extra code to translate a key to KEY_FN[#381]. This change
wasn't put in another patch as the code that translates the Fn key needs
to be changed because of the changes in the patch, and those changes
would be discarded with the next patch anyway (the part that originally
translates KEY_FN to KEY_LEFTCTRL needs to be made an else-if branch of
the part that transltes KEY_LEFTCTRL to KEY_FN).
Note: Line numbers (#XYZ) are for drivers/hid/hid-apple.c at commit
20afcc462579 ("HID: apple: Add "GANSS" to the non-Apple list").
Note: These bugs are only present on Macs with a keyboard with no
dedicated escape key and a non-English layout.
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-09-24 09:53:05 +00:00
|
|
|
if (swap_fn_leftctrl) {
|
|
|
|
trans = apple_find_translation(swapped_fn_leftctrl_keys, code);
|
|
|
|
|
|
|
|
if (trans)
|
|
|
|
code = trans->to;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iso_layout > 0 || (iso_layout < 0 && (asc->quirks & APPLE_ISO_TILDE_QUIRK) &&
|
|
|
|
hid->country == HID_COUNTRY_INTERNATIONAL_ISO)) {
|
|
|
|
trans = apple_find_translation(apple_iso_keyboard, code);
|
|
|
|
|
|
|
|
if (trans)
|
|
|
|
code = trans->to;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (swap_opt_cmd) {
|
2023-05-22 18:40:12 +00:00
|
|
|
if (swap_opt_cmd == 2)
|
|
|
|
trans = apple_find_translation(swapped_option_cmd_left_keys, code);
|
|
|
|
else
|
|
|
|
trans = apple_find_translation(swapped_option_cmd_keys, code);
|
HID: apple: fix key translations where multiple quirks attempt to translate the same key
The hid-apple driver does not support chaining translations or
dependencies on other translations. This creates two problems:
1 - In Non-English keyboards of Macs, KEY_102ND and KEY_GRAVE are
swapped and the APPLE_ISO_TILDE_QUIRK is used to work around this
problem. The quirk is not set for the Macs where these bugs happen yet
(see the 2nd patch for that), but this can be forced by setting the
iso_layout parameter. Unfortunately, this only partially works.
KEY_102ND gets translated to KEY_GRAVE, but KEY_GRAVE does not get
translated to KEY_102ND, so both of them end up functioning as
KEY_GRAVE. This is because the driver translates the keys as if Fn was
pressed and the original is sent if it is not pressed, without any
further translations happening on the key[#463]. KEY_GRAVE is present at
macbookpro_no_esc_fn_keys[#195], so this is what happens:
- KEY_GRAVE -> KEY_ESC (as if Fn is pressed)
- KEY_GRAVE is returned (Fn isn't pressed, so translation is discarded)
- KEY_GRAVE -> KEY_102ND (this part is not reached!)
...
2 - In case the touchbar does not work, the driver supports sending
Escape when Fn+KEY_GRAVE is pressed. As mentioned previously, KEY_102ND
is actually KEY_GRAVE and needs to be translated before this happens.
Normally, these are the steps that should happen:
- KEY_102ND -> KEY_GRAVE
- KEY_GRAVE -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
Though this is what happens instead, as dependencies on other
translations are not supported:
- KEY_102ND -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
This patch fixes both bugs by ordering the translations correctly and by
making the translations continue and not return immediately after
translating a key so that chained translations work and translations can
depend on other ones.
This patch also simplifies the implementation of the swap_fn_leftctrl
option a little bit, as it makes it simply use a normal translation
instead adding extra code to translate a key to KEY_FN[#381]. This change
wasn't put in another patch as the code that translates the Fn key needs
to be changed because of the changes in the patch, and those changes
would be discarded with the next patch anyway (the part that originally
translates KEY_FN to KEY_LEFTCTRL needs to be made an else-if branch of
the part that transltes KEY_LEFTCTRL to KEY_FN).
Note: Line numbers (#XYZ) are for drivers/hid/hid-apple.c at commit
20afcc462579 ("HID: apple: Add "GANSS" to the non-Apple list").
Note: These bugs are only present on Macs with a keyboard with no
dedicated escape key and a non-English layout.
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-09-24 09:53:05 +00:00
|
|
|
|
|
|
|
if (trans)
|
|
|
|
code = trans->to;
|
|
|
|
}
|
|
|
|
|
2022-11-04 11:55:35 +00:00
|
|
|
if (swap_ctrl_cmd) {
|
|
|
|
trans = apple_find_translation(swapped_ctrl_cmd_keys, code);
|
|
|
|
|
|
|
|
if (trans)
|
|
|
|
code = trans->to;
|
|
|
|
}
|
|
|
|
|
HID: apple: fix key translations where multiple quirks attempt to translate the same key
The hid-apple driver does not support chaining translations or
dependencies on other translations. This creates two problems:
1 - In Non-English keyboards of Macs, KEY_102ND and KEY_GRAVE are
swapped and the APPLE_ISO_TILDE_QUIRK is used to work around this
problem. The quirk is not set for the Macs where these bugs happen yet
(see the 2nd patch for that), but this can be forced by setting the
iso_layout parameter. Unfortunately, this only partially works.
KEY_102ND gets translated to KEY_GRAVE, but KEY_GRAVE does not get
translated to KEY_102ND, so both of them end up functioning as
KEY_GRAVE. This is because the driver translates the keys as if Fn was
pressed and the original is sent if it is not pressed, without any
further translations happening on the key[#463]. KEY_GRAVE is present at
macbookpro_no_esc_fn_keys[#195], so this is what happens:
- KEY_GRAVE -> KEY_ESC (as if Fn is pressed)
- KEY_GRAVE is returned (Fn isn't pressed, so translation is discarded)
- KEY_GRAVE -> KEY_102ND (this part is not reached!)
...
2 - In case the touchbar does not work, the driver supports sending
Escape when Fn+KEY_GRAVE is pressed. As mentioned previously, KEY_102ND
is actually KEY_GRAVE and needs to be translated before this happens.
Normally, these are the steps that should happen:
- KEY_102ND -> KEY_GRAVE
- KEY_GRAVE -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
Though this is what happens instead, as dependencies on other
translations are not supported:
- KEY_102ND -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
This patch fixes both bugs by ordering the translations correctly and by
making the translations continue and not return immediately after
translating a key so that chained translations work and translations can
depend on other ones.
This patch also simplifies the implementation of the swap_fn_leftctrl
option a little bit, as it makes it simply use a normal translation
instead adding extra code to translate a key to KEY_FN[#381]. This change
wasn't put in another patch as the code that translates the Fn key needs
to be changed because of the changes in the patch, and those changes
would be discarded with the next patch anyway (the part that originally
translates KEY_FN to KEY_LEFTCTRL needs to be made an else-if branch of
the part that transltes KEY_LEFTCTRL to KEY_FN).
Note: Line numbers (#XYZ) are for drivers/hid/hid-apple.c at commit
20afcc462579 ("HID: apple: Add "GANSS" to the non-Apple list").
Note: These bugs are only present on Macs with a keyboard with no
dedicated escape key and a non-English layout.
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-09-24 09:53:05 +00:00
|
|
|
if (code == KEY_FN)
|
|
|
|
asc->fn_on = !!value;
|
|
|
|
|
2022-05-05 19:12:21 +00:00
|
|
|
if (real_fnmode) {
|
2022-02-08 18:37:03 +00:00
|
|
|
if (hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI ||
|
|
|
|
hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO ||
|
|
|
|
hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS ||
|
|
|
|
hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI ||
|
|
|
|
hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO ||
|
|
|
|
hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS ||
|
|
|
|
hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI ||
|
|
|
|
hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO ||
|
|
|
|
hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS)
|
|
|
|
table = magic_keyboard_alu_fn_keys;
|
2022-02-08 18:37:04 +00:00
|
|
|
else if (hid->product == USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2015 ||
|
|
|
|
hid->product == USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2015)
|
|
|
|
table = magic_keyboard_2015_fn_keys;
|
2022-02-08 18:37:03 +00:00
|
|
|
else if (hid->product == USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021 ||
|
|
|
|
hid->product == USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021 ||
|
|
|
|
hid->product == USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021)
|
2021-11-08 12:50:38 +00:00
|
|
|
table = apple2021_fn_keys;
|
2022-02-03 12:23:02 +00:00
|
|
|
else if (hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132 ||
|
|
|
|
hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680 ||
|
|
|
|
hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213)
|
|
|
|
table = macbookpro_no_esc_fn_keys;
|
|
|
|
else if (hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K ||
|
|
|
|
hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223 ||
|
|
|
|
hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F)
|
|
|
|
table = macbookpro_dedicated_esc_fn_keys;
|
|
|
|
else if (hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K ||
|
|
|
|
hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K)
|
|
|
|
table = apple_fn_keys;
|
2021-11-08 12:50:38 +00:00
|
|
|
else if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI &&
|
2010-11-03 14:42:02 +00:00
|
|
|
hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS)
|
|
|
|
table = macbookair_fn_keys;
|
|
|
|
else if (hid->product < 0x21d || hid->product >= 0x300)
|
|
|
|
table = powerbook_fn_keys;
|
|
|
|
else
|
|
|
|
table = apple_fn_keys;
|
|
|
|
|
HID: apple: fix key translations where multiple quirks attempt to translate the same key
The hid-apple driver does not support chaining translations or
dependencies on other translations. This creates two problems:
1 - In Non-English keyboards of Macs, KEY_102ND and KEY_GRAVE are
swapped and the APPLE_ISO_TILDE_QUIRK is used to work around this
problem. The quirk is not set for the Macs where these bugs happen yet
(see the 2nd patch for that), but this can be forced by setting the
iso_layout parameter. Unfortunately, this only partially works.
KEY_102ND gets translated to KEY_GRAVE, but KEY_GRAVE does not get
translated to KEY_102ND, so both of them end up functioning as
KEY_GRAVE. This is because the driver translates the keys as if Fn was
pressed and the original is sent if it is not pressed, without any
further translations happening on the key[#463]. KEY_GRAVE is present at
macbookpro_no_esc_fn_keys[#195], so this is what happens:
- KEY_GRAVE -> KEY_ESC (as if Fn is pressed)
- KEY_GRAVE is returned (Fn isn't pressed, so translation is discarded)
- KEY_GRAVE -> KEY_102ND (this part is not reached!)
...
2 - In case the touchbar does not work, the driver supports sending
Escape when Fn+KEY_GRAVE is pressed. As mentioned previously, KEY_102ND
is actually KEY_GRAVE and needs to be translated before this happens.
Normally, these are the steps that should happen:
- KEY_102ND -> KEY_GRAVE
- KEY_GRAVE -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
Though this is what happens instead, as dependencies on other
translations are not supported:
- KEY_102ND -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
This patch fixes both bugs by ordering the translations correctly and by
making the translations continue and not return immediately after
translating a key so that chained translations work and translations can
depend on other ones.
This patch also simplifies the implementation of the swap_fn_leftctrl
option a little bit, as it makes it simply use a normal translation
instead adding extra code to translate a key to KEY_FN[#381]. This change
wasn't put in another patch as the code that translates the Fn key needs
to be changed because of the changes in the patch, and those changes
would be discarded with the next patch anyway (the part that originally
translates KEY_FN to KEY_LEFTCTRL needs to be made an else-if branch of
the part that transltes KEY_LEFTCTRL to KEY_FN).
Note: Line numbers (#XYZ) are for drivers/hid/hid-apple.c at commit
20afcc462579 ("HID: apple: Add "GANSS" to the non-Apple list").
Note: These bugs are only present on Macs with a keyboard with no
dedicated escape key and a non-English layout.
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-09-24 09:53:05 +00:00
|
|
|
trans = apple_find_translation(table, code);
|
2010-11-03 14:36:18 +00:00
|
|
|
|
2008-06-18 21:36:49 +00:00
|
|
|
if (trans) {
|
HID: apple: fix key translations where multiple quirks attempt to translate the same key
The hid-apple driver does not support chaining translations or
dependencies on other translations. This creates two problems:
1 - In Non-English keyboards of Macs, KEY_102ND and KEY_GRAVE are
swapped and the APPLE_ISO_TILDE_QUIRK is used to work around this
problem. The quirk is not set for the Macs where these bugs happen yet
(see the 2nd patch for that), but this can be forced by setting the
iso_layout parameter. Unfortunately, this only partially works.
KEY_102ND gets translated to KEY_GRAVE, but KEY_GRAVE does not get
translated to KEY_102ND, so both of them end up functioning as
KEY_GRAVE. This is because the driver translates the keys as if Fn was
pressed and the original is sent if it is not pressed, without any
further translations happening on the key[#463]. KEY_GRAVE is present at
macbookpro_no_esc_fn_keys[#195], so this is what happens:
- KEY_GRAVE -> KEY_ESC (as if Fn is pressed)
- KEY_GRAVE is returned (Fn isn't pressed, so translation is discarded)
- KEY_GRAVE -> KEY_102ND (this part is not reached!)
...
2 - In case the touchbar does not work, the driver supports sending
Escape when Fn+KEY_GRAVE is pressed. As mentioned previously, KEY_102ND
is actually KEY_GRAVE and needs to be translated before this happens.
Normally, these are the steps that should happen:
- KEY_102ND -> KEY_GRAVE
- KEY_GRAVE -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
Though this is what happens instead, as dependencies on other
translations are not supported:
- KEY_102ND -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
This patch fixes both bugs by ordering the translations correctly and by
making the translations continue and not return immediately after
translating a key so that chained translations work and translations can
depend on other ones.
This patch also simplifies the implementation of the swap_fn_leftctrl
option a little bit, as it makes it simply use a normal translation
instead adding extra code to translate a key to KEY_FN[#381]. This change
wasn't put in another patch as the code that translates the Fn key needs
to be changed because of the changes in the patch, and those changes
would be discarded with the next patch anyway (the part that originally
translates KEY_FN to KEY_LEFTCTRL needs to be made an else-if branch of
the part that transltes KEY_LEFTCTRL to KEY_FN).
Note: Line numbers (#XYZ) are for drivers/hid/hid-apple.c at commit
20afcc462579 ("HID: apple: Add "GANSS" to the non-Apple list").
Note: These bugs are only present on Macs with a keyboard with no
dedicated escape key and a non-English layout.
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-09-24 09:53:05 +00:00
|
|
|
bool from_is_set = test_bit(trans->from, input->key);
|
|
|
|
bool to_is_set = test_bit(trans->to, input->key);
|
|
|
|
|
|
|
|
if (from_is_set)
|
2019-09-03 14:46:32 +00:00
|
|
|
code = trans->from;
|
HID: apple: fix key translations where multiple quirks attempt to translate the same key
The hid-apple driver does not support chaining translations or
dependencies on other translations. This creates two problems:
1 - In Non-English keyboards of Macs, KEY_102ND and KEY_GRAVE are
swapped and the APPLE_ISO_TILDE_QUIRK is used to work around this
problem. The quirk is not set for the Macs where these bugs happen yet
(see the 2nd patch for that), but this can be forced by setting the
iso_layout parameter. Unfortunately, this only partially works.
KEY_102ND gets translated to KEY_GRAVE, but KEY_GRAVE does not get
translated to KEY_102ND, so both of them end up functioning as
KEY_GRAVE. This is because the driver translates the keys as if Fn was
pressed and the original is sent if it is not pressed, without any
further translations happening on the key[#463]. KEY_GRAVE is present at
macbookpro_no_esc_fn_keys[#195], so this is what happens:
- KEY_GRAVE -> KEY_ESC (as if Fn is pressed)
- KEY_GRAVE is returned (Fn isn't pressed, so translation is discarded)
- KEY_GRAVE -> KEY_102ND (this part is not reached!)
...
2 - In case the touchbar does not work, the driver supports sending
Escape when Fn+KEY_GRAVE is pressed. As mentioned previously, KEY_102ND
is actually KEY_GRAVE and needs to be translated before this happens.
Normally, these are the steps that should happen:
- KEY_102ND -> KEY_GRAVE
- KEY_GRAVE -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
Though this is what happens instead, as dependencies on other
translations are not supported:
- KEY_102ND -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
This patch fixes both bugs by ordering the translations correctly and by
making the translations continue and not return immediately after
translating a key so that chained translations work and translations can
depend on other ones.
This patch also simplifies the implementation of the swap_fn_leftctrl
option a little bit, as it makes it simply use a normal translation
instead adding extra code to translate a key to KEY_FN[#381]. This change
wasn't put in another patch as the code that translates the Fn key needs
to be changed because of the changes in the patch, and those changes
would be discarded with the next patch anyway (the part that originally
translates KEY_FN to KEY_LEFTCTRL needs to be made an else-if branch of
the part that transltes KEY_LEFTCTRL to KEY_FN).
Note: Line numbers (#XYZ) are for drivers/hid/hid-apple.c at commit
20afcc462579 ("HID: apple: Add "GANSS" to the non-Apple list").
Note: These bugs are only present on Macs with a keyboard with no
dedicated escape key and a non-English layout.
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-09-24 09:53:05 +00:00
|
|
|
else if (to_is_set)
|
2019-09-03 14:46:32 +00:00
|
|
|
code = trans->to;
|
|
|
|
|
HID: apple: fix key translations where multiple quirks attempt to translate the same key
The hid-apple driver does not support chaining translations or
dependencies on other translations. This creates two problems:
1 - In Non-English keyboards of Macs, KEY_102ND and KEY_GRAVE are
swapped and the APPLE_ISO_TILDE_QUIRK is used to work around this
problem. The quirk is not set for the Macs where these bugs happen yet
(see the 2nd patch for that), but this can be forced by setting the
iso_layout parameter. Unfortunately, this only partially works.
KEY_102ND gets translated to KEY_GRAVE, but KEY_GRAVE does not get
translated to KEY_102ND, so both of them end up functioning as
KEY_GRAVE. This is because the driver translates the keys as if Fn was
pressed and the original is sent if it is not pressed, without any
further translations happening on the key[#463]. KEY_GRAVE is present at
macbookpro_no_esc_fn_keys[#195], so this is what happens:
- KEY_GRAVE -> KEY_ESC (as if Fn is pressed)
- KEY_GRAVE is returned (Fn isn't pressed, so translation is discarded)
- KEY_GRAVE -> KEY_102ND (this part is not reached!)
...
2 - In case the touchbar does not work, the driver supports sending
Escape when Fn+KEY_GRAVE is pressed. As mentioned previously, KEY_102ND
is actually KEY_GRAVE and needs to be translated before this happens.
Normally, these are the steps that should happen:
- KEY_102ND -> KEY_GRAVE
- KEY_GRAVE -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
Though this is what happens instead, as dependencies on other
translations are not supported:
- KEY_102ND -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
This patch fixes both bugs by ordering the translations correctly and by
making the translations continue and not return immediately after
translating a key so that chained translations work and translations can
depend on other ones.
This patch also simplifies the implementation of the swap_fn_leftctrl
option a little bit, as it makes it simply use a normal translation
instead adding extra code to translate a key to KEY_FN[#381]. This change
wasn't put in another patch as the code that translates the Fn key needs
to be changed because of the changes in the patch, and those changes
would be discarded with the next patch anyway (the part that originally
translates KEY_FN to KEY_LEFTCTRL needs to be made an else-if branch of
the part that transltes KEY_LEFTCTRL to KEY_FN).
Note: Line numbers (#XYZ) are for drivers/hid/hid-apple.c at commit
20afcc462579 ("HID: apple: Add "GANSS" to the non-Apple list").
Note: These bugs are only present on Macs with a keyboard with no
dedicated escape key and a non-English layout.
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-09-24 09:53:05 +00:00
|
|
|
if (!(from_is_set || to_is_set)) {
|
2019-09-03 14:46:32 +00:00
|
|
|
if (trans->flags & APPLE_FLAG_FKEY) {
|
2022-05-05 19:12:21 +00:00
|
|
|
switch (real_fnmode) {
|
2019-09-03 14:46:32 +00:00
|
|
|
case 1:
|
|
|
|
do_translate = !asc->fn_on;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
do_translate = asc->fn_on;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* should never happen */
|
|
|
|
do_translate = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
do_translate = asc->fn_on;
|
|
|
|
}
|
|
|
|
|
HID: apple: fix key translations where multiple quirks attempt to translate the same key
The hid-apple driver does not support chaining translations or
dependencies on other translations. This creates two problems:
1 - In Non-English keyboards of Macs, KEY_102ND and KEY_GRAVE are
swapped and the APPLE_ISO_TILDE_QUIRK is used to work around this
problem. The quirk is not set for the Macs where these bugs happen yet
(see the 2nd patch for that), but this can be forced by setting the
iso_layout parameter. Unfortunately, this only partially works.
KEY_102ND gets translated to KEY_GRAVE, but KEY_GRAVE does not get
translated to KEY_102ND, so both of them end up functioning as
KEY_GRAVE. This is because the driver translates the keys as if Fn was
pressed and the original is sent if it is not pressed, without any
further translations happening on the key[#463]. KEY_GRAVE is present at
macbookpro_no_esc_fn_keys[#195], so this is what happens:
- KEY_GRAVE -> KEY_ESC (as if Fn is pressed)
- KEY_GRAVE is returned (Fn isn't pressed, so translation is discarded)
- KEY_GRAVE -> KEY_102ND (this part is not reached!)
...
2 - In case the touchbar does not work, the driver supports sending
Escape when Fn+KEY_GRAVE is pressed. As mentioned previously, KEY_102ND
is actually KEY_GRAVE and needs to be translated before this happens.
Normally, these are the steps that should happen:
- KEY_102ND -> KEY_GRAVE
- KEY_GRAVE -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
Though this is what happens instead, as dependencies on other
translations are not supported:
- KEY_102ND -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
This patch fixes both bugs by ordering the translations correctly and by
making the translations continue and not return immediately after
translating a key so that chained translations work and translations can
depend on other ones.
This patch also simplifies the implementation of the swap_fn_leftctrl
option a little bit, as it makes it simply use a normal translation
instead adding extra code to translate a key to KEY_FN[#381]. This change
wasn't put in another patch as the code that translates the Fn key needs
to be changed because of the changes in the patch, and those changes
would be discarded with the next patch anyway (the part that originally
translates KEY_FN to KEY_LEFTCTRL needs to be made an else-if branch of
the part that transltes KEY_LEFTCTRL to KEY_FN).
Note: Line numbers (#XYZ) are for drivers/hid/hid-apple.c at commit
20afcc462579 ("HID: apple: Add "GANSS" to the non-Apple list").
Note: These bugs are only present on Macs with a keyboard with no
dedicated escape key and a non-English layout.
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-09-24 09:53:05 +00:00
|
|
|
if (do_translate)
|
|
|
|
code = trans->to;
|
2008-06-18 21:36:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (asc->quirks & APPLE_NUMLOCK_EMULATION &&
|
HID: apple: fix key translations where multiple quirks attempt to translate the same key
The hid-apple driver does not support chaining translations or
dependencies on other translations. This creates two problems:
1 - In Non-English keyboards of Macs, KEY_102ND and KEY_GRAVE are
swapped and the APPLE_ISO_TILDE_QUIRK is used to work around this
problem. The quirk is not set for the Macs where these bugs happen yet
(see the 2nd patch for that), but this can be forced by setting the
iso_layout parameter. Unfortunately, this only partially works.
KEY_102ND gets translated to KEY_GRAVE, but KEY_GRAVE does not get
translated to KEY_102ND, so both of them end up functioning as
KEY_GRAVE. This is because the driver translates the keys as if Fn was
pressed and the original is sent if it is not pressed, without any
further translations happening on the key[#463]. KEY_GRAVE is present at
macbookpro_no_esc_fn_keys[#195], so this is what happens:
- KEY_GRAVE -> KEY_ESC (as if Fn is pressed)
- KEY_GRAVE is returned (Fn isn't pressed, so translation is discarded)
- KEY_GRAVE -> KEY_102ND (this part is not reached!)
...
2 - In case the touchbar does not work, the driver supports sending
Escape when Fn+KEY_GRAVE is pressed. As mentioned previously, KEY_102ND
is actually KEY_GRAVE and needs to be translated before this happens.
Normally, these are the steps that should happen:
- KEY_102ND -> KEY_GRAVE
- KEY_GRAVE -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
Though this is what happens instead, as dependencies on other
translations are not supported:
- KEY_102ND -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
This patch fixes both bugs by ordering the translations correctly and by
making the translations continue and not return immediately after
translating a key so that chained translations work and translations can
depend on other ones.
This patch also simplifies the implementation of the swap_fn_leftctrl
option a little bit, as it makes it simply use a normal translation
instead adding extra code to translate a key to KEY_FN[#381]. This change
wasn't put in another patch as the code that translates the Fn key needs
to be changed because of the changes in the patch, and those changes
would be discarded with the next patch anyway (the part that originally
translates KEY_FN to KEY_LEFTCTRL needs to be made an else-if branch of
the part that transltes KEY_LEFTCTRL to KEY_FN).
Note: Line numbers (#XYZ) are for drivers/hid/hid-apple.c at commit
20afcc462579 ("HID: apple: Add "GANSS" to the non-Apple list").
Note: These bugs are only present on Macs with a keyboard with no
dedicated escape key and a non-English layout.
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-09-24 09:53:05 +00:00
|
|
|
(test_bit(code, asc->pressed_numlock) ||
|
2008-06-18 21:36:49 +00:00
|
|
|
test_bit(LED_NUML, input->led))) {
|
HID: apple: fix key translations where multiple quirks attempt to translate the same key
The hid-apple driver does not support chaining translations or
dependencies on other translations. This creates two problems:
1 - In Non-English keyboards of Macs, KEY_102ND and KEY_GRAVE are
swapped and the APPLE_ISO_TILDE_QUIRK is used to work around this
problem. The quirk is not set for the Macs where these bugs happen yet
(see the 2nd patch for that), but this can be forced by setting the
iso_layout parameter. Unfortunately, this only partially works.
KEY_102ND gets translated to KEY_GRAVE, but KEY_GRAVE does not get
translated to KEY_102ND, so both of them end up functioning as
KEY_GRAVE. This is because the driver translates the keys as if Fn was
pressed and the original is sent if it is not pressed, without any
further translations happening on the key[#463]. KEY_GRAVE is present at
macbookpro_no_esc_fn_keys[#195], so this is what happens:
- KEY_GRAVE -> KEY_ESC (as if Fn is pressed)
- KEY_GRAVE is returned (Fn isn't pressed, so translation is discarded)
- KEY_GRAVE -> KEY_102ND (this part is not reached!)
...
2 - In case the touchbar does not work, the driver supports sending
Escape when Fn+KEY_GRAVE is pressed. As mentioned previously, KEY_102ND
is actually KEY_GRAVE and needs to be translated before this happens.
Normally, these are the steps that should happen:
- KEY_102ND -> KEY_GRAVE
- KEY_GRAVE -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
Though this is what happens instead, as dependencies on other
translations are not supported:
- KEY_102ND -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
This patch fixes both bugs by ordering the translations correctly and by
making the translations continue and not return immediately after
translating a key so that chained translations work and translations can
depend on other ones.
This patch also simplifies the implementation of the swap_fn_leftctrl
option a little bit, as it makes it simply use a normal translation
instead adding extra code to translate a key to KEY_FN[#381]. This change
wasn't put in another patch as the code that translates the Fn key needs
to be changed because of the changes in the patch, and those changes
would be discarded with the next patch anyway (the part that originally
translates KEY_FN to KEY_LEFTCTRL needs to be made an else-if branch of
the part that transltes KEY_LEFTCTRL to KEY_FN).
Note: Line numbers (#XYZ) are for drivers/hid/hid-apple.c at commit
20afcc462579 ("HID: apple: Add "GANSS" to the non-Apple list").
Note: These bugs are only present on Macs with a keyboard with no
dedicated escape key and a non-English layout.
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-09-24 09:53:05 +00:00
|
|
|
trans = apple_find_translation(powerbook_numlock_keys, code);
|
2008-06-18 21:36:49 +00:00
|
|
|
|
|
|
|
if (trans) {
|
|
|
|
if (value)
|
HID: apple: fix key translations where multiple quirks attempt to translate the same key
The hid-apple driver does not support chaining translations or
dependencies on other translations. This creates two problems:
1 - In Non-English keyboards of Macs, KEY_102ND and KEY_GRAVE are
swapped and the APPLE_ISO_TILDE_QUIRK is used to work around this
problem. The quirk is not set for the Macs where these bugs happen yet
(see the 2nd patch for that), but this can be forced by setting the
iso_layout parameter. Unfortunately, this only partially works.
KEY_102ND gets translated to KEY_GRAVE, but KEY_GRAVE does not get
translated to KEY_102ND, so both of them end up functioning as
KEY_GRAVE. This is because the driver translates the keys as if Fn was
pressed and the original is sent if it is not pressed, without any
further translations happening on the key[#463]. KEY_GRAVE is present at
macbookpro_no_esc_fn_keys[#195], so this is what happens:
- KEY_GRAVE -> KEY_ESC (as if Fn is pressed)
- KEY_GRAVE is returned (Fn isn't pressed, so translation is discarded)
- KEY_GRAVE -> KEY_102ND (this part is not reached!)
...
2 - In case the touchbar does not work, the driver supports sending
Escape when Fn+KEY_GRAVE is pressed. As mentioned previously, KEY_102ND
is actually KEY_GRAVE and needs to be translated before this happens.
Normally, these are the steps that should happen:
- KEY_102ND -> KEY_GRAVE
- KEY_GRAVE -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
Though this is what happens instead, as dependencies on other
translations are not supported:
- KEY_102ND -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
This patch fixes both bugs by ordering the translations correctly and by
making the translations continue and not return immediately after
translating a key so that chained translations work and translations can
depend on other ones.
This patch also simplifies the implementation of the swap_fn_leftctrl
option a little bit, as it makes it simply use a normal translation
instead adding extra code to translate a key to KEY_FN[#381]. This change
wasn't put in another patch as the code that translates the Fn key needs
to be changed because of the changes in the patch, and those changes
would be discarded with the next patch anyway (the part that originally
translates KEY_FN to KEY_LEFTCTRL needs to be made an else-if branch of
the part that transltes KEY_LEFTCTRL to KEY_FN).
Note: Line numbers (#XYZ) are for drivers/hid/hid-apple.c at commit
20afcc462579 ("HID: apple: Add "GANSS" to the non-Apple list").
Note: These bugs are only present on Macs with a keyboard with no
dedicated escape key and a non-English layout.
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-09-24 09:53:05 +00:00
|
|
|
set_bit(code, asc->pressed_numlock);
|
2008-06-18 21:36:49 +00:00
|
|
|
else
|
HID: apple: fix key translations where multiple quirks attempt to translate the same key
The hid-apple driver does not support chaining translations or
dependencies on other translations. This creates two problems:
1 - In Non-English keyboards of Macs, KEY_102ND and KEY_GRAVE are
swapped and the APPLE_ISO_TILDE_QUIRK is used to work around this
problem. The quirk is not set for the Macs where these bugs happen yet
(see the 2nd patch for that), but this can be forced by setting the
iso_layout parameter. Unfortunately, this only partially works.
KEY_102ND gets translated to KEY_GRAVE, but KEY_GRAVE does not get
translated to KEY_102ND, so both of them end up functioning as
KEY_GRAVE. This is because the driver translates the keys as if Fn was
pressed and the original is sent if it is not pressed, without any
further translations happening on the key[#463]. KEY_GRAVE is present at
macbookpro_no_esc_fn_keys[#195], so this is what happens:
- KEY_GRAVE -> KEY_ESC (as if Fn is pressed)
- KEY_GRAVE is returned (Fn isn't pressed, so translation is discarded)
- KEY_GRAVE -> KEY_102ND (this part is not reached!)
...
2 - In case the touchbar does not work, the driver supports sending
Escape when Fn+KEY_GRAVE is pressed. As mentioned previously, KEY_102ND
is actually KEY_GRAVE and needs to be translated before this happens.
Normally, these are the steps that should happen:
- KEY_102ND -> KEY_GRAVE
- KEY_GRAVE -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
Though this is what happens instead, as dependencies on other
translations are not supported:
- KEY_102ND -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
This patch fixes both bugs by ordering the translations correctly and by
making the translations continue and not return immediately after
translating a key so that chained translations work and translations can
depend on other ones.
This patch also simplifies the implementation of the swap_fn_leftctrl
option a little bit, as it makes it simply use a normal translation
instead adding extra code to translate a key to KEY_FN[#381]. This change
wasn't put in another patch as the code that translates the Fn key needs
to be changed because of the changes in the patch, and those changes
would be discarded with the next patch anyway (the part that originally
translates KEY_FN to KEY_LEFTCTRL needs to be made an else-if branch of
the part that transltes KEY_LEFTCTRL to KEY_FN).
Note: Line numbers (#XYZ) are for drivers/hid/hid-apple.c at commit
20afcc462579 ("HID: apple: Add "GANSS" to the non-Apple list").
Note: These bugs are only present on Macs with a keyboard with no
dedicated escape key and a non-English layout.
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-09-24 09:53:05 +00:00
|
|
|
clear_bit(code, asc->pressed_numlock);
|
2008-06-18 21:36:49 +00:00
|
|
|
|
HID: apple: fix key translations where multiple quirks attempt to translate the same key
The hid-apple driver does not support chaining translations or
dependencies on other translations. This creates two problems:
1 - In Non-English keyboards of Macs, KEY_102ND and KEY_GRAVE are
swapped and the APPLE_ISO_TILDE_QUIRK is used to work around this
problem. The quirk is not set for the Macs where these bugs happen yet
(see the 2nd patch for that), but this can be forced by setting the
iso_layout parameter. Unfortunately, this only partially works.
KEY_102ND gets translated to KEY_GRAVE, but KEY_GRAVE does not get
translated to KEY_102ND, so both of them end up functioning as
KEY_GRAVE. This is because the driver translates the keys as if Fn was
pressed and the original is sent if it is not pressed, without any
further translations happening on the key[#463]. KEY_GRAVE is present at
macbookpro_no_esc_fn_keys[#195], so this is what happens:
- KEY_GRAVE -> KEY_ESC (as if Fn is pressed)
- KEY_GRAVE is returned (Fn isn't pressed, so translation is discarded)
- KEY_GRAVE -> KEY_102ND (this part is not reached!)
...
2 - In case the touchbar does not work, the driver supports sending
Escape when Fn+KEY_GRAVE is pressed. As mentioned previously, KEY_102ND
is actually KEY_GRAVE and needs to be translated before this happens.
Normally, these are the steps that should happen:
- KEY_102ND -> KEY_GRAVE
- KEY_GRAVE -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
Though this is what happens instead, as dependencies on other
translations are not supported:
- KEY_102ND -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
This patch fixes both bugs by ordering the translations correctly and by
making the translations continue and not return immediately after
translating a key so that chained translations work and translations can
depend on other ones.
This patch also simplifies the implementation of the swap_fn_leftctrl
option a little bit, as it makes it simply use a normal translation
instead adding extra code to translate a key to KEY_FN[#381]. This change
wasn't put in another patch as the code that translates the Fn key needs
to be changed because of the changes in the patch, and those changes
would be discarded with the next patch anyway (the part that originally
translates KEY_FN to KEY_LEFTCTRL needs to be made an else-if branch of
the part that transltes KEY_LEFTCTRL to KEY_FN).
Note: Line numbers (#XYZ) are for drivers/hid/hid-apple.c at commit
20afcc462579 ("HID: apple: Add "GANSS" to the non-Apple list").
Note: These bugs are only present on Macs with a keyboard with no
dedicated escape key and a non-English layout.
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-09-24 09:53:05 +00:00
|
|
|
code = trans->to;
|
2008-06-18 21:36:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
HID: apple: fix key translations where multiple quirks attempt to translate the same key
The hid-apple driver does not support chaining translations or
dependencies on other translations. This creates two problems:
1 - In Non-English keyboards of Macs, KEY_102ND and KEY_GRAVE are
swapped and the APPLE_ISO_TILDE_QUIRK is used to work around this
problem. The quirk is not set for the Macs where these bugs happen yet
(see the 2nd patch for that), but this can be forced by setting the
iso_layout parameter. Unfortunately, this only partially works.
KEY_102ND gets translated to KEY_GRAVE, but KEY_GRAVE does not get
translated to KEY_102ND, so both of them end up functioning as
KEY_GRAVE. This is because the driver translates the keys as if Fn was
pressed and the original is sent if it is not pressed, without any
further translations happening on the key[#463]. KEY_GRAVE is present at
macbookpro_no_esc_fn_keys[#195], so this is what happens:
- KEY_GRAVE -> KEY_ESC (as if Fn is pressed)
- KEY_GRAVE is returned (Fn isn't pressed, so translation is discarded)
- KEY_GRAVE -> KEY_102ND (this part is not reached!)
...
2 - In case the touchbar does not work, the driver supports sending
Escape when Fn+KEY_GRAVE is pressed. As mentioned previously, KEY_102ND
is actually KEY_GRAVE and needs to be translated before this happens.
Normally, these are the steps that should happen:
- KEY_102ND -> KEY_GRAVE
- KEY_GRAVE -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
Though this is what happens instead, as dependencies on other
translations are not supported:
- KEY_102ND -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
This patch fixes both bugs by ordering the translations correctly and by
making the translations continue and not return immediately after
translating a key so that chained translations work and translations can
depend on other ones.
This patch also simplifies the implementation of the swap_fn_leftctrl
option a little bit, as it makes it simply use a normal translation
instead adding extra code to translate a key to KEY_FN[#381]. This change
wasn't put in another patch as the code that translates the Fn key needs
to be changed because of the changes in the patch, and those changes
would be discarded with the next patch anyway (the part that originally
translates KEY_FN to KEY_LEFTCTRL needs to be made an else-if branch of
the part that transltes KEY_LEFTCTRL to KEY_FN).
Note: Line numbers (#XYZ) are for drivers/hid/hid-apple.c at commit
20afcc462579 ("HID: apple: Add "GANSS" to the non-Apple list").
Note: These bugs are only present on Macs with a keyboard with no
dedicated escape key and a non-English layout.
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-09-24 09:53:05 +00:00
|
|
|
if (usage->code != code) {
|
|
|
|
input_event_with_scancode(input, usage->type, code, usage->hid, value);
|
2008-06-18 21:36:49 +00:00
|
|
|
|
HID: apple: fix key translations where multiple quirks attempt to translate the same key
The hid-apple driver does not support chaining translations or
dependencies on other translations. This creates two problems:
1 - In Non-English keyboards of Macs, KEY_102ND and KEY_GRAVE are
swapped and the APPLE_ISO_TILDE_QUIRK is used to work around this
problem. The quirk is not set for the Macs where these bugs happen yet
(see the 2nd patch for that), but this can be forced by setting the
iso_layout parameter. Unfortunately, this only partially works.
KEY_102ND gets translated to KEY_GRAVE, but KEY_GRAVE does not get
translated to KEY_102ND, so both of them end up functioning as
KEY_GRAVE. This is because the driver translates the keys as if Fn was
pressed and the original is sent if it is not pressed, without any
further translations happening on the key[#463]. KEY_GRAVE is present at
macbookpro_no_esc_fn_keys[#195], so this is what happens:
- KEY_GRAVE -> KEY_ESC (as if Fn is pressed)
- KEY_GRAVE is returned (Fn isn't pressed, so translation is discarded)
- KEY_GRAVE -> KEY_102ND (this part is not reached!)
...
2 - In case the touchbar does not work, the driver supports sending
Escape when Fn+KEY_GRAVE is pressed. As mentioned previously, KEY_102ND
is actually KEY_GRAVE and needs to be translated before this happens.
Normally, these are the steps that should happen:
- KEY_102ND -> KEY_GRAVE
- KEY_GRAVE -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
Though this is what happens instead, as dependencies on other
translations are not supported:
- KEY_102ND -> KEY_ESC (Fn is pressed)
- KEY_ESC is returned
This patch fixes both bugs by ordering the translations correctly and by
making the translations continue and not return immediately after
translating a key so that chained translations work and translations can
depend on other ones.
This patch also simplifies the implementation of the swap_fn_leftctrl
option a little bit, as it makes it simply use a normal translation
instead adding extra code to translate a key to KEY_FN[#381]. This change
wasn't put in another patch as the code that translates the Fn key needs
to be changed because of the changes in the patch, and those changes
would be discarded with the next patch anyway (the part that originally
translates KEY_FN to KEY_LEFTCTRL needs to be made an else-if branch of
the part that transltes KEY_LEFTCTRL to KEY_FN).
Note: Line numbers (#XYZ) are for drivers/hid/hid-apple.c at commit
20afcc462579 ("HID: apple: Add "GANSS" to the non-Apple list").
Note: These bugs are only present on Macs with a keyboard with no
dedicated escape key and a non-English layout.
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-09-24 09:53:05 +00:00
|
|
|
return 1;
|
2020-05-15 06:14:00 +00:00
|
|
|
}
|
|
|
|
|
2008-06-18 21:36:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int apple_event(struct hid_device *hdev, struct hid_field *field,
|
|
|
|
struct hid_usage *usage, __s32 value)
|
|
|
|
{
|
|
|
|
struct apple_sc *asc = hid_get_drvdata(hdev);
|
|
|
|
|
|
|
|
if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput ||
|
|
|
|
!usage->type)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if ((asc->quirks & APPLE_INVERT_HWHEEL) &&
|
|
|
|
usage->code == REL_HWHEEL) {
|
2021-07-22 01:25:44 +00:00
|
|
|
input_event_with_scancode(field->hidinput->input, usage->type,
|
|
|
|
usage->code, usage->hid, -value);
|
2008-06-18 21:36:49 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((asc->quirks & APPLE_HAS_FN) &&
|
|
|
|
hidinput_apple_event(hdev, field->hidinput->input,
|
|
|
|
usage, value))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-11-18 07:29:55 +00:00
|
|
|
static int apple_fetch_battery(struct hid_device *hdev)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_HID_BATTERY_STRENGTH
|
|
|
|
struct apple_sc *asc = hid_get_drvdata(hdev);
|
|
|
|
struct hid_report_enum *report_enum;
|
|
|
|
struct hid_report *report;
|
|
|
|
|
|
|
|
if (!(asc->quirks & APPLE_RDESC_BATTERY) || !hdev->battery)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
report_enum = &hdev->report_enum[hdev->battery_report_type];
|
|
|
|
report = report_enum->report_id_hash[hdev->battery_report_id];
|
|
|
|
|
|
|
|
if (!report || report->maxfield < 1)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (hdev->battery_capacity == hdev->battery_max)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
hid_hw_request(hdev, report, HID_REQ_GET_REPORT);
|
|
|
|
return 0;
|
|
|
|
#else
|
|
|
|
return -1;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void apple_battery_timer_tick(struct timer_list *t)
|
|
|
|
{
|
|
|
|
struct apple_sc *asc = from_timer(asc, t, battery_timer);
|
|
|
|
struct hid_device *hdev = asc->hdev;
|
|
|
|
|
|
|
|
if (apple_fetch_battery(hdev) == 0) {
|
|
|
|
mod_timer(&asc->battery_timer,
|
|
|
|
jiffies + msecs_to_jiffies(APPLE_BATTERY_TIMEOUT_MS));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-18 21:36:49 +00:00
|
|
|
/*
|
|
|
|
* MacBook JIS keyboard has wrong logical maximum
|
HID: apple: Fix logical maximum and usage maximum of Magic Keyboard JIS
Apple Magic Keyboard(JIS)'s Logical Maximum and Usage Maximum are wrong.
Below is a report descriptor.
0x05, 0x01, /* Usage Page (Desktop), */
0x09, 0x06, /* Usage (Keyboard), */
0xA1, 0x01, /* Collection (Application), */
0x85, 0x01, /* Report ID (1), */
0x05, 0x07, /* Usage Page (Keyboard), */
0x15, 0x00, /* Logical Minimum (0), */
0x25, 0x01, /* Logical Maximum (1), */
0x19, 0xE0, /* Usage Minimum (KB Leftcontrol), */
0x29, 0xE7, /* Usage Maximum (KB Right GUI), */
0x75, 0x01, /* Report Size (1), */
0x95, 0x08, /* Report Count (8), */
0x81, 0x02, /* Input (Variable), */
0x95, 0x05, /* Report Count (5), */
0x75, 0x01, /* Report Size (1), */
0x05, 0x08, /* Usage Page (LED), */
0x19, 0x01, /* Usage Minimum (01h), */
0x29, 0x05, /* Usage Maximum (05h), */
0x91, 0x02, /* Output (Variable), */
0x95, 0x01, /* Report Count (1), */
0x75, 0x03, /* Report Size (3), */
0x91, 0x03, /* Output (Constant, Variable), */
0x95, 0x08, /* Report Count (8), */
0x75, 0x01, /* Report Size (1), */
0x15, 0x00, /* Logical Minimum (0), */
0x25, 0x01, /* Logical Maximum (1), */
here is a report descriptor which is parsed one in kernel.
see sys/kernel/debug/hid/<dev>/rdesc
05 01 09 06 a1 01 85 01 05 07
15 00 25 01 19 e0 29 e7 75 01
95 08 81 02 95 05 75 01 05 08
19 01 29 05 91 02 95 01 75 03
91 03 95 08 75 01 15 00 25 01
06 00 ff 09 03 81 03 95 06 75
08 15 00 25 [65] 05 07 19 00 29
[65] 81 00 95 01 75 01 15 00 25
01 05 0c 09 b8 81 02 95 01 75
01 06 01 ff 09 03 81 02 95 01
75 06 81 03 06 02 ff 09 55 85
55 15 00 26 ff 00 75 08 95 40
b1 a2 c0 06 00 ff 09 14 a1 01
85 90 05 84 75 01 95 03 15 00
25 01 09 61 05 85 09 44 09 46
81 02 95 05 81 01 75 08 95 01
15 00 26 ff 00 09 65 81 02 c0
00
Position 64(Logical Maximum) and 70(Usage Maximum) are 101.
Both should be 0xE7 to support JIS specific keys(ろ, Eisu, Kana, |) support.
position 117 is also 101 but not related(it is Usage 65h).
There are no difference of product id between JIS and ANSI.
They are same 0x0267.
Signed-off-by: Mizuho Mori <morimolymoly@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2021-07-29 11:03:25 +00:00
|
|
|
* Magic Keyboard JIS has wrong logical maximum
|
2008-06-18 21:36:49 +00:00
|
|
|
*/
|
2010-08-06 19:03:06 +00:00
|
|
|
static __u8 *apple_report_fixup(struct hid_device *hdev, __u8 *rdesc,
|
|
|
|
unsigned int *rsize)
|
2008-06-18 21:36:49 +00:00
|
|
|
{
|
|
|
|
struct apple_sc *asc = hid_get_drvdata(hdev);
|
|
|
|
|
HID: apple: Fix logical maximum and usage maximum of Magic Keyboard JIS
Apple Magic Keyboard(JIS)'s Logical Maximum and Usage Maximum are wrong.
Below is a report descriptor.
0x05, 0x01, /* Usage Page (Desktop), */
0x09, 0x06, /* Usage (Keyboard), */
0xA1, 0x01, /* Collection (Application), */
0x85, 0x01, /* Report ID (1), */
0x05, 0x07, /* Usage Page (Keyboard), */
0x15, 0x00, /* Logical Minimum (0), */
0x25, 0x01, /* Logical Maximum (1), */
0x19, 0xE0, /* Usage Minimum (KB Leftcontrol), */
0x29, 0xE7, /* Usage Maximum (KB Right GUI), */
0x75, 0x01, /* Report Size (1), */
0x95, 0x08, /* Report Count (8), */
0x81, 0x02, /* Input (Variable), */
0x95, 0x05, /* Report Count (5), */
0x75, 0x01, /* Report Size (1), */
0x05, 0x08, /* Usage Page (LED), */
0x19, 0x01, /* Usage Minimum (01h), */
0x29, 0x05, /* Usage Maximum (05h), */
0x91, 0x02, /* Output (Variable), */
0x95, 0x01, /* Report Count (1), */
0x75, 0x03, /* Report Size (3), */
0x91, 0x03, /* Output (Constant, Variable), */
0x95, 0x08, /* Report Count (8), */
0x75, 0x01, /* Report Size (1), */
0x15, 0x00, /* Logical Minimum (0), */
0x25, 0x01, /* Logical Maximum (1), */
here is a report descriptor which is parsed one in kernel.
see sys/kernel/debug/hid/<dev>/rdesc
05 01 09 06 a1 01 85 01 05 07
15 00 25 01 19 e0 29 e7 75 01
95 08 81 02 95 05 75 01 05 08
19 01 29 05 91 02 95 01 75 03
91 03 95 08 75 01 15 00 25 01
06 00 ff 09 03 81 03 95 06 75
08 15 00 25 [65] 05 07 19 00 29
[65] 81 00 95 01 75 01 15 00 25
01 05 0c 09 b8 81 02 95 01 75
01 06 01 ff 09 03 81 02 95 01
75 06 81 03 06 02 ff 09 55 85
55 15 00 26 ff 00 75 08 95 40
b1 a2 c0 06 00 ff 09 14 a1 01
85 90 05 84 75 01 95 03 15 00
25 01 09 61 05 85 09 44 09 46
81 02 95 05 81 01 75 08 95 01
15 00 26 ff 00 09 65 81 02 c0
00
Position 64(Logical Maximum) and 70(Usage Maximum) are 101.
Both should be 0xE7 to support JIS specific keys(ろ, Eisu, Kana, |) support.
position 117 is also 101 but not related(it is Usage 65h).
There are no difference of product id between JIS and ANSI.
They are same 0x0267.
Signed-off-by: Mizuho Mori <morimolymoly@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2021-07-29 11:03:25 +00:00
|
|
|
if(*rsize >=71 && rdesc[70] == 0x65 && rdesc[64] == 0x65) {
|
|
|
|
hid_info(hdev,
|
|
|
|
"fixing up Magic Keyboard JIS report descriptor\n");
|
|
|
|
rdesc[64] = rdesc[70] = 0xe7;
|
|
|
|
}
|
|
|
|
|
2010-08-06 19:03:06 +00:00
|
|
|
if ((asc->quirks & APPLE_RDESC_JIS) && *rsize >= 60 &&
|
2008-06-18 21:36:49 +00:00
|
|
|
rdesc[53] == 0x65 && rdesc[59] == 0x65) {
|
2010-12-10 03:29:03 +00:00
|
|
|
hid_info(hdev,
|
|
|
|
"fixing up MacBook JIS keyboard report descriptor\n");
|
2008-06-18 21:36:49 +00:00
|
|
|
rdesc[53] = rdesc[59] = 0xe7;
|
|
|
|
}
|
2021-11-18 07:29:55 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Change the usage from:
|
|
|
|
* 0x06, 0x00, 0xff, // Usage Page (Vendor Defined Page 1) 0
|
|
|
|
* 0x09, 0x0b, // Usage (Vendor Usage 0x0b) 3
|
|
|
|
* To:
|
|
|
|
* 0x05, 0x01, // Usage Page (Generic Desktop) 0
|
|
|
|
* 0x09, 0x06, // Usage (Keyboard) 2
|
|
|
|
*/
|
|
|
|
if ((asc->quirks & APPLE_RDESC_BATTERY) && *rsize == 83 &&
|
|
|
|
rdesc[46] == 0x84 && rdesc[58] == 0x85) {
|
|
|
|
hid_info(hdev,
|
|
|
|
"fixing up Magic Keyboard battery report descriptor\n");
|
|
|
|
*rsize = *rsize - 1;
|
|
|
|
rdesc = kmemdup(rdesc + 1, *rsize, GFP_KERNEL);
|
|
|
|
if (!rdesc)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
rdesc[0] = 0x05;
|
|
|
|
rdesc[1] = 0x01;
|
|
|
|
rdesc[2] = 0x09;
|
|
|
|
rdesc[3] = 0x06;
|
|
|
|
}
|
|
|
|
|
2010-08-06 19:03:06 +00:00
|
|
|
return rdesc;
|
2008-06-18 21:36:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void apple_setup_input(struct input_dev *input)
|
|
|
|
{
|
|
|
|
set_bit(KEY_NUMLOCK, input->keybit);
|
|
|
|
|
|
|
|
/* Enable all needed keys */
|
2022-02-08 18:37:02 +00:00
|
|
|
apple_setup_key_translation(input, apple_fn_keys);
|
|
|
|
apple_setup_key_translation(input, powerbook_fn_keys);
|
|
|
|
apple_setup_key_translation(input, powerbook_numlock_keys);
|
|
|
|
apple_setup_key_translation(input, apple_iso_keyboard);
|
2022-02-08 18:37:03 +00:00
|
|
|
apple_setup_key_translation(input, magic_keyboard_alu_fn_keys);
|
2022-02-08 18:37:04 +00:00
|
|
|
apple_setup_key_translation(input, magic_keyboard_2015_fn_keys);
|
2022-02-08 18:37:02 +00:00
|
|
|
apple_setup_key_translation(input, apple2021_fn_keys);
|
2022-02-03 12:23:02 +00:00
|
|
|
apple_setup_key_translation(input, macbookpro_no_esc_fn_keys);
|
|
|
|
apple_setup_key_translation(input, macbookpro_dedicated_esc_fn_keys);
|
2008-06-18 21:36:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi,
|
|
|
|
struct hid_field *field, struct hid_usage *usage,
|
|
|
|
unsigned long **bit, int *max)
|
|
|
|
{
|
2020-06-20 12:32:29 +00:00
|
|
|
struct apple_sc *asc = hid_get_drvdata(hdev);
|
|
|
|
|
2018-08-27 20:02:15 +00:00
|
|
|
if (usage->hid == (HID_UP_CUSTOM | 0x0003) ||
|
2020-01-29 06:26:31 +00:00
|
|
|
usage->hid == (HID_UP_MSVENDOR | 0x0003) ||
|
|
|
|
usage->hid == (HID_UP_HPVENDOR2 | 0x0003)) {
|
2008-06-18 21:36:49 +00:00
|
|
|
/* The fn key on Apple USB keyboards */
|
|
|
|
set_bit(EV_REP, hi->input->evbit);
|
|
|
|
hid_map_usage_clear(hi, usage, bit, max, EV_KEY, KEY_FN);
|
2020-06-20 12:32:29 +00:00
|
|
|
asc->fn_found = true;
|
2008-06-18 21:36:49 +00:00
|
|
|
apple_setup_input(hi->input);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we want the hid layer to go through standard path (set and ignore) */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int apple_input_mapped(struct hid_device *hdev, struct hid_input *hi,
|
|
|
|
struct hid_field *field, struct hid_usage *usage,
|
|
|
|
unsigned long **bit, int *max)
|
|
|
|
{
|
|
|
|
struct apple_sc *asc = hid_get_drvdata(hdev);
|
|
|
|
|
|
|
|
if (asc->quirks & APPLE_MIGHTYMOUSE) {
|
|
|
|
if (usage->hid == HID_GD_Z)
|
|
|
|
hid_map_usage(hi, usage, bit, max, EV_REL, REL_HWHEEL);
|
|
|
|
else if (usage->code == BTN_1)
|
|
|
|
hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_2);
|
|
|
|
else if (usage->code == BTN_2)
|
|
|
|
hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-06-20 12:32:29 +00:00
|
|
|
static int apple_input_configured(struct hid_device *hdev,
|
|
|
|
struct hid_input *hidinput)
|
|
|
|
{
|
|
|
|
struct apple_sc *asc = hid_get_drvdata(hdev);
|
|
|
|
|
|
|
|
if ((asc->quirks & APPLE_HAS_FN) && !asc->fn_found) {
|
|
|
|
hid_info(hdev, "Fn key not found (Apple Wireless Keyboard clone?), disabling Fn key handling\n");
|
2021-11-18 07:29:53 +00:00
|
|
|
asc->quirks &= ~APPLE_HAS_FN;
|
2020-06-20 12:32:29 +00:00
|
|
|
}
|
|
|
|
|
2022-06-02 08:12:19 +00:00
|
|
|
if (apple_is_non_apple_keyboard(hdev)) {
|
|
|
|
hid_info(hdev, "Non-apple keyboard detected; function keys will default to fnmode=2 behavior\n");
|
|
|
|
asc->quirks |= APPLE_IS_NON_APPLE;
|
2022-05-05 19:12:21 +00:00
|
|
|
}
|
|
|
|
|
2020-06-20 12:32:29 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-02-03 12:21:13 +00:00
|
|
|
static bool apple_backlight_check_support(struct hid_device *hdev)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
unsigned int hid;
|
|
|
|
struct hid_report *report;
|
|
|
|
|
|
|
|
list_for_each_entry(report, &hdev->report_enum[HID_INPUT_REPORT].report_list, list) {
|
|
|
|
for (i = 0; i < report->maxfield; i++) {
|
|
|
|
hid = report->field[i]->usage->hid;
|
|
|
|
if ((hid & HID_USAGE_PAGE) == HID_UP_MSVENDOR && (hid & HID_USAGE) == 0xf)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int apple_backlight_set(struct hid_device *hdev, u16 value, u16 rate)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
struct apple_backlight_set_report *rep;
|
|
|
|
|
|
|
|
rep = kmalloc(sizeof(*rep), GFP_KERNEL);
|
|
|
|
if (rep == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
rep->report_id = 0xB0;
|
|
|
|
rep->version = 1;
|
|
|
|
rep->backlight = value;
|
|
|
|
rep->rate = rate;
|
|
|
|
|
|
|
|
ret = hid_hw_raw_request(hdev, 0xB0u, (u8 *) rep, sizeof(*rep),
|
|
|
|
HID_OUTPUT_REPORT, HID_REQ_SET_REPORT);
|
|
|
|
|
|
|
|
kfree(rep);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int apple_backlight_led_set(struct led_classdev *led_cdev,
|
|
|
|
enum led_brightness brightness)
|
|
|
|
{
|
|
|
|
struct apple_sc_backlight *backlight = container_of(led_cdev,
|
|
|
|
struct apple_sc_backlight, cdev);
|
|
|
|
|
|
|
|
return apple_backlight_set(backlight->hdev, brightness, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int apple_backlight_init(struct hid_device *hdev)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct apple_sc *asc = hid_get_drvdata(hdev);
|
|
|
|
struct apple_backlight_config_report *rep;
|
|
|
|
|
|
|
|
if (!apple_backlight_check_support(hdev))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
rep = kmalloc(0x200, GFP_KERNEL);
|
|
|
|
if (rep == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
ret = hid_hw_raw_request(hdev, 0xBFu, (u8 *) rep, sizeof(*rep),
|
|
|
|
HID_FEATURE_REPORT, HID_REQ_GET_REPORT);
|
|
|
|
if (ret < 0) {
|
|
|
|
hid_err(hdev, "backlight request failed: %d\n", ret);
|
|
|
|
goto cleanup_and_exit;
|
|
|
|
}
|
|
|
|
if (ret < 8 || rep->version != 1) {
|
|
|
|
hid_err(hdev, "backlight config struct: bad version %i\n", rep->version);
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto cleanup_and_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
hid_dbg(hdev, "backlight config: off=%u, on_min=%u, on_max=%u\n",
|
|
|
|
rep->backlight_off, rep->backlight_on_min, rep->backlight_on_max);
|
|
|
|
|
|
|
|
asc->backlight = devm_kzalloc(&hdev->dev, sizeof(*asc->backlight), GFP_KERNEL);
|
|
|
|
if (!asc->backlight) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto cleanup_and_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
asc->backlight->hdev = hdev;
|
|
|
|
asc->backlight->cdev.name = "apple::kbd_backlight";
|
|
|
|
asc->backlight->cdev.max_brightness = rep->backlight_on_max;
|
|
|
|
asc->backlight->cdev.brightness_set_blocking = apple_backlight_led_set;
|
|
|
|
|
|
|
|
ret = apple_backlight_set(hdev, 0, 0);
|
|
|
|
if (ret < 0) {
|
|
|
|
hid_err(hdev, "backlight set request failed: %d\n", ret);
|
|
|
|
goto cleanup_and_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = devm_led_classdev_register(&hdev->dev, &asc->backlight->cdev);
|
|
|
|
|
|
|
|
cleanup_and_exit:
|
|
|
|
kfree(rep);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-06-18 21:36:49 +00:00
|
|
|
static int apple_probe(struct hid_device *hdev,
|
|
|
|
const struct hid_device_id *id)
|
|
|
|
{
|
|
|
|
unsigned long quirks = id->driver_data;
|
|
|
|
struct apple_sc *asc;
|
|
|
|
int ret;
|
|
|
|
|
2013-07-24 17:38:04 +00:00
|
|
|
asc = devm_kzalloc(&hdev->dev, sizeof(*asc), GFP_KERNEL);
|
2008-06-18 21:36:49 +00:00
|
|
|
if (asc == NULL) {
|
2010-12-10 03:29:03 +00:00
|
|
|
hid_err(hdev, "can't alloc apple descriptor\n");
|
2008-06-18 21:36:49 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2021-11-18 07:29:55 +00:00
|
|
|
asc->hdev = hdev;
|
2008-06-18 21:36:49 +00:00
|
|
|
asc->quirks = quirks;
|
|
|
|
|
|
|
|
hid_set_drvdata(hdev, asc);
|
|
|
|
|
|
|
|
ret = hid_parse(hdev);
|
|
|
|
if (ret) {
|
2010-12-10 03:29:03 +00:00
|
|
|
hid_err(hdev, "parse failed\n");
|
2013-07-24 17:38:04 +00:00
|
|
|
return ret;
|
2008-06-18 21:36:49 +00:00
|
|
|
}
|
|
|
|
|
2021-09-16 19:38:40 +00:00
|
|
|
ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
|
2008-06-18 21:36:49 +00:00
|
|
|
if (ret) {
|
2010-12-10 03:29:03 +00:00
|
|
|
hid_err(hdev, "hw start failed\n");
|
2013-07-24 17:38:04 +00:00
|
|
|
return ret;
|
2008-06-18 21:36:49 +00:00
|
|
|
}
|
|
|
|
|
2021-11-18 07:29:55 +00:00
|
|
|
timer_setup(&asc->battery_timer, apple_battery_timer_tick, 0);
|
|
|
|
mod_timer(&asc->battery_timer,
|
|
|
|
jiffies + msecs_to_jiffies(APPLE_BATTERY_TIMEOUT_MS));
|
|
|
|
apple_fetch_battery(hdev);
|
|
|
|
|
2022-02-03 12:21:13 +00:00
|
|
|
if (quirks & APPLE_BACKLIGHT_CTL)
|
|
|
|
apple_backlight_init(hdev);
|
|
|
|
|
2008-06-18 21:36:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-11-18 07:29:55 +00:00
|
|
|
static void apple_remove(struct hid_device *hdev)
|
|
|
|
{
|
|
|
|
struct apple_sc *asc = hid_get_drvdata(hdev);
|
|
|
|
|
|
|
|
del_timer_sync(&asc->battery_timer);
|
|
|
|
|
|
|
|
hid_hw_stop(hdev);
|
|
|
|
}
|
|
|
|
|
2008-06-18 21:36:49 +00:00
|
|
|
static const struct hid_device_id apple_devices[] = {
|
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE),
|
|
|
|
.driver_data = APPLE_MIGHTYMOUSE | APPLE_INVERT_HWHEEL },
|
|
|
|
|
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI),
|
2008-10-22 12:47:18 +00:00
|
|
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
2008-06-18 21:36:49 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO),
|
2008-10-22 12:47:18 +00:00
|
|
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
2008-06-18 21:36:49 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI),
|
2008-10-22 12:47:18 +00:00
|
|
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
2008-06-18 21:36:49 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO),
|
2017-06-02 15:28:39 +00:00
|
|
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
2008-06-18 21:36:49 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS),
|
2008-10-22 12:47:18 +00:00
|
|
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
2008-06-18 21:36:49 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI),
|
2008-10-22 12:47:18 +00:00
|
|
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
2008-06-18 21:36:49 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO),
|
2023-04-04 02:48:29 +00:00
|
|
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
|
|
|
|
APPLE_ISO_TILDE_QUIRK },
|
2008-06-18 21:36:49 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS),
|
|
|
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
|
2008-10-22 12:47:18 +00:00
|
|
|
APPLE_RDESC_JIS },
|
2008-06-18 21:36:49 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI),
|
2008-10-22 12:47:18 +00:00
|
|
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
2008-06-18 21:36:49 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO),
|
2023-02-27 03:06:13 +00:00
|
|
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
|
|
|
|
APPLE_ISO_TILDE_QUIRK },
|
2008-06-18 21:36:49 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS),
|
|
|
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
|
2008-10-22 12:47:18 +00:00
|
|
|
APPLE_RDESC_JIS },
|
2009-03-05 09:18:01 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI),
|
|
|
|
.driver_data = APPLE_HAS_FN },
|
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO),
|
2017-06-02 15:28:39 +00:00
|
|
|
.driver_data = APPLE_HAS_FN },
|
2009-03-05 09:18:01 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS),
|
|
|
|
.driver_data = APPLE_HAS_FN },
|
2008-06-18 21:36:49 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI),
|
|
|
|
.driver_data = APPLE_HAS_FN },
|
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO),
|
2017-06-02 15:28:39 +00:00
|
|
|
.driver_data = APPLE_HAS_FN },
|
2008-06-18 21:36:49 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS),
|
|
|
|
.driver_data = APPLE_HAS_FN },
|
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI),
|
2008-10-22 12:47:18 +00:00
|
|
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
2008-06-18 21:36:49 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO),
|
2023-02-27 03:06:13 +00:00
|
|
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
|
|
|
|
APPLE_ISO_TILDE_QUIRK },
|
2008-06-18 21:36:49 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS),
|
|
|
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
|
2008-10-22 12:47:18 +00:00
|
|
|
APPLE_RDESC_JIS },
|
2011-07-31 11:40:49 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI),
|
|
|
|
.driver_data = APPLE_HAS_FN },
|
2021-07-17 17:04:31 +00:00
|
|
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI),
|
|
|
|
.driver_data = APPLE_HAS_FN },
|
2011-07-31 11:40:49 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO),
|
2017-06-02 15:28:39 +00:00
|
|
|
.driver_data = APPLE_HAS_FN },
|
2020-07-20 20:53:46 +00:00
|
|
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO),
|
|
|
|
.driver_data = APPLE_HAS_FN },
|
2011-07-31 11:40:49 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_JIS),
|
|
|
|
.driver_data = APPLE_HAS_FN },
|
2008-11-26 14:33:45 +00:00
|
|
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI),
|
2008-06-18 21:36:49 +00:00
|
|
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
2008-11-26 14:33:45 +00:00
|
|
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO),
|
2021-10-19 07:12:32 +00:00
|
|
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
|
|
|
|
APPLE_ISO_TILDE_QUIRK },
|
2011-10-28 16:50:39 +00:00
|
|
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO),
|
2021-10-19 07:12:32 +00:00
|
|
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
|
|
|
|
APPLE_ISO_TILDE_QUIRK },
|
2012-04-23 16:02:18 +00:00
|
|
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
|
|
|
|
USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI),
|
|
|
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
2014-02-06 09:40:34 +00:00
|
|
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
|
|
|
|
USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS),
|
|
|
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
2008-11-26 14:33:45 +00:00
|
|
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS),
|
2008-06-18 21:36:49 +00:00
|
|
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
2021-10-08 07:37:00 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2015),
|
2021-11-18 07:29:55 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK | APPLE_RDESC_BATTERY },
|
2021-10-08 07:37:00 +00:00
|
|
|
{ HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2015),
|
2021-10-19 07:12:32 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
2021-10-08 07:37:00 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2015),
|
2021-11-18 07:29:55 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK | APPLE_RDESC_BATTERY },
|
2021-10-08 07:37:00 +00:00
|
|
|
{ HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2015),
|
2021-10-19 07:12:32 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
2008-06-18 21:36:49 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI),
|
2008-10-22 12:47:18 +00:00
|
|
|
.driver_data = APPLE_HAS_FN },
|
2008-06-18 21:36:49 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO),
|
2023-02-27 03:06:13 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
2008-06-18 21:36:49 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS),
|
2008-10-22 12:47:18 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
|
2008-06-18 21:36:49 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI),
|
2008-10-22 12:47:18 +00:00
|
|
|
.driver_data = APPLE_HAS_FN },
|
2008-06-18 21:36:49 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO),
|
2023-02-27 03:06:13 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
2008-06-18 21:36:49 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS),
|
2008-10-22 12:47:18 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
|
2008-11-04 19:03:45 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI),
|
|
|
|
.driver_data = APPLE_HAS_FN },
|
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO),
|
2023-02-27 03:06:13 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
2008-11-04 19:03:45 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS),
|
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
|
2010-11-03 14:36:18 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI),
|
|
|
|
.driver_data = APPLE_HAS_FN },
|
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO),
|
2023-02-27 03:06:13 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
2010-11-03 14:36:18 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS),
|
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
|
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI),
|
|
|
|
.driver_data = APPLE_HAS_FN },
|
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO),
|
2023-02-27 03:06:13 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
2010-11-03 14:36:18 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS),
|
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
|
2011-03-13 04:27:22 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI),
|
|
|
|
.driver_data = APPLE_HAS_FN },
|
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO),
|
2022-01-16 23:01:58 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
2011-03-13 04:27:22 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS),
|
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
|
2011-08-05 19:05:22 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI),
|
|
|
|
.driver_data = APPLE_HAS_FN },
|
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO),
|
2022-01-16 23:01:58 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
2011-08-05 19:05:22 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS),
|
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
|
2011-10-01 06:54:53 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI),
|
|
|
|
.driver_data = APPLE_HAS_FN },
|
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO),
|
2022-01-16 23:01:58 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
2011-10-01 06:54:53 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS),
|
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
|
2011-10-22 19:39:06 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI),
|
|
|
|
.driver_data = APPLE_HAS_FN },
|
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO),
|
2022-01-16 23:01:58 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
2011-10-22 19:39:06 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS),
|
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
|
2012-07-10 16:43:33 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI),
|
|
|
|
.driver_data = APPLE_HAS_FN },
|
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ISO),
|
2022-01-16 23:01:58 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
2012-07-10 16:43:33 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_JIS),
|
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
|
2012-10-30 18:11:48 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI),
|
|
|
|
.driver_data = APPLE_HAS_FN },
|
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO),
|
2022-01-16 23:01:58 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
2012-10-30 18:11:48 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS),
|
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
|
2013-07-01 18:46:27 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI),
|
|
|
|
.driver_data = APPLE_HAS_FN },
|
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ISO),
|
2022-01-16 23:01:58 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
2013-07-01 18:46:27 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_JIS),
|
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
|
2015-07-24 21:45:05 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI),
|
|
|
|
.driver_data = APPLE_HAS_FN },
|
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ISO),
|
2022-01-16 23:01:58 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
2015-07-24 21:45:05 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS),
|
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
|
2022-02-03 12:22:09 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K),
|
2022-09-24 09:53:06 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL | APPLE_ISO_TILDE_QUIRK },
|
2022-02-03 12:22:09 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132),
|
2022-09-24 09:53:06 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL | APPLE_ISO_TILDE_QUIRK },
|
2022-02-03 12:22:09 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680),
|
2022-09-24 09:53:06 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL | APPLE_ISO_TILDE_QUIRK },
|
2022-02-03 12:22:09 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213),
|
2022-09-24 09:53:06 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL | APPLE_ISO_TILDE_QUIRK },
|
2022-02-03 12:22:09 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K),
|
2022-09-24 09:53:06 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
2022-02-03 12:22:09 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223),
|
2022-09-24 09:53:06 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
2022-02-03 12:22:09 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K),
|
2022-09-24 09:53:06 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
2022-02-03 12:22:09 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F),
|
2022-09-24 09:53:06 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
2010-01-06 13:49:57 +00:00
|
|
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
|
|
|
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
|
|
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
|
2021-10-19 07:12:32 +00:00
|
|
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
|
|
|
|
APPLE_ISO_TILDE_QUIRK },
|
2010-01-06 13:49:57 +00:00
|
|
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS),
|
|
|
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
2008-06-18 21:36:49 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY),
|
2008-10-22 12:47:18 +00:00
|
|
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
2008-06-18 21:36:49 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY),
|
2008-10-22 12:47:18 +00:00
|
|
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
2021-10-08 07:37:01 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021),
|
2022-02-08 18:50:09 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK | APPLE_RDESC_BATTERY },
|
2021-10-08 07:37:01 +00:00
|
|
|
{ HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021),
|
2021-10-19 07:12:32 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
2021-12-02 06:16:50 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021),
|
2022-02-08 18:55:30 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK | APPLE_RDESC_BATTERY },
|
2021-12-02 06:16:50 +00:00
|
|
|
{ HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021),
|
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
2021-12-02 06:16:51 +00:00
|
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021),
|
2022-02-08 18:55:30 +00:00
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK | APPLE_RDESC_BATTERY },
|
2021-12-02 06:16:51 +00:00
|
|
|
{ HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021),
|
|
|
|
.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
|
2008-06-18 21:36:49 +00:00
|
|
|
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(hid, apple_devices);
|
|
|
|
|
|
|
|
static struct hid_driver apple_driver = {
|
|
|
|
.name = "apple",
|
|
|
|
.id_table = apple_devices,
|
|
|
|
.report_fixup = apple_report_fixup,
|
|
|
|
.probe = apple_probe,
|
2021-11-18 07:29:55 +00:00
|
|
|
.remove = apple_remove,
|
2008-06-18 21:36:49 +00:00
|
|
|
.event = apple_event,
|
|
|
|
.input_mapping = apple_input_mapping,
|
|
|
|
.input_mapped = apple_input_mapped,
|
2020-06-20 12:32:29 +00:00
|
|
|
.input_configured = apple_input_configured,
|
2008-06-18 21:36:49 +00:00
|
|
|
};
|
2012-12-17 22:28:26 +00:00
|
|
|
module_hid_driver(apple_driver);
|
2008-06-18 21:36:49 +00:00
|
|
|
|
|
|
|
MODULE_LICENSE("GPL");
|