{"action":"created","issue":{"url":"https://api.github.com/repos/libgdx/libgdx/issues/2524","repository_url":"https://api.github.com/repos/libgdx/libgdx","labels_url":"https://api.github.com/repos/libgdx/libgdx/issues/2524/labels{/name}","comments_url":"https://api.github.com/repos/libgdx/libgdx/issues/2524/comments","events_url":"https://api.github.com/repos/libgdx/libgdx/issues/2524/events","html_url":"https://github.com/libgdx/libgdx/issues/2524","id":47281962,"number":2524,"title":"LwjglInput numeric keyboard keycode mismatches","user":{"login":"ghost","id":10137,"avatar_url":"https://avatars3.githubusercontent.com/u/10137?v=4","gravatar_id":"","url":"https://api.github.com/users/ghost","html_url":"https://github.com/ghost","followers_url":"https://api.github.com/users/ghost/followers","following_url":"https://api.github.com/users/ghost/following{/other_user}","gists_url":"https://api.github.com/users/ghost/gists{/gist_id}","starred_url":"https://api.github.com/users/ghost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ghost/subscriptions","organizations_url":"https://api.github.com/users/ghost/orgs","repos_url":"https://api.github.com/users/ghost/repos","events_url":"https://api.github.com/users/ghost/events{/privacy}","received_events_url":"https://api.github.com/users/ghost/received_events","type":"User","site_admin":false},"labels":[{"id":119244972,"url":"https://api.github.com/repos/libgdx/libgdx/labels/desktop","name":"desktop","color":"eb6420","default":false},{"id":11336982,"url":"https://api.github.com/repos/libgdx/libgdx/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2014-10-30T15:12:46Z","updated_at":"2018-03-05T15:24:25Z","closed_at":"2016-08-07T01:20:35Z","author_association":"NONE","body":"Current implementation has one serious flaw: while it allows to easily recognize numpad 0-9, and + \\* keys, as well as NumLock (named Num in Keys class for some reason), it makes it completely impossible to distinguish numpad Enter, slash, minus and period from regular one - and this distinction is quite important in many games. It wouldn't be a problem for KeyTyped, but it certainly is bad for KeyDown, as it breaks the \"one key, one keycode\" principle - I know it's not the case in 100%, but at least POLA requires to try to stick to it, and it _does_ work for every other key on my keyboard, with exception of those unlucky two.\n\nLWJGL offers this possibility natively, and since desktop is IMO actually the only platform that should get this correction, I reckon it shouldn't break any compatibility whatsoever. The outline of my proposal is as follows:\n\n_com.badlogic.gdx.Input.java_, _Keys_ class\n\n``` java\n        public static final int NUMPAD_9 = 153;\n```\n\nchanged to \n\n``` java\n        public static final int NUMPAD_9 = 153;\n\n        public static final int NUMPAD_DIVIDE = 154;\n        public static final int NUMPAD_MULTIPLY = 155;\n        public static final int NUMPAD_SUBTRACT= 156;\n        public static final int NUMPAD_ADD = 157;\n        public static final int NUMPAD_DOT = 158;\n        public static final int NUMPAD_COMMA= 159;\n        public static final int NUMPAD_ENTER = 160;\n\n        public static final int NUMLOCK = NUM; // to keep the backward compatibility but offer a more \"regular\" name, as per http://en.wikipedia.org/wiki/Num_lock\n```\n\nand to _com.badlogic.gdx.backends.lwjgl.LwjglInput.java_\nin _getGdxKeyCode()_\n\n``` java\ncase Keyboard.KEY_NUMLOCK:\nreturn Input.Keys.NUMLOCK;\ncase Keyboard.KEY_DECIMAL:\nreturn Input.Keys.NUMPAD_DOT;\ncase Keyboard.KEY_DIVIDE:\nreturn Input.Keys.SLASH;\ncase Keyboard.KEY_LMETA:\nreturn Input.Keys.SYM;\ncase Keyboard.KEY_RMETA:\nreturn Input.Keys.SYM;\ncase Keyboard.KEY_NUMPADEQUALS:\nreturn Input.Keys.EQUALS;\ncase Keyboard.KEY_AT:\nreturn Input.Keys.AT;\ncase Keyboard.KEY_EQUALS:\nreturn Input.Keys.EQUALS;\ncase Keyboard.KEY_NUMPADCOMMA:\nreturn Input.Keys.COMMA;\ncase Keyboard.KEY_NUMPADENTER:\nreturn Input.Keys.ENTER;\n```\n\nto\n\n``` java\ncase Keyboard.KEY_NUMLOCK:\nreturn Input.Keys.NUMLOCK;\ncase Keyboard.KEY_DECIMAL:\nreturn Input.Keys.NUMPAD_DOT;\ncase Keyboard.KEY_DIVIDE:\nreturn Input.Keys.SLASH;\ncase Keyboard.KEY_LMETA:\nreturn Input.Keys.SYM;\ncase Keyboard.KEY_RMETA:\nreturn Input.Keys.SYM;\ncase Keyboard.KEY_NUMPADEQUALS:\nreturn Input.Keys.EQUALS;\ncase Keyboard.KEY_AT:\nreturn Input.Keys.AT;\ncase Keyboard.KEY_EQUALS:\nreturn Input.Keys.EQUALS;\ncase Keyboard.KEY_NUMPADCOMMA:\nreturn Input.Keys.NUMPAD_COMMA;\ncase Keyboard.KEY_NUMPADENTER:\nreturn Input.Keys.NUMPAD_ENTER;\n```\n\nand (in _getLwjglKeyCode()_)\n\n``` java\ncase Input.Keys.NUMPAD_9:\nreturn Keyboard.KEY_NUMPAD9;\n```\n\nto\n\n``` java\ncase Input.Keys.NUMPAD_9:\nreturn Keyboard.KEY_NUMPAD9;\ncase Input.Keys.NUMPAD_ENTER:\nreturn Keyboard.KEY_NUMPADENTER;\ncase Input.Keys.NUMPAD_DOT:\nreturn Keyboard.KEY_DECIMAL;\ncase Input.Keys.NUMPAD_COMMA:\nreturn Keyboard.KEY_NUMPADCOMMA;\n```\n\nand so on for other numpad keys (/ and, possibly, + - *)\n\nPS. Is changing current case-based key matching to map-based one sensible? AFAIK Java does that internally for big switch/case blocks in newest versions, but counting on that for Java 6 is a bit far-fetched IMO (and I don't know if Delvik is doing that at all); I use LwjglInput changed to map-based keycode translation myself, so if you consider this change sensible I'll gladly contribute the code. It shortens the keycode translation code in half, BTW.\n"},"comment":{"url":"https://api.github.com/repos/libgdx/libgdx/issues/comments/370454188","html_url":"https://github.com/libgdx/libgdx/issues/2524#issuecomment-370454188","issue_url":"https://api.github.com/repos/libgdx/libgdx/issues/2524","id":370454188,"user":{"login":"CreamyCookie","id":3063858,"avatar_url":"https://avatars2.githubusercontent.com/u/3063858?v=4","gravatar_id":"","url":"https://api.github.com/users/CreamyCookie","html_url":"https://github.com/CreamyCookie","followers_url":"https://api.github.com/users/CreamyCookie/followers","following_url":"https://api.github.com/users/CreamyCookie/following{/other_user}","gists_url":"https://api.github.com/users/CreamyCookie/gists{/gist_id}","starred_url":"https://api.github.com/users/CreamyCookie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CreamyCookie/subscriptions","organizations_url":"https://api.github.com/users/CreamyCookie/orgs","repos_url":"https://api.github.com/users/CreamyCookie/repos","events_url":"https://api.github.com/users/CreamyCookie/events{/privacy}","received_events_url":"https://api.github.com/users/CreamyCookie/received_events","type":"User","site_admin":false},"created_at":"2018-03-05T15:24:25Z","updated_at":"2018-03-05T15:24:25Z","author_association":"CONTRIBUTOR","body":"@NathanSweet Sorry, I thought this was fixed because the pull request #2592 was closed, but looking at it now, it apparently wasn't merged for reason, only closed. Again, I want to apologize for any inconvenience I may have caused. Please re-open this issue.\r\n\r\n@Tom-Ski Do you know why #2592 was closed at the time? There was no explanation given on that pull request. "}}
{"actor":{"display_login":"CreamyCookie"}}