MODULE_AUTHOR("Daniel M. Lambea ");
MODULE_DESCRIPTION("Cougar 500k Gaming Keyboard");
MODULE_LICENSE("GPL");
MODULE_INFO(key_mappings, "G1-G6 are mapped to F13-F18");
staticbool 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.
*/ staticunsignedchar 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 },
};
/* Try to find an already-probed interface from the same device */
list_for_each_entry(shared, &cougar_udev_list, list) { if (hid_compare_device_paths(hdev, shared->dev, '/')) {
kref_get(&shared->kref); return shared;
}
} return NULL;
}
if (cougar->shared) {
kref_put(&cougar->shared->kref, cougar_release_shared_data);
cougar->shared = NULL;
}
}
/* * Bind the device group's shared data to this cougar struct. * If no shared data exists for this group, create and initialize it.
*/ staticint cougar_bind_shared_data(struct hid_device *hdev, struct cougar *cougar)
{ struct cougar_shared *shared; int error = 0;
mutex_lock(&cougar_udev_list_lock);
shared = cougar_get_shared_data(hdev); if (!shared) {
shared = kzalloc(sizeof(*shared), GFP_KERNEL); if (!shared) {
error = -ENOMEM; goto out;
}
error = cougar_bind_shared_data(hdev, cougar); if (error) goto fail_stop_and_cleanup;
/* The custom vendor interface will use the hid_input registered * for the keyboard interface, in order to send translated key codes * to it.
*/ if (hdev->collection->usage == HID_GD_KEYBOARD) {
list_for_each_entry_safe(hidinput, next, &hdev->inputs, list) { if (hidinput->registered && hidinput->input != NULL) {
cougar->shared->input = hidinput->input;
cougar->shared->enabled = true; break;
}
}
} elseif (hdev->collection->usage == COUGAR_VENDOR_USAGE) { /* Preinit the mapping table */
cougar_fix_g6_mapping();
error = hid_hw_open(hdev); if (error) goto fail_stop_and_cleanup;
} return 0;
if (cougar) { /* Stop the vendor intf to process more events */ if (cougar->shared)
cougar->shared->enabled = false; if (cougar->special_intf)
hid_hw_close(hdev);
}
hid_hw_stop(hdev);
}
staticint cougar_param_set_g6_is_space(constchar *val, conststruct kernel_param *kp)
{ int ret;
ret = param_set_bool(val, kp); if (ret) return ret;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.