Incorrect Keycodes Returned

The PicoCalc returns incorrect keycodes for certain Ctrl-keys. Ctrl-A through Ctrl-Z are handled properly (codes 0x01 - 0x1A) but the other keys aren’t. In the latest PicoMite firmware, PrintScreen responds to Ctrl-\ (code 0x1C) but when Ctrl-\ is pressed on PicoCalc, the \ key is returned (code 0x5C) without the Ctrl modifier.

There are other annoying traits. For instance, shifted left and right return nothing.

Some background that may help, from writing a keyboard handler for a PicoCalc program (a WordStar-style editor).

What I know:

  • The keyboard controller (BIOS 1.7), doesn’t apply Ctrl itself. It reports Ctrl as a key event of its own (code 0xA5, pressed and released), and the same goes for both Shifts (0xA2, 0xA3) and Alt (0xA1). For Ctrl-\ the Pico receives: Ctrl pressed, \ pressed, \ released, Ctrl released.
  • It’s up to the program on the Pico to combine them. In Blair’s picocalc-text-starter keyboard driver, Ctrl is applied only to a–z (if (ch >= 'a' && ch <= 'z') ... ch &= 0x1F), and my editor does the same. That gives exactly the behaviour Toml describes: Ctrl-A to Ctrl-Z work, and Ctrl-\ arrives as a plain \.

What I think, but haven’t checked:

  • PicoMite probably does the same thing, since the symptom matches. I haven’t read its keyboard code. If so, it’s fixable in the firmware: apply Ctrl to the whole range @ through _ (0x40–0x5F, and the lower-case equivalents), so that Ctrl-\ gives 0x1C, Ctrl-] 0x1D, Ctrl-^ 0x1E, Ctrl-_ 0x1F and Ctrl-[ 0x1B (Esc).
  • Shift with left and right is a different case. If nothing at all arrives while Shift is held, as Blair says, then the keyboard controller is dropping those presses before they reach the Pico. No program can recover a key press it never receives, so that one would need a change to the controller’s own firmware. I haven’t tested this myself.
1 Like

Hello,

what is the latest bios for picocalc? I have 1.6 now.

And can somehow solve this ctrl problem? Many of keyboards has no code for ctrl combination.

G@bor

Please I hope this behavior is not ‘fixed’ as zeptoforth on the PicoCalc’s terminal emulators rely on the existing behavior (i.e. reporting control key presses separate from key presses for the other key presses).

Peter has put in a fix for the \ key only. Now Ctrl-\ returns 0x1C. All other Ctrl key combos work the same as before.

I have to second tabemann’s post since WordStar-style editors rely on the same behavior. The \ key fix makes no difference but going further would be bad.

From what I can see, I couldn’t find a clear answer to Gábor’s question about the latest BIOS from a quick search. The forum threads on it are long and scattered, so I wouldn’t name a version as “latest” in reply. I’m running v1.7 for what it’s worth.

Great. I wouldn’t call that a fix at all. The proper way to handle that would be within MMBasic, not within the BIOS.