Skip to content

Commit

Permalink
xpadneo, keyboard: Add keyboard support
Browse files Browse the repository at this point in the history
Signed-off-by: Kai Krakow <[email protected]>
  • Loading branch information
kakra committed May 30, 2022
1 parent 727a84f commit 262c56b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hid-xpadneo/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ hid-xpadneo-y += xpadneo.o
$(obj)/xpadneo.c: $(src)/hid-xpadneo.c
cp $< $@

hid-xpadneo-y += xpadneo/core.o xpadneo/consumer.o
hid-xpadneo-y += xpadneo/core.o xpadneo/consumer.o xpadneo/keyboard.o
4 changes: 4 additions & 0 deletions hid-xpadneo/src/hid-xpadneo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,10 @@ static int xpadneo_probe(struct hid_device *hdev, const struct hid_device_id *id
if (ret)
return ret;

ret = xpadneo_init_keyboard(xdata);
if (ret)
return ret;

ret = xpadneo_init_hw(hdev);
if (ret) {
hid_err(hdev, "hw init failed: %d\n", ret);
Expand Down
1 change: 1 addition & 0 deletions hid-xpadneo/src/xpadneo.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ struct xpadneo_devdata {
};

extern int xpadneo_init_consumer(struct xpadneo_devdata *);
extern int xpadneo_init_keyboard(struct xpadneo_devdata *);
extern int xpadneo_init_synthetic(struct xpadneo_devdata *, char *, struct input_dev **);

#endif
32 changes: 32 additions & 0 deletions hid-xpadneo/src/xpadneo/keyboard.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* xpadneo keyboard driver
*
* Copyright (c) 2021 Kai Krakow <[email protected]>
*/

#include "../xpadneo.h"

extern int xpadneo_init_keyboard(struct xpadneo_devdata *xdata)
{
struct hid_device *hdev = xdata->hdev;
int ret, synth = 0;

if (!xdata->keyboard) {
synth = 1;
ret = xpadneo_init_synthetic(xdata, "Keyboard", &xdata->keyboard);
if (ret || !xdata->keyboard)
return ret;
}

if (synth) {
ret = input_register_device(xdata->keyboard);
if (ret) {
hid_err(hdev, "failed to register keyboard\n");
return ret;
}

hid_info(hdev, "keyboard added\n");
}

return 0;
}

0 comments on commit 262c56b

Please sign in to comment.