[C-API] Get User Input?

Is there a standard way to get string input from the user in C?
No versions of the lua playdate.keyboard routines seem to exist in the C-API.

I would rather not invest a heap of time into writing something that will just be replaced later.

My use-case is just getting a user-name for the high-score table.

1 Like

Your top level eventHandler() will get kEventKeyPressed, kEventKeyReleased messages. You’ll have to build your own system from there.

I notice that it provides a keycode. I haven’t used the Playdate keyboard input yet, but if this works like libSDL, you may have to map this to a letter if you want text.

These events only works in the simulator:

When an arbitrary key is pressed or released in the simulator this function is called with event set to kEventKeyPressed or kEventKeyReleased and the keycode of the key in the arg argument.

Someone said he wanted to port the Lua keyboard to C but not sure if it was released or not.

Edit: I was thinking about this post from @fzzr

1 Like

I thought I read that the mirror app provides key presses as well for accessibility purposes. But I can’t find any reference to this and could be hallucinating.

Update: I tested it in Mirror. It does not pass through keystrokes.

That's a start, however it's important to handle all the language localisation stuff. It's pretty simple for Latin based input, even handling the extra umlauts, accents, etc.

But I can't imagine knowing how to combine say Japanese hiragana input and mapping that to Kanji. Then there's cultures that write right->left, etc. etc. Once you scratch the surface, it's a big can-o-worms.

I guess we could start an open-source input module.

Honestly, I expected there to be a widget/control for this already.