mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
FS#10704 - Make a configuration option to disable USB HID
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23322 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
6314952ff1
commit
83d24f89df
14 changed files with 137 additions and 57 deletions
|
@ -23,6 +23,7 @@
|
|||
#ifdef USB_ENABLE_HID
|
||||
#include "action.h"
|
||||
#include "lang.h"
|
||||
#include "misc.h"
|
||||
#include "usbstack/usb_hid.h"
|
||||
//#define LOGF_ENABLE
|
||||
#include "logf.h"
|
||||
|
@ -174,40 +175,47 @@ extern int usb_keypad_mode;
|
|||
|
||||
int get_hid_usb_action(void)
|
||||
{
|
||||
int action;
|
||||
int action, step;
|
||||
const hid_key_mapping_t *key_mapping = hid_key_mappings[usb_keypad_mode];
|
||||
|
||||
step = -1;
|
||||
action = get_action(key_mapping->context, HZ/4);
|
||||
/* Skip key mappings in a cyclic way */
|
||||
if (action == ACTION_USB_HID_MODE_SWITCH_NEXT)
|
||||
switch (action)
|
||||
{
|
||||
/* TODO: Use clamp_value_wrap() */
|
||||
usb_keypad_mode = (usb_keypad_mode + 1) % NUM_KEY_MAPPINGS;
|
||||
}
|
||||
else if (action == ACTION_USB_HID_MODE_SWITCH_PREV)
|
||||
{
|
||||
/* TODO: Use clamp_value_wrap() */
|
||||
usb_keypad_mode = (usb_keypad_mode - 1) % NUM_KEY_MAPPINGS;
|
||||
}
|
||||
else if (action > ACTION_USB_HID_FIRST && action < ACTION_USB_HID_LAST)
|
||||
{
|
||||
const mapping_t *mapping;
|
||||
const hid_key_mapping_t *key_mapping =
|
||||
hid_key_mappings[usb_keypad_mode];
|
||||
|
||||
for (mapping = key_mapping->mapping; mapping->action; mapping++)
|
||||
{
|
||||
if (action == mapping->action)
|
||||
case ACTION_USB_HID_MODE_SWITCH_NEXT:
|
||||
step = 1;
|
||||
case ACTION_USB_HID_MODE_SWITCH_PREV:
|
||||
/* Switch key mappings in a cyclic way */
|
||||
usb_keypad_mode = clamp_value_wrap(usb_keypad_mode + step,
|
||||
NUM_KEY_MAPPINGS - 1, 0);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
logf("Action %d", action);
|
||||
usb_hid_send(key_mapping->usage_page, mapping->id);
|
||||
const mapping_t *mapping;
|
||||
const hid_key_mapping_t *key_mapping =
|
||||
hid_key_mappings[usb_keypad_mode];
|
||||
|
||||
if (action <= ACTION_USB_HID_FIRST ||
|
||||
action >= ACTION_USB_HID_LAST)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
for (mapping = key_mapping->mapping; mapping->action; mapping++)
|
||||
{
|
||||
if (action == mapping->action)
|
||||
{
|
||||
logf("Action %d", action);
|
||||
usb_hid_send(key_mapping->usage_page, mapping->id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (!mapping->action)
|
||||
logf("Action %d not found", action);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (!mapping->action)
|
||||
logf("Action %d not found", action);
|
||||
#endif
|
||||
}
|
||||
|
||||
return action;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue