[-- Attachment #1: Type: text/plain, Size: 558 bytes --] Final version for Ravcore Javelin and VKB Gladiator MKII Στις 5/8/19 10:50 μ.μ., ο John Grs έγραψε: > > Στις 23/4/19 4:30 π.μ., ο John Grs έγραψε: >> After a couple of tries here my results. > > Still 2 problems, but at least the hat works. > > Problem 1) Only 7 of 8 direction works as for some reason the physical > maximum value doesn't work (the correct value must be 240-30=210 equal > to direction 7) so i put as logical maximum 14 and not the use 8 2) to > correct the opposite direction of hat report count = 2 (??) > > [-- Attachment #2: hid-ravcore.c --] [-- Type: text/x-csrc, Size: 1994 bytes --] // SPDX-License-Identifier: GPL-2.0-or-later /* * HID driver for Ravcore Javelin & VKB Joysticks * Currently supported devices are: * * Ravcore Javelin: v11C0 p5607 * VKB Gladiator MKII: v231d p0121 * * Copyright (c) 2019 John Grs <johnpgrs@gmail.com> */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/device.h> #include <linux/hid.h> #define USB_VENDOR_ID_RAVCORE 0x11C0 #define USB_DEVICE_ID_RAVCORE_VKB5607 0x5607 #define USB_VENDOR_ID_VKB 0x231d #define USB_DEVICE_ID_GLADIATOR 0x0121 static const struct { __s32 x; __s32 y; } hid_hat_to_axis[] = {{ 0, 0}, { 0,-1}, { 1,-1}, { 1, 0}, { 1, 1}, { 0, 1}, {-1, 1}, {-1, 0}, {-1,-1}}; static __u8 *gladiator_report_fixup(struct hid_device *hdev, __u8 *rdesc, unsigned int *rsize) { hid_info(hdev, "Fix HAT for Gladiator MKII Joystick\n"); rdesc[177]=0x08; // Logigal Maximum = 8 return rdesc; } static int gladiator_event(struct hid_device *hdev, struct hid_field *field, struct hid_usage *usage, __s32 value) { struct input_dev *input = field->hidinput->input; if (usage->type == EV_ABS && usage->code == 16) { if (value > 239) { value=-1; } else { value /= 30; } value +=1; input_event(input, usage->type, usage->code, hid_hat_to_axis[value].x); input_event(input, usage->type, usage->code+1, hid_hat_to_axis[value].y); return 1; } return 0; } static const struct hid_device_id gladiator_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_RAVCORE, USB_DEVICE_ID_RAVCORE_VKB5607) }, { HID_USB_DEVICE(USB_VENDOR_ID_VKB, USB_DEVICE_ID_GLADIATOR) }, { } }; MODULE_DEVICE_TABLE(hid, gladiator_devices); static struct hid_driver gladiator_driver = { .name = "VKB Gladiator MKII", .id_table = gladiator_devices, .report_fixup = gladiator_report_fixup, .event = gladiator_event, }; module_hid_driver(gladiator_driver); MODULE_AUTHOR("John Grs <johnpgrs@gmail.com>"); MODULE_DESCRIPTION("VKB Gladiator MKII driver"); MODULE_LICENSE("GPL");