Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.6] Track xpadneo as in-kernel driver #29

Draft
wants to merge 6 commits into
base: base-6.6
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions drivers/hid/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,14 @@ config HID_XINMO
standard. Currently only supports the Xin-Mo Dual Arcade. Say Y here
if you have a Xin-Mo Dual Arcade controller.

config HID_XPADNEO
tristate "XBOX ONE S and X controller over Bluetooth, including FF"
depends on HID
select INPUT_FF_MEMLESS
help
Support for Xbox One S and X controllers over BT, including
force-feedback.

config HID_ZEROPLUS
tristate "Zeroplus based game controller support"
help
Expand Down
5 changes: 5 additions & 0 deletions drivers/hid/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ obj-$(CONFIG_HID_UDRAW_PS3) += hid-udraw-ps3.o
obj-$(CONFIG_HID_LED) += hid-led.o
obj-$(CONFIG_HID_XIAOMI) += hid-xiaomi.o
obj-$(CONFIG_HID_XINMO) += hid-xinmo.o
hid-xpadneo-objs := xpadneo/consumer.o \
xpadneo/core.o \
xpadneo/keyboard.o \
xpadneo/legacy.o
obj-$(CONFIG_HID_XPADNEO) += hid-xpadneo.o
obj-$(CONFIG_HID_ZEROPLUS) += hid-zpff.o
obj-$(CONFIG_HID_ZYDACRON) += hid-zydacron.o
obj-$(CONFIG_HID_VIEWSONIC) += hid-viewsonic.o
Expand Down
2 changes: 2 additions & 0 deletions drivers/hid/hid-microsoft.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ static const struct hid_device_id ms_devices[] = {
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, 0x091B),
.driver_data = MS_SURFACE_DIAL },

#if !IS_ENABLED(CONFIG_HID_XPADNEO)
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_XBOX_CONTROLLER_MODEL_1708),
.driver_data = MS_QUIRK_FF },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_XBOX_CONTROLLER_MODEL_1708_BLE),
Expand All @@ -459,6 +460,7 @@ static const struct hid_device_id ms_devices[] = {
.driver_data = MS_QUIRK_FF },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_8BITDO_SN30_PRO_PLUS),
.driver_data = MS_QUIRK_FF },
#endif
{ }
};
MODULE_DEVICE_TABLE(hid, ms_devices);
Expand Down
8 changes: 8 additions & 0 deletions drivers/hid/hid-quirks.c
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,14 @@ static const struct hid_device_id hid_have_special_driver[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_XIN_MO_DUAL_ARCADE) },
{ HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_THT_2P_ARCADE) },
#endif
#if IS_ENABLED(CONFIG_HID_XPADNEO)
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, 0x02FD) },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, 0x02E0) },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, 0x0B05) },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, 0x0B13) },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, 0x0B20) },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, 0x0B22) },
#endif
#if IS_ENABLED(CONFIG_HID_ZEROPLUS)
{ HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) },
{ HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) },
Expand Down
32 changes: 32 additions & 0 deletions drivers/hid/xpadneo/consumer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* xpadneo consumer control driver
*
* Copyright (c) 2021 Kai Krakow <kai@kaishome.de>
*/

#include "xpadneo.h"

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

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

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

hid_info(hdev, "consumer control added\n");
}

return 0;
}
37 changes: 37 additions & 0 deletions drivers/hid/xpadneo/core.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* xpadneo driver core
*
* Copyright (c) 2021 Kai Krakow <kai@kaishome.de>
*/

#include "xpadneo.h"

extern int xpadneo_init_synthetic(struct xpadneo_devdata *xdata, char *suffix,
struct input_dev **devp)
{
struct hid_device *hdev = xdata->hdev;
struct input_dev *input_dev = devm_input_allocate_device(&hdev->dev);
size_t suffix_len, name_len;

if (!input_dev)
return -ENOMEM;

name_len = strlen(hdev->name);
suffix_len = strlen(suffix);
if ((name_len < suffix_len) || strcmp(xdata->hdev->name + name_len - suffix_len, suffix)) {
input_dev->name = kasprintf(GFP_KERNEL, "%s %s", hdev->name, suffix);
if (!input_dev->name)
return -ENOMEM;
}

dev_set_drvdata(&input_dev->dev, xdata);
input_dev->phys = hdev->phys;
input_dev->uniq = hdev->uniq;
input_dev->id.bustype = hdev->bus;
input_dev->id.vendor = hdev->vendor;
input_dev->id.product = hdev->product;
input_dev->id.version = hdev->version;

*devp = input_dev;
return 0;
}
35 changes: 35 additions & 0 deletions drivers/hid/xpadneo/keyboard.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* xpadneo keyboard driver
*
* Copyright (c) 2021 Kai Krakow <kai@kaishome.de>
*/

#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;
}

/* enable key events for keyboard */
input_set_capability(xdata->keyboard, EV_KEY, BTN_SHARE);

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;
}
Loading