Skip to content

GCA Async API 1.0

Mario Martínez edited this page Aug 4, 2021 · 1 revision

gca-node and gca+ share the same GCA API, although they have some minor differences.

gca-js uses an asynchronous version of the 2.0 version of the GCA API.

getAdaptersList()

Detects all Nintendo® Wii U GameCube™ Adapter connected in your computer.

  • Returns all compatible adapters detected in an array.

startAdapter(adapter)

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 0 if done succesfully.
  • Returns any other value associated with the libusb API otherwise.

readData(adapter,callback)

Makes a single, synchronous communication to the selected adapter to get the current data. This is a blocking communication and the process will stall until the communication is complete.

pollData(adapter,callback)

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.

rawData(data)

One of the two built-in callback functions in gca-js.

Returns a list of 37 bytes in binary format 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
  • 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

objectData(data)

One of the two built-in callback functions in gca-js.

Processes the data obtained in a formatted object form.

  • 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.

checkRumble(adapter,controllers)

Sends a rumble command to the adapter to toggle the rumble on all controllers of the adapter if the property rumble is set to true in a Controller object.

  • Returns an array indicating the state of rumble if succesful
  • Returns any other value associated with the libusb API otherwise.

stopAdapter(adapter)

Stops the communication with the adapter and makes it available for other processes.

  • Returns 0 if succesful
  • Returns any other value associated with the libusb API otherwise.