SI_DeviceGCSteeringWheel: Amend variable naming

This commit is contained in:
Lioncash 2017-03-14 17:49:29 -04:00
parent 89f5b3b5d9
commit c45f8e2e3c
2 changed files with 42 additions and 42 deletions

View File

@ -8,106 +8,106 @@
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
#include "Core/HW/GCPad.h" #include "Core/HW/GCPad.h"
CSIDevice_GCSteeringWheel::CSIDevice_GCSteeringWheel(SIDevices device, int _iDeviceNumber) CSIDevice_GCSteeringWheel::CSIDevice_GCSteeringWheel(SIDevices device, int device_number)
: CSIDevice_GCController(device, _iDeviceNumber) : CSIDevice_GCController(device, device_number)
{ {
} }
int CSIDevice_GCSteeringWheel::RunBuffer(u8* _pBuffer, int _iLength) int CSIDevice_GCSteeringWheel::RunBuffer(u8* buffer, int length)
{ {
// For debug logging only // For debug logging only
ISIDevice::RunBuffer(_pBuffer, _iLength); ISIDevice::RunBuffer(buffer, length);
// Read the command // Read the command
EBufferCommands command = static_cast<EBufferCommands>(_pBuffer[3]); EBufferCommands command = static_cast<EBufferCommands>(buffer[3]);
// Handle it // Handle it
switch (command) switch (command)
{ {
case CMD_RESET: case CMD_RESET:
case CMD_ID: case CMD_ID:
*(u32*)&_pBuffer[0] = SI_GC_STEERING; *(u32*)&buffer[0] = SI_GC_STEERING;
break; break;
// DEFAULT // DEFAULT
default: default:
{ {
return CSIDevice_GCController::RunBuffer(_pBuffer, _iLength); return CSIDevice_GCController::RunBuffer(buffer, length);
} }
break; break;
} }
return _iLength; return length;
} }
bool CSIDevice_GCSteeringWheel::GetData(u32& _Hi, u32& _Low) bool CSIDevice_GCSteeringWheel::GetData(u32& hi, u32& low)
{ {
if (m_mode == 6) if (m_mode == 6)
{ {
GCPadStatus PadStatus = GetPadStatus(); GCPadStatus pad_status = GetPadStatus();
_Hi = (u32)((u8)PadStatus.stickX); // Steering hi = (u32)((u8)pad_status.stickX); // Steering
_Hi |= 0x800; // Pedal connected flag hi |= 0x800; // Pedal connected flag
_Hi |= (u32)((u16)(PadStatus.button | PAD_USE_ORIGIN) << 16); hi |= (u32)((u16)(pad_status.button | PAD_USE_ORIGIN) << 16);
_Low = (u8)PadStatus.triggerRight; // All 8 bits low = (u8)pad_status.triggerRight; // All 8 bits
_Low |= (u32)((u8)PadStatus.triggerLeft << 8); // All 8 bits low |= (u32)((u8)pad_status.triggerLeft << 8); // All 8 bits
// The GC Steering Wheel appears to have combined pedals // The GC Steering Wheel appears to have combined pedals
// (both the Accelerate and Brake pedals are mapped to a single axis) // (both the Accelerate and Brake pedals are mapped to a single axis)
// We use the stickY axis for the pedals. // We use the stickY axis for the pedals.
if (PadStatus.stickY < 128) if (pad_status.stickY < 128)
_Low |= (u32)((u8)(255 - ((PadStatus.stickY & 0x7f) * 2)) << 16); // All 8 bits (Brake) low |= (u32)((u8)(255 - ((pad_status.stickY & 0x7f) * 2)) << 16); // All 8 bits (Brake)
if (PadStatus.stickY >= 128) if (pad_status.stickY >= 128)
_Low |= (u32)((u8)((PadStatus.stickY & 0x7f) * 2) << 24); // All 8 bits (Accelerate) low |= (u32)((u8)((pad_status.stickY & 0x7f) * 2) << 24); // All 8 bits (Accelerate)
HandleButtonCombos(PadStatus); HandleButtonCombos(pad_status);
} }
else else
{ {
return CSIDevice_GCController::GetData(_Hi, _Low); return CSIDevice_GCController::GetData(hi, low);
} }
return true; return true;
} }
void CSIDevice_GCSteeringWheel::SendCommand(u32 _Cmd, u8 _Poll) void CSIDevice_GCSteeringWheel::SendCommand(u32 command, u8 poll)
{ {
UCommand command(_Cmd); UCommand wheel_command(command);
if (command.command == CMD_FORCE) if (wheel_command.command == CMD_FORCE)
{ {
// 0 = left strong, 127 = left weak, 128 = right weak, 255 = right strong // 0 = left strong, 127 = left weak, 128 = right weak, 255 = right strong
unsigned int uStrength = command.parameter1; unsigned int strength = wheel_command.parameter1;
// 06 = motor on, 04 = motor off // 06 = motor on, 04 = motor off
unsigned int uType = command.parameter2; unsigned int type = wheel_command.parameter2;
// get the correct pad number that should rumble locally when using netplay // get the correct pad number that should rumble locally when using netplay
const int numPAD = NetPlay_InGamePadToLocalPad(m_device_number); const int pad_num = NetPlay_InGamePadToLocalPad(m_device_number);
if (numPAD < 4) if (pad_num < 4)
{ {
if (uType == 0x06) if (type == 0x06)
{ {
// map 0..255 to -1.0..1.0 // map 0..255 to -1.0..1.0
ControlState strength = uStrength / 127.5 - 1; ControlState mapped_strength = strength / 127.5 - 1;
Pad::Rumble(numPAD, strength); Pad::Rumble(pad_num, mapped_strength);
} }
else else
{ {
Pad::Rumble(numPAD, 0); Pad::Rumble(pad_num, 0);
} }
} }
if (!_Poll) if (!poll)
{ {
m_mode = command.parameter2; m_mode = wheel_command.parameter2;
INFO_LOG(SERIALINTERFACE, "PAD %i set to mode %i", m_device_number, m_mode); INFO_LOG(SERIALINTERFACE, "PAD %i set to mode %i", m_device_number, m_mode);
} }
} }
else else
{ {
return CSIDevice_GCController::SendCommand(_Cmd, _Poll); return CSIDevice_GCController::SendCommand(command, poll);
} }
} }

View File

@ -8,6 +8,13 @@
class CSIDevice_GCSteeringWheel : public CSIDevice_GCController class CSIDevice_GCSteeringWheel : public CSIDevice_GCController
{ {
public:
CSIDevice_GCSteeringWheel(SIDevices device, int device_number);
int RunBuffer(u8* buffer, int length) override;
bool GetData(u32& hi, u32& low) override;
void SendCommand(u32 command, u8 poll) override;
private: private:
// Commands // Commands
enum EBufferCommands enum EBufferCommands
@ -23,11 +30,4 @@ private:
CMD_FORCE = 0x30, CMD_FORCE = 0x30,
CMD_WRITE = 0x40 CMD_WRITE = 0x40
}; };
public:
CSIDevice_GCSteeringWheel(SIDevices device, int _iDeviceNumber);
int RunBuffer(u8* _pBuffer, int _iLength) override;
bool GetData(u32& _Hi, u32& _Low) override;
void SendCommand(u32 _Cmd, u8 _Poll) override;
}; };