ColinPitrat / caprice32

An emulator of the Amstrad CPC 8bit home computer range.
GNU General Public License v2.0
147 stars 32 forks source link

cannot generate SHIFT+CONTROL+<any key> and CONTROL+<arrow> events #230

Open polijan opened 2 years ago

polijan commented 2 years ago

I was using some CPC software that expected CTRL + arrow keys. Unfortunately, I'm not able to generate such keyboard events in Caprice32. I do not believe this is an issue with my keymap.

I also realized any press of SHIFT+CONTROL+ is also not generating anything.

The virtual keyboard is also not able to help me.


The following BASIC program might be useful to check the control+ issue:

10 IF INKEY(0)<>128 THEN 10:' press ctrl+up arrow to exit

The following BASIC program might be useful to check the control+shift+ issue:

10 IF INKEY(55)<>160 THEN 10:' press shift+ctrl+v to exit
ColinPitrat commented 2 years ago

Yeah that's #151. I added support for CTRL + cursor.

It's easy to add more combinations but I'm not sure the path I chose for #151 is the right way to support all of them.

The keyboard handling has basically three layers:

Control and shift are considered as modifiers in SDL key code and are also considered as modifiers in CPC key codes, but not in Caprice translation layer in-between. The reason for that is that depending on the keyboard, you may have to type a modifier on the host to get a non-modified CPC key (e.g. ':' requires typing shift on a modern keyboard but didn't on a CPC).

This means that however we support it, as long as we use logical mapping[1] rather than physical mapping[2], some key combinations won't be possible (e.g. SHIFT+':').

I'll keep #151 to support more key combinations. Add some info there if you need some. I'd need to do some redesign (e.g. allow includes in keymap, have a single entry fully filled in cpc_kbd with only the differences being patched for fr & es) to make things a bit easier.

[1] what you type on your host keyboard is what the CPC receives in input. For example you type ':', the CPC receives ':' [2] the key you type on you keyboard is mapped to a CPC key based on it's position on the keyboard, not what it actually corresponds to. For example, you type the key right to L (';' on a QWERTY keyboard) to type a ':' on the CPC.