// SPDX-License-Identifier: GPL-2.0-or-later
/*
* HID driver for VRC - 2 2 - axis Car controller
*
* Copyright ( C ) 2022 Marcus Folkesson < marcus . folkesson @ gmail . com >
*/
#include <linux/device.h>
#include <linux/hid.h>
#include <linux/module.h>
/*
* VID / PID are probably " borrowed " , so keep them locally and
* do not populate hid - ids . h with those .
*/
#define USB_VENDOR_ID_VRC2 (0 x07c0)
#define USB_DEVICE_ID_VRC2 (0 x1125)
static const __u8 vrc2_rdesc_fixed[] = {
0 x05, 0 x01, // Usage Page (Generic Desktop Ctrls)
0 x09, 0 x04, // Usage (Joystick)
0 xA1, 0 x01, // Collection (Application)
0 x09, 0 x01, // Usage (Pointer)
0 xA1, 0 x00, // Collection (Physical)
0 x09, 0 x30, // Usage (X)
0 x09, 0 x31, // Usage (Y)
0 x15, 0 x00, // Logical Minimum (0)
0 x26, 0 xFF, 0 x07, // Logical Maximum (2047)
0 x35, 0 x00, // Physical Minimum (0)
0 x46, 0 xFF, 0 x00, // Physical Maximum (255)
0 x75, 0 x10, // Report Size (16)
0 x95, 0 x02, // Report Count (2)
0 x81, 0 x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
0 xC0, // End Collection
0 x75, 0 x08, // Report Size (8)
0 x95, 0 x03, // Report Count (3)
0 x81, 0 x03, // Input (Cnst,Var,Abs)
0 xC0, // End Collection
};
static const __u8 *vrc2_report_fixup(struct hid_device *hdev, __u8 *rdesc,
unsigned int *rsize)
{
hid_info(hdev, "fixing up VRC-2 report descriptor\n" );
*rsize = sizeof (vrc2_rdesc_fixed);
return vrc2_rdesc_fixed;
}
static int vrc2_probe(struct hid_device *hdev, const struct hid_device_id *id)
{
int ret;
/*
* The device gives us 2 separate USB endpoints .
* One of those ( the one with report descriptor size of 23 ) is just bogus so ignore it
*/
if (hdev->dev_rsize == 23 )
return -ENODEV;
ret = hid_parse(hdev);
if (ret) {
hid_err(hdev, "parse failed\n" );
return ret;
}
ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
if (ret) {
hid_err(hdev, "hw start failed\n" );
return ret;
}
return 0 ;
}
static const struct hid_device_id vrc2_devices[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_VRC2, USB_DEVICE_ID_VRC2) },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(hid, vrc2_devices);
static struct hid_driver vrc2_driver = {
.name = "vrc2" ,
.id_table = vrc2_devices,
.report_fixup = vrc2_report_fixup,
.probe = vrc2_probe,
};
module_hid_driver(vrc2_driver);
MODULE_AUTHOR("Marcus Folkesson <marcus.folkesson@gmail.com>" );
MODULE_DESCRIPTION("HID driver for VRC-2 2-axis Car controller" );
MODULE_LICENSE("GPL" );
Messung V0.5 in Prozent C=75 H=100 G=88
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-09-29)
¤
*© Formatika GbR, Deutschland