Skip to content

Commit 12871a5

Browse files
gcn: detect GameCube Dance Mat (SI_DANCEMAT, 0x09000300)
Unlike DK Bongos (which share the standard GC controller's SI device ID), the dance mat has a unique SI sub-type: 0x09000300 -- matches Dolphin's SI_DANCEMAT enum (SI_TYPE_GC | SI_GC_STANDARD | 0x00000300). libogc2 doesn't ship a constant for it, so we just hard-code the 0x00000300 sub-type check. snap_gc()'s style-resolution chain is now ordered: 1. (t & 0x0000FF00) == 0x00000300 -> DanceMat (unique SI type) 2. (t & SI_GC_WAVEBIRD) match -> WaveBird (wireless mix) 3. PAD_IsBarrel(chan) -> DK Bongo (USE_ORIGIN latch) 4. fallback -> GCN DanceMat check comes first because its sub-type bits would otherwise trip the GCN fallback (and incorrectly read "GCN" with all-zero analog axes, since dance mats have no sticks/triggers). DK Bongo check stays after WaveBird so we don't accidentally relabel a wireless pad whose origin hasn't synced yet. Rumble disabled for both bongos and dance mats (neither has a motor).
1 parent ff93708 commit 12871a5

1 file changed

Lines changed: 31 additions & 16 deletions

File tree

gcn/ppc/main.c

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ typedef enum {
151151
STYLE_GCN,
152152
STYLE_WAVEBIRD,
153153
STYLE_BONGO,
154+
STYLE_DANCEMAT,
154155
STYLE_WHEEL,
155156
STYLE_MOUSE,
156157
STYLE_MIC,
@@ -164,6 +165,7 @@ static const char *format_style(pad_style_t s) {
164165
case STYLE_GCN: return "GCN ";
165166
case STYLE_WAVEBIRD: return "WaveBird";
166167
case STYLE_BONGO: return "DK Bongo";
168+
case STYLE_DANCEMAT: return "DanceMat";
167169
case STYLE_WHEEL: return "Wheel ";
168170
case STYLE_MOUSE: return "Mouse ";
169171
case STYLE_MIC: return "Mic ";
@@ -350,25 +352,38 @@ static void snap_n64(pad_snap_t *out, int chan, const N64State *s,
350352
}
351353

352354
static void snap_gc(pad_snap_t *out, int p, u16 buttons) {
353-
// libogc's SI_DecodeType test: when the wavebird-specific flag mix
354-
// matches, this is an active wireless controller paired with its
355-
// receiver. Otherwise it's a wired Standard GC controller.
356355
u32 t = SI_GetType(p);
357-
out->style = ((t & SI_GC_WAVEBIRD) == SI_GC_WAVEBIRD) ? STYLE_WAVEBIRD
358-
: STYLE_GCN;
359-
// DK Bongo (TaruKonga) shares the SI device type with a standard
360-
// controller (0x09000000); libogc disambiguates by watching the
361-
// PAD_USE_ORIGIN bit in the status report -- bongos never set it,
362-
// so PAD_IsBarrel latches the channel as "barrel" (libogc's
363-
// internal codename for the drum). Override the style after
364-
// ScanPads has had a chance to set the barrel bit.
365-
if (PAD_IsBarrel(p)) {
356+
// Disambiguate the GC-controller-family variants from their SI
357+
// device-type bits + libogc's barrel latch:
358+
// - DanceMat: unique SI sub-type 0x09000300 (libogc doesn't ship
359+
// a constant for it; value matches Dolphin's
360+
// SI_DANCEMAT enum: SI_TYPE_GC | SI_GC_STANDARD |
361+
// 0x00000300). Checked first because its sub-type
362+
// bits override the GCN/WaveBird heuristics.
363+
// - WaveBird: paired wireless mix (SI_GC_WIRELESS | STANDARD |
364+
// STATE | FIX_ID).
365+
// - DK Bongo: shares the SI device ID with a wired GCN; libogc
366+
// latches the channel as "barrel" via the
367+
// PAD_USE_ORIGIN status bit (bongos never assert it).
368+
// Checked after WaveBird so we don't accidentally
369+
// relabel a barrel-bit-set channel that's actually
370+
// a wireless pad whose origin hasn't synced yet.
371+
// - GCN: fallback for everything else with SI_GC_STANDARD.
372+
if ((t & 0x0000FF00) == 0x00000300) {
373+
out->style = STYLE_DANCEMAT;
374+
} else if ((t & SI_GC_WAVEBIRD) == SI_GC_WAVEBIRD) {
375+
out->style = STYLE_WAVEBIRD;
376+
} else if (PAD_IsBarrel(p)) {
366377
out->style = STYLE_BONGO;
378+
} else {
379+
out->style = STYLE_GCN;
367380
}
368-
// Bongos and WaveBirds have no rumble motor; SI_GC_NOMOTOR is set
369-
// in the wireless type for WaveBird. Standard GC controllers do
370-
// have a motor.
371-
out->rumble_supported = !(t & SI_GC_NOMOTOR) && out->style != STYLE_BONGO;
381+
// No rumble motor on WaveBird (SI_GC_NOMOTOR set in the wireless
382+
// type), bongos, or dance mats. Standard wired GC controllers have
383+
// it built in.
384+
out->rumble_supported = !(t & SI_GC_NOMOTOR) &&
385+
out->style != STYLE_BONGO &&
386+
out->style != STYLE_DANCEMAT;
372387
out->stick_x = PAD_StickX(p);
373388
out->stick_y = PAD_StickY(p);
374389
out->cstick_x = PAD_SubStickX(p);

0 commit comments

Comments
 (0)