Linux Input Archive on lore.kernel.org
 help / color / Atom feed
* Re: Kernel support for joystick RAVCORE JAVELIN
       [not found] ` <55dfec8d-c9de-6295-0695-7fc0aa6533bc@gmail.com>
@ 2020-02-04 21:48   ` John Grs
  0 siblings, 0 replies; only message in thread
From: John Grs @ 2020-02-04 21:48 UTC (permalink / raw)
  To: linux-input

[-- 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");

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <ae53b87c-1544-bb6a-1d83-311ada4c580c@gmail.com>
     [not found] ` <55dfec8d-c9de-6295-0695-7fc0aa6533bc@gmail.com>
2020-02-04 21:48   ` Kernel support for joystick RAVCORE JAVELIN John Grs

Linux Input Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-input/0 linux-input/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-input linux-input/ https://lore.kernel.org/linux-input \
		linux-input@vger.kernel.org
	public-inbox-index linux-input

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-input


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git