Merge pull request #4079 from lioncash/state
HW: Make GC input retrieval functions return by value
This commit is contained in:
commit
facf02686a
|
@ -47,12 +47,8 @@ void LoadConfig()
|
|||
s_config.LoadConfig(true);
|
||||
}
|
||||
|
||||
void GetStatus(u8 port, KeyboardStatus* keyboard_status)
|
||||
KeyboardStatus GetStatus(u8 port)
|
||||
{
|
||||
memset(keyboard_status, 0, sizeof(*keyboard_status));
|
||||
keyboard_status->err = PAD_ERR_NONE;
|
||||
|
||||
// Get input
|
||||
static_cast<GCKeyboard*>(s_config.GetController(port))->GetInput(keyboard_status);
|
||||
return static_cast<GCKeyboard*>(s_config.GetController(port))->GetInput();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,5 +17,5 @@ void LoadConfig();
|
|||
|
||||
InputConfig* GetConfig();
|
||||
|
||||
void GetStatus(u8 port, KeyboardStatus* keyboard_status);
|
||||
KeyboardStatus GetStatus(u8 port);
|
||||
}
|
||||
|
|
|
@ -84,15 +84,20 @@ std::string GCKeyboard::GetName() const
|
|||
return std::string("GCKeyboard") + char('1' + m_index);
|
||||
}
|
||||
|
||||
void GCKeyboard::GetInput(KeyboardStatus* const kb)
|
||||
KeyboardStatus GCKeyboard::GetInput() const
|
||||
{
|
||||
auto lock = ControllerEmu::GetStateLock();
|
||||
m_keys0x->GetState(&kb->key0x, keys0_bitmasks);
|
||||
m_keys1x->GetState(&kb->key1x, keys1_bitmasks);
|
||||
m_keys2x->GetState(&kb->key2x, keys2_bitmasks);
|
||||
m_keys3x->GetState(&kb->key3x, keys3_bitmasks);
|
||||
m_keys4x->GetState(&kb->key4x, keys4_bitmasks);
|
||||
m_keys5x->GetState(&kb->key5x, keys5_bitmasks);
|
||||
|
||||
KeyboardStatus kb = {};
|
||||
|
||||
m_keys0x->GetState(&kb.key0x, keys0_bitmasks);
|
||||
m_keys1x->GetState(&kb.key1x, keys1_bitmasks);
|
||||
m_keys2x->GetState(&kb.key2x, keys2_bitmasks);
|
||||
m_keys3x->GetState(&kb.key3x, keys3_bitmasks);
|
||||
m_keys4x->GetState(&kb.key4x, keys4_bitmasks);
|
||||
m_keys5x->GetState(&kb.key5x, keys5_bitmasks);
|
||||
|
||||
return kb;
|
||||
}
|
||||
|
||||
void GCKeyboard::LoadDefaults(const ControllerInterface& ciface)
|
||||
|
|
|
@ -14,7 +14,7 @@ class GCKeyboard : public ControllerEmu
|
|||
{
|
||||
public:
|
||||
GCKeyboard(const unsigned int index);
|
||||
void GetInput(KeyboardStatus* const pad);
|
||||
KeyboardStatus GetInput() const;
|
||||
std::string GetName() const override;
|
||||
void LoadDefaults(const ControllerInterface& ciface) override;
|
||||
|
||||
|
|
|
@ -46,13 +46,9 @@ void LoadConfig()
|
|||
s_config.LoadConfig(true);
|
||||
}
|
||||
|
||||
void GetStatus(u8 pad_num, GCPadStatus* pad_status)
|
||||
GCPadStatus GetStatus(u8 pad_num)
|
||||
{
|
||||
memset(pad_status, 0, sizeof(*pad_status));
|
||||
pad_status->err = PAD_ERR_NONE;
|
||||
|
||||
// Get input
|
||||
static_cast<GCPad*>(s_config.GetController(pad_num))->GetInput(pad_status);
|
||||
return static_cast<GCPad*>(s_config.GetController(pad_num))->GetInput();
|
||||
}
|
||||
|
||||
void Rumble(const u8 pad_num, const ControlState strength)
|
||||
|
|
|
@ -18,7 +18,7 @@ void LoadConfig();
|
|||
|
||||
InputConfig* GetConfig();
|
||||
|
||||
void GetStatus(u8 pad_num, GCPadStatus* pad_status);
|
||||
GCPadStatus GetStatus(u8 pad_num);
|
||||
void Rumble(u8 pad_num, ControlState strength);
|
||||
|
||||
bool GetMicButton(u8 pad_num);
|
||||
|
|
|
@ -79,41 +79,44 @@ std::string GCPad::GetName() const
|
|||
return std::string("GCPad") + char('1' + m_index);
|
||||
}
|
||||
|
||||
void GCPad::GetInput(GCPadStatus* const pad)
|
||||
GCPadStatus GCPad::GetInput() const
|
||||
{
|
||||
auto lock = ControllerEmu::GetStateLock();
|
||||
|
||||
ControlState x, y, triggers[2];
|
||||
GCPadStatus pad = {};
|
||||
|
||||
// buttons
|
||||
m_buttons->GetState(&pad->button, button_bitmasks);
|
||||
m_buttons->GetState(&pad.button, button_bitmasks);
|
||||
|
||||
// set analog A/B analog to full or w/e, prolly not needed
|
||||
if (pad->button & PAD_BUTTON_A)
|
||||
pad->analogA = 0xFF;
|
||||
if (pad->button & PAD_BUTTON_B)
|
||||
pad->analogB = 0xFF;
|
||||
if (pad.button & PAD_BUTTON_A)
|
||||
pad.analogA = 0xFF;
|
||||
if (pad.button & PAD_BUTTON_B)
|
||||
pad.analogB = 0xFF;
|
||||
|
||||
// dpad
|
||||
m_dpad->GetState(&pad->button, dpad_bitmasks);
|
||||
m_dpad->GetState(&pad.button, dpad_bitmasks);
|
||||
|
||||
// sticks
|
||||
m_main_stick->GetState(&x, &y);
|
||||
pad->stickX =
|
||||
pad.stickX =
|
||||
static_cast<u8>(GCPadStatus::MAIN_STICK_CENTER_X + (x * GCPadStatus::MAIN_STICK_RADIUS));
|
||||
pad->stickY =
|
||||
pad.stickY =
|
||||
static_cast<u8>(GCPadStatus::MAIN_STICK_CENTER_Y + (y * GCPadStatus::MAIN_STICK_RADIUS));
|
||||
|
||||
m_c_stick->GetState(&x, &y);
|
||||
pad->substickX =
|
||||
pad.substickX =
|
||||
static_cast<u8>(GCPadStatus::C_STICK_CENTER_X + (x * GCPadStatus::C_STICK_RADIUS));
|
||||
pad->substickY =
|
||||
pad.substickY =
|
||||
static_cast<u8>(GCPadStatus::C_STICK_CENTER_Y + (y * GCPadStatus::C_STICK_RADIUS));
|
||||
|
||||
// triggers
|
||||
m_triggers->GetState(&pad->button, trigger_bitmasks, triggers);
|
||||
pad->triggerLeft = static_cast<u8>(triggers[0] * 0xFF);
|
||||
pad->triggerRight = static_cast<u8>(triggers[1] * 0xFF);
|
||||
m_triggers->GetState(&pad.button, trigger_bitmasks, triggers);
|
||||
pad.triggerLeft = static_cast<u8>(triggers[0] * 0xFF);
|
||||
pad.triggerRight = static_cast<u8>(triggers[1] * 0xFF);
|
||||
|
||||
return pad;
|
||||
}
|
||||
|
||||
void GCPad::SetOutput(const ControlState strength)
|
||||
|
|
|
@ -12,7 +12,7 @@ class GCPad : public ControllerEmu
|
|||
{
|
||||
public:
|
||||
GCPad(const unsigned int index);
|
||||
void GetInput(GCPadStatus* const pad);
|
||||
GCPadStatus GetInput() const;
|
||||
void SetOutput(const ControlState strength);
|
||||
|
||||
bool GetMicButton() const;
|
||||
|
|
|
@ -132,16 +132,14 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* _pBuffer, int _iLength)
|
|||
case 0x10:
|
||||
{
|
||||
DEBUG_LOG(AMBASEBOARDDEBUG, "GC-AM: Command 10, %02x (READ STATUS&SWITCHES)", ptr(1));
|
||||
GCPadStatus PadStatus;
|
||||
memset(&PadStatus, 0, sizeof(PadStatus));
|
||||
Pad::GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus);
|
||||
GCPadStatus pad_status = Pad::GetStatus(m_iDeviceNumber);
|
||||
res[resp++] = 0x10;
|
||||
res[resp++] = 0x2;
|
||||
int d10_0 = 0xdf;
|
||||
|
||||
if (PadStatus.triggerLeft)
|
||||
if (pad_status.triggerLeft)
|
||||
d10_0 &= ~0x80;
|
||||
if (PadStatus.triggerRight)
|
||||
if (pad_status.triggerRight)
|
||||
d10_0 &= ~0x40;
|
||||
|
||||
res[resp++] = d10_0;
|
||||
|
@ -299,32 +297,31 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* _pBuffer, int _iLength)
|
|||
msg.AddData(0); // tilt
|
||||
for (i = 0; i < nr_players; ++i)
|
||||
{
|
||||
GCPadStatus PadStatus;
|
||||
Pad::GetStatus(i, &PadStatus);
|
||||
GCPadStatus pad_status = Pad::GetStatus(i);
|
||||
unsigned char player_data[2] = {0, 0};
|
||||
if (PadStatus.button & PAD_BUTTON_START)
|
||||
if (pad_status.button & PAD_BUTTON_START)
|
||||
player_data[0] |= 0x80;
|
||||
if (PadStatus.button & PAD_BUTTON_UP)
|
||||
if (pad_status.button & PAD_BUTTON_UP)
|
||||
player_data[0] |= 0x20;
|
||||
if (PadStatus.button & PAD_BUTTON_DOWN)
|
||||
if (pad_status.button & PAD_BUTTON_DOWN)
|
||||
player_data[0] |= 0x10;
|
||||
if (PadStatus.button & PAD_BUTTON_LEFT)
|
||||
if (pad_status.button & PAD_BUTTON_LEFT)
|
||||
player_data[0] |= 0x08;
|
||||
if (PadStatus.button & PAD_BUTTON_RIGHT)
|
||||
if (pad_status.button & PAD_BUTTON_RIGHT)
|
||||
player_data[0] |= 0x04;
|
||||
|
||||
if (PadStatus.button & PAD_BUTTON_A)
|
||||
if (pad_status.button & PAD_BUTTON_A)
|
||||
player_data[0] |= 0x02;
|
||||
if (PadStatus.button & PAD_BUTTON_B)
|
||||
if (pad_status.button & PAD_BUTTON_B)
|
||||
player_data[0] |= 0x01;
|
||||
|
||||
if (PadStatus.button & PAD_BUTTON_X)
|
||||
if (pad_status.button & PAD_BUTTON_X)
|
||||
player_data[1] |= 0x80;
|
||||
if (PadStatus.button & PAD_BUTTON_Y)
|
||||
if (pad_status.button & PAD_BUTTON_Y)
|
||||
player_data[1] |= 0x40;
|
||||
if (PadStatus.button & PAD_TRIGGER_L)
|
||||
if (pad_status.button & PAD_TRIGGER_L)
|
||||
player_data[1] |= 0x20;
|
||||
if (PadStatus.button & PAD_TRIGGER_R)
|
||||
if (pad_status.button & PAD_TRIGGER_R)
|
||||
player_data[1] |= 0x10;
|
||||
|
||||
for (j = 0; j < bytes_per_player; ++j)
|
||||
|
@ -336,12 +333,11 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* _pBuffer, int _iLength)
|
|||
{
|
||||
int slots = *jvs_io++;
|
||||
msg.AddData(1);
|
||||
GCPadStatus PadStatus;
|
||||
Pad::GetStatus(0, &PadStatus);
|
||||
GCPadStatus pad_status = Pad::GetStatus(0);
|
||||
while (slots--)
|
||||
{
|
||||
msg.AddData(0);
|
||||
msg.AddData((PadStatus.button & PAD_BUTTON_START) ? 1 : 0);
|
||||
msg.AddData((pad_status.button & PAD_BUTTON_START) ? 1 : 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -25,19 +25,18 @@ CSIDevice_GCAdapter::CSIDevice_GCAdapter(SIDevices device, int _iDeviceNumber)
|
|||
|
||||
GCPadStatus CSIDevice_GCAdapter::GetPadStatus()
|
||||
{
|
||||
GCPadStatus PadStatus;
|
||||
memset(&PadStatus, 0, sizeof(PadStatus));
|
||||
GCPadStatus pad_status = {};
|
||||
|
||||
// For netplay, the local controllers are polled in GetNetPads(), and
|
||||
// the remote controllers receive their status there as well
|
||||
if (!NetPlay::IsNetPlayRunning())
|
||||
{
|
||||
GCAdapter::Input(ISIDevice::m_iDeviceNumber, &PadStatus);
|
||||
pad_status = GCAdapter::Input(m_iDeviceNumber);
|
||||
}
|
||||
|
||||
HandleMoviePadStatus(&PadStatus);
|
||||
HandleMoviePadStatus(&pad_status);
|
||||
|
||||
return PadStatus;
|
||||
return pad_status;
|
||||
}
|
||||
|
||||
int CSIDevice_GCAdapter::RunBuffer(u8* buffer, int length)
|
||||
|
|
|
@ -140,18 +140,17 @@ void CSIDevice_GCController::HandleMoviePadStatus(GCPadStatus* PadStatus)
|
|||
|
||||
GCPadStatus CSIDevice_GCController::GetPadStatus()
|
||||
{
|
||||
GCPadStatus PadStatus;
|
||||
memset(&PadStatus, 0, sizeof(PadStatus));
|
||||
GCPadStatus pad_status = {};
|
||||
|
||||
// For netplay, the local controllers are polled in GetNetPads(), and
|
||||
// the remote controllers receive their status there as well
|
||||
if (!NetPlay::IsNetPlayRunning())
|
||||
{
|
||||
Pad::GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus);
|
||||
pad_status = Pad::GetStatus(m_iDeviceNumber);
|
||||
}
|
||||
|
||||
HandleMoviePadStatus(&PadStatus);
|
||||
return PadStatus;
|
||||
HandleMoviePadStatus(&pad_status);
|
||||
return pad_status;
|
||||
}
|
||||
|
||||
// GetData
|
||||
|
|
|
@ -56,9 +56,7 @@ int CSIDevice_Keyboard::RunBuffer(u8* _pBuffer, int _iLength)
|
|||
|
||||
KeyboardStatus CSIDevice_Keyboard::GetKeyboardStatus() const
|
||||
{
|
||||
KeyboardStatus KeyStatus = {};
|
||||
Keyboard::GetStatus(ISIDevice::m_iDeviceNumber, &KeyStatus);
|
||||
return KeyStatus;
|
||||
return Keyboard::GetStatus(m_iDeviceNumber);
|
||||
}
|
||||
|
||||
bool CSIDevice_Keyboard::GetData(u32& _Hi, u32& _Low)
|
||||
|
|
|
@ -973,11 +973,11 @@ bool NetPlayClient::GetNetPads(const u8 pad_nb, GCPadStatus* pad_status)
|
|||
switch (SConfig::GetInstance().m_SIDevice[local_pad])
|
||||
{
|
||||
case SIDEVICE_WIIU_ADAPTER:
|
||||
GCAdapter::Input(local_pad, pad_status);
|
||||
*pad_status = GCAdapter::Input(local_pad);
|
||||
break;
|
||||
case SIDEVICE_GC_CONTROLLER:
|
||||
default:
|
||||
Pad::GetStatus(local_pad, pad_status);
|
||||
*pad_status = Pad::GetStatus(local_pad);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -371,13 +371,13 @@ static void Reset()
|
|||
NOTICE_LOG(SERIALINTERFACE, "GC Adapter detached");
|
||||
}
|
||||
|
||||
void Input(int chan, GCPadStatus* pad)
|
||||
GCPadStatus Input(int chan)
|
||||
{
|
||||
if (!UseAdapter())
|
||||
return;
|
||||
return {};
|
||||
|
||||
if (s_handle == nullptr || !s_detected)
|
||||
return;
|
||||
return {};
|
||||
|
||||
int payload_size = 0;
|
||||
u8 controller_payload_copy[37];
|
||||
|
@ -389,6 +389,7 @@ void Input(int chan, GCPadStatus* pad)
|
|||
payload_size = s_controller_payload_size.load();
|
||||
}
|
||||
|
||||
GCPadStatus pad = {};
|
||||
if (payload_size != sizeof(controller_payload_copy) ||
|
||||
controller_payload_copy[0] != LIBUSB_DT_HID)
|
||||
{
|
||||
|
@ -410,57 +411,58 @@ void Input(int chan, GCPadStatus* pad)
|
|||
|
||||
s_controller_type[chan] = type;
|
||||
|
||||
memset(pad, 0, sizeof(*pad));
|
||||
if (s_controller_type[chan] != ControllerTypes::CONTROLLER_NONE)
|
||||
{
|
||||
u8 b1 = controller_payload_copy[1 + (9 * chan) + 1];
|
||||
u8 b2 = controller_payload_copy[1 + (9 * chan) + 2];
|
||||
|
||||
if (b1 & (1 << 0))
|
||||
pad->button |= PAD_BUTTON_A;
|
||||
pad.button |= PAD_BUTTON_A;
|
||||
if (b1 & (1 << 1))
|
||||
pad->button |= PAD_BUTTON_B;
|
||||
pad.button |= PAD_BUTTON_B;
|
||||
if (b1 & (1 << 2))
|
||||
pad->button |= PAD_BUTTON_X;
|
||||
pad.button |= PAD_BUTTON_X;
|
||||
if (b1 & (1 << 3))
|
||||
pad->button |= PAD_BUTTON_Y;
|
||||
pad.button |= PAD_BUTTON_Y;
|
||||
|
||||
if (b1 & (1 << 4))
|
||||
pad->button |= PAD_BUTTON_LEFT;
|
||||
pad.button |= PAD_BUTTON_LEFT;
|
||||
if (b1 & (1 << 5))
|
||||
pad->button |= PAD_BUTTON_RIGHT;
|
||||
pad.button |= PAD_BUTTON_RIGHT;
|
||||
if (b1 & (1 << 6))
|
||||
pad->button |= PAD_BUTTON_DOWN;
|
||||
pad.button |= PAD_BUTTON_DOWN;
|
||||
if (b1 & (1 << 7))
|
||||
pad->button |= PAD_BUTTON_UP;
|
||||
pad.button |= PAD_BUTTON_UP;
|
||||
|
||||
if (b2 & (1 << 0))
|
||||
pad->button |= PAD_BUTTON_START;
|
||||
pad.button |= PAD_BUTTON_START;
|
||||
if (b2 & (1 << 1))
|
||||
pad->button |= PAD_TRIGGER_Z;
|
||||
pad.button |= PAD_TRIGGER_Z;
|
||||
if (b2 & (1 << 2))
|
||||
pad->button |= PAD_TRIGGER_R;
|
||||
pad.button |= PAD_TRIGGER_R;
|
||||
if (b2 & (1 << 3))
|
||||
pad->button |= PAD_TRIGGER_L;
|
||||
pad.button |= PAD_TRIGGER_L;
|
||||
|
||||
if (get_origin)
|
||||
pad->button |= PAD_GET_ORIGIN;
|
||||
pad.button |= PAD_GET_ORIGIN;
|
||||
|
||||
pad->stickX = controller_payload_copy[1 + (9 * chan) + 3];
|
||||
pad->stickY = controller_payload_copy[1 + (9 * chan) + 4];
|
||||
pad->substickX = controller_payload_copy[1 + (9 * chan) + 5];
|
||||
pad->substickY = controller_payload_copy[1 + (9 * chan) + 6];
|
||||
pad->triggerLeft = controller_payload_copy[1 + (9 * chan) + 7];
|
||||
pad->triggerRight = controller_payload_copy[1 + (9 * chan) + 8];
|
||||
pad.stickX = controller_payload_copy[1 + (9 * chan) + 3];
|
||||
pad.stickY = controller_payload_copy[1 + (9 * chan) + 4];
|
||||
pad.substickX = controller_payload_copy[1 + (9 * chan) + 5];
|
||||
pad.substickY = controller_payload_copy[1 + (9 * chan) + 6];
|
||||
pad.triggerLeft = controller_payload_copy[1 + (9 * chan) + 7];
|
||||
pad.triggerRight = controller_payload_copy[1 + (9 * chan) + 8];
|
||||
}
|
||||
else if (!Core::g_want_determinism)
|
||||
{
|
||||
// This is a hack to prevent a desync due to SI devices
|
||||
// being different and returning different values.
|
||||
// The corresponding code in DeviceGCAdapter has the same check
|
||||
pad->button = PAD_ERR_STATUS;
|
||||
pad.button = PAD_ERR_STATUS;
|
||||
}
|
||||
}
|
||||
|
||||
return pad;
|
||||
}
|
||||
|
||||
bool DeviceConnected(int chan)
|
||||
|
|
|
@ -24,7 +24,7 @@ void Shutdown();
|
|||
void SetAdapterCallback(std::function<void(void)> func);
|
||||
void StartScanThread();
|
||||
void StopScanThread();
|
||||
void Input(int chan, GCPadStatus* pad);
|
||||
GCPadStatus Input(int chan);
|
||||
void Output(int chan, u8 rumble_command);
|
||||
bool IsDetected();
|
||||
bool IsDriverDetected();
|
||||
|
|
|
@ -262,10 +262,10 @@ void StopScanThread()
|
|||
s_adapter_detect_thread.join();
|
||||
}
|
||||
|
||||
void Input(int chan, GCPadStatus* pad)
|
||||
GCPadStatus Input(int chan)
|
||||
{
|
||||
if (!UseAdapter() || !s_detected || !s_fd)
|
||||
return;
|
||||
return {};
|
||||
|
||||
int payload_size = 0;
|
||||
u8 controller_payload_copy[37];
|
||||
|
@ -277,6 +277,7 @@ void Input(int chan, GCPadStatus* pad)
|
|||
payload_size = s_controller_payload_size.load();
|
||||
}
|
||||
|
||||
GCPadStatus pad = {};
|
||||
if (payload_size != sizeof(controller_payload_copy))
|
||||
{
|
||||
ERROR_LOG(SERIALINTERFACE, "error reading payload (size: %d, type: %02x)", payload_size,
|
||||
|
@ -297,54 +298,55 @@ void Input(int chan, GCPadStatus* pad)
|
|||
|
||||
s_controller_type[chan] = type;
|
||||
|
||||
memset(pad, 0, sizeof(*pad));
|
||||
if (s_controller_type[chan] != ControllerTypes::CONTROLLER_NONE)
|
||||
{
|
||||
u8 b1 = controller_payload_copy[1 + (9 * chan) + 1];
|
||||
u8 b2 = controller_payload_copy[1 + (9 * chan) + 2];
|
||||
|
||||
if (b1 & (1 << 0))
|
||||
pad->button |= PAD_BUTTON_A;
|
||||
pad.button |= PAD_BUTTON_A;
|
||||
if (b1 & (1 << 1))
|
||||
pad->button |= PAD_BUTTON_B;
|
||||
pad.button |= PAD_BUTTON_B;
|
||||
if (b1 & (1 << 2))
|
||||
pad->button |= PAD_BUTTON_X;
|
||||
pad.button |= PAD_BUTTON_X;
|
||||
if (b1 & (1 << 3))
|
||||
pad->button |= PAD_BUTTON_Y;
|
||||
pad.button |= PAD_BUTTON_Y;
|
||||
|
||||
if (b1 & (1 << 4))
|
||||
pad->button |= PAD_BUTTON_LEFT;
|
||||
pad.button |= PAD_BUTTON_LEFT;
|
||||
if (b1 & (1 << 5))
|
||||
pad->button |= PAD_BUTTON_RIGHT;
|
||||
pad.button |= PAD_BUTTON_RIGHT;
|
||||
if (b1 & (1 << 6))
|
||||
pad->button |= PAD_BUTTON_DOWN;
|
||||
pad.button |= PAD_BUTTON_DOWN;
|
||||
if (b1 & (1 << 7))
|
||||
pad->button |= PAD_BUTTON_UP;
|
||||
pad.button |= PAD_BUTTON_UP;
|
||||
|
||||
if (b2 & (1 << 0))
|
||||
pad->button |= PAD_BUTTON_START;
|
||||
pad.button |= PAD_BUTTON_START;
|
||||
if (b2 & (1 << 1))
|
||||
pad->button |= PAD_TRIGGER_Z;
|
||||
pad.button |= PAD_TRIGGER_Z;
|
||||
if (b2 & (1 << 2))
|
||||
pad->button |= PAD_TRIGGER_R;
|
||||
pad.button |= PAD_TRIGGER_R;
|
||||
if (b2 & (1 << 3))
|
||||
pad->button |= PAD_TRIGGER_L;
|
||||
pad.button |= PAD_TRIGGER_L;
|
||||
|
||||
if (get_origin)
|
||||
pad->button |= PAD_GET_ORIGIN;
|
||||
pad.button |= PAD_GET_ORIGIN;
|
||||
|
||||
pad->stickX = controller_payload_copy[1 + (9 * chan) + 3];
|
||||
pad->stickY = controller_payload_copy[1 + (9 * chan) + 4];
|
||||
pad->substickX = controller_payload_copy[1 + (9 * chan) + 5];
|
||||
pad->substickY = controller_payload_copy[1 + (9 * chan) + 6];
|
||||
pad->triggerLeft = controller_payload_copy[1 + (9 * chan) + 7];
|
||||
pad->triggerRight = controller_payload_copy[1 + (9 * chan) + 8];
|
||||
pad.stickX = controller_payload_copy[1 + (9 * chan) + 3];
|
||||
pad.stickY = controller_payload_copy[1 + (9 * chan) + 4];
|
||||
pad.substickX = controller_payload_copy[1 + (9 * chan) + 5];
|
||||
pad.substickY = controller_payload_copy[1 + (9 * chan) + 6];
|
||||
pad.triggerLeft = controller_payload_copy[1 + (9 * chan) + 7];
|
||||
pad.triggerRight = controller_payload_copy[1 + (9 * chan) + 8];
|
||||
}
|
||||
else
|
||||
{
|
||||
pad->button = PAD_ERR_STATUS;
|
||||
pad.button = PAD_ERR_STATUS;
|
||||
}
|
||||
}
|
||||
|
||||
return pad;
|
||||
}
|
||||
|
||||
void Output(int chan, u8 rumble_command)
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "InputCommon/GCAdapter.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "InputCommon/GCPadStatus.h"
|
||||
|
||||
namespace GCAdapter
|
||||
{
|
||||
|
@ -25,8 +26,9 @@ void StartScanThread()
|
|||
void StopScanThread()
|
||||
{
|
||||
}
|
||||
void Input(int chan, GCPadStatus* pad)
|
||||
GCPadStatus Input(int chan)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
void Output(int chan, u8 rumble_command)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue