Clearing the keyboard buffer

bbc micro/electron/atom/risc os coding queries and routines
Post Reply
emiliom
Posts: 39
Joined: Mon Dec 04, 2023 6:05 pm
Contact:

Clearing the keyboard buffer

Post by emiliom »

I can't seem to get either *FX15 or *FX20 to correctly flush the keyboard buffer. Basically I allow the user to press Q to quit out of machine code and return to a BASIC program that called it, and then the BASIC program has a few options, one of which is also Q for quit, so I've tried putting in the *FX command just after the machine code call statement so that I don't get the code quitting out of BASIC just because I pressed Q in the machine code program. But that's exactly what happens. Sometimes it doesn't, but more than half the time it quits straight to BASIC. Doing a bit of testing just in BASIC I can see that flushing the buffer seems to generally flush everything except the last character, although sometimes the last character pressed also doesn't appear so seems successfully flushed. It seems to be a bit hit and miss.

I'm not holding down the key for an excessive length of time, just the same as when I'm typing, and I don't get multiple characters appearing when I type so I'm not sure why this happens. I can 'fix' it by creating a short delay before I flush the buffer, but this doesn't seem right. If it's flushed, it should be flushed.

Can anyone tell me what I'm doing wrong, or suggest a method that works consistently?
User avatar
tricky
Posts: 7695
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Clearing the keyboard buffer

Post by tricky »

I wonder if it is affected by the auto repair delay or rate.
Post Reply

Return to “programming”