wiiremotej
Class ButtonMap

java.lang.Object
  extended by wiiremotej.ButtonMap
Direct Known Subclasses:
ButtonKeyMap, ButtonMouseMap, ButtonMouseWheelMap

public class ButtonMap
extends java.lang.Object

Maps a button on the remote or an extension to one or more actions. ButtonMaps are immutable (as far as the user is concerned). Note that if you specify both extension buttons and Wii remote buttons, both sets of buttons must be depressed for the action(s) to occur. See WRButtonEvent for Wii remote buttons, WRNunchuckEvent for nunchuk buttons, WRGuitarExtensionEvent for Wii guitar buttons, and WRClassicControllerEvent for classic controller buttons. You may map to a device that is not enabled, but maps to a disabled device will do nothing until the device is enabled, at which point they will function normally. See java.awt.KeyEvent for key map options (any of the VK_ constants are acceptable). The order the keys are pressed and released is determined by their order in the array. It is the user's responsibility to make sure valid keys are entered. If invalid keys are entered, no exception will be thrown until the map is triggered, at which point errors will be generated. See java.awt.InputEvent for mouse button map options. Only InputEvent.BUTTON1_MASK, InputEvent.BUTTON2_MASK, and InputEvent.BUTTON3_MASK are valid mouse buttons. If you map a mouse wheel, note that you have two options: push-to-scroll, and hold-to-scroll. In the former, the button must be pressed and released each time to scroll the scroll amount. In the latter, the button may be held down. The wheel will scroll the scroll amount once per scroll interval (milliseconds).

See Also:
WRButtonEvent, WRNunchukExtensionEvent, WRClassicControllerExtensionEvent

Field Summary
static int CLASSIC_CONTROLLER
          Indicates the classic controller extension.
static int GUITAR
          Indicates the Wii guitar extension.
static int NUNCHUK
          Indicates the nunchuk extension.
 
Constructor Summary
ButtonMap(int wiiRemoteButtons, int[] keys, int mouseButton, int scrollAmount, int scrollInterval)
          Creates a new ButtonMap for the Wii remote with the given keys, mouse button, scroll wheel amount, and scroll wheel interval.
ButtonMap(int extension, int extensionButtons, int[] keys, int mouseButton, int scrollAmount, int scrollInterval)
          Creates a new ButtonMap for the given extension with the given keys, mouse button, scroll wheel amount, and scroll wheel interval.
ButtonMap(int wiiRemoteButtons, int extension, int extensionButtons, int[] keys, int mouseButton, int scrollAmount, int scrollInterval)
          Creates a new ButtonMap for the Wii remote and the given extension with the given keys, mouse button, scroll wheel amount, and scroll wheel interval.
 
Method Summary
 boolean equals(java.lang.Object other)
          Returns true if this ButtonMap is equivalent to the given ButtonMap; otherwise false.
 int getExtension()
          Returns the extension on which the extension buttons must be depressed to trigger this ButtonMap.
 int getExtensionButtons()
          Returns the extension buttons that must be depressed to trigger this ButtonMap.
 int[] getKeys()
          Returns the keyboard keys pressed when this ButtonMap is triggered or null if this map does not use keys.
 int getMouseButton()
          Returns the mouse button clicked when this ButtonMap is triggered or -1 if this map does not use a mouse button.
 int getScrollAmount()
          Returns the scroll amount or 0 if this map does not use the scroll wheel.
 int getScrollInterval()
          Returns the scroll interval.
 int getWiiRemoteButtons()
          Returns the Wii remote buttons that must be depressed to trigger this ButtonMap.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NUNCHUK

public static final int NUNCHUK
Indicates the nunchuk extension.

See Also:
Constant Field Values

CLASSIC_CONTROLLER

public static final int CLASSIC_CONTROLLER
Indicates the classic controller extension.

See Also:
Constant Field Values

GUITAR

public static final int GUITAR
Indicates the Wii guitar extension.

See Also:
Constant Field Values
Constructor Detail

ButtonMap

public ButtonMap(int wiiRemoteButtons,
                 int[] keys,
                 int mouseButton,
                 int scrollAmount,
                 int scrollInterval)
          throws java.lang.IllegalArgumentException
Creates a new ButtonMap for the Wii remote with the given keys, mouse button, scroll wheel amount, and scroll wheel interval. You must specify at least one action (of any of the three types). Note that if you specify 0 for scroll wheel amount, scroll wheel interval will be set to -1.

Parameters:
wiiRemoteButtons - the Wii remote buttons that must be depressed to trigger this ButtonMap. May be either a single button or a multi-button mask.
keys - keyboard keys to map to or null if keys are not used. A list of keys (the VK_ constants) from java.awt.KeyEvent.
mouseButton - mouse button(s) to map to or -1 if mouse button not used. A mouse button mask from java.awt.InputEvent.
scrollAmount - the amount to scroll when the button is pressed or 0 if not used. A positive value indicates scrolling down, and a negative value indicates scrolling up. The value is in scroll-wheel "notches," i.e. the least amount you can move a scroll wheel on a standard mouse.
scrollInterval - the delay (in milliseconds) between scrolling when holding the button or -1 if you must push to scroll. Must be at least 10, if not -1.
Throws:
java.lang.IllegalArgumentException - if there is no action.
java.lang.IllegalArgumentException - if mouseButton is not some combination of InputEvent.BUTTON1_MASK, InputEvent.BUTTON2_MASK, and InputEvent.BUTTON3_MASK or -1.
java.lang.IllegalArgumentException - if scrollInterval is less than 10 and not equal to -1.
java.lang.IllegalArgumentException - if no Wii remote buttons are indicated.

ButtonMap

public ButtonMap(int extension,
                 int extensionButtons,
                 int[] keys,
                 int mouseButton,
                 int scrollAmount,
                 int scrollInterval)
          throws java.lang.IllegalArgumentException
Creates a new ButtonMap for the given extension with the given keys, mouse button, scroll wheel amount, and scroll wheel interval. You must specify at least one action (of any of the three types). Note that if you specify 0 for scroll wheel amount, scroll wheel interval will be set to -1.

Parameters:
extension - the extension on which the extension buttons must be depressed to trigger the action(s).
extensionButtons - the extension buttons that must be depressed to trigger this ButtonMap. May be either a single button or a multi-button mask.
keys - keyboard keys to map to or null if keys are not used. A list of keys (the VK_ constants) from java.awt.KeyEvent.
mouseButton - mouse button(s) to map to or -1 if mouse button not used. A mouse button mask from java.awt.InputEvent.
scrollAmount - the amount to scroll when the button is pressed or 0 if not used. A positive value indicates scrolling down, and a negative value indicates scrolling up. The value is in scroll-wheel "notches," i.e. the least amount you can move a scroll wheel on a standard mouse.
scrollInterval - the delay (in milliseconds) between scrolling when holding the button or -1 if you must push to scroll. Must be at least 10, if not -1.
Throws:
java.lang.IllegalArgumentException - if there is no action.
java.lang.IllegalArgumentException - if mouseButton is not some combination of InputEvent.BUTTON1_MASK, InputEvent.BUTTON2_MASK, and InputEvent.BUTTON3_MASK.
java.lang.IllegalArgumentException - if scrollInterval is less than 10 and not equal to -1.
java.lang.IllegalArgumentException - if no extension buttons are indicated.

ButtonMap

public ButtonMap(int wiiRemoteButtons,
                 int extension,
                 int extensionButtons,
                 int[] keys,
                 int mouseButton,
                 int scrollAmount,
                 int scrollInterval)
          throws java.lang.IllegalArgumentException
Creates a new ButtonMap for the Wii remote and the given extension with the given keys, mouse button, scroll wheel amount, and scroll wheel interval. You must specify at least one action (of any of the three types). Note that if you specify 0 for scroll wheel amount, scroll wheel interval will be set to -1.

Parameters:
wiiRemoteButtons - the Wii remote buttons that must be depressed to trigger this ButtonMap. May be either a single button or a multi-button mask.
extension - the extension on which the extension buttons must be depressed to trigger the action(s).
extensionButtons - the extension buttons that must be depressed to trigger this ButtonMap. May be either a single button or a multi-button mask.
keys - keyboard keys to map to or null if keys are not used. A list of keys (the VK_ constants) from java.awt.KeyEvent.
mouseButton - mouse button(s) to map to or -1 if mouse button not used. A mouse button mask from java.awt.InputEvent.
scrollAmount - the amount to scroll when the button is pressed or 0 if not used. A positive value indicates scrolling down, and a negative value indicates scrolling up. The value is in scroll-wheel "notches," i.e. the least amount you can move a scroll wheel on a standard mouse.
scrollInterval - the delay (in milliseconds) between scrolling when holding the button or -1 if you must push to scroll. Must be at least 10, if not -1.
Throws:
java.lang.IllegalArgumentException - if there is no action.
java.lang.IllegalArgumentException - if mouseButton is not some combination of InputEvent.BUTTON1_MASK, InputEvent.BUTTON2_MASK, and InputEvent.BUTTON3_MASK.
java.lang.IllegalArgumentException - if scrollInterval is less than 10 and not equal to -1.
java.lang.IllegalArgumentException - if no Wii remote or extension buttons are indicated.
Method Detail

getWiiRemoteButtons

public int getWiiRemoteButtons()
Returns the Wii remote buttons that must be depressed to trigger this ButtonMap. May be either a single button or a multi-button mask.

Returns:
the Wii remote buttons that must be depressed to trigger this ButtonMap.

getExtension

public int getExtension()
Returns the extension on which the extension buttons must be depressed to trigger this ButtonMap.

Returns:
the extension on which the extension buttons must be depressed to trigger this ButtonMap.

getExtensionButtons

public int getExtensionButtons()
Returns the extension buttons that must be depressed to trigger this ButtonMap. May be either a single button or a multi-button mask.

Returns:
the extension buttons that must be depressed to trigger this ButtonMap.

getKeys

public int[] getKeys()
Returns the keyboard keys pressed when this ButtonMap is triggered or null if this map does not use keys.

Returns:
the keyboard keys pressed when this ButtonMap is triggered or null if this map does not use keys.

getMouseButton

public int getMouseButton()
Returns the mouse button clicked when this ButtonMap is triggered or -1 if this map does not use a mouse button.

Returns:
the mouse button clicked when this ButtonMap is triggered or -1 if this map does not use a mouse button.

getScrollAmount

public int getScrollAmount()
Returns the scroll amount or 0 if this map does not use the scroll wheel. This is the number of scroll-wheel notches to scroll each time the button is pressed or each time scroll interval elapses, if the button is being held down.

Returns:
the scroll amount or 0 if this map does not use the scroll wheel.

getScrollInterval

public int getScrollInterval()
Returns the scroll interval. The scroll interval is the time (in milliseconds) between each scroll when holding down the associated button. If it is -1, then you may not hold the button to scroll.

Returns:
the scroll interval.

equals

public boolean equals(java.lang.Object other)
Returns true if this ButtonMap is equivalent to the given ButtonMap; otherwise false. All attributes must match. Note that they keys array must be in the same order in both maps as well.

Overrides:
equals in class java.lang.Object
Parameters:
other - the other ButtonMap to compare to.
Returns:
true if this ButtonMap is equivalent to the given ButtonMap; otherwise false.