|
|||||||||
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). 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 name "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.
WiiRemote
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 WiiRemote |
findRemote()
Searches for a WiiRemote and pairs with it via Bluetooth. |
static void |
findRemotes(WiiRemoteDiscoveryListener listener)
Searches for WiiRemotes indefinitely, until stopFind() is called. |
static void |
findRemotes(WiiRemoteDiscoveryListener listener,
int number)
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 remotes initiated by findRemotes(...). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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 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 remotes were already being found.
java.lang.InterruptedException
- on interruption while waiting for discovery.
java.io.IOException
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 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 remotes were already being found.
java.lang.InterruptedException
- on interruption while waiting for discovery.
java.io.IOException
public static void findRemotes(WiiRemoteDiscoveryListener 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 remotes are already being found.public static void findRemotes(WiiRemoteDiscoveryListener listener, int number) 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.number
- 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 remotes 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 |