mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-22 17:01:14 +00:00
HID: wacom: Refactor button-to-key translation into function
This just centralizes the logic used in both wacom_setup_numbered_buttons and wacom_report_numbered_buttons so that they don't drift out of sync. Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
This commit is contained in:
parent
1b18b75c7e
commit
49005b9fd0
1 changed files with 24 additions and 12 deletions
|
@ -2769,17 +2769,29 @@ int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int wacom_numbered_button_to_key(int n)
|
||||||
|
{
|
||||||
|
if (n < 10)
|
||||||
|
return BTN_0 + n;
|
||||||
|
else if (n < 16)
|
||||||
|
return BTN_A + (n-10);
|
||||||
|
else if (n < 18)
|
||||||
|
return BTN_BASE + (n-16);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void wacom_setup_numbered_buttons(struct input_dev *input_dev,
|
static void wacom_setup_numbered_buttons(struct input_dev *input_dev,
|
||||||
int button_count)
|
int button_count)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < button_count && i < 10; i++)
|
for (i = 0; i < button_count; i++) {
|
||||||
__set_bit(BTN_0 + i, input_dev->keybit);
|
int key = wacom_numbered_button_to_key(i);
|
||||||
for (i = 10; i < button_count && i < 16; i++)
|
|
||||||
__set_bit(BTN_A + (i-10), input_dev->keybit);
|
if (key)
|
||||||
for (i = 16; i < button_count && i < 18; i++)
|
__set_bit(key, input_dev->keybit);
|
||||||
__set_bit(BTN_BASE + (i-16), input_dev->keybit);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wacom_24hd_update_leds(struct wacom *wacom, int mask, int group)
|
static void wacom_24hd_update_leds(struct wacom *wacom, int mask, int group)
|
||||||
|
@ -2881,12 +2893,12 @@ static void wacom_report_numbered_buttons(struct input_dev *input_dev,
|
||||||
for (i = 0; i < wacom->led.count; i++)
|
for (i = 0; i < wacom->led.count; i++)
|
||||||
wacom_update_led(wacom, button_count, mask, i);
|
wacom_update_led(wacom, button_count, mask, i);
|
||||||
|
|
||||||
for (i = 0; i < button_count && i < 10; i++)
|
for (i = 0; i < button_count; i++) {
|
||||||
input_report_key(input_dev, BTN_0 + i, mask & (1 << i));
|
int key = wacom_numbered_button_to_key(i);
|
||||||
for (i = 10; i < button_count && i < 16; i++)
|
|
||||||
input_report_key(input_dev, BTN_A + (i-10), mask & (1 << i));
|
if (key)
|
||||||
for (i = 16; i < button_count && i < 18; i++)
|
input_report_key(input_dev, key, mask & (1 << i));
|
||||||
input_report_key(input_dev, BTN_BASE + (i-16), mask & (1 << i));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
|
int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
|
||||||
|
|
Loading…
Reference in a new issue