diff --git a/coreAPI/src/java/net/java/games/input/Mouse.java b/coreAPI/src/java/net/java/games/input/Mouse.java index 8063eac..74301ff 100644 --- a/coreAPI/src/java/net/java/games/input/Mouse.java +++ b/coreAPI/src/java/net/java/games/input/Mouse.java @@ -82,22 +82,55 @@ public abstract class Mouse extends AbstractController { /** * Returns the left or primary mouse button, never null. */ - public Component getLeft() { - return getComponent(Component.Identifier.Button.LEFT); + public Component getPrimaryButton() { + Component primaryButton = getComponent(Component.Identifier.Button.LEFT); + if(primaryButton==null) { + primaryButton = getComponent(Component.Identifier.Button._1); + } + return primaryButton; } /** * Returns the right or secondary mouse button, null if the mouse is * a single-button mouse. */ - public Component getRight() { - return getComponent(Component.Identifier.Button.RIGHT); + public Component getSecondaryButton() { + Component secondaryButton = getComponent(Component.Identifier.Button.RIGHT); + if(secondaryButton==null) { + secondaryButton = getComponent(Component.Identifier.Button._2); + } + return secondaryButton; } /** * Returns the middle or tertiary mouse button, null if the mouse has * fewer than three buttons. */ + public Component getTertiaryButton() { + Component tertiaryButton = getComponent(Component.Identifier.Button.MIDDLE); + if(tertiaryButton==null) { + tertiaryButton = getComponent(Component.Identifier.Button._3); + } + return tertiaryButton; + } + + /** + * Returns the left mouse button. + */ + public Component getLeft() { + return getComponent(Component.Identifier.Button.LEFT); + } + + /** + * Returns the right, null if the mouse is a single-button mouse. + */ + public Component getRight() { + return getComponent(Component.Identifier.Button.RIGHT); + } + + /** + * Returns the middle, null if the mouse has fewer than three buttons. + */ public Component getMiddle() { return getComponent(Component.Identifier.Button.MIDDLE); } diff --git a/plugins/OSX/src/java/net/java/games/input/OSXEnvironmentPlugin.java b/plugins/OSX/src/java/net/java/games/input/OSXEnvironmentPlugin.java index 9ba03a1..cc9289b 100755 --- a/plugins/OSX/src/java/net/java/games/input/OSXEnvironmentPlugin.java +++ b/plugins/OSX/src/java/net/java/games/input/OSXEnvironmentPlugin.java @@ -191,7 +191,7 @@ public final class OSXEnvironmentPlugin extends ControllerEnvironment implements Component[] components_array = new Component[components.size()]; components.toArray(components_array); Mouse mouse = new OSXMouse(device, queue, components_array, new Controller[]{}, new Rumbler[]{}); - if (mouse.getLeft() != null && mouse.getX() != null && mouse.getY() != null) { + if (mouse.getPrimaryButton() != null && mouse.getX() != null && mouse.getY() != null) { return mouse; } else { queue.release(); diff --git a/plugins/linux/src/java/net/java/games/input/LinuxEnvironmentPlugin.java b/plugins/linux/src/java/net/java/games/input/LinuxEnvironmentPlugin.java index 1ad937a..7b90cab 100644 --- a/plugins/linux/src/java/net/java/games/input/LinuxEnvironmentPlugin.java +++ b/plugins/linux/src/java/net/java/games/input/LinuxEnvironmentPlugin.java @@ -193,7 +193,7 @@ public final class LinuxEnvironmentPlugin extends ControllerEnvironment implemen private final static Mouse createMouseFromDevice(LinuxEventDevice device, Component[] components) throws IOException { Mouse mouse = new LinuxMouse(device, components, new Controller[]{}, device.getRumblers()); - if (mouse.getX() != null && mouse.getY() != null && mouse.getLeft() != null) + if (mouse.getX() != null && mouse.getY() != null && mouse.getPrimaryButton() != null) return mouse; else return null; diff --git a/plugins/windows/src/java/net/java/games/input/DirectInputEnvironmentPlugin.java b/plugins/windows/src/java/net/java/games/input/DirectInputEnvironmentPlugin.java index be452bc..5e31bad 100644 --- a/plugins/windows/src/java/net/java/games/input/DirectInputEnvironmentPlugin.java +++ b/plugins/windows/src/java/net/java/games/input/DirectInputEnvironmentPlugin.java @@ -166,7 +166,7 @@ public final class DirectInputEnvironmentPlugin extends ControllerEnvironment im private final Mouse createMouseFromDevice(IDirectInputDevice device) { Component[] components = createComponents(device, true); Mouse mouse = new DIMouse(device, components, new Controller[]{}, device.getRumblers()); - if (mouse.getX() != null && mouse.getY() != null && mouse.getLeft() != null) + if (mouse.getX() != null && mouse.getY() != null && mouse.getPrimaryButton() != null) return mouse; else return null; diff --git a/plugins/windows/src/java/net/java/games/input/RawMouse.java b/plugins/windows/src/java/net/java/games/input/RawMouse.java index e6fc324..57b6cc0 100644 --- a/plugins/windows/src/java/net/java/games/input/RawMouse.java +++ b/plugins/windows/src/java/net/java/games/input/RawMouse.java @@ -128,17 +128,17 @@ final class RawMouse extends Mouse { break; case EVENT_BUTTON_0: event_state = EVENT_BUTTON_1; - if (makeButtonEvent(current_event, event, getLeft(), RawDevice.RI_MOUSE_BUTTON_1_DOWN, RawDevice.RI_MOUSE_BUTTON_1_UP)) + if (makeButtonEvent(current_event, event, getPrimaryButton(), RawDevice.RI_MOUSE_BUTTON_1_DOWN, RawDevice.RI_MOUSE_BUTTON_1_UP)) return true; break; case EVENT_BUTTON_1: event_state = EVENT_BUTTON_2; - if (makeButtonEvent(current_event, event, getRight(), RawDevice.RI_MOUSE_BUTTON_2_DOWN, RawDevice.RI_MOUSE_BUTTON_2_UP)) + if (makeButtonEvent(current_event, event, getSecondaryButton(), RawDevice.RI_MOUSE_BUTTON_2_DOWN, RawDevice.RI_MOUSE_BUTTON_2_UP)) return true; break; case EVENT_BUTTON_2: event_state = EVENT_BUTTON_3; - if (makeButtonEvent(current_event, event, getMiddle(), RawDevice.RI_MOUSE_BUTTON_3_DOWN, RawDevice.RI_MOUSE_BUTTON_3_UP)) + if (makeButtonEvent(current_event, event, getTertiaryButton(), RawDevice.RI_MOUSE_BUTTON_3_DOWN, RawDevice.RI_MOUSE_BUTTON_3_UP)) return true; break; case EVENT_BUTTON_3: