Skip to content

Commit

Permalink
Merge pull request dolphin-emu#5328 from leoetlino/wiimote-fix
Browse files Browse the repository at this point in the history
Fix emulated Wiimotes
  • Loading branch information
leoetlino authored Apr 26, 2017
2 parents aedfb5d + 4d42a09 commit 9fc394f
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion Source/Core/Core/HW/WiimoteCommon/WiimoteReport.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ enum ReportType

// Source: http://wiibrew.org/wiki/Wiimote
// Custom structs

#pragma pack(push, 1)
union wm_buttons // also just called "core data"
{
u16 hex;
Expand All @@ -67,11 +67,13 @@ union wm_buttons // also just called "core data"
u8 home : 1;
};
};
static_assert(sizeof(wm_buttons) == 2, "Wrong size");

struct wm_accel
{
u8 x, y, z;
};
static_assert(sizeof(wm_accel) == 3, "Wrong size");

// Four bytes for two objects. Filled with 0xFF if empty
struct wm_ir_basic
Expand All @@ -85,6 +87,7 @@ struct wm_ir_basic
u8 x2;
u8 y2;
};
static_assert(sizeof(wm_ir_basic) == 5, "Wrong size");

// Three bytes for one object
struct wm_ir_extended
Expand All @@ -95,6 +98,7 @@ struct wm_ir_extended
u8 xhi : 2;
u8 yhi : 2;
};
static_assert(sizeof(wm_ir_extended) == 3, "Wrong size");

// Nunchuk
union wm_nc_core
Expand All @@ -112,6 +116,7 @@ union wm_nc_core
u8 acc_z_lsb : 2;
};
};
static_assert(sizeof(wm_nc_core) == 1, "Wrong size");

union wm_nc
{
Expand Down Expand Up @@ -148,6 +153,7 @@ union wm_nc
u8 acc_z_lsb : 2;
} passthrough_data;
};
static_assert(sizeof(wm_nc) == 6, "Wrong size");

union wm_classic_extension_buttons
{
Expand Down Expand Up @@ -193,6 +199,7 @@ union wm_classic_extension_buttons
u8 : 6;
} passthrough_data;
};
static_assert(sizeof(wm_classic_extension_buttons) == 2, "Wrong size");

union wm_classic_extension
{
Expand Down Expand Up @@ -243,6 +250,7 @@ union wm_classic_extension
unsigned : 32;
} passthrough_data;
};
static_assert(sizeof(wm_classic_extension) == 6, "Wrong size");

struct wm_guitar_extension
{
Expand All @@ -260,6 +268,7 @@ struct wm_guitar_extension

u16 bt; // buttons
};
static_assert(sizeof(wm_guitar_extension) == 6, "Wrong size");

struct wm_drums_extension
{
Expand All @@ -280,6 +289,7 @@ struct wm_drums_extension

u16 bt; // buttons
};
static_assert(sizeof(wm_drums_extension) == 6, "Wrong size");

struct wm_turntable_extension
{
Expand All @@ -303,6 +313,7 @@ struct wm_turntable_extension
u16 bt; // buttons
};
};
static_assert(sizeof(wm_turntable_extension) == 6, "Wrong size");

struct wm_motionplus_data
{
Expand All @@ -325,6 +336,7 @@ struct wm_motionplus_data
u8 is_mp_data : 1;
u8 pitch2 : 6;
};
static_assert(sizeof(wm_motionplus_data) == 6, "Wrong size");

struct wm_report
{
Expand All @@ -341,6 +353,7 @@ struct wm_report
};
};
};
static_assert(sizeof(wm_report) == 2, "Wrong size");

struct wm_leds
{
Expand All @@ -349,6 +362,7 @@ struct wm_leds
u8 : 3;
u8 leds : 4;
};
static_assert(sizeof(wm_leds) == 1, "Wrong size");

struct wm_report_mode
{
Expand All @@ -359,12 +373,14 @@ struct wm_report_mode
u8 : 5;
u8 mode;
};
static_assert(sizeof(wm_report_mode) == 2, "Wrong size");

struct wm_request_status
{
u8 rumble : 1;
u8 : 7;
};
static_assert(sizeof(wm_request_status) == 1, "Wrong size");

struct wm_status_report
{
Expand All @@ -377,6 +393,7 @@ struct wm_status_report
u8 padding2[2]; // two 00, TODO: this needs more investigation
u8 battery;
};
static_assert(sizeof(wm_status_report) == 6, "Wrong size");

struct wm_write_data
{
Expand All @@ -387,13 +404,15 @@ struct wm_write_data
u8 size;
u8 data[16];
};
static_assert(sizeof(wm_write_data) == 21, "Wrong size");

struct wm_acknowledge
{
wm_buttons buttons;
u8 reportID;
u8 errorID;
};
static_assert(sizeof(wm_acknowledge) == 4, "Wrong size");

struct wm_read_data
{
Expand All @@ -403,6 +422,7 @@ struct wm_read_data
u8 address[3];
u16 size;
};
static_assert(sizeof(wm_read_data) == 6, "Wrong size");

struct wm_read_data_reply
{
Expand All @@ -412,26 +432,30 @@ struct wm_read_data_reply
u16 address;
u8 data[16];
};
static_assert(sizeof(wm_read_data_reply) == 21, "Wrong size");

// Data reports

struct wm_report_core
{
wm_buttons c;
};
static_assert(sizeof(wm_report_core) == 2, "Wrong size");

struct wm_report_core_accel
{
wm_buttons c;
wm_accel a;
};
static_assert(sizeof(wm_report_core_accel) == 5, "Wrong size");

struct wm_report_core_accel_ir12
{
wm_buttons c;
wm_accel a;
wm_ir_extended ir[4];
};
static_assert(sizeof(wm_report_core_accel_ir12) == 17, "Wrong size");

struct wm_report_core_accel_ext16
{
Expand All @@ -441,6 +465,7 @@ struct wm_report_core_accel_ext16
// wm_ir_basic ir[2];
u8 pad[10];
};
static_assert(sizeof(wm_report_core_accel_ext16) == 21, "Wrong size");

struct wm_report_core_accel_ir10_ext6
{
Expand All @@ -450,15 +475,19 @@ struct wm_report_core_accel_ir10_ext6
// u8 ext[6];
wm_nc ext; // TODO: Does this make any sense? Shouldn't it be just a general "extension" field?
};
static_assert(sizeof(wm_report_core_accel_ir10_ext6) == 21, "Wrong size");

struct wm_report_ext21
{
u8 ext[21];
};
static_assert(sizeof(wm_report_ext21) == 21, "Wrong size");

struct wm_speaker_data
{
u8 unknown : 3;
u8 length : 5;
u8 data[20];
};
static_assert(sizeof(wm_speaker_data) == 21, "Wrong size");
#pragma pack(pop)

0 comments on commit 9fc394f

Please sign in to comment.