Support USB key repeat
This commit is contained in:
parent
ab247a453f
commit
7e6975d7ea
2 changed files with 23 additions and 4 deletions
|
@ -490,6 +490,9 @@ grub_print_spaces (struct grub_term_output *term, int number_spaces)
|
||||||
|
|
||||||
extern void (*EXPORT_VAR (grub_term_poll_usb)) (void);
|
extern void (*EXPORT_VAR (grub_term_poll_usb)) (void);
|
||||||
|
|
||||||
|
#define GRUB_TERM_REPEAT_PRE_INTERVAL 100
|
||||||
|
#define GRUB_TERM_REPEAT_INTERVAL 50
|
||||||
|
|
||||||
#endif /* ! ASM_FILE */
|
#endif /* ! ASM_FILE */
|
||||||
|
|
||||||
#endif /* ! GRUB_TERM_HEADER */
|
#endif /* ! GRUB_TERM_HEADER */
|
||||||
|
|
|
@ -144,6 +144,8 @@ struct grub_usb_keyboard_data
|
||||||
grub_usb_transfer_t transfer;
|
grub_usb_transfer_t transfer;
|
||||||
grub_uint8_t report[8];
|
grub_uint8_t report[8];
|
||||||
int dead;
|
int dead;
|
||||||
|
int last_key;
|
||||||
|
grub_uint64_t repeat_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct grub_term_input grub_usb_keyboards[16];
|
static struct grub_term_input grub_usb_keyboards[16];
|
||||||
|
@ -368,7 +370,16 @@ grub_usb_keyboard_checkkey (struct grub_term_input *term)
|
||||||
err = grub_usb_check_transfer (termdata->transfer, &actual);
|
err = grub_usb_check_transfer (termdata->transfer, &actual);
|
||||||
|
|
||||||
if (err == GRUB_USB_ERR_WAIT)
|
if (err == GRUB_USB_ERR_WAIT)
|
||||||
return -1;
|
{
|
||||||
|
if (termdata->last_key != -1
|
||||||
|
&& grub_get_time_ms () > termdata->repeat_time)
|
||||||
|
{
|
||||||
|
termdata->key = termdata->last_key;
|
||||||
|
termdata->repeat_time = grub_get_time_ms ()
|
||||||
|
+ GRUB_TERM_REPEAT_INTERVAL;
|
||||||
|
}
|
||||||
|
return termdata->key;
|
||||||
|
}
|
||||||
|
|
||||||
grub_memcpy (data, termdata->report, sizeof (data));
|
grub_memcpy (data, termdata->report, sizeof (data));
|
||||||
|
|
||||||
|
@ -382,6 +393,7 @@ grub_usb_keyboard_checkkey (struct grub_term_input *term)
|
||||||
termdata->dead = 1;
|
termdata->dead = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
termdata->last_key = -1;
|
||||||
|
|
||||||
grub_dprintf ("usb_keyboard",
|
grub_dprintf ("usb_keyboard",
|
||||||
"err = %d, actual = %d report: 0x%02x 0x%02x 0x%02x 0x%02x"
|
"err = %d, actual = %d report: 0x%02x 0x%02x 0x%02x 0x%02x"
|
||||||
|
@ -419,9 +431,13 @@ grub_usb_keyboard_checkkey (struct grub_term_input *term)
|
||||||
if (data[2] > ARRAY_SIZE (usb_to_at_map) || usb_to_at_map[data[2]] == 0)
|
if (data[2] > ARRAY_SIZE (usb_to_at_map) || usb_to_at_map[data[2]] == 0)
|
||||||
grub_printf ("Unknown key 0x%02x detected\n", data[2]);
|
grub_printf ("Unknown key 0x%02x detected\n", data[2]);
|
||||||
else
|
else
|
||||||
termdata->key = grub_term_map_key (usb_to_at_map[data[2]],
|
{
|
||||||
interpret_status (data[0])
|
termdata->last_key = termdata->key
|
||||||
| termdata->mods);
|
= grub_term_map_key (usb_to_at_map[data[2]],
|
||||||
|
interpret_status (data[0]) | termdata->mods);
|
||||||
|
termdata->repeat_time = grub_get_time_ms ()
|
||||||
|
+ GRUB_TERM_REPEAT_PRE_INTERVAL;
|
||||||
|
}
|
||||||
|
|
||||||
grub_errno = GRUB_ERR_NONE;
|
grub_errno = GRUB_ERR_NONE;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue