libpayload: Export usbhid_getmodifiers
Add a new method to retrieve active usb keyboard modifiers. Change-Id: Ief6679ce782b58b9ced207f4f27504fb2a517b76 Signed-off-by: Patrick Rudolph <siro@das-labor.org> Reviewed-on: https://review.coreboot.org/18602 Reviewed-by: Martin Roth <martinroth@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
9aaf59aa6d
commit
1f5ebf7c8b
|
@ -87,6 +87,7 @@ usb_hid_destroy (usbdev_t *dev)
|
||||||
static int keycount;
|
static int keycount;
|
||||||
#define KEYBOARD_BUFFER_SIZE 16
|
#define KEYBOARD_BUFFER_SIZE 16
|
||||||
static short keybuffer[KEYBOARD_BUFFER_SIZE];
|
static short keybuffer[KEYBOARD_BUFFER_SIZE];
|
||||||
|
static int modifiers;
|
||||||
|
|
||||||
const char *countries[36][2] = {
|
const char *countries[36][2] = {
|
||||||
{ "not supported", "us" },
|
{ "not supported", "us" },
|
||||||
|
@ -244,9 +245,6 @@ static const struct layout_maps keyboard_layouts[] = {
|
||||||
//#endif
|
//#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MOD_SHIFT (1 << 0)
|
|
||||||
#define MOD_ALT (1 << 1)
|
|
||||||
#define MOD_CTRL (1 << 2)
|
|
||||||
|
|
||||||
static void usb_hid_keyboard_queue(int ch) {
|
static void usb_hid_keyboard_queue(int ch) {
|
||||||
/* ignore key presses if buffer full */
|
/* ignore key presses if buffer full */
|
||||||
|
@ -264,15 +262,17 @@ usb_hid_process_keyboard_event(usbhid_inst_t *const inst,
|
||||||
{
|
{
|
||||||
const usb_hid_keyboard_event_t *const previous = &inst->previous;
|
const usb_hid_keyboard_event_t *const previous = &inst->previous;
|
||||||
|
|
||||||
int i, keypress = 0, modifiers = 0;
|
int i, keypress = 0;
|
||||||
|
|
||||||
if (current->modifiers & 0x01) /* Left-Ctrl */ modifiers |= MOD_CTRL;
|
modifiers = 0;
|
||||||
if (current->modifiers & 0x02) /* Left-Shift */ modifiers |= MOD_SHIFT;
|
|
||||||
if (current->modifiers & 0x04) /* Left-Alt */ modifiers |= MOD_ALT;
|
if (current->modifiers & 0x01) /* Left-Ctrl */ modifiers |= KB_MOD_CTRL;
|
||||||
|
if (current->modifiers & 0x02) /* Left-Shift */ modifiers |= KB_MOD_SHIFT;
|
||||||
|
if (current->modifiers & 0x04) /* Left-Alt */ modifiers |= KB_MOD_ALT;
|
||||||
if (current->modifiers & 0x08) /* Left-GUI */ ;
|
if (current->modifiers & 0x08) /* Left-GUI */ ;
|
||||||
if (current->modifiers & 0x10) /* Right-Ctrl */ modifiers |= MOD_CTRL;
|
if (current->modifiers & 0x10) /* Right-Ctrl */ modifiers |= KB_MOD_CTRL;
|
||||||
if (current->modifiers & 0x20) /* Right-Shift */ modifiers |= MOD_SHIFT;
|
if (current->modifiers & 0x20) /* Right-Shift */ modifiers |= KB_MOD_SHIFT;
|
||||||
if (current->modifiers & 0x40) /* Right-AltGr */ modifiers |= MOD_ALT;
|
if (current->modifiers & 0x40) /* Right-AltGr */ modifiers |= KB_MOD_ALT;
|
||||||
if (current->modifiers & 0x80) /* Right-GUI */ ;
|
if (current->modifiers & 0x80) /* Right-GUI */ ;
|
||||||
|
|
||||||
if ((current->modifiers & 0x05) && ((current->keys[0] == 0x4c) ||
|
if ((current->modifiers & 0x05) && ((current->keys[0] == 0x4c) ||
|
||||||
|
@ -315,10 +315,10 @@ usb_hid_process_keyboard_event(usbhid_inst_t *const inst,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
/* Mask off MOD_CTRL */
|
/* Mask off KB_MOD_CTRL */
|
||||||
keypress = map->map[modifiers & 0x03][current->keys[i]];
|
keypress = map->map[modifiers & 0x03][current->keys[i]];
|
||||||
|
|
||||||
if (modifiers & MOD_CTRL) {
|
if (modifiers & KB_MOD_CTRL) {
|
||||||
switch (keypress) {
|
switch (keypress) {
|
||||||
case 'a' ... 'z':
|
case 'a' ... 'z':
|
||||||
keypress &= 0x1f;
|
keypress &= 0x1f;
|
||||||
|
@ -509,3 +509,8 @@ int usbhid_getchar (void)
|
||||||
|
|
||||||
return (int)ret;
|
return (int)ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int usbhid_getmodifiers(void)
|
||||||
|
{
|
||||||
|
return modifiers;
|
||||||
|
}
|
||||||
|
|
|
@ -141,6 +141,7 @@ int usb_initialize(void);
|
||||||
int usb_exit (void);
|
int usb_exit (void);
|
||||||
int usbhid_havechar(void);
|
int usbhid_havechar(void);
|
||||||
int usbhid_getchar(void);
|
int usbhid_getchar(void);
|
||||||
|
int usbhid_getmodifiers(void);
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue