From 7692ade2e5b4c9fe253a60592317a49153df5550 Mon Sep 17 00:00:00 2001 From: "nathan@archer" Date: Sun, 3 Apr 2016 02:11:29 +0100 Subject: [PATCH 1/2] Changed keybinds for hopefully better cross-platform compatibility. --- src/main/java/musicplayer/swingui/PlayerGUI.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/musicplayer/swingui/PlayerGUI.java b/src/main/java/musicplayer/swingui/PlayerGUI.java index 3f42d44..aead2a0 100644 --- a/src/main/java/musicplayer/swingui/PlayerGUI.java +++ b/src/main/java/musicplayer/swingui/PlayerGUI.java @@ -295,10 +295,10 @@ public class PlayerGUI extends JPanel implements PlayerCallbackInterface { private class GlobalKeyboardShortcuts implements NativeKeyListener { boolean modified = false; - final int playPause = 192; - final int stop = 222; - final int previous = 219; - final int next = 221; + final int playPause = NativeKeyEvent.VC_QUOTE; + final int stop = NativeKeyEvent.VC_BACK_SLASH; + final int previous = NativeKeyEvent.VC_OPEN_BRACKET; + final int next = NativeKeyEvent.VC_CLOSE_BRACKET; @Override public void nativeKeyPressed(NativeKeyEvent nativeKeyEvent) { From d3ff04bf9988b77fd1f7140a8908bd5319b89308 Mon Sep 17 00:00:00 2001 From: "nathan@archer" Date: Sun, 3 Apr 2016 02:28:48 +0100 Subject: [PATCH 2/2] Switched to char based key identification. --- src/main/java/musicplayer/swingui/PlayerGUI.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/musicplayer/swingui/PlayerGUI.java b/src/main/java/musicplayer/swingui/PlayerGUI.java index aead2a0..41839da 100644 --- a/src/main/java/musicplayer/swingui/PlayerGUI.java +++ b/src/main/java/musicplayer/swingui/PlayerGUI.java @@ -295,10 +295,10 @@ public class PlayerGUI extends JPanel implements PlayerCallbackInterface { private class GlobalKeyboardShortcuts implements NativeKeyListener { boolean modified = false; - final int playPause = NativeKeyEvent.VC_QUOTE; - final int stop = NativeKeyEvent.VC_BACK_SLASH; - final int previous = NativeKeyEvent.VC_OPEN_BRACKET; - final int next = NativeKeyEvent.VC_CLOSE_BRACKET; + final char playPause = '\''; + final char stop = '#'; + final char previous = '['; + final char next = ']'; @Override public void nativeKeyPressed(NativeKeyEvent nativeKeyEvent) { @@ -316,7 +316,7 @@ public class PlayerGUI extends JPanel implements PlayerCallbackInterface { public void nativeKeyTyped(NativeKeyEvent nativeKeyEvent) { if (modified) { try { - switch (nativeKeyEvent.getRawCode()) { + switch (nativeKeyEvent.getKeyChar()) { case playPause: if (player.isPlaying()) { player.pause();