linux/drivers/hid/hid-roccat-kone.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Roccat Kone driver for Linux
 *
 * Copyright (c) 2010 Stefan Achatz <[email protected]>
 */

/*
 */

/*
 * Roccat Kone is a gamer mouse which consists of a mouse part and a keyboard
 * part. The keyboard part enables the mouse to execute stored macros with mixed
 * key- and button-events.
 *
 * TODO implement on-the-fly polling-rate change
 *      The windows driver has the ability to change the polling rate of the
 *      device on the press of a mousebutton.
 *      Is it possible to remove and reinstall the urb in raw-event- or any
 *      other handler, or to defer this action to be executed somewhere else?
 *
 * TODO is it possible to overwrite group for sysfs attributes via udev?
 */

#include <linux/device.h>
#include <linux/input.h>
#include <linux/hid.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/hid-roccat.h>
#include "hid-ids.h"
#include "hid-roccat-common.h"
#include "hid-roccat-kone.h"

static uint profile_numbers[5] =;

static void kone_profile_activated(struct kone_device *kone, uint new_profile)
{}

static void kone_profile_report(struct kone_device *kone, uint new_profile)
{}

static int kone_receive(struct usb_device *usb_dev, uint usb_command,
		void *data, uint size)
{}

static int kone_send(struct usb_device *usb_dev, uint usb_command,
		void const *data, uint size)
{}

static void kone_set_settings_checksum(struct kone_settings *settings)
{}

/*
 * Checks success after writing data to mouse
 * On success returns 0
 * On failure returns errno
 */
static int kone_check_write(struct usb_device *usb_dev)
{}

/*
 * Reads settings from mouse and stores it in @buf
 * On success returns 0
 * On failure returns errno
 */
static int kone_get_settings(struct usb_device *usb_dev,
		struct kone_settings *buf)
{}

/*
 * Writes settings from @buf to mouse
 * On success returns 0
 * On failure returns errno
 */
static int kone_set_settings(struct usb_device *usb_dev,
		struct kone_settings const *settings)
{}

/*
 * Reads profile data from mouse and stores it in @buf
 * @number: profile number to read
 * On success returns 0
 * On failure returns errno
 */
static int kone_get_profile(struct usb_device *usb_dev,
		struct kone_profile *buf, int number)
{}

/*
 * Writes profile data to mouse.
 * @number: profile number to write
 * On success returns 0
 * On failure returns errno
 */
static int kone_set_profile(struct usb_device *usb_dev,
		struct kone_profile const *profile, int number)
{}

/*
 * Reads value of "fast-clip-weight" and stores it in @result
 * On success returns 0
 * On failure returns errno
 */
static int kone_get_weight(struct usb_device *usb_dev, int *result)
{}

/*
 * Reads firmware_version of mouse and stores it in @result
 * On success returns 0
 * On failure returns errno
 */
static int kone_get_firmware_version(struct usb_device *usb_dev, int *result)
{}

static ssize_t kone_sysfs_read_settings(struct file *fp, struct kobject *kobj,
		struct bin_attribute *attr, char *buf,
		loff_t off, size_t count) {}

/*
 * Writing settings automatically activates startup_profile.
 * This function keeps values in kone_device up to date and assumes that in
 * case of error the old data is still valid
 */
static ssize_t kone_sysfs_write_settings(struct file *fp, struct kobject *kobj,
		struct bin_attribute *attr, char *buf,
		loff_t off, size_t count) {}
static BIN_ATTR(settings, 0660, kone_sysfs_read_settings,
		kone_sysfs_write_settings, sizeof(struct kone_settings));

static ssize_t kone_sysfs_read_profilex(struct file *fp,
		struct kobject *kobj, struct bin_attribute *attr,
		char *buf, loff_t off, size_t count) {}

/* Writes data only if different to stored data */
static ssize_t kone_sysfs_write_profilex(struct file *fp,
		struct kobject *kobj, struct bin_attribute *attr,
		char *buf, loff_t off, size_t count) {}
#define PROFILE_ATTR(number)
PROFILE_ATTR();
PROFILE_ATTR();
PROFILE_ATTR();
PROFILE_ATTR();
PROFILE_ATTR();

static ssize_t kone_sysfs_show_actual_profile(struct device *dev,
		struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR(actual_profile, 0440, kone_sysfs_show_actual_profile, NULL);

static ssize_t kone_sysfs_show_actual_dpi(struct device *dev,
		struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR(actual_dpi, 0440, kone_sysfs_show_actual_dpi, NULL);

/* weight is read each time, since we don't get informed when it's changed */
static ssize_t kone_sysfs_show_weight(struct device *dev,
		struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR(weight, 0440, kone_sysfs_show_weight, NULL);

static ssize_t kone_sysfs_show_firmware_version(struct device *dev,
		struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR(firmware_version, 0440, kone_sysfs_show_firmware_version,
		   NULL);

static ssize_t kone_sysfs_show_tcu(struct device *dev,
		struct device_attribute *attr, char *buf)
{}

static int kone_tcu_command(struct usb_device *usb_dev, int number)
{}

/*
 * Calibrating the tcu is the only action that changes settings data inside the
 * mouse, so this data needs to be reread
 */
static ssize_t kone_sysfs_set_tcu(struct device *dev,
		struct device_attribute *attr, char const *buf, size_t size)
{}
static DEVICE_ATTR(tcu, 0660, kone_sysfs_show_tcu, kone_sysfs_set_tcu);

static ssize_t kone_sysfs_show_startup_profile(struct device *dev,
		struct device_attribute *attr, char *buf)
{}

static ssize_t kone_sysfs_set_startup_profile(struct device *dev,
		struct device_attribute *attr, char const *buf, size_t size)
{}
static DEVICE_ATTR(startup_profile, 0660, kone_sysfs_show_startup_profile,
		   kone_sysfs_set_startup_profile);

static struct attribute *kone_attrs[] =;

static struct bin_attribute *kone_bin_attributes[] =;

static const struct attribute_group kone_group =;

static const struct attribute_group *kone_groups[] =;

/* kone_class is used for creating sysfs attributes via roccat char device */
static const struct class kone_class =;

static int kone_init_kone_device_struct(struct usb_device *usb_dev,
		struct kone_device *kone)
{}

/*
 * Since IGNORE_MOUSE quirk moved to hid-apple, there is no way to bind only to
 * mousepart if usb_hid is compiled into the kernel and kone is compiled as
 * module.
 * Secial behaviour is bound only to mousepart since only mouseevents contain
 * additional notifications.
 */
static int kone_init_specials(struct hid_device *hdev)
{}

static void kone_remove_specials(struct hid_device *hdev)
{}

static int kone_probe(struct hid_device *hdev, const struct hid_device_id *id)
{}

static void kone_remove(struct hid_device *hdev)
{}

/* handle special events and keep actual profile and dpi values up to date */
static void kone_keep_values_up_to_date(struct kone_device *kone,
		struct kone_mouse_event const *event)
{}

static void kone_report_to_chrdev(struct kone_device const *kone,
		struct kone_mouse_event const *event)
{}

/*
 * Is called for keyboard- and mousepart.
 * Only mousepart gets informations about special events in its extended event
 * structure.
 */
static int kone_raw_event(struct hid_device *hdev, struct hid_report *report,
		u8 *data, int size)
{}

static const struct hid_device_id kone_devices[] =;

MODULE_DEVICE_TABLE(hid, kone_devices);

static struct hid_driver kone_driver =;

static int __init kone_init(void)
{}

static void __exit kone_exit(void)
{}

module_init();
module_exit(kone_exit);

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();