[PATCH] 8182572 Numpad keys not working with JavaFX Monocle

Milan Fabian mimac2 at gmail.com
Wed Sep 20 16:34:53 UTC 2017


I have prepared patch (attached) for bug JDK-8182572 (http://bugs.java.com/
bugdatabase/view_bug.do?bug_id=JDK-8182572). The keys on numpad are now
correctly mapped to KeyEvents.

The patch was tested on Raspberry Pi with various builds OpenJDK 8 and
various keyboards. I don't have any other device which supports Monocle, if
anybody has such device, I would be glad if you could test it on it as well.

As this is my first patch submitted to OpenJDK, is there anything else I
should add?

Best Regards
Milan Fabian
-------------- next part --------------
diff --git a/modules/graphics/src/main/java/com/sun/glass/ui/monocle/LinuxKeyProcessor.java b/modules/graphics/src/main/java/com/sun/glass/ui/monocle/LinuxKeyProcessor.java
--- a/modules/graphics/src/main/java/com/sun/glass/ui/monocle/LinuxKeyProcessor.java
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/monocle/LinuxKeyProcessor.java
@@ -76,6 +76,16 @@
         } else if (linuxKeyCode >= LinuxInput.KEY_F13 && linuxKeyCode <= LinuxInput.KEY_F24) {
             return linuxKeyCode - LinuxInput.KEY_F13 + KeyEvent.VK_F13;
         } else switch (linuxKeyCode) {
+            case LinuxInput.KEY_KP0: return KeyEvent.VK_NUMPAD0;
+            case LinuxInput.KEY_KP1: return KeyEvent.VK_NUMPAD1;
+            case LinuxInput.KEY_KP2: return KeyEvent.VK_NUMPAD2;
+            case LinuxInput.KEY_KP3: return KeyEvent.VK_NUMPAD3;
+            case LinuxInput.KEY_KP4: return KeyEvent.VK_NUMPAD4;
+            case LinuxInput.KEY_KP5: return KeyEvent.VK_NUMPAD5;
+            case LinuxInput.KEY_KP6: return KeyEvent.VK_NUMPAD6;
+            case LinuxInput.KEY_KP7: return KeyEvent.VK_NUMPAD7;
+            case LinuxInput.KEY_KP8: return KeyEvent.VK_NUMPAD8;
+            case LinuxInput.KEY_KP9: return KeyEvent.VK_NUMPAD9;
             case LinuxInput.KEY_0: return KeyEvent.VK_0;
             case LinuxInput.KEY_A: return KeyEvent.VK_A;
             case LinuxInput.KEY_B: return KeyEvent.VK_B;
@@ -110,7 +120,9 @@
             case LinuxInput.KEY_CAPSLOCK: return KeyEvent.VK_CAPS_LOCK;
             case LinuxInput.KEY_TAB: return KeyEvent.VK_TAB;
             case LinuxInput.KEY_GRAVE: return KeyEvent.VK_BACK_QUOTE;
+            case LinuxInput.KEY_KPMINUS:
             case LinuxInput.KEY_MINUS: return KeyEvent.VK_MINUS;
+            case LinuxInput.KEY_KPPLUS: return KeyEvent.VK_PLUS;
             case LinuxInput.KEY_EQUAL: return KeyEvent.VK_EQUALS;
             case LinuxInput.KEY_BACKSPACE: return KeyEvent.VK_BACKSPACE;
             case LinuxInput.KEY_LEFTBRACE: return KeyEvent.VK_BRACELEFT;
@@ -119,7 +131,9 @@
             case LinuxInput.KEY_SEMICOLON: return KeyEvent.VK_SEMICOLON;
             case LinuxInput.KEY_APOSTROPHE: return KeyEvent.VK_QUOTE;
             case LinuxInput.KEY_COMMA: return KeyEvent.VK_COMMA;
+            case LinuxInput.KEY_KPDOT:
             case LinuxInput.KEY_DOT: return KeyEvent.VK_PERIOD;
+            case LinuxInput.KEY_KPSLASH:
             case LinuxInput.KEY_SLASH: return KeyEvent.VK_SLASH;
             case LinuxInput.KEY_LEFTALT:
             case LinuxInput.KEY_RIGHTALT: return KeyEvent.VK_ALT;
@@ -127,6 +141,7 @@
             case LinuxInput.KEY_RIGHTMETA: return KeyEvent.VK_COMMAND;
             case LinuxInput.KEY_SPACE: return KeyEvent.VK_SPACE;
             case LinuxInput.KEY_MENU: return KeyEvent.VK_CONTEXT_MENU;
+            case LinuxInput.KEY_KPENTER:
             case LinuxInput.KEY_ENTER: return KeyEvent.VK_ENTER;
             case LinuxInput.KEY_LEFT: return KeyEvent.VK_LEFT;
             case LinuxInput.KEY_RIGHT: return KeyEvent.VK_RIGHT;
@@ -141,6 +156,7 @@
             case LinuxInput.KEY_NUMLOCK: return KeyEvent.VK_NUM_LOCK;
             case LinuxInput.KEY_ESC: return KeyEvent.VK_ESCAPE;
             case LinuxInput.KEY_NUMERIC_STAR: return KeyEvent.VK_MULTIPLY;
+            case LinuxInput.KEY_KPASTERISK: return KeyEvent.VK_ASTERISK;
             default: return KeyEvent.VK_UNDEFINED;

More information about the openjfx-dev mailing list