-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Whether the key variable is set to CODED or not is inconsistent between the default renderer and P2D/P3D #376
Comments
Created by: benfry Thanks for looking into it and the thorough writeup. Will try this out when I have a moment and see about getting it into the next release. |
Created by: ChristopherCanfield Thank you! |
Created by: benfry Thanks again, just merged your suggestions in for beta 6; we'll see how it goes! |
Created by: ChristopherCanfield Thank you for implementing this! |
Created by: github-actions[bot] This issue has been automatically locked. To avoid confusion with reports that have already been resolved, closed issues are automatically locked 30 days after the last comment. Please open a new issue for related bugs. |
Created by: ChristopherCanfield
Description
Under the default renderer, when a non-printable key is pressed, the
key
variable is set toCODED
(0xffff). The sketch developer can then check the keyCode variable against one of the Processing key code constants (UP
/DOWN
/LEFT
/RIGHT
/ALT
/CONTROL
/SHIFT
), or against thejava.awt.event.KeyEvent
constants if other key codes are needed (e.g., Function keys). This behavior matches the keyCode reference documentation.When using the JOGL renderers (P2D/P3D), the
key
variable is correctly set toCODED
when one of the seven keys above are pressed, or when the Windows key is pressed. However, pressing any other non-printable key sets thekey
variable to zero, rather thanCODED
, which differs from the behavior of the default renderer and the keyCode documentation (though the documentation does warn about differences between platforms). ThekeyCode
variable is correctly set to the NEWT key code, though.While this is very minor, this difference in whether
key
is set toCODED
or not is a bit confusing at first, especially if a Processing user starts with the default renderer, and then switches to the P2D/P3D renderer as they gain more knowledge.Expected Behavior
Whether the
key
variable is set toCODED
or not should be consistent between the default renderer and the P2D/P3D renderers. All other behavior, such as the differences inkeyCode
values between renderers, remains the same as before.Current Behavior / Steps to Reproduce
size(1280, 720, P2D)
;The difference between renderers for
keyCode
is expected and documented, but the difference for whetherkey
is set toCODED
or not is not expected.Your Environment
Possible Causes / Solutions
One low-impact way to make the
key == CODED
behavior consistent between the three core renderers, while keeping all other behavior the same as before, is to edit four lines in PSurfaceJOGL.java:PsurfaceJOGL.isPCodedKey
private static method (line 1109), add a second parameter for whether the key is a printable key:nativeEvent.isPrintableKey()
toisPCodedKey(short, boolean)
in two locations, and remove the isHackyKey check in one location, since it would now duplicate the check within isPCodedKey:With these changes, the five hacky keys (backspace, tab, enter, escape, and delete) work the same as before, as do the seven key constants listed above in the first section. And the CODED functionality becomes consistent between the default renderer and P2D/P3D.
Thank you for considering this, and for your work on Processing. I’ve been using it to make fun projects with my six year-old son for the past month, after using it for personal projects for years, and he loves it.
Chris Canfield
The text was updated successfully, but these errors were encountered: