mirror of
https://github.com/shadowfacts/jinput-arm64.git
synced 2026-01-16 21:50:55 +01:00
Make the API docs and the code match for the Mouse.get<button> methods. Add the methods that we actually wanted to be there.
This commit is contained in:
parent
10214031df
commit
fd2a1b073d
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue