mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 23:23:52 +01:00
asus: warn on unknown key codes
This commit is contained in:
@@ -113,10 +113,11 @@ asus_find_key_code(unsigned int linux_code)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* convert ASUS key code to Linux key code */
|
||||
int
|
||||
asus_get_linux_key_code(uint8_t asus_code) {
|
||||
assert(asus_code <= ARRAY_LENGTH(ASUS_KEY_MAPPING));
|
||||
if (asus_code > ARRAY_LENGTH(ASUS_KEY_MAPPING)) {
|
||||
return -1;
|
||||
}
|
||||
return ASUS_KEY_MAPPING[asus_code];
|
||||
}
|
||||
|
||||
|
||||
@@ -164,6 +164,11 @@ asus_find_button_by_code(uint8_t asus_code);
|
||||
int
|
||||
asus_find_key_code(unsigned int linux_code);
|
||||
|
||||
/*
|
||||
* @param asus_code ASUS key code.
|
||||
* @return Linux key code (as defined defined in linux/input-event-codes.h) or
|
||||
* -1 on error.
|
||||
*/
|
||||
int
|
||||
asus_get_linux_key_code(uint8_t asus_code);
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <libevdev/libevdev.h>
|
||||
#include <linux/input.h>
|
||||
@@ -116,8 +115,12 @@ asus_driver_load_profile(struct ratbag_device *device, struct ratbag_profile *pr
|
||||
switch (asus_binding->type) {
|
||||
case ASUS_BUTTON_ACTION_TYPE_KEY:
|
||||
button->action.type = RATBAG_BUTTON_ACTION_TYPE_KEY;
|
||||
/* ASUS code to Linux code */
|
||||
button->action.action.key.key = asus_get_linux_key_code(asus_binding->action);
|
||||
rc = asus_get_linux_key_code(asus_binding->action);
|
||||
if (rc > 0) {
|
||||
button->action.action.key.key = (unsigned int)rc;
|
||||
} else {
|
||||
log_debug(device->ratbag, "Unknown button code %02x\n", asus_binding->action);
|
||||
}
|
||||
break;
|
||||
|
||||
case ASUS_BUTTON_ACTION_TYPE_BUTTON:
|
||||
|
||||
Reference in New Issue
Block a user