

Chris has personally written over 2,000 articles that have been read more than one billion times-and that's just here at How-To Geek.

If you want to find the scancode associated with a key, you can use this other program that show you a table with the pressed scancodes (press ESC to exit).įor example, if I press a and d I get the values used in the demoġI create this boot program (intended for NASM) to test my hypothesis, at least in my hardware.Ģ Effectively speaking the repeat feature is useful only in typing software, every other application, like games, that explicitly check for keys status don't need it.ģ There are actually extended (multi byte scancode) but they are ignored here.Chris Hoffman is the former Editor-in-Chief of How-To Geek.

No, restore interrupt so the CPU can process the prending ones Swap the pointer in the IVT for int 15h with the pointer in old_isr_15Ĭli Prevent the ISR from messing things up old_isr_15 is now a far pointer to new_isr_15Ĭall swap_isr_15 Swap the current isr15 with the one in old_isr_15 Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll Ll L StrCommand db "Press 'a' and 'd' to exit", 13, 10, 24h Wait for a change in the scancode tables

Warning Since we are using scancodes, this is keyboard layout dependent! BITS 16 The program below, for NASM, waits for you to press both a and d keys to exit. It is also useful keep a count of the processed scancodes, so a program can wait for new scancodes with trivial arithmetic. We can have an array of 128 bytes, each for any possible scancode value ( bit0-6) 3 and store in each element 0ffh if the scancode indicates a press or 00h if it indicates a release. We can intercept that interrupt and check if the scancode is for a key down or a key up. Without explaining how the 8259A and the IRQ mapping works, it's enough to say that the interrupt 15h/AH=4fh is called with the scancode in AL when a key is pressed/released. While the 8042 chip is very simple, there is not need to get dirty with IO instruction. The only solution is handling scancode directly. I cannot find any interrupt service that handle key up and down events.
#ANDROID DOSBOX KEY PRESS REPEAT SOFTWARE#
The software can thus tell when a key is down without further notice from the keyboard 2. The trick is that the keyboard sends two codes ( scancodes) when a key is pressed: one when the key goes down (and many others while it is kept down) and one when it is released. However the software handle multiple keys at once everywhere, how do they do it? It seems that from an hardware perspective the keyboard repeats only the last pressed key 1, so if two players are pressing two keys, only one is actually sent by the keyboard. I also know you write for TASM but I forgot that and started with NASM, converting however should be very easy (just add segments declarations, take out the segment register from the brackets and add PTR). So I'm writing this in the hope that, if not you, some other troubled coder can find something useful. I know this is not the simple, drop-in, solution you were looking for but I'm afraid there is none.
