Loading...
1/*
2 * HID driver for Xin-Mo devices, currently only the Dual Arcade controller.
3 * Fixes the negative axis event values (the devices sends -2) to match the
4 * logical axis minimum of the HID report descriptor (the report announces
5 * -1). It is needed because hid-input discards out of bounds values.
6 * (This module is based on "hid-saitek" and "hid-lg".)
7 *
8 * Copyright (c) 2013 Olivier Scherler
9 */
10
11/*
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the Free
14 * Software Foundation; either version 2 of the License, or (at your option)
15 * any later version.
16 */
17
18#include <linux/device.h>
19#include <linux/hid.h>
20#include <linux/module.h>
21#include <linux/kernel.h>
22
23#include "hid-ids.h"
24
25/*
26 * Fix negative events that are out of bounds.
27 */
28static int xinmo_event(struct hid_device *hdev, struct hid_field *field,
29 struct hid_usage *usage, __s32 value)
30{
31 switch (usage->code) {
32 case ABS_X:
33 case ABS_Y:
34 case ABS_Z:
35 case ABS_RX:
36 if (value < -1) {
37 input_event(field->hidinput->input, usage->type,
38 usage->code, -1);
39 return 1;
40 }
41 break;
42 }
43
44 return 0;
45}
46
47static const struct hid_device_id xinmo_devices[] = {
48 { HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_XIN_MO_DUAL_ARCADE) },
49 { }
50};
51
52MODULE_DEVICE_TABLE(hid, xinmo_devices);
53
54static struct hid_driver xinmo_driver = {
55 .name = "xinmo",
56 .id_table = xinmo_devices,
57 .event = xinmo_event
58};
59
60module_hid_driver(xinmo_driver);
61MODULE_LICENSE("GPL");
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * HID driver for Xin-Mo devices, currently only the Dual Arcade controller.
4 * Fixes the negative axis event values (the devices sends -2) to match the
5 * logical axis minimum of the HID report descriptor (the report announces
6 * -1). It is needed because hid-input discards out of bounds values.
7 * (This module is based on "hid-saitek" and "hid-lg".)
8 *
9 * Copyright (c) 2013 Olivier Scherler
10 */
11
12/*
13 */
14
15#include <linux/device.h>
16#include <linux/hid.h>
17#include <linux/module.h>
18#include <linux/kernel.h>
19
20#include "hid-ids.h"
21
22/*
23 * Fix negative events that are out of bounds.
24 */
25static int xinmo_event(struct hid_device *hdev, struct hid_field *field,
26 struct hid_usage *usage, __s32 value)
27{
28 switch (usage->code) {
29 case ABS_X:
30 case ABS_Y:
31 case ABS_Z:
32 case ABS_RX:
33 if (value < -1) {
34 input_event(field->hidinput->input, usage->type,
35 usage->code, -1);
36 return 1;
37 }
38 break;
39 }
40
41 return 0;
42}
43
44static const struct hid_device_id xinmo_devices[] = {
45 { HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_XIN_MO_DUAL_ARCADE) },
46 { HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_THT_2P_ARCADE) },
47 { }
48};
49
50MODULE_DEVICE_TABLE(hid, xinmo_devices);
51
52static struct hid_driver xinmo_driver = {
53 .name = "xinmo",
54 .id_table = xinmo_devices,
55 .event = xinmo_event
56};
57
58module_hid_driver(xinmo_driver);
59MODULE_LICENSE("GPL");