Add support for the Wiimote controller

Thanks @Fussmatte for the button pictures. The Product IDs added here
are those reported by libSDL when running on a Wii.

Fixes: #1136
This commit is contained in:
Alberto Mardegan 2024-01-29 22:37:05 +03:00
parent 448c4a5514
commit f3c87643e2
7 changed files with 40 additions and 8 deletions

View File

@ -5,9 +5,9 @@
<height>10</height>
<white_teeth>1</white_teeth>
<chars>
<range start="0xEB00" end="0xEB36"/>
<range start="0xEB00" end="0xEB3C"/>
</chars>
<special>
<range start="0xEB00" end="0xEB36" color="1"/>
<range start="0xEB00" end="0xEB3C" color="1"/>
</special>
</font_metadata>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -5,9 +5,9 @@
<height>12</height>
<white_teeth>1</white_teeth>
<chars>
<range start="0xEB00" end="0xEB36"/>
<range start="0xEB00" end="0xEB3C"/>
</chars>
<special>
<range start="0xEB00" end="0xEB36" color="1"/>
<range start="0xEB00" end="0xEB3C" color="1"/>
</special>
</font_metadata>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -5,9 +5,9 @@
<height>8</height>
<white_teeth>1</white_teeth>
<chars>
<range start="0xEB00" end="0xEB36"/>
<range start="0xEB00" end="0xEB3C"/>
</chars>
<special>
<range start="0xEB00" end="0xEB36" color="1"/>
<range start="0xEB00" end="0xEB3C" color="1"/>
</special>
</font_metadata>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -71,6 +71,13 @@ typedef enum
GLYPH_NINTENDO_GAMECUBE_R,
GLYPH_NINTENDO_GAMECUBE_Z,
GLYPH_NINTENDO_WII_A,
GLYPH_NINTENDO_WII_B,
GLYPH_NINTENDO_WII_1,
GLYPH_NINTENDO_WII_2,
GLYPH_NINTENDO_WII_MINUS,
GLYPH_NINTENDO_WII_PLUS,
GLYPH_TOTAL
}
ButtonGlyphKey;
@ -89,6 +96,8 @@ typedef enum
/* Added after 2.4 */
LAYOUT_GAMECUBE,
LAYOUT_WIIMOTE_ON_WII,
LAYOUT_WIIMOTE_ON_PC,
LAYOUT_TOTAL
}
@ -152,7 +161,21 @@ static const char* glyph_layout[LAYOUT_TOTAL][SDL_CONTROLLER_BUTTON_RIGHTSHOULDE
glyph[GLYPH_UNKNOWN], glyph[GLYPH_UNKNOWN], "START",
glyph[GLYPH_UNKNOWN], glyph[GLYPH_UNKNOWN],
glyph[GLYPH_UNKNOWN], glyph[GLYPH_NINTENDO_GAMECUBE_Z]
}
},
{ // WIIMOTE on WII
glyph[GLYPH_NINTENDO_WII_1], glyph[GLYPH_NINTENDO_WII_2],
glyph[GLYPH_NINTENDO_WII_A], glyph[GLYPH_NINTENDO_WII_B],
"HOME", glyph[GLYPH_NINTENDO_WII_MINUS], glyph[GLYPH_NINTENDO_WII_PLUS],
glyph[GLYPH_UNKNOWN], glyph[GLYPH_UNKNOWN],
glyph[GLYPH_UNKNOWN], glyph[GLYPH_UNKNOWN]
},
{ // WIIMOTE on PC
glyph[GLYPH_NINTENDO_WII_A], glyph[GLYPH_NINTENDO_WII_B],
glyph[GLYPH_NINTENDO_WII_1], glyph[GLYPH_NINTENDO_WII_2],
"HOME", glyph[GLYPH_NINTENDO_WII_MINUS], glyph[GLYPH_NINTENDO_WII_PLUS],
glyph[GLYPH_UNKNOWN], glyph[GLYPH_UNKNOWN],
glyph[GLYPH_UNKNOWN], glyph[GLYPH_UNKNOWN]
},
};
static bool keyboard_is_active = true;
@ -232,10 +255,19 @@ void BUTTONGLYPHS_update_layout(SDL_GameController *c)
{
layout = LAYOUT_NINTENDO_SWITCH_JOYCON_R;
}
else if (product == 0x0337)
else if (product == 0x0337 ||
product == 0x0100) // First GC controller on a Wii or Gamecube
{
layout = LAYOUT_GAMECUBE;
}
else if (product == 0x0306)
{
layout = LAYOUT_WIIMOTE_ON_PC;
}
else if (product == 0x0501) // First wiimote on Wii
{
layout = LAYOUT_WIIMOTE_ON_WII;
}
else
{
layout = LAYOUT_NINTENDO_SWITCH_PRO;