pdjstone / archimedes-live

An Acorn Archimedes running live in your browser!
22 stars 4 forks source link

Chrome keyboard mapping is "incorrect" #2

Open pdjstone opened 1 year ago

pdjstone commented 1 year ago

The Archimedes ' key (" with shift) on Chrome maps to ` / ~. This particularly causes a problem in games where the controls are Z X / ". On Firefox it maps to ' (or @ with shift) which seems more correct. The keyboard mappings should least be consistent between browsers.

pdjstone commented 1 year ago

Using this key event tester, I can see that for the ' key (which is just above / on my keyboard and next to the right shift key), Firefox gives keyCode 222, but Chrome gives 192. JSBeeb has some overrides to deal with this problem.

The Emscripten SDL key handling code has a map of SDL to browser key codes. I'm not sure how easy it would be to override this at the SDL level.

It might be better to bypass the SDL key handling code altogether and have some Javascript to directly alter the key array in input_sdl2.c. This would avoid the browser > SDL > Archimedes key translation.

pdjstone commented 1 year ago

SDL event handling can be disabled like this: https://github.com/emscripten-core/emscripten/issues/3621#issuecomment-230153130

The mapping of host platform keys to Archimedes keys is currently done with defines. It would probably be better to do this with an initialisation function so it can be configured from JavaScript.