Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
cf620bda
Commit
cf620bda
authored
May 24, 2022
by
Jiri Kosina
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'for-5.19/apple' into for-linus
- Support for Keychron keyboards (Bryan Cain)
parents
8959f007
fa33382c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
4 deletions
+18
-4
drivers/hid/hid-apple.c
drivers/hid/hid-apple.c
+18
-4
No files found.
drivers/hid/hid-apple.c
View file @
cf620bda
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#include <linux/module.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/slab.h>
#include <linux/timer.h>
#include <linux/timer.h>
#include <linux/string.h>
#include "hid-ids.h"
#include "hid-ids.h"
...
@@ -35,16 +36,17 @@
...
@@ -35,16 +36,17 @@
#define APPLE_NUMLOCK_EMULATION BIT(8)
#define APPLE_NUMLOCK_EMULATION BIT(8)
#define APPLE_RDESC_BATTERY BIT(9)
#define APPLE_RDESC_BATTERY BIT(9)
#define APPLE_BACKLIGHT_CTL BIT(10)
#define APPLE_BACKLIGHT_CTL BIT(10)
#define APPLE_IS_KEYCHRON BIT(11)
#define APPLE_FLAG_FKEY 0x01
#define APPLE_FLAG_FKEY 0x01
#define HID_COUNTRY_INTERNATIONAL_ISO 13
#define HID_COUNTRY_INTERNATIONAL_ISO 13
#define APPLE_BATTERY_TIMEOUT_MS 60000
#define APPLE_BATTERY_TIMEOUT_MS 60000
static
unsigned
int
fnmode
=
1
;
static
unsigned
int
fnmode
=
3
;
module_param
(
fnmode
,
uint
,
0644
);
module_param
(
fnmode
,
uint
,
0644
);
MODULE_PARM_DESC
(
fnmode
,
"Mode of fn key on Apple keyboards (0 = disabled, "
MODULE_PARM_DESC
(
fnmode
,
"Mode of fn key on Apple keyboards (0 = disabled, "
"
[1] = fkeyslast, 2 = fkeysfirst
)"
);
"
1 = fkeyslast, 2 = fkeysfirst, [3] = auto
)"
);
static
int
iso_layout
=
-
1
;
static
int
iso_layout
=
-
1
;
module_param
(
iso_layout
,
int
,
0644
);
module_param
(
iso_layout
,
int
,
0644
);
...
@@ -349,6 +351,7 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
...
@@ -349,6 +351,7 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
const
struct
apple_key_translation
*
trans
,
*
table
;
const
struct
apple_key_translation
*
trans
,
*
table
;
bool
do_translate
;
bool
do_translate
;
u16
code
=
0
;
u16
code
=
0
;
unsigned
int
real_fnmode
;
u16
fn_keycode
=
(
swap_fn_leftctrl
)
?
(
KEY_LEFTCTRL
)
:
(
KEY_FN
);
u16
fn_keycode
=
(
swap_fn_leftctrl
)
?
(
KEY_LEFTCTRL
)
:
(
KEY_FN
);
...
@@ -359,7 +362,13 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
...
@@ -359,7 +362,13 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
return
1
;
return
1
;
}
}
if
(
fnmode
)
{
if
(
fnmode
==
3
)
{
real_fnmode
=
(
asc
->
quirks
&
APPLE_IS_KEYCHRON
)
?
2
:
1
;
}
else
{
real_fnmode
=
fnmode
;
}
if
(
real_fnmode
)
{
if
(
hid
->
product
==
USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI
||
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_ISO
||
hid
->
product
==
USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS
||
hid
->
product
==
USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS
||
...
@@ -406,7 +415,7 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
...
@@ -406,7 +415,7 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
if
(
!
code
)
{
if
(
!
code
)
{
if
(
trans
->
flags
&
APPLE_FLAG_FKEY
)
{
if
(
trans
->
flags
&
APPLE_FLAG_FKEY
)
{
switch
(
fnmode
)
{
switch
(
real_
fnmode
)
{
case
1
:
case
1
:
do_translate
=
!
asc
->
fn_on
;
do_translate
=
!
asc
->
fn_on
;
break
;
break
;
...
@@ -660,6 +669,11 @@ static int apple_input_configured(struct hid_device *hdev,
...
@@ -660,6 +669,11 @@ static int apple_input_configured(struct hid_device *hdev,
asc
->
quirks
&=
~
APPLE_HAS_FN
;
asc
->
quirks
&=
~
APPLE_HAS_FN
;
}
}
if
(
strncmp
(
hdev
->
name
,
"Keychron"
,
8
)
==
0
)
{
hid_info
(
hdev
,
"Keychron keyboard detected; function keys will default to fnmode=2 behavior
\n
"
);
asc
->
quirks
|=
APPLE_IS_KEYCHRON
;
}
return
0
;
return
0
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment