hid-cougar.c (6b003a8ddd6f413a7e17470515accdd4cd80e871) | hid-cougar.c (75f1f19bdd60575164b5d1fb04602bf4450e2b62) |
---|---|
1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * HID driver for Cougar 500k Gaming Keyboard 4 * 5 * Copyright (c) 2018 Daniel M. Lambea <dmlambea@gmail.com> 6 */ 7 8#include <linux/hid.h> --- 247 unchanged lines hidden (view full) --- 256 257/* 258 * Convert events from vendor intf to input key events 259 */ 260static int cougar_raw_event(struct hid_device *hdev, struct hid_report *report, 261 u8 *data, int size) 262{ 263 struct cougar *cougar; | 1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * HID driver for Cougar 500k Gaming Keyboard 4 * 5 * Copyright (c) 2018 Daniel M. Lambea <dmlambea@gmail.com> 6 */ 7 8#include <linux/hid.h> --- 247 unchanged lines hidden (view full) --- 256 257/* 258 * Convert events from vendor intf to input key events 259 */ 260static int cougar_raw_event(struct hid_device *hdev, struct hid_report *report, 261 u8 *data, int size) 262{ 263 struct cougar *cougar; |
264 struct cougar_shared *shared; |
|
264 unsigned char code, action; 265 int i; 266 267 cougar = hid_get_drvdata(hdev); | 265 unsigned char code, action; 266 int i; 267 268 cougar = hid_get_drvdata(hdev); |
268 if (!cougar->special_intf || !cougar->shared || 269 !cougar->shared->input || !cougar->shared->enabled) | 269 shared = cougar->shared; 270 if (!cougar->special_intf || !shared) |
270 return 0; 271 | 271 return 0; 272 |
273 if (!shared->enabled || !shared->input) 274 return -EPERM; 275 |
|
272 code = data[COUGAR_FIELD_CODE]; 273 action = data[COUGAR_FIELD_ACTION]; 274 for (i = 0; cougar_mapping[i][0]; i++) { 275 if (code == cougar_mapping[i][0]) { | 276 code = data[COUGAR_FIELD_CODE]; 277 action = data[COUGAR_FIELD_ACTION]; 278 for (i = 0; cougar_mapping[i][0]; i++) { 279 if (code == cougar_mapping[i][0]) { |
276 input_event(cougar->shared->input, EV_KEY, | 280 input_event(shared->input, EV_KEY, |
277 cougar_mapping[i][1], action); | 281 cougar_mapping[i][1], action); |
278 input_sync(cougar->shared->input); 279 return 0; | 282 input_sync(shared->input); 283 return -EPERM; |
280 } 281 } | 284 } 285 } |
282 hid_warn(hdev, "unmapped special key code %x: ignoring\n", code); 283 return 0; | 286 /* Avoid warnings on the same unmapped key twice */ 287 if (action != 0) 288 hid_warn(hdev, "unmapped special key code %0x: ignoring\n", code); 289 return -EPERM; |
284} 285 286static void cougar_remove(struct hid_device *hdev) 287{ 288 struct cougar *cougar = hid_get_drvdata(hdev); 289 290 if (cougar) { 291 /* Stop the vendor intf to process more events */ --- 45 unchanged lines hidden --- | 290} 291 292static void cougar_remove(struct hid_device *hdev) 293{ 294 struct cougar *cougar = hid_get_drvdata(hdev); 295 296 if (cougar) { 297 /* Stop the vendor intf to process more events */ --- 45 unchanged lines hidden --- |