From ee7726c4ecb58d88b12ac792ac561a5a296824f0 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Thu, 16 May 2024 03:12:17 +0200 Subject: [PATCH] fix GunCon3 warnings --- rpcs3/Emu/Io/GunCon3.cpp | 20 ++++++++++---------- rpcs3/Emu/Io/GunCon3.h | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/rpcs3/Emu/Io/GunCon3.cpp b/rpcs3/Emu/Io/GunCon3.cpp index 154b6e43e0..aa24cdcde8 100644 --- a/rpcs3/Emu/Io/GunCon3.cpp +++ b/rpcs3/Emu/Io/GunCon3.cpp @@ -93,7 +93,7 @@ static void guncon3_encode(const GunCon3_data* gc, u8* data, const u8* key) { std::memcpy(data, gc, sizeof(GunCon3_data)); - u8 key_offset = ((key[1] ^ key[2]) - key[3] - key[4] ^ key[5]) + key[6] - key[7] ^ data[14]; + u8 key_offset = ((key[1] ^ key[2]) - key[3] - (key[4] ^ key[5])) + key[6] - (key[7] ^ data[14]); u8 key_index = 0; for (int i = 0; i < 13; i++) @@ -118,9 +118,9 @@ static void guncon3_encode(const GunCon3_data* gc, u8* data, const u8* key) data[i] = byte; } - data[13] = ((key[7] + data[0] - data[1] - data[2] ^ data[3]) - + data[4] + data[5] ^ data[6] ^ data[7]) - + data[8] + data[9] - data[10] - data[11] ^ data[12]; + data[13] = ((key[7] + data[0] - data[1] - (data[2] ^ data[3])) + + data[4] + (data[5] ^ (data[6] ^ data[7]))) + + data[8] + data[9] - data[10] - (data[11] ^ data[12]); } usb_device_guncon3::usb_device_guncon3(u32 controller_index, const std::array& location) @@ -197,7 +197,7 @@ void usb_device_guncon3::interrupt_transfer(u32 buf_size, u8* buf, u32 endpoint, if ((endpoint & 0x80) == LIBUSB_ENDPOINT_OUT) { - std::memcpy(m_key, buf, std::min(buf_size, static_cast(sizeof(m_key)))); + std::memcpy(m_key.data(), buf, std::min(buf_size, m_key.size())); return; } // else ENDPOINT_IN @@ -209,14 +209,14 @@ void usb_device_guncon3::interrupt_transfer(u32 buf_size, u8* buf, u32 endpoint, if (!is_input_allowed()) { - guncon3_encode(&gc, buf, m_key); + guncon3_encode(&gc, buf, m_key.data()); return; } if (g_cfg.io.mouse == mouse_handler::null) { guncon3_log.warning("GunCon3 requires a Mouse Handler enabled"); - guncon3_encode(&gc, buf, m_key); + guncon3_encode(&gc, buf, m_key.data()); return; } @@ -262,14 +262,14 @@ void usb_device_guncon3::interrupt_transfer(u32 buf_size, u8* buf, u32 endpoint, if (m_controller_index >= mouse_handler.GetMice().size()) { - guncon3_encode(&gc, buf, m_key); + guncon3_encode(&gc, buf, m_key.data()); return; } const Mouse& mouse_data = ::at32(mouse_handler.GetMice(), m_controller_index); if (mouse_data.x_max <= 0 || mouse_data.y_max <= 0) { - guncon3_encode(&gc, buf, m_key); + guncon3_encode(&gc, buf, m_key.data()); return; } @@ -280,5 +280,5 @@ void usb_device_guncon3::interrupt_transfer(u32 buf_size, u8* buf, u32 endpoint, gc.btn_trigger |= !!(mouse_data.buttons & CELL_MOUSE_BUTTON_1); } - guncon3_encode(&gc, buf, m_key); + guncon3_encode(&gc, buf, m_key.data()); } diff --git a/rpcs3/Emu/Io/GunCon3.h b/rpcs3/Emu/Io/GunCon3.h index c5613c6734..df013e4240 100644 --- a/rpcs3/Emu/Io/GunCon3.h +++ b/rpcs3/Emu/Io/GunCon3.h @@ -13,5 +13,5 @@ public: private: u32 m_controller_index; - u8 m_key[8]; + std::array m_key{}; };