In memory of Ben “bushing” Byer, who passed away on Monday, February 8th, 2016.

User:Goofster1020/Code Tutorials/Tutorial 1 - Basic Wiimote Usage: Difference between revisions

From WiiBrew
Jump to navigation Jump to search
Line 65: Line 65:
Instead, you only have to type the name of the button.
Instead, you only have to type the name of the button.
====Wiimote Codes====
====Wiimote Codes====
The definitions for the buttons on the Wiimote follow:
<source lang="c">
WPAD_BUTTON_2
// 2 Button.
WPAD_BUTTON_1
// 1 Button.
WPAD_BUTTON_B
// B Button.
WPAD_BUTTON_A
// A Button.
WPAD_BUTTON_MINUS
// Minus Button.
WPAD_BUTTON_HOME
// Home Button.
WPAD_BUTTON_PLUS
// Plus Button.
WPAD_BUTTON_LEFT
// Left Button.
WPAD_BUTTON_RIGHT
// Right Button.
WPAD_BUTTON_DOWN
// Down Button.
WPAD_BUTTON_UP
// Up Button.
</source>
====Nunchuk Codes====
====Nunchuk Codes====
====Classic Controller Codes====
====Classic Controller Codes====

Revision as of 08:02, 27 June 2009

This tutorial explains how to use the wiimote in many different ways:

Useful Codes

Basic Usage

Wiimote Features

Expansions

Detection

Other


Useful Codes

Wiimote Channels

When programming, the Wiimote channels start from 0 and go to 3. So:

  • Wiimote 1 = Channel 0
  • Wiimote 2 = Channel 1
  • Wiimote 3 = Channel 2
  • Wiimote 4 = Channel 3


Furthermore, there are preprocessor (macro) codes to make life a little simpler:

WPAD_CHAN_0
// For the first Wiimote. (equals 0)
WPAD_CHAN_1
// For the second Wiimote. (equals 1)
WPAD_CHAN_2
// For the third Wiimote. (equals 2)
WPAD_CHAN_3
// For the fourth Wiimote. (equals 3)

Additionally, there is a code for all Wiimotes that can be used as well:

WPAD_CHAN_ALL
// For every Wiimote. (equals -1)

Wiimote Buttons

In order to detect a button press, you need to define the button. Thankfully, Wiiuse defines these, otherwise you would have to type codes such as:

(0x0001<<16)
// Z button on the Nunchuk. (Defined as WPAD_NUNCHUK_BUTTON_Z)

Instead, you only have to type the name of the button.

Wiimote Codes

The definitions for the buttons on the Wiimote follow:

WPAD_BUTTON_2
// 2 Button.
WPAD_BUTTON_1
// 1 Button.
WPAD_BUTTON_B
// B Button.
WPAD_BUTTON_A
// A Button.
WPAD_BUTTON_MINUS
// Minus Button.
WPAD_BUTTON_HOME
// Home Button.
WPAD_BUTTON_PLUS
// Plus Button.
WPAD_BUTTON_LEFT
// Left Button.
WPAD_BUTTON_RIGHT
// Right Button.
WPAD_BUTTON_DOWN
// Down Button.
WPAD_BUTTON_UP
// Up Button.

Nunchuk Codes

Classic Controller Codes

Guitar Codes

Wiimote Expansions

Wiimote Errors

Basic Usage

The following section includes the very basic usage of the Wiimote.

If you are using the Wiimote, no matter what, you always need to have this line in your file:

#include <wiiuse/wpad.h>
//This simple line allows your program access to everything available (in LibWiiuse)  for the Wiimote.


Initializing the Wiimote

In order to turn on and use the Wiimote, you need to add this line (at least once) in your program:

WPAD_Init();
// This will turn on and allow you to use the Wiimote.


Disconnecting the Wiimote

If you want to, you can disconnect the Wiimote when you are done using it. This can be done by:

WPAD_Flush(WPAD_CHAN_ALL);
// This will stop all data being transferred between the Wiimote and the Wii. (Not required)
WPAD_Disconnect(WPAD_CHAN_ALL);
// This will turn off all connected Wiimotes.

Wiimote Features

Using the Buttons

Using the Joysticks

Using the Accelerometer

Using the IR

Using Rumble

Expansions

Nunchuk

Classic Controller

Guitar

Balance Board

Detection

Wiimote Detection

Expansion Detection

Other

Wiimote Settings

Wiimote Callbacks