From 785372e2ccc6f12e83e4d99d35a678b6561a1081 Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke <grumbel@gmx.de> Date: Sun, 18 Apr 2010 02:24:55 +0200 Subject: [PATCH] Fix for 'dereferencing type-punned pointer...' warning --- src/xbox360_controller.cpp | 4 ++-- src/xbox360_wireless_controller.cpp | 2 +- src/xbox_controller.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/xbox360_controller.cpp b/src/xbox360_controller.cpp index 9f59f63..15980b9 100755 --- a/src/xbox360_controller.cpp +++ b/src/xbox360_controller.cpp @@ -237,12 +237,12 @@ Xbox360Controller::read(XboxGenericMsg& msg, bool verbose, int timeout) if (is_guitar) { msg.type = XBOX_MSG_XBOX360_GUITAR; - msg.guitar = *reinterpret_cast<Xbox360GuitarMsg*>(data); + memcpy(&msg.guitar, data, sizeof(Xbox360GuitarMsg)); } else { msg.type = XBOX_MSG_XBOX360; - msg.xbox360 = *reinterpret_cast<Xbox360Msg*>(data); + memcpy(&msg.xbox360, data, sizeof(Xbox360Msg)); } return true; } diff --git a/src/xbox360_wireless_controller.cpp b/src/xbox360_wireless_controller.cpp index fdfa515..15fcc51 100755 --- a/src/xbox360_wireless_controller.cpp +++ b/src/xbox360_wireless_controller.cpp @@ -156,7 +156,7 @@ Xbox360WirelessController::read(XboxGenericMsg& msg, bool verbose, int timeout) else if (data[0] == 0x00 && data[1] == 0x01 && data[2] == 0x00 && data[3] == 0xf0 && data[4] == 0x00 && data[5] == 0x13) { // Event message msg.type = XBOX_MSG_XBOX360; - msg.xbox360 = *reinterpret_cast<Xbox360Msg*>(&data[4]); + memcpy(&msg.xbox360, data+4, sizeof(Xbox360Msg)); return true; } else if (data[0] == 0x00 && data[1] == 0x00 && data[2] == 0x00 && data[3] == 0x13) diff --git a/src/xbox_controller.cpp b/src/xbox_controller.cpp index c99c0b6..5232b94 100644 --- a/src/xbox_controller.cpp +++ b/src/xbox_controller.cpp @@ -83,7 +83,7 @@ XboxController::read(XboxGenericMsg& msg, bool verbose, int timeout) else if (ret == 20 && data[0] == 0x00 && data[1] == 0x14) { msg.type = XBOX_MSG_XBOX; - msg.xbox = *reinterpret_cast<XboxMsg*>(data); + memcpy(&msg.xbox, data, sizeof(XboxMsg)); return true; } return false;