Skip to content

Commit 262c56b

Browse files
committed
xpadneo, keyboard: Add keyboard support
Signed-off-by: Kai Krakow <[email protected]>
1 parent 727a84f commit 262c56b

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

hid-xpadneo/src/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ hid-xpadneo-y += xpadneo.o
99
$(obj)/xpadneo.c: $(src)/hid-xpadneo.c
1010
cp $< $@
1111

12-
hid-xpadneo-y += xpadneo/core.o xpadneo/consumer.o
12+
hid-xpadneo-y += xpadneo/core.o xpadneo/consumer.o xpadneo/keyboard.o

hid-xpadneo/src/hid-xpadneo.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,10 @@ static int xpadneo_probe(struct hid_device *hdev, const struct hid_device_id *id
11651165
if (ret)
11661166
return ret;
11671167

1168+
ret = xpadneo_init_keyboard(xdata);
1169+
if (ret)
1170+
return ret;
1171+
11681172
ret = xpadneo_init_hw(hdev);
11691173
if (ret) {
11701174
hid_err(hdev, "hw init failed: %d\n", ret);

hid-xpadneo/src/xpadneo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ struct xpadneo_devdata {
184184
};
185185

186186
extern int xpadneo_init_consumer(struct xpadneo_devdata *);
187+
extern int xpadneo_init_keyboard(struct xpadneo_devdata *);
187188
extern int xpadneo_init_synthetic(struct xpadneo_devdata *, char *, struct input_dev **);
188189

189190
#endif

hid-xpadneo/src/xpadneo/keyboard.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* xpadneo keyboard driver
3+
*
4+
* Copyright (c) 2021 Kai Krakow <[email protected]>
5+
*/
6+
7+
#include "../xpadneo.h"
8+
9+
extern int xpadneo_init_keyboard(struct xpadneo_devdata *xdata)
10+
{
11+
struct hid_device *hdev = xdata->hdev;
12+
int ret, synth = 0;
13+
14+
if (!xdata->keyboard) {
15+
synth = 1;
16+
ret = xpadneo_init_synthetic(xdata, "Keyboard", &xdata->keyboard);
17+
if (ret || !xdata->keyboard)
18+
return ret;
19+
}
20+
21+
if (synth) {
22+
ret = input_register_device(xdata->keyboard);
23+
if (ret) {
24+
hid_err(hdev, "failed to register keyboard\n");
25+
return ret;
26+
}
27+
28+
hid_info(hdev, "keyboard added\n");
29+
}
30+
31+
return 0;
32+
}

0 commit comments

Comments
 (0)