diff --git a/Source/Core/Core/Movie.cpp b/Source/Core/Core/Movie.cpp index 0807a6e651..20a6d1db25 100644 --- a/Source/Core/Core/Movie.cpp +++ b/Source/Core/Core/Movie.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -642,7 +643,7 @@ static void SetInputDisplayString(ControllerState padState, int controllerID) } // NOTE: CPU Thread -static void SetWiiInputDisplayString(int remoteID, u8* const data, +static void SetWiiInputDisplayString(int remoteID, const u8* const data, const WiimoteEmu::ReportFeatures& rptf, int ext, const wiimote_key key) { @@ -650,14 +651,16 @@ static void SetWiiInputDisplayString(int remoteID, u8* const data, std::string display_str = StringFromFormat("R%d:", remoteID + 1); - u8* const coreData = rptf.core ? (data + rptf.core) : nullptr; - u8* const accelData = rptf.accel ? (data + rptf.accel) : nullptr; - u8* const irData = rptf.ir ? (data + rptf.ir) : nullptr; - u8* const extData = rptf.ext ? (data + rptf.ext) : nullptr; + const u8* const coreData = rptf.core ? (data + rptf.core) : nullptr; + const u8* const accelData = rptf.accel ? (data + rptf.accel) : nullptr; + const u8* const irData = rptf.ir ? (data + rptf.ir) : nullptr; + const u8* const extData = rptf.ext ? (data + rptf.ext) : nullptr; if (coreData) { - wm_buttons buttons = *(wm_buttons*)coreData; + wm_buttons buttons; + std::memcpy(&buttons, coreData, sizeof(buttons)); + if (buttons.left) display_str += " LEFT"; if (buttons.right) @@ -684,10 +687,12 @@ static void SetWiiInputDisplayString(int remoteID, u8* const data, // A few bits of accelData are actually inside the coreData struct. if (accelData) { - wm_accel* dt = (wm_accel*)accelData; - display_str += StringFromFormat(" ACC:%d,%d,%d", dt->x << 2 | buttons.acc_x_lsb, - dt->y << 2 | buttons.acc_y_lsb << 1, - dt->z << 2 | buttons.acc_z_lsb << 1); + wm_accel dt; + std::memcpy(&dt, accelData, sizeof(dt)); + + display_str += + StringFromFormat(" ACC:%d,%d,%d", dt.x << 2 | buttons.acc_x_lsb, + dt.y << 2 | buttons.acc_y_lsb << 1, dt.z << 2 | buttons.acc_z_lsb << 1); } } @@ -764,7 +769,7 @@ static void SetWiiInputDisplayString(int remoteID, u8* const data, } // NOTE: CPU Thread -void CheckPadStatus(GCPadStatus* PadStatus, int controllerID) +void CheckPadStatus(const GCPadStatus* PadStatus, int controllerID) { s_padState.A = ((PadStatus->button & PAD_BUTTON_A) != 0); s_padState.B = ((PadStatus->button & PAD_BUTTON_B) != 0); @@ -800,7 +805,7 @@ void CheckPadStatus(GCPadStatus* PadStatus, int controllerID) } // NOTE: CPU Thread -void RecordInput(GCPadStatus* PadStatus, int controllerID) +void RecordInput(const GCPadStatus* PadStatus, int controllerID) { if (!IsRecordingInput() || !IsUsingPad(controllerID)) return; @@ -813,8 +818,8 @@ void RecordInput(GCPadStatus* PadStatus, int controllerID) } // NOTE: CPU Thread -void CheckWiimoteStatus(int wiimote, u8* data, const WiimoteEmu::ReportFeatures& rptf, int ext, - const wiimote_key key) +void CheckWiimoteStatus(int wiimote, const u8* data, const WiimoteEmu::ReportFeatures& rptf, + int ext, const wiimote_key key) { SetWiiInputDisplayString(wiimote, data, rptf, ext, key); @@ -822,7 +827,7 @@ void CheckWiimoteStatus(int wiimote, u8* data, const WiimoteEmu::ReportFeatures& RecordWiimote(wiimote, data, rptf.size); } -void RecordWiimote(int wiimote, u8* data, u8 size) +void RecordWiimote(int wiimote, const u8* data, u8 size) { if (!IsRecordingInput() || !IsUsingWiimote(wiimote)) return; diff --git a/Source/Core/Core/Movie.h b/Source/Core/Core/Movie.h index f8d1351151..28253cc44e 100644 --- a/Source/Core/Core/Movie.h +++ b/Source/Core/Core/Movie.h @@ -156,8 +156,8 @@ void ChangeWiiPads(bool instantly = false); void SetReadOnly(bool bEnabled); bool BeginRecordingInput(int controllers); -void RecordInput(GCPadStatus* PadStatus, int controllerID); -void RecordWiimote(int wiimote, u8* data, u8 size); +void RecordInput(const GCPadStatus* PadStatus, int controllerID); +void RecordWiimote(int wiimote, const u8* data, u8 size); bool PlayInput(const std::string& movie_path, std::optional* savestate_path); void LoadInput(const std::string& movie_path); @@ -169,8 +169,8 @@ void EndPlayInput(bool cont); void SaveRecording(const std::string& filename); void DoState(PointerWrap& p); void Shutdown(); -void CheckPadStatus(GCPadStatus* PadStatus, int controllerID); -void CheckWiimoteStatus(int wiimote, u8* data, const struct WiimoteEmu::ReportFeatures& rptf, +void CheckPadStatus(const GCPadStatus* PadStatus, int controllerID); +void CheckWiimoteStatus(int wiimote, const u8* data, const struct WiimoteEmu::ReportFeatures& rptf, int ext, const wiimote_key key); std::string GetInputDisplay();