linux/drivers/hid/hid-corsair.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * HID driver for Corsair devices
 *
 * Supported devices:
 *  - Vengeance K70 Keyboard
 *  - K70 RAPIDFIRE Keyboard
 *  - Vengeance K90 Keyboard
 *  - Scimitar PRO RGB Gaming Mouse
 *
 * Copyright (c) 2015 Clement Vuchener
 * Copyright (c) 2017 Oscar Campos
 * Copyright (c) 2017 Aaron Bottegal
 */

/*
 */

#include <linux/hid.h>
#include <linux/module.h>
#include <linux/usb.h>
#include <linux/leds.h>

#include "hid-ids.h"

#define CORSAIR_USE_K90_MACRO
#define CORSAIR_USE_K90_BACKLIGHT

struct k90_led {};

struct k90_drvdata {};

struct corsair_drvdata {};

#define K90_GKEY_COUNT

static int corsair_usage_to_gkey(unsigned int usage)
{}

static unsigned short corsair_gkey_map[K90_GKEY_COUNT] =;

module_param_array_named();
MODULE_PARM_DESC();

static unsigned short corsair_record_keycodes[2] =;

module_param_array_named();
MODULE_PARM_DESC();

static unsigned short corsair_profile_keycodes[3] =;

module_param_array_named();
MODULE_PARM_DESC();

#define CORSAIR_USAGE_SPECIAL_MIN
#define CORSAIR_USAGE_SPECIAL_MAX

#define CORSAIR_USAGE_MACRO_RECORD_START
#define CORSAIR_USAGE_MACRO_RECORD_STOP

#define CORSAIR_USAGE_PROFILE
#define CORSAIR_USAGE_M1
#define CORSAIR_USAGE_M2
#define CORSAIR_USAGE_M3
#define CORSAIR_USAGE_PROFILE_MAX

#define CORSAIR_USAGE_META_OFF
#define CORSAIR_USAGE_META_ON

#define CORSAIR_USAGE_LIGHT
#define CORSAIR_USAGE_LIGHT_OFF
#define CORSAIR_USAGE_LIGHT_DIM
#define CORSAIR_USAGE_LIGHT_MEDIUM
#define CORSAIR_USAGE_LIGHT_BRIGHT
#define CORSAIR_USAGE_LIGHT_MAX

/* USB control protocol */

#define K90_REQUEST_BRIGHTNESS
#define K90_REQUEST_MACRO_MODE
#define K90_REQUEST_STATUS
#define K90_REQUEST_GET_MODE
#define K90_REQUEST_PROFILE

#define K90_MACRO_MODE_SW
#define K90_MACRO_MODE_HW

#define K90_MACRO_LED_ON
#define K90_MACRO_LED_OFF

/*
 * LED class devices
 */

#define K90_BACKLIGHT_LED_SUFFIX
#define K90_RECORD_LED_SUFFIX

static enum led_brightness k90_backlight_get(struct led_classdev *led_cdev)
{}

static enum led_brightness k90_record_led_get(struct led_classdev *led_cdev)
{}

static void k90_brightness_set(struct led_classdev *led_cdev,
			       enum led_brightness brightness)
{}

static void k90_backlight_work(struct work_struct *work)
{}

static void k90_record_led_work(struct work_struct *work)
{}

/*
 * Keyboard attributes
 */

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

static ssize_t k90_store_macro_mode(struct device *dev,
				    struct device_attribute *attr,
				    const char *buf, size_t count)
{}

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

static ssize_t k90_store_current_profile(struct device *dev,
					 struct device_attribute *attr,
					 const char *buf, size_t count)
{}

static DEVICE_ATTR(macro_mode, 0644, k90_show_macro_mode, k90_store_macro_mode);
static DEVICE_ATTR(current_profile, 0644, k90_show_current_profile,
		   k90_store_current_profile);

static struct attribute *k90_attrs[] =;

static const struct attribute_group k90_attr_group =;

/*
 * Driver functions
 */

static int k90_init_backlight(struct hid_device *dev)
{}

static int k90_init_macro_functions(struct hid_device *dev)
{}

static void k90_cleanup_backlight(struct hid_device *dev)
{}

static void k90_cleanup_macro_functions(struct hid_device *dev)
{}

static int corsair_probe(struct hid_device *dev, const struct hid_device_id *id)
{}

static void corsair_remove(struct hid_device *dev)
{}

static int corsair_event(struct hid_device *dev, struct hid_field *field,
			 struct hid_usage *usage, __s32 value)
{}

static int corsair_input_mapping(struct hid_device *dev,
				 struct hid_input *input,
				 struct hid_field *field,
				 struct hid_usage *usage, unsigned long **bit,
				 int *max)
{}

/*
 * The report descriptor of some of the Corsair gaming mice is
 * non parseable as they define two consecutive Logical Minimum for
 * the Usage Page (Consumer) in rdescs bytes 75 and 77 being 77 0x16
 * that should be obviousy 0x26 for Logical Magimum of 16 bits. This
 * prevents poper parsing of the report descriptor due Logical
 * Minimum being larger than Logical Maximum.
 *
 * This driver fixes the report descriptor for:
 * - USB ID 1b1c:1b34, sold as GLAIVE RGB Gaming mouse
 * - USB ID 1b1c:1b3e, sold as Scimitar RGB Pro Gaming mouse
 */

static __u8 *corsair_mouse_report_fixup(struct hid_device *hdev, __u8 *rdesc,
        unsigned int *rsize)
{}

static const struct hid_device_id corsair_devices[] =;

MODULE_DEVICE_TABLE(hid, corsair_devices);

static struct hid_driver corsair_driver =;

module_hid_driver();

MODULE_LICENSE();
/* Original K90 driver author */
MODULE_AUTHOR();
/* Scimitar PRO RGB driver author */
MODULE_AUTHOR();
MODULE_DESCRIPTION();