-
Notifications
You must be signed in to change notification settings - Fork 3
/
hid-simagic.c
66 lines (56 loc) · 1.43 KB
/
hid-simagic.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* HID driver for Simagic Steering Wheels
*
* Copyright (c) 2023 Makarenko Oleg
*/
#include <linux/device.h>
#include <linux/hid.h>
#include <linux/module.h>
#include "hid-simagic.h"
static const struct hid_device_id simagic_devices[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_SIMAGIC, USB_DEVICE_ID_SIMAGIC_WHEEL) },
{ }
};
MODULE_DEVICE_TABLE(hid, simagic_devices);
static int simagic_probe(struct hid_device *hdev,
const struct hid_device_id *id)
{
int ret;
ret = hid_parse(hdev);
if (ret) {
hid_err(hdev, "parse failed\n");
goto err;
}
ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF);
if (ret) {
hid_err(hdev, "hw start failed\n");
goto err;
}
ret = hid_pidff_init_simagic(hdev);
if (ret) {
hid_warn(hdev, "Force feedback not supported\n");
goto err;
}
return 0;
err:
return ret;
}
static int simagic_input_configured(struct hid_device *hdev,
struct hid_input *hidinput)
{
struct input_dev *input = hidinput->input;
input_set_abs_params(input, ABS_X,
input->absinfo[ABS_X].minimum, input->absinfo[ABS_X].maximum, 0, 0);
return 0;
}
static struct hid_driver simagic_ff = {
.name = "simagic-ff",
.id_table = simagic_devices,
.probe = simagic_probe,
.input_configured = simagic_input_configured,
};
module_hid_driver(simagic_ff);
MODULE_AUTHOR("Oleg Makarenko <[email protected]>");
MODULE_DESCRIPTION("Simagic HID FF Driver");
MODULE_LICENSE("GPL");