Skip to contentSkip to conversation

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

PATCH In review Stefan Achatz 2 participants 3 messages May 19, 2010 – May 25, 2010

Subsystems (2)
lore
Share & tools
lore

Stefan Achatz

author maintainer
#0 lore raw

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

Module roccat is a char device used to report special events of roccat hardware to userland. These events include requests for on-screen-display of profile or dpi settings or requests for execution of macro sequences that are not stored in device. The information in these events depends on hid device implementation and contains data that is not available in a single hid event or else hidraw could have been used.
It is inspired by hidraw, but uses only one circular buffer for all readers. The device is as generic as possible so that the functionality is usable by all (kone and upcomming) roccat device drivers.

---
 drivers/hid/Kconfig           |    8 +
 drivers/hid/Makefile          |    1 +
 drivers/hid/hid-roccat-kone.c |   49 +++++
 drivers/hid/hid-roccat-kone.h |    9 +
 drivers/hid/hid-roccat.c      |  428 +++++++++++++++++++++++++++++++++++++++++
 drivers/hid/hid-roccat.h      |   31 +++
 6 files changed, 526 insertions(+), 0 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 +49 -0

83 lines not on this page · raw message

drivers/hid/hid-roccat-kone.h +9 -0
index b413b10..003e6f8 100644
@@ -189,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 {
@@ -219,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
#1 lore raw
Quoted 2 lines · Stefan Achatz

Module roccat is a char device used to report special events of roccat hardware to userland.

I have now applied it.

It would be also nice if you could provide a link to the userspace software taking care of these special events somewhere.

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs, Novell Inc.
#2 lore raw
Quoted 4 lines · Jiri Kosina
Quoted 2 lines

Module roccat is a char device used to report special events of roccat hardware to userland.

I have now applied it.

Plus I had to apply the patch below on top of it.

From: Jiri Kosina <[email protected]>
Subject: [PATCH] HID: roccat: fix build failure if built as module

Fix build failure when roccat and roccat-kone are built as modules.

---
 drivers/hid/hid-roccat.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/hid/hid-roccat.h +1 -1
index 40cca5b..d8aae0c 100644
@@ -15,7 +15,7 @@
 #include <linux/hid.h>
 #include <linux/types.h>
 
-#ifdef CONFIG_HID_ROCCAT
+#if defined(CONFIG_HID_ROCCAT) || defined (CONFIG_HID_ROCCAT_MODULE)
 int roccat_connect(struct hid_device *hid);
 void roccat_disconnect(int minor);
 int roccat_report_event(int minor, u8 const *data, int len);
Signature · 2 lines
Jiri Kosina
SUSE Labs, Novell Inc.