Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SI_Devices: Get rid of pointer casts for ID assignment in RunBuffer #5229

Merged
merged 1 commit into from
Apr 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion Source/Core/Core/HW/SI/SI_DeviceDanceMat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "Core/HW/SI/SI_DeviceDanceMat.h"

#include <cstring>

#include "Common/CommonTypes.h"
#include "InputCommon/GCPadStatus.h"

Expand All @@ -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
{
Expand Down
7 changes: 6 additions & 1 deletion Source/Core/Core/HW/SI/SI_DeviceGCController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
{
Expand Down
11 changes: 6 additions & 5 deletions Source/Core/Core/HW/SI/SI_DeviceGCSteeringWheel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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;
}
Expand Down
7 changes: 6 additions & 1 deletion Source/Core/Core/HW/SI/SI_DeviceKeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
{
Expand Down