Possible slow KDMMIO input update issue
Closed this issue · 6 comments
I wrote a code that prints 1
if an specific key is down and 0
if not.
When reading KDMMIO input every 16ms holding the specific key, that's the output:
101010101010101010101010101010101101011010101001010101010101101010
As you can see, there's a lot of rogue 0s in the output, and in some cases there are two 0s in sequence.
As I'm holding the key, the output should be only 1s.
When reading it every 32ms, I get a better output (but there are still some 0s):
111111111011111111111110111111111111111111111111111111111111111111
I was under the impression that the KDMMIO_Ctrl bit was reset every time you read it, like a "there's a new keydown event" bit instead of a "there's a pressed key" bit. That's why you see this behavior. I'll work on it soon.
Thanks again for the reports :)
Actually, I'm not sure what the behavior should be... I looked at it again and I'm pretty sure RARS only resets the KDMMIO_Ctrl (0xff200000
) bit if you read the KDMMIO_Data (0xff200004
). This is what's currently implemented in FPGRARS, but I found this in the FPGA implementation docs:
3) Compatibilidade com o Keyboard Display MMIO Tool do Rars
- O endereço KDMMIO_Ctrl possui no seu bit menos significativo a informação se há ou não uma tecla pressionada.
- O endereço KDMMIO_Data possui o código ASCII da tecla pressionada. Permitindo assim a detecção do pressionamento
de uma tecla de cada vez.
I guess it's a lot easier to work with the "there's a pressed key" bit, but implementing this might break some programs that never read from KDMMIO_Data...
Any suggestions? Also, does your program output 1111111111111
in RARS?
Ok, I tested the input code separately on RARS and the output was 10101010
. In my previous test the output was 11111111
probably cause RARS is slow and the code was not tested individually.
So it seems that's the default behavior.
I think this issue should be closed, since the problem is not related to this project.
Maybe we can have the best of both worlds? I can make a KDMMIO_KEYDOWN
bit that is set iff the current key is pressed, maybe at 0xff210000
, then duplicate KDMMIO_DATA
at 0xff210004
. This way, you can have FPGA behavior or RARS behavior at the change of 1 bit. Programs made for FPGRARS wouldn't work at all in other platforms, but you could change 21
to 20
to make them work again
If implementing a KDMMIO_KEYDOWN
bit is simple, I think it would be a great idea.
I don't like the idea of something only working in FPGRARS, but in this case I think it would be helpful.
Simple enough. I should write some documentation for this...