Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard #1060

Merged
merged 9 commits into from
Feb 2, 2015
Merged

Keyboard #1060

merged 9 commits into from
Feb 2, 2015

Conversation

DanielSWolf
Copy link
Contributor

This pull request brings much more robust keyboard handling.

  • It introduces an authoritative list of key codes for all hosts. So instead of writing if key == 338, you can now write if key == MOAIKeyCode.UP and be sure it'll work on all hosts and platforms with keyboard support. Before, that key produced 38 using the HTML host, 338 using SDL, and didn't work at all using GLUT on Windows.
  • Wherever possible, the new key codes are backwards compatible: All characters keys are still mapped to their respective ASCII codes.
  • The new key codes are based on Microsoft's virtual key codes, so they should work on any keyboard layout, not just US.
  • Text input wasn't really possible until now. Depending on the keyboard layout, the same key can produce dozens of different characters. Existing code hat to hard-code logic for the US keyboard that would fail on any other layout. Now there is an additional keyboard event that gives you actual Unicode characters.
  • I've included a sample at samples/input-text that shows a fully editable textbox, complete with cursor navigation. It works on any keyboard layout and is fully Unicode-compatible.

editor

This pull request is based on this forum discussion: [WIP CONTRIB] Proposal for robust keyboard handling.

This will make key events from all hosts compatible.
Also did some refactoring.
Also removed AKUEnqueueKeyboard*Event functions that are now superfluous
Existing text input code relied on knowing the layout of US keyboards and didn't work on non-US keyboards.
Now there's a dedicated keyboard event that delivers UTF-8-encoded characters on any keyboard.
Made sure the Chrome host compiles. It will still send incorrect key codes, though. See code comment.
@halfnelson
Copy link
Contributor

Rest looks good. Since this is a change of feature instead of new functionality or bug fixes, I think I will let @patrickmeehan merge it but LGTM 👍 Thanks for the contribution!

patrickmeehan pushed a commit that referenced this pull request Feb 2, 2015
@patrickmeehan patrickmeehan merged commit 0e54385 into moai:develop Feb 2, 2015
@DanielSWolf DanielSWolf deleted the keyboard branch March 7, 2015 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants