|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwiiremotej.WiiRemoteJ
public class WiiRemoteJ
Library for connecting to and interacting with a Nintendo (R) Wii Remote (TM) and Balance Board (TM) via Bluetooth (R).
See accompanying LICENSE for trademark information.
Note that Bluetooth must be available on class loading, as the library connects to the local device at this time.
WiiRemoteJ also contains the Logger from the Java logging API. The logger is named "wiiremotej" (for those wishing to utilize
the logging API). Note that a ConsoleHandler is provided to output messages to the standard output (System.out). If you remove this handler, then you will cease to
receive messages on the console from this handler, even if you call one of the setConsoleLogging methods. By default, only error (warning and severe) messages are output
to the console.
Note that the bulk of the information you will need to program using WiiRemoteJ is located in the header of the WiiRemote class in the API docs.
WiiRemote
Field Summary | |
---|---|
static int |
ALL
Indicates all devices. |
static int |
BALANCE_BOARD
Indicates a Balance Board device. |
static int |
WII_REMOTE
Indicates a Wii Remote device. |
Constructor Summary | |
---|---|
WiiRemoteJ()
|
Method Summary | |
---|---|
static int |
bytesToInt(byte[] bytes)
Converts a byte array (big endian) to an int. |
static int |
bytesToInt(byte[] bytes,
boolean bigEndian)
Converts a byte array (big endian) to an int. |
static BalanceBoard |
connectToBalanceBoard(java.lang.String bluetoothAddress)
Connects to the BalanceBoard with the specified bluetooth address. |
static WiiRemote |
connectToRemote(java.lang.String bluetoothAddress)
Connects to the Wii Remote with the specified bluetooth address. |
static BalanceBoard |
findBalanceBoard()
Searches for a BalanceBoard and pairs with it via Bluetooth. |
static WiiDevice |
findDevice(int deviceType)
Searches for a WiiDevice and pairs with it via Bluetooth. |
static void |
findDevices(WiiDeviceDiscoveryListener listener,
int deviceType)
Searches for WiiDevices indefinitely, until stopFind() is called. |
static void |
findDevices(WiiDeviceDiscoveryListener listener,
int deviceType,
int numDevices)
Searches for WiiDevices until the given number of devices are found or until until stopFind() is called. |
static WiiRemote |
findRemote()
Searches for a WiiRemote and pairs with it via Bluetooth. |
static void |
findRemotes(WiiDeviceDiscoveryListener listener)
Searches for WiiRemotes indefinitely, until stopFind() is called. |
static void |
findRemotes(WiiDeviceDiscoveryListener listener,
int numRemotes)
Searches for WiiRemotes until the given number are found or until stopFind() is called. |
static byte[] |
intToBytes(int integer)
Converts an int to a byte array (big endian). |
static byte[] |
intToBytes(int integer,
boolean bigEndian)
Converts an int to a byte array. |
static boolean |
isFindInProgress()
Returns true if a find operation is in progress; otherwise false . |
static void |
setConsoleLoggingAll()
Outputs all messages to the console by default. |
static void |
setConsoleLoggingErrors()
Limits the types of messages output to the console by default to error (warning and severe) messages only. |
static void |
setConsoleLoggingOff()
Outputs no messages to the console by default. |
static void |
stopFind()
Cancels a search for multiple devices initiated by findDevices(...). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int WII_REMOTE
public static final int BALANCE_BOARD
public static final int ALL
Constructor Detail |
---|
public WiiRemoteJ()
Method Detail |
---|
public static byte[] intToBytes(int integer)
integer
- an int to convert.
public static byte[] intToBytes(int integer, boolean bigEndian)
integer
- an int to convert.bigEndian
- if true
, the byte order will be big endian; if false
, the byte order will be little endian.
public static int bytesToInt(byte[] bytes) throws java.lang.IllegalArgumentException
bytes
- a byte array to convert.
java.lang.IllegalArgumentException
- if the byte array is longer than 4 bytes or is 0 bytes.public static int bytesToInt(byte[] bytes, boolean bigEndian) throws java.lang.IllegalArgumentException
bytes
- a byte array to convert.bigEndian
- if true
,the input is considered to be big endian; if false
, the input is considered to be little endian.
java.lang.IllegalArgumentException
- if the byte array is longer than 4 bytes or is 0 bytes.public static WiiRemote connectToRemote(java.lang.String bluetoothAddress) throws java.lang.IllegalStateException, java.io.IOException
bluetoothAddress
- the bluetooth address of the remote to connect to. Just a straight up address, no dashes, spaces, etc. Example: 0017AB322D14.
java.lang.IllegalStateException
- on error intializing Bluetooth.
java.io.IOException
- if there is an error connecting to the remote at given address.public static BalanceBoard connectToBalanceBoard(java.lang.String bluetoothAddress) throws java.lang.IllegalStateException, java.io.IOException
bluetoothAddress
- the bluetooth address of the balance baord to connect to. Just a straight up address, no dashes, spaces, etc. Example: 0017AB322D14.
java.lang.IllegalStateException
- on error intializing Bluetooth.
java.io.IOException
- if there is an error connecting to the balance board at given address.public static WiiDevice findDevice(int deviceType) throws java.lang.IllegalStateException, java.lang.InterruptedException, java.io.IOException
deviceType
- the type of device to find. Can be a mask of multiple devices (simply add the devices you want together). See constants in WiiRemoteJ for options.
null
if no device matching the deviceType is found.
java.lang.IllegalStateException
- on error intializing Bluetooth or starting inquiry.
java.lang.IllegalStateException
- if devices were already being found.
java.lang.InterruptedException
- on interruption while waiting for discovery.
java.io.IOException
public static WiiRemote findRemote() throws java.lang.IllegalStateException, java.lang.InterruptedException, java.io.IOException
null
if no remote is found.
java.lang.IllegalStateException
- on error intializing Bluetooth or starting inquiry.
java.lang.IllegalStateException
- if devices were already being found.
java.lang.InterruptedException
- on interruption while waiting for discovery.
java.io.IOException
public static BalanceBoard findBalanceBoard() throws java.lang.IllegalStateException, java.lang.InterruptedException, java.io.IOException
null
if no balance board is found.
java.lang.IllegalStateException
- on error intializing Bluetooth or starting inquiry.
java.lang.IllegalStateException
- if devices were already being found.
java.lang.InterruptedException
- on interruption while waiting for discovery.
java.io.IOException
public static void findDevices(WiiDeviceDiscoveryListener listener, int deviceType) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
null
to a listener. The time to attach listeners is in
WiiDeviceDiscoveryListener's wiiDeviceDiscovered(...) method. Convenience method for findDevices(listener, deviceType, Integer.MAX_VALUE).
listener
- listens for discovered WiiDevices. Whenever a device is discovered, it will be passed to this listener. Can not be null
.deviceType
- the type of device to find. Can be a mask of multiple devices (simply add the devices you want together). See constants in WiiRemoteJ for options.
java.lang.IllegalArgumentException
- if listener is null.
java.lang.IllegalStateException
- on error intializing Bluetooth or starting inquiry.
java.lang.IllegalStateException
- if devices are already being found.public static void findDevices(WiiDeviceDiscoveryListener listener, int deviceType, int numDevices) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
null
to a listener. The time to attach listeners is in
WiiDeviceDiscoveryListener's wiiDeviceDiscovered(...) method.
listener
- listens for discovered WiiDevices. Whenever a device is discovered, it will be passed to this listener. Can not be null
.deviceType
- the type of device to find. Can be a mask of multiple devices (simply add the devices you want together). See constants in WiiRemoteJ for options.numDevices
- the number of devices to search for.
java.lang.IllegalArgumentException
- if listener is null.
java.lang.IllegalStateException
- on error intializing Bluetooth or starting inquiry.
java.lang.IllegalStateException
- if devices are already being found.public static void findRemotes(WiiDeviceDiscoveryListener listener) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
listener
- listens for discovered WiiRemotes. Whenever a remote is discovered, it will be passed to this listener. Can not be null.
java.lang.IllegalArgumentException
- if listener is null.
java.lang.IllegalStateException
- on error intializing Bluetooth or starting inquiry.
java.lang.IllegalStateException
- if devices are already being found.public static void findRemotes(WiiDeviceDiscoveryListener listener, int numRemotes) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
listener
- listens for discovered WiiRemotes. Whenever a remote is discovered, it will be passed to this listener. Can not be null.numRemotes
- the number of remotes to search for.
java.lang.IllegalArgumentException
- if listener is null.
java.lang.IllegalStateException
- on error intializing Bluetooth or starting inquiry.
java.lang.IllegalStateException
- if devices are already being found.public static void stopFind()
public static boolean isFindInProgress()
true
if a find operation is in progress; otherwise false
.
true
if a find operation is in progress; otherwise false
.public static void setConsoleLoggingErrors()
public static void setConsoleLoggingAll()
public static void setConsoleLoggingOff()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |