- outputf("Injecting key");
- /* Actually do the inject. */
- outb(0x64, 0xD2); /* "Inject, please!" */
- while (inb(0x64) & 0x02) /* Busy? */
- ;
- outb(0x60, kbd_get_injected_scancode()); /* data */
- while (inb(0x64) & 0x02) /* wait for completion */
- ;
+ while (kbd_has_injected_scancode() && !(inb(0x64) & 0x01)) {
+ int i = 1000;
+ outb(0x64, 0xD2); /* "Inject, please!" */
+ while (inb(0x64) & 0x02) /* Busy? */
+ ;
+ outb(0x60, kbd_get_injected_scancode()); /* data */
+ while ((inb(0x64) & 0x02) && i--) /* wait for completion */
+ ;
+ }