A GameCube controller adapter library for Wii and vWii homebrew built with libogc. It reads the official adapter sold for the Wii U and again for the Switch (model WUP-028, the same device in both), and third-party adapters in their "Wii U/NS" mode.
Plug the adapter into the console's USB port, and an app can read up to four GameCube controllers from it (wired, or WaveBird, tested so far only in Dolphin), rumble included. An app that already reads GameCube controllers through libogc's PAD_* calls needs one #include and one wup_init().
Status: the first version, 0.1.0. Tested on a Wii U (vWii) with the guided test app below, and in WiiSX, Wii64 and YAWM ModMii Edition. Not tried yet on a real Wii, with a WaveBird, or with a third-party adapter: results from any of them are welcome as an issue. The report reading and the controller merge are also tested on a PC (
make test), and the USB side, ported from wup-028-bslug, runs in Dolphin against an emulated adapter.
#include <gccore.h>
#include <wup028_pad.h> // after <gccore.h>, in each file that reads controllers
int main(void) {
PAD_Init();
WPAD_Init();
wup_init(); // once, before or after WPAD_Init(); again after an IOS reload
while (running) {
u32 connected = PAD_ScanPads(); // the ports with a controller, on the Wii or the adapter
u16 held = PAD_ButtonsHeld(0); // and the rest of PAD_*, as before
...
}
wup_shutdown(); // before an IOS reload or exit
}The adapter's port 1 joins the Wii's port 1, and so on:
- Buttons come from either controller.
- Each stick is the Wii controller's, unless it rests in the middle; then it's the adapter's.
- Each trigger is whichever is pressed further.
- Sticks and triggers have the same ranges as the Wii's ports: neither goes through a clamp or a dead zone, as libogc gives its own ports. The app's own dead zone, if it has one, works for both.
PAD_ControlMotorrumbles both.PAD_Read, libogc's other way of reading all four ports at once, gets the same combined values in its entries. An app that callsPAD_Clampafter it, as libogc's ownPAD_Readexpects, clamps the adapter's values too.
Built for the GameCube, the library is still there and does nothing, so an app with a GameCube version needs no #ifdef around it.
An app that wants libogc's own result as well (the Wii's ports alone) can call libogc's PAD_ScanPads() itself and pass what it returned to wup_PAD_Merge(); the wup_PAD_* calls then have both. The example app does that.
Why a header, not a function to call after PAD_ScanPads()
libogc keeps what PAD_ScanPads() reads to itself, in storage private to its pad.o. Its PAD_ScanPads also calls PAD_Read from inside that same file, so even a linker wrap can't reach it. So nothing outside libogc can add ports to what PAD_ButtonsHeld and the others return. wup028_pad.h renames those calls, in the files that include it, to stand-ins. Each stand-in calls libogc's own call and adds the adapter's ports. Define WUP028_NO_PAD_MACROS before including it to get the wup_PAD_* functions without the renaming.
#include <wup028.h>
wup_init();
wup_status_t st;
if (wup_get(0, &st)) { // false: no controller in the adapter's port 1
if (st.buttons & WUP_BUTTON_A) { ... } // the same bits as libogc's PAD_BUTTON_*
int x = st.stick_x; // about -100..100, as the adapter reads it
}
uint32_t ports = wup_connected(); // bit 0 is port 1
wup_rumble(0, true);
wup_shutdown();wup_status_t also says whether a port holds a wired controller or a WaveBird (kind), and whether the adapter's grey plug is in (rumble_power). Rumble needs the grey plug: it brings the power for the motors, and without it the library doesn't send rumble at all (an app can use rumble_power to ask the player to plug it in). One controller did rumble without it on a Wii U, but four at once from one USB port's power could make the adapter drop off USB.
For test tools and problem reports: wup_hid_version() says which /dev/usb/hid is in use (4, 5, or 0 when not open), and wup_get_stats() counts the reports read, the times an adapter went away, and the last read error.
examples/padview puts what the library reads on screen. It shows three views, one row per port: the adapter's ports, the Wii's own GameCube ports, and the two together. It's also the console test tool:
Running in Dolphin with an emulated adapter. More pictures in docs/padview/.
- Y rumbles that port.
- Z + Left/Right picks an IOS, and Z + A reloads it. If no controller shows up within 5 seconds (the adapter may not work under that IOS), it goes back to the last one.
- Z + X times reading 32 MB from a USB drive, with the adapter on and then off, to check the adapter doesn't slow game loading.
- Z + Start exits (or HOME on a Wii Remote).
Everything works from a GameCube controller, and Z must be held on the same controller as the other button. The adapter is never left off, since on a Wii U it may be the only controller. make dist in its folder makes a padview/ folder for sd:/apps/.
examples/wuptest is the guided version, for a full console test. It walks you through every check, one step at a time: controllers in each port, every button and stick, rumble with and without the grey cable, unplugging, every installed IOS on each USB port (both back ports, and the Wii U's front ports), USB game loading and a second adapter. Most steps move on by themselves when they see the thing happen; A or B answers a question, and holding Start for 2 seconds skips a step. It saves a log and a results table to sd:/wuptest/, and a session stopped part way picks up where it left off.
- IOS37 or newer. The adapter is reached through IOS's
/dev/usb/hid. It changed in IOS58, and both versions are handled. IOS36 and older don't have it. - On a Wii U (vWii): all four USB ports, back and front, work under every regular IOS that has
/dev/usb/hid, and under a d2x cIOS based on IOS58. A d2x cIOS based on IOS56 or IOS57 sees the adapter only in the bottom back port: in the other three it opens/dev/usb/hidbut never sees the adapter. - Shares libogc's USB. With version 5 under IOS58 a console lets only one program open
/dev/usb/hid, and libogc's USB (whichWPAD_Init()starts) is that program, so the library goes through libogc's USB calls. The app's other USB use (storage, keyboards) carries on as before, andwup_init()can come before or afterWPAD_Init(). - No thread and no waiting. Once
wup_init()has started, the adapter is read nonstop in IOS's callbacks, so the app's calls only read the newest report. The library allocates nothing afterwup_init(). (Under IOS58 the first call after the adapter is plugged in takes a few milliseconds to open it.) - Stick centre: sticks and triggers are measured from where they rest when a controller is plugged in, as the Wii does for its own ports, so a worn stick doesn't drift. A controller just plugged in reads as empty for a moment (about 25 ms) while the library waits for steady readings at rest: right after a controller appears, the adapter has been seen to send a reading or two far off, and taking one of those would pin the stick off centre. An axis that hasn't settled within half a second (a stick held over while plugging in) is measured from the middle. X + Y + Start takes the resting place again, as on a GameCube: held for about a second, the controller stops answering and its port reads as empty (the controller's own doing), and when let go it comes back and its resting place is taken anew, so let go with hands off the sticks. (A controller that stays in its port through the hold, as in Dolphin, has it taken after 3 seconds.)
- Dead zones are the app's. The library takes care of where each stick rests; how far a stick must move to count is up to the app, as it is for the Wii's own ports. An app that wants the GameCube's standard clamp can call libogc's
PAD_Clamp()on whatPAD_Read()gives it. - An IOS reload: call
wup_shutdown()and then libogc'sUSB_Deinitialize()beforeIOS_ReloadIOS(), thenwup_init()after it. The reload closes libogc's USB handles (USB drives' too) without libogc knowing, so withoutUSB_Deinitialize()it keeps using dead ones. Under IOS58,wup_init()then returnsWUP_ERR_RELOAD; under a vWii's IOS57, nothing answers. Call it only when the reload will happen (docs/INTEGRATING.mdsays why). - Memory: about 12 KB of code and 1 KB of fixed data in the app's MEM1, plus a 2 KB MEM2 block for IOS's buffers, made once by the first
wup_init(). Nothing is allocated after that. (MEM1 is the 24 MB an emulator needs most; MEM2 has 64 MB.) - Unplugging is fine: the adapter can be plugged in, unplugged and plugged in again at any time. If no report comes for 1.5 seconds, every port reads as empty.
- Two adapters: the library reads one at a time, and keeps reading the one in use when another is plugged in. It moves to the other one only if the first is unplugged.
The official adapter, either version. The one sold for the Wii U and the one sold later for the Switch are the same device (model WUP-028, USB ID 057E:0337); only the logo on top differs.
Third-party adapters (Mayflash and others) only in "Wii U/NS" mode. Most have a small switch on the side, its two sides marked "Wii U" and "PC" (on newer ones, sold for the Switch too, "Wii U/NS" and "PC": the Switch mode is the same as the Wii U one):
- Wii U/NS mode makes the adapter pass itself off as the official one: the same USB ID and the same way of talking. The library should read it like the real one. Not tested yet: if you have one, a run of
examples/wuptestand its results in an issue would be welcome. - PC mode turns it into an ordinary USB gamepad with a different ID (0079:1843, 1844 or 1846, from the chip maker DragonRise). The library doesn't look for those, so an adapter in PC mode isn't found.
What people report with third-party adapters elsewhere (in Dolphin and Nintendont): rumble is the usual weak spot (some never rumble, some only with both cables in), and a few units connect but send no buttons. One that never reports its power plug as in would get no rumble from the library. wuptest checks both: the rumble steps with the grey cable in and out, and the button steps.
Tested with Nintendo's own standard GameCube controllers, wired. WaveBirds have been tested only in Dolphin so far.
Not tested: DK Bongos, dance mats, the Resident Evil 4 chainsaw controller and steering wheels. They act like ordinary controllers, so they may well work, but a wheel's force feedback won't (the library only turns rumble on and off). The ASCII keyboard controller and the Game Boy Advance link cable talk to the console differently, and the adapter may not pass them on at all. Third-party controllers aren't tested either.
If you try any of these, a run of examples/wuptest and an issue with its results would be welcome.
An app that adds the library behaves as before for players without the adapter:
- Nothing printed. The library never prints or logs anything; its state is in
wup_get_stats()for an app that wants it. - The same controllers. With nothing in the adapter's ports,
wup028_pad.h'sPAD_*calls give exactly what libogc's own do (a PC test checks it, frame by frame). - If
wup_init()can't start (IOS36 or older,/dev/usb/hidin use, no memory), it returns an error code and every other call reads as "no adapter". Callingwup_shutdown()withoutwup_init(), or twice, does nothing; callingwup_init()twice starts over. - Memory: see "What it needs" above (about 12 KB of code, 1 KB of data in MEM1, a 2 KB MEM2 block).
- Time: the library adds about 1 µs a frame to reading the controllers on a Wii U, with the adapter or without it (wuptest measures it; padview shows it live, beside what
PAD_ScanPads()takes on its own).
With devkitPro's devkitPPC and libogc:
make # lib/libogc/libwup028.a
make OGC=libogc2 # lib/libogc2/libwup028.a, against libogc2 instead
make check # the PC tests, plus: every export is wup_*, the headers compile as C++
make install # into the chosen library's portlibs (add OGC=libogc2 for libogc2's)GitHub runs the same checks on every push and pull request (.github/workflows/checks.yml):
- the PC tests;
- the library against libogc and libogc2;
- padview and wuptest;
- the CMake build for the Wii and the GameCube.
Each run keeps padview's SD card folder for two weeks, under the run's artifacts.
docs/INTEGRATING.md walks through adding the adapter to an app, using pcsxgc as the worked example. In short, any of these works:
-
CMake:
add_subdirectory(path/to/libwup028), then link thewup028target. If the app defines anogctarget, the library uses its libogc or libogc2 headers. -
Installed: after
make install(withOGC=libogc2for a libogc2 app), add-lwup028to the app's libraries. The headers are on the library's include path. -
Copied in: copy these into the app's source tree, and its own Makefile builds them as it builds everything else:
include/wup028.handinclude/wup028_pad.h;src/wup_report.c,src/wup_report.h,src/wup_transport.c,src/wup_pad.c.
Leave out
src/wup_pad.candwup028_pad.hif the app only useswup_get().
Every name the library makes visible starts with wup_ (make check checks this), so nothing can clash with an app's own names.
Both work, built the same way. The header sees which one it's compiled against and fits in:
- libogc2's button calls have 32 bits. The extra bits (
PADEX_*, a stick or analog trigger past halfway) are set for the adapter's controllers just as libogc2 sets them for its own. - No clamping with either: neither library's
PAD_ScanPads()clamps its own ports, so the adapter's values aren't clamped either. - libogc2's other PAD calls, the stick deltas and analog A and B, still read the Wii's ports only.
padview builds with libogc. With libogc2 it also needs libogc2's libfat (libogc2-libfat or libogc2-libdvm).
WUP028_VERSION in the header is the version as 0xMMmmpp. An app can test it with #if WUP028_VERSION >= 0x000200. wup_version() gives the version actually linked in.
Each release is a vX.Y.Z tag with a GitHub release: a zip with the headers, the library built for libogc and for libogc2, and the sources, plus padview and wuptest ready for the SD card. CHANGELOG.md says what changed. How releases are made: docs/RELEASING.md.
It returns one of the following, and every other call then reads as "no adapter":
| Code | Meaning |
|---|---|
WUP_ERR_OPEN |
No /dev/usb/hid: IOS36 or older, or something else has it open. |
WUP_ERR_VERSION |
/dev/usb/hid is neither version 4 nor 5. |
WUP_ERR_MEMORY |
No room for its IOS buffers. |
WUP_ERR_START |
The first request couldn't be sent to IOS. |
IOS answers that first request later, in the background, so if it refuses it then, wup_init() has already returned WUP_OK: the adapter just never appears. Either way, wup_get_stats() keeps the IOS's own error number, for problem reports.
| Path | What it is |
|---|---|
include/wup028.h |
The library's own calls. |
include/wup028_pad.h |
The PAD_* stand-ins. |
src/wup_report.c |
The adapter's 37-byte report read into four controllers, the rumble message, the merge. Plain C, no IOS, tested on a PC. |
src/wup_transport.c |
Talking to the adapter through /dev/usb/hid, versions 4 and 5. |
src/wup_pad.c |
The stand-ins behind wup028_pad.h. |
tests/ |
The PC tests, and a check that the headers compile as C++. |
docs/INTEGRATING.md |
How to add the adapter to an app. |
docs/RELEASING.md |
How a release is made. |
docs/padview/ |
Pictures of padview. |
CHANGELOG.md |
What changed in each version. |
CMakeLists.txt |
For CMake apps: add_subdirectory() and link wup028. |
examples/padview/ |
The example app and console test tool. |
examples/wuptest/ |
The guided console test: walks you through every check and saves the results to the SD card. |
bslug/ |
The BrainSlug module this started from, as it was: it adds the adapter to Wii games. |
The USB side comes from wup-028-bslug by Alex "Chadderz" Chadwick (2017), who worked out how to talk to the adapter through both versions of /dev/usb/hid.
How it was made: written with AI assistance (Claude). Every change was reviewed and tested by Grant Morin: on a Wii U with wuptest, in Dolphin, and with the PC tests. Bug reports and pull requests are welcome either way.
MIT licence: see LICENSE.
Not affiliated with or endorsed by Nintendo. GameCube, Wii, Wii U and Switch are trademarks of Nintendo.
