I looked into SDL_TextInputEvent, it doesn’t fit with the way the frame loop works. I’d have to do some major kludging to make it work. Keyboards are a mess. A few weeks ago on Twitter, John Blow was ranting about how fucked up it was. Oh well…
The numpad works now, but I have to say, it’s a little confusing due to how the phone and keyboard keypads are flipped. I’m not sure I’m going to leave it in.
Do you see the buttons being pushed at the same time you push on the keyboard? I can imagine, why this might be confusing but I´m not sure if I will be looking at the screen at the same time I enter the numbers on the keyboard, I can´t be certain until I´ve tried it.
Is this the reasons you cannot use all kind of keys in the settings file?
What about allowing (additionally) using scancodes in the settings file, e.g. when 0x prefix is used or when it’s more than 1 character assume scancode.
That’s fine! I can’t stand the phone layout anyway because of this flipping around.
Oh, and will there be a rotary dial DLC later with VR controller support?
That surprises me too. I haven’t worked with SDL for a while, but I will dig into this when I have some spare time. It works in other games and I am pretty sure I got that working the last time I did stuff with SDL…
[quote=“RonGilbert, post:1, topic:718”]
Since we’re doing a update in the next few weeks/month, are there any UI/keyboard/mouse changes you’d like to see?
[/quote]There is one thing Day of the Tentacle handles slightly more comfortable:
If you left click on an item in the inventory, “use” is selected automatically. If you right click, you “look at” it. That way, both mouse buttons have useful default verbs in the inventory.
And some cosmetic detail in Day of the Tentacle and most later LucasArts adventures: When use is selected on an item which needs to be combined, the mouse cursor turns into the item’s icon.
That seems a work for SDL_TextInputEvent, that handles all the mapping and gives you the UTF-8 chars. But it seems that you already had a look at it. What’s the issue?
With the latter method you have to handle @ and other special keys yourself. But it produces the letter Z on a QWERTZ and a QWERTY keyboard.
If both won’t work, you have to use a Unicode library, I have to fear. Another solution would be to allow the players to change the keyboard mapping in the game options with some mouse clicks. But that would be additional work of course…
/edit: “e.key.keysym.sym” is a value that you can compare with the SDL_Keycode constants (https://wiki.libsdl.org/SDL_Keycode). The conversion to a string in the example on this site: https://wiki.libsdl.org/SDL_Keycode is done only to print the character on the screen. The value in “e.key.keysym.sym” is (in most cases/on most systems) the Unicode value of the corresponding key. So you can even do:
if(e.key.keysym.sym == 0x31) // then the key with the number 1 is pressed (1 in Unicode is hex 0x31 or decimal 49)
e.text.text saves a Unicode value too. So you don’t have to compare or convert a string.
If it still doesn’t work for you, just let me know (if possible with a short description of the problems). I will try to find another way or a workaround.
As far as I understand it, SDL_TEXTINPUT events are really meant for typing stuff into a textfield or such, and need to be specifically enabled with SDL_StartTextInput. Can’t image that this is what you’ll want.
key.keysym.sym will give the unmodified key based on the users keyboard layout, but if you’re actually interested in knowing when something like “@” or other special symbols were typed, this won’t help you much. The data for the SDL_TEXTINPUT event is directly retrieved from the OS-specifc input events, so there’s no a way to derive that from pure SDL keypress events.
Uppercase/lowercase letters should be fine, though, by taking the modifier key state into account. Still a bit tricky, when capslock comes into play.
I guess if this wouldn’t be time critical, you could drop a few lines over at https://discourse.libsdl.org/. Ryan and Sam are helpful enough and perhaps a solution could be worked out. Though I assume it will be a matter of months, or longer, if code changes are involved.
This was my experience when I first tried to around a year ago. I might pop over to the SDL forums. My guess is there is no way to do this, otherwise it would be documented.
No, you can use SDL_TEXTINPUT events without SDL_StartTextInput. The latter one is only needed to turn explicitly on and of the SDL_TEXTINPUT event (for example if you want to offer a text input field or an editor). My code posted above works.
You just want to know when particular keys are pressed.
Answer) Use scancodes, and allow the user to remap keys whenever they want.
You want Unicode.
Answer) Use the text-editing events, because that’s the only way that
you can get all Unicode characters.
You want to know when keys that map directly to Unicode are pressed.
Answer) Use keycodes, checking the high bit to determine if it carries
a Unicode value or a scancode value.