Skip to content

Keyboard input problem for games #23

@tanoxyz

Description

@tanoxyz

Hi!
I was trying to use the CPC emulator to bundle a web version of a game I made, but I've noticed that there is a problem with the input handling. Maybe you already know about this problem and that there is no clear solution .

The problem

In

case SAPP_EVENTTYPE_CHAR:
you check most keys in the keyboard from char events, as they don't specify key down/up, the key up and down event are sent in the same frame. This seems mostly fine on the default CPC's firmware but some games may need to hold the key for more than 1 frame, for example our game's jump height varies based on how long you have been pressing the key. Our game
I suppose that you did it that way in order to map any keyboard layout to the original, for example on the CPC's case the symbol " is on the Key 2 but on today's keyboards it may vary.

Solutions?

For our game, I've ignored the char events from A to Z and used the usual key down/up events to detect them, code here. But a more robust solution would be to just map the all key up/down events to the original keyboard's position. Although some keys won't match in some keyboards, it will be the "real position", in Retro Virtual Machine works that way.
We can also add a toggle to change the layout to "physically correct" or not.

Thanks for these emulators by the way!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions