Skip to content

Commit 3f643c2

Browse files
authored
linux/hidraw: Add support for BUS_VIRTUAL (#745)
This driver implements support of a virtual HID device on linux: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/platform/x86/tuxedo/nb04/wmi_ab.c?id=cfd84b3f419bf0aec60ecddc92c61b539c339ec9#n841 Signed-off-by: Werner Sembach <wse@tuxedocomputers.com>
1 parent d6b2a97 commit 3f643c2

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

hidapi/hidapi.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ extern "C" {
144144
Specifications:
145145
https://www.microsoft.com/download/details.aspx?id=103325 */
146146
HID_API_BUS_SPI = 0x04,
147+
148+
/** Virtual device
149+
E.g.: https://elixir.bootlin.com/linux/v4.0/source/include/uapi/linux/input.h#L955
150+
151+
Since version 0.16.0, @ref HID_API_VERSION >= HID_API_MAKE_VERSION(0, 16, 0)
152+
*/
153+
HID_API_BUS_VIRTUAL = 0x05,
147154
} hid_bus_type;
148155

149156
/** hidapi info structure */

linux/hid.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,7 @@ static struct hid_device_info * create_device_info_for_device(struct udev_device
683683
case BUS_I2C:
684684
case BUS_USB:
685685
case BUS_SPI:
686+
case BUS_VIRTUAL:
686687
break;
687688

688689
default:
@@ -779,6 +780,14 @@ static struct hid_device_info * create_device_info_for_device(struct udev_device
779780

780781
break;
781782

783+
case BUS_VIRTUAL:
784+
cur_dev->manufacturer_string = wcsdup(L"");
785+
cur_dev->product_string = utf8_to_wchar_t(product_name_utf8);
786+
787+
cur_dev->bus_type = HID_API_BUS_VIRTUAL;
788+
789+
break;
790+
782791
default:
783792
/* Unknown device type - this should never happen, as we
784793
* check for USB and Bluetooth devices above */

windows/hid.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,7 @@ static struct hid_device_info *hid_internal_get_device_info(const wchar_t *path,
804804
case HID_API_BUS_UNKNOWN:
805805
case HID_API_BUS_SPI:
806806
case HID_API_BUS_I2C:
807+
case HID_API_BUS_VIRTUAL:
807808
/* shut down -Wswitch */
808809
break;
809810
}

0 commit comments

Comments
 (0)