Skip to contentSkip to conversation

HID: add chardev to propagate special events of Roccat hardware to userland

PATCH New Stefan Achatz 1 participant 1 message Apr 15, 2010

Subsystems (2)
lore
Share & tools
lore

Stefan Achatz

author maintainer
#0 lore raw

PATCH 1/1 HID: add chardev to propagate special events of Roccat hardware to userland

Quoted 1 line

From 0692c53dfb745df62fd805fe089786951a8d96ec Mon Sep 17 00:00:00 2001

From: Stefan Achatz <[email protected]>
Date: Thu, 15 Apr 2010 17:24:45 +0200
Subject: [PATCH] HID: add chardev to propagate special events of Roccat hardware to userland

This Patch adds a chardev that is used to report special events like request for on-screen-display of actual mouse-setting informations, request for execution of macro sequences not stored in mouse. The device is as generic as possible so that the functionality is usable by all (kone and upcomming) roccat device drivers.

Also small improvements in kone driver are implemented as understanding of the device and kernel programming increases.

---
 drivers/hid/Kconfig           |    8 +
 drivers/hid/Makefile          |    1 +
 drivers/hid/hid-roccat-kone.c |  127 ++++++++-----
 drivers/hid/hid-roccat-kone.h |   33 +++-
 drivers/hid/hid-roccat.c      |  428 +++++++++++++++++++++++++++++++++++++++++
 drivers/hid/hid-roccat.h      |   31 +++
 6 files changed, 576 insertions(+), 52 deletions(-)
 create mode 100644 drivers/hid/hid-roccat.c
 create mode 100644 drivers/hid/hid-roccat.h
drivers/hid/Kconfig +8 -0
index 44b4691..2c7018b 100644
@@ -268,6 +268,14 @@ config HID_QUANTA
 	---help---
 	Support for Quanta Optical Touch dual-touch panels.
 
+config HID_ROCCAT
+	tristate "Roccat special event support"
+	depends on USB_HID
+	---help---
+	Support for Roccat special events.
+	Say Y here if you have a Roccat mouse or keyboard and want OSD or
+	macro execution support.
+
 config HID_ROCCAT_KONE
 	tristate "Roccat Kone Mouse support"
 	depends on USB_HID
drivers/hid/Makefile +1 -0
index 08b83cc..77fad93 100644
@@ -44,6 +44,7 @@ obj-$(CONFIG_HID_ORTEK)		+= hid-ortek.o
 obj-$(CONFIG_HID_QUANTA)	+= hid-quanta.o
 obj-$(CONFIG_HID_PANTHERLORD)	+= hid-pl.o
 obj-$(CONFIG_HID_PETALYNX)	+= hid-petalynx.o
+obj-$(CONFIG_HID_ROCCAT)	+= hid-roccat.o
 obj-$(CONFIG_HID_ROCCAT_KONE)	+= hid-roccat-kone.o
 obj-$(CONFIG_HID_SAMSUNG)	+= hid-samsung.o
 obj-$(CONFIG_HID_SMARTJOYPLUS)	+= hid-sjoy.o
drivers/hid/hid-roccat-kone.c +82 -45

185 lines not on this page · raw message

drivers/hid/hid-roccat-kone.h +26 -7
index ee6898c..003e6f8 100644
@@ -14,10 +14,7 @@
 
 #include <linux/types.h>
 
-#define DRIVER_VERSION "v0.3.0"
-#define DRIVER_AUTHOR "Stefan Achatz"
-#define DRIVER_DESC "USB Roccat Kone driver"
-#define DRIVER_LICENSE "GPL v2"
+#define ROCCAT_KONE_DRIVER_VERSION "v0.3.1"
 
 #pragma pack(push)
 #pragma pack(1)
@@ -83,6 +80,17 @@ enum kone_button_info_types {
 	kone_button_info_type_multimedia_volume_down = 0x27
 };
 
+enum kone_button_info_numbers {
+	kone_button_top = 1,
+	kone_button_wheel_tilt_left = 2,
+	kone_button_wheel_tilt_right = 3,
+	kone_button_forward = 4,
+	kone_button_backward = 5,
+	kone_button_middle = 6,
+	kone_button_plus = 7,
+	kone_button_minus = 8,
+};
+
 struct kone_light_info {
 	uint8_t number; /* number of light 1-5 */
 	uint8_t mod;   /* 1 = on, 2 = off */
@@ -120,6 +128,7 @@ struct kone_profile {
 	uint8_t light_effect_speed; /* range 0-255 */
 
 	struct kone_light_info light_infos[5];
+	/* offset is kone_button_info_numbers - 1 */
 	struct kone_button_info button_infos[8];
 
 	uint16_t checksum; /* \brief holds checksum of struct */
@@ -165,7 +174,7 @@ enum kone_mouse_events {
 	/* TODO clarify meaning and occurence of kone_mouse_event_calibration */
 	kone_mouse_event_calibration = 0xc0,
 	kone_mouse_event_call_overlong_macro = 0xe0,
-	/* switch events notify if user changed values wiht mousebutton click */
+	/* switch events notify if user changed values with mousebutton click */
 	kone_mouse_event_switch_dpi = 0xf0,
 	kone_mouse_event_switch_profile = 0xf1
 };
@@ -180,6 +189,12 @@ enum kone_commands {
 	kone_command_firmware = 0xe5a
 };
 
+struct kone_roccat_report {
+	uint8_t event;
+	uint8_t value; /* holds dpi or profile value */
+	uint8_t key; /* macro key on overlong macro execution */
+};
+
 #pragma pack(pop)
 
 struct kone_device {
@@ -188,8 +203,9 @@ struct kone_device {
 	 * is no way of getting this information from the device on demand
 	 */
 	int actual_profile, actual_dpi;
-	/* Used for neutralizing abnormal tilt button behaviour */
-	int last_tilt_state;
+	/* Used for neutralizing abnormal button behaviour */
+	struct kone_mouse_event last_mouse_event;
+
 	/*
 	 * It's unlikely that multiple sysfs attributes are accessed at a time,
 	 * so only one mutex is used to secure hardware access and profiles and
@@ -209,6 +225,9 @@ struct kone_device {
 	 * so it's read only once
 	 */
 	int firmware_version;
+
+	int roccat_claimed;
+	int chrdev_minor;
 };
 
 #endif
drivers/hid/hid-roccat.c new file +428 -0

428 lines not on this page · raw message

drivers/hid/hid-roccat.h new file +31 -0
new file mode 100644
index 0000000..40cca5b
@@ -0,0 +1,31 @@
+#ifndef __HID_ROCCAT_H
+#define __HID_ROCCAT_H
+
+/*
+ * Copyright (c) 2010 Stefan Achatz <[email protected]>
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ */
+
+#include <linux/hid.h>
+#include <linux/types.h>
+
+#ifdef CONFIG_HID_ROCCAT
+int roccat_connect(struct hid_device *hid);
+void roccat_disconnect(int minor);
+int roccat_report_event(int minor, u8 const *data, int len);
+#else
+static inline int roccat_connect(struct hid_device *hid) { return -1; }
+static inline void roccat_disconnect(int minor) {}
+static inline int roccat_report_event(int minor, u8 const *data, int len)
+{
+	return 0;
+}
+#endif
+
+#endif
Signature · 1 line
1.6.6.1