-
Notifications
You must be signed in to change notification settings - Fork 0
GCA Async API 2.0
gca-js uses an asynchronous version of the 2.1 version of the GCA API shared by gca+.
The interface struct used for handling the controller status of any given port of the adapter.
Detects all Nintendo® Wii U GameCube™ Adapter connected in your computer.
- Returns a Promise with all compatible adapters detected in an array.
Claims the usage of the adapter and enables the communication with a given adapter and sends a command to it so that it can begin polling data.
- Returns a Promise that is fulfilled when the adapter has started.
Makes a single, synchronous communication to the selected adapter to get the current input data. This is a blocking communication and the process will stall until the communication is complete.
- Returns a Promise with the input data that is fulfilled once the communication is complete.
This is a legacy alias of the previous function, that uses a callback instead of returning a promise.
Enables a continuous, asynchronous communication via events with the selected adapter, and executes the callback function when a communication is complete. This is a non-blocking communication, so the process will continue to be running even if the communication is still in progress.
Sends a rumble command to the adapter to toggle the rumble on all controller ports of the adapter.
controllers
is an array of 4 booleans, one for each port. When true, the controller plugged in that port will start rumbling. When false, it will stop rumbling.
- Returns a Promise that is fulfilled once the communication is complete.
Stops the communication with the adapter and makes it available for other processes.
- Returns a Promise.
These built-in functions allow processing the input data received from the adapter.
Returns a copy of the data buffer.
Returns a list of 37 bytes in binary strings about the adapter's current state (9 status bytes * 4 ports + 1 header byte = 37 bytes) The list contains the following information (using LSB 0 bit numbering). Multiply the byte number by the port number you want to use to get the element of the list that contains the same information for said port):
- Byte 0: GameCube Adapter header
- Byte 1: Port connection status.
- High nibble: Least significant bit is 1 when a controller is connected to said port, 0 when nothing is connected.
- Low nibble: Not used.
- Byte 2: Main buttons and D-Pad status.
- High nibble:
- Bit 7: D-Pad Left
- Bit 6: D-Pad Right
- Bit 5: D-Pad Down
- Bit 4: D-Pad Up
- Low nibble:
- Bit 3: Y button
- Bit 2: X button
- Bit 1: B button
- Bit 0: A button
- High nibble:
- Byte 3: Auxiliar buttons
- High nibble: Not used
- Low nibble:
- Bit 3: Start button
- Bit 2: Z button
- Bit 1: R trigger button
- Bit 0: L trigger button
- Byte 4: Main stick horizontal axis (left-right)
- Byte 5: Main stick vertical axis (up-down)
- Byte 6: C-Stick horizontal axis (left-right)
- Byte 7: C-Stick vertical axis (left-right)
- Byte 8: L trigger axis
- Byte 9: R trigger axis
Returns a list of the 37 bytes received in a UInt8Array.
Processes the data obtained to an ControllerStatus object.
- Returns an array of 4 Controller objects. Each one corresponds to one of the four ports of the adapter, and contains the status the GameCube controller was when the data was sent to the computer.