Source
x
static int cougar_raw_event(struct hid_device *hdev, struct hid_report *report,
// SPDX-License-Identifier: GPL-2.0+
/*
* HID driver for Cougar 500k Gaming Keyboard
*
* Copyright (c) 2018 Daniel M. Lambea <dmlambea@gmail.com>
*/
MODULE_AUTHOR("Daniel M. Lambea <dmlambea@gmail.com>");
MODULE_DESCRIPTION("Cougar 500k Gaming Keyboard");
MODULE_LICENSE("GPL");
MODULE_INFO(key_mappings, "G1-G6 are mapped to F13-F18");
static bool g6_is_space = true;
MODULE_PARM_DESC(g6_is_space,
"If true, G6 programmable key sends SPACE instead of F18 (default=true)");
/* Default key mappings. The special key COUGAR_KEY_G6 is defined first
* because it is more frequent to use the spacebar rather than any other
* special keys. Depending on the value of the parameter 'g6_is_space',
* the mapping will be updated in the probe function.
*/
static unsigned char cougar_mapping[][2] = {
{ COUGAR_KEY_G6, KEY_SPACE },
{ COUGAR_KEY_G1, KEY_F13 },
{ COUGAR_KEY_G2, KEY_F14 },
{ COUGAR_KEY_G3, KEY_F15 },
{ COUGAR_KEY_G4, KEY_F16 },
{ COUGAR_KEY_G5, KEY_F17 },
{ COUGAR_KEY_LOCK, KEY_SCREENLOCK },
/* The following keys are handled by the hardware itself, so no special
* treatment is required:
{ COUGAR_KEY_FN, KEY_RESERVED },
{ COUGAR_KEY_MR, KEY_RESERVED },
{ COUGAR_KEY_M1, KEY_RESERVED },
{ COUGAR_KEY_M2, KEY_RESERVED },
{ COUGAR_KEY_M3, KEY_RESERVED },
{ COUGAR_KEY_LEDS, KEY_RESERVED },
*/
{ 0, 0 },
};
struct cougar_shared {
struct list_head list;
struct kref kref;
bool enabled;
struct hid_device *dev;
struct input_dev *input;
};
struct cougar {
bool special_intf;
struct cougar_shared *shared;
};
static LIST_HEAD(cougar_udev_list);
static DEFINE_MUTEX(cougar_udev_list_lock);
/**
* cougar_fix_g6_mapping - configure the mapping for key G6/Spacebar
*/
static void cougar_fix_g6_mapping(void)
{
int i;
for (i = 0; cougar_mapping[i][0]; i++) {
if (cougar_mapping[i][0] == COUGAR_KEY_G6) {