summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorMatthew Parlane <parlane@gmail.com>2017-04-09 20:09:44 +1200
committerGitHub <noreply@github.com>2017-04-09 20:09:44 +1200
commit394b847b6c0fd4bf8dab619f4cb0084dbdc23ea0 (patch)
treebcb0117f4600eb16ef86b5e38292748c3a016c9b /Source/Core
parentdb79c8db2985edc05454a0de066c0db0d1eb842d (diff)
parent069b70b2b449abeccf88578f75298acc71a08333 (diff)
Merge pull request #5229 from lioncash/si-id
SI_Devices: Get rid of pointer casts for ID assignment in RunBuffer
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/HW/SI/SI_DeviceDanceMat.cpp6
-rw-r--r--Source/Core/Core/HW/SI/SI_DeviceGCController.cpp7
-rw-r--r--Source/Core/Core/HW/SI/SI_DeviceGCSteeringWheel.cpp11
-rw-r--r--Source/Core/Core/HW/SI/SI_DeviceKeyboard.cpp7
4 files changed, 23 insertions, 8 deletions
diff --git a/Source/Core/Core/HW/SI/SI_DeviceDanceMat.cpp b/Source/Core/Core/HW/SI/SI_DeviceDanceMat.cpp
index bd172c4f63..7a940cc755 100644
--- a/Source/Core/Core/HW/SI/SI_DeviceDanceMat.cpp
+++ b/Source/Core/Core/HW/SI/SI_DeviceDanceMat.cpp
@@ -4,6 +4,8 @@
#include "Core/HW/SI/SI_DeviceDanceMat.h"
+#include <cstring>
+
#include "Common/CommonTypes.h"
#include "InputCommon/GCPadStatus.h"
@@ -22,7 +24,9 @@ int CSIDevice_DanceMat::RunBuffer(u8* buffer, int length)
if (command == CMD_RESET)
{
ISIDevice::RunBuffer(buffer, length);
- *(u32*)&buffer[0] = SI_DANCEMAT;
+
+ constexpr u32 id = SI_DANCEMAT;
+ std::memcpy(buffer, &id, sizeof(id));
}
else
{
diff --git a/Source/Core/Core/HW/SI/SI_DeviceGCController.cpp b/Source/Core/Core/HW/SI/SI_DeviceGCController.cpp
index f8e2ccb0fb..d921ea2937 100644
--- a/Source/Core/Core/HW/SI/SI_DeviceGCController.cpp
+++ b/Source/Core/Core/HW/SI/SI_DeviceGCController.cpp
@@ -4,6 +4,8 @@
#include "Core/HW/SI/SI_DeviceGCController.h"
+#include <cstring>
+
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
@@ -53,8 +55,11 @@ int CSIDevice_GCController::RunBuffer(u8* buffer, int length)
{
case CMD_RESET:
case CMD_ID:
- *(u32*)&buffer[0] = SI_GC_CONTROLLER;
+ {
+ constexpr u32 id = SI_GC_CONTROLLER;
+ std::memcpy(buffer, &id, sizeof(id));
break;
+ }
case CMD_DIRECT:
{
diff --git a/Source/Core/Core/HW/SI/SI_DeviceGCSteeringWheel.cpp b/Source/Core/Core/HW/SI/SI_DeviceGCSteeringWheel.cpp
index 54ad6fed81..b21551315d 100644
--- a/Source/Core/Core/HW/SI/SI_DeviceGCSteeringWheel.cpp
+++ b/Source/Core/Core/HW/SI/SI_DeviceGCSteeringWheel.cpp
@@ -4,6 +4,8 @@
#include "Core/HW/SI/SI_DeviceGCSteeringWheel.h"
+#include <cstring>
+
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Core/HW/GCPad.h"
@@ -28,16 +30,15 @@ int CSIDevice_GCSteeringWheel::RunBuffer(u8* buffer, int length)
{
case CMD_RESET:
case CMD_ID:
- *(u32*)&buffer[0] = SI_GC_STEERING;
+ {
+ constexpr u32 id = SI_GC_STEERING;
+ std::memcpy(buffer, &id, sizeof(id));
break;
+ }
- // DEFAULT
default:
- {
return CSIDevice_GCController::RunBuffer(buffer, length);
}
- break;
- }
return length;
}
diff --git a/Source/Core/Core/HW/SI/SI_DeviceKeyboard.cpp b/Source/Core/Core/HW/SI/SI_DeviceKeyboard.cpp
index 57d2fa627c..fc29ff7da6 100644
--- a/Source/Core/Core/HW/SI/SI_DeviceKeyboard.cpp
+++ b/Source/Core/Core/HW/SI/SI_DeviceKeyboard.cpp
@@ -4,6 +4,8 @@
#include "Core/HW/SI/SI_DeviceKeyboard.h"
+#include <cstring>
+
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
@@ -31,8 +33,11 @@ int CSIDevice_Keyboard::RunBuffer(u8* buffer, int length)
{
case CMD_RESET:
case CMD_ID:
- *(u32*)&buffer[0] = SI_GC_KEYBOARD;
+ {
+ constexpr u32 id = SI_GC_KEYBOARD;
+ std::memcpy(buffer, &id, sizeof(id));
break;
+ }
case CMD_DIRECT:
{