summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/GCAdapter_Android.cpp
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2016-08-02 07:32:26 +0200
committerGitHub <noreply@github.com>2016-08-02 07:32:26 +0200
commitfacf02686a542e7250fb01f97a4e6159a8aae41d (patch)
tree6aed18cddffa2a6b01b8cce7c09cec101f5c0b9f /Source/Core/InputCommon/GCAdapter_Android.cpp
parent84c936cab86bd43de52b5523752b74c3ff05ca8f (diff)
parent041f4f5eeae70b0c0d66e100d6dcede01450bf45 (diff)
Merge pull request #4079 from lioncash/state
HW: Make GC input retrieval functions return by value
Diffstat (limited to 'Source/Core/InputCommon/GCAdapter_Android.cpp')
-rw-r--r--Source/Core/InputCommon/GCAdapter_Android.cpp50
1 files changed, 26 insertions, 24 deletions
diff --git a/Source/Core/InputCommon/GCAdapter_Android.cpp b/Source/Core/InputCommon/GCAdapter_Android.cpp
index 8d2d6be6fe..c5f8a98922 100644
--- a/Source/Core/InputCommon/GCAdapter_Android.cpp
+++ b/Source/Core/InputCommon/GCAdapter_Android.cpp
@@ -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->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.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];
}
else
{
- pad->button = PAD_ERR_STATUS;
+ pad.button = PAD_ERR_STATUS;
}
}
+
+ return pad;
}
void Output(int chan, u8 rumble_command)