|
|
|
@ -1,6 +1,7 @@
@@ -1,6 +1,7 @@
|
|
|
|
|
#include "Controller.h" |
|
|
|
|
#include <memory> |
|
|
|
|
#include <algorithm> |
|
|
|
|
#include "Cvar.h" |
|
|
|
|
#if __APPLE__ |
|
|
|
|
#include <SDL_events.h> |
|
|
|
|
#else |
|
|
|
@ -21,58 +22,67 @@ namespace Ship {
@@ -21,58 +22,67 @@ namespace Ship {
|
|
|
|
|
void Controller::Read(OSContPad* pad, int32_t virtualSlot) { |
|
|
|
|
ReadFromSource(virtualSlot); |
|
|
|
|
|
|
|
|
|
OSContPad padToBuffer = { 0 }; |
|
|
|
|
|
|
|
|
|
#ifndef __WIIU__ |
|
|
|
|
SDL_PumpEvents(); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// Button Inputs
|
|
|
|
|
pad->button |= getPressedButtons(virtualSlot) & 0xFFFF; |
|
|
|
|
padToBuffer.button |= getPressedButtons(virtualSlot) & 0xFFFF; |
|
|
|
|
|
|
|
|
|
// Stick Inputs
|
|
|
|
|
if (getLeftStickX(virtualSlot) == 0) { |
|
|
|
|
if (getPressedButtons(virtualSlot) & BTN_STICKLEFT) { |
|
|
|
|
pad->stick_x = -128; |
|
|
|
|
padToBuffer.stick_x = -128; |
|
|
|
|
} else if (getPressedButtons(virtualSlot) & BTN_STICKRIGHT) { |
|
|
|
|
pad->stick_x = 127; |
|
|
|
|
padToBuffer.stick_x = 127; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
pad->stick_x = getLeftStickX(virtualSlot); |
|
|
|
|
padToBuffer.stick_x = getLeftStickX(virtualSlot); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (getLeftStickY(virtualSlot) == 0) { |
|
|
|
|
if (getPressedButtons(virtualSlot) & BTN_STICKDOWN) { |
|
|
|
|
pad->stick_y = -128; |
|
|
|
|
padToBuffer.stick_y = -128; |
|
|
|
|
} else if (getPressedButtons(virtualSlot) & BTN_STICKUP) { |
|
|
|
|
pad->stick_y = 127; |
|
|
|
|
padToBuffer.stick_y = 127; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
pad->stick_y = getLeftStickY(virtualSlot); |
|
|
|
|
padToBuffer.stick_y = getLeftStickY(virtualSlot); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Stick Inputs
|
|
|
|
|
if (getRightStickX(virtualSlot) == 0) { |
|
|
|
|
if (getPressedButtons(virtualSlot) & BTN_VSTICKLEFT) { |
|
|
|
|
pad->right_stick_x = -128; |
|
|
|
|
padToBuffer.right_stick_x = -128; |
|
|
|
|
} else if (getPressedButtons(virtualSlot) & BTN_VSTICKRIGHT) { |
|
|
|
|
pad->right_stick_x = 127; |
|
|
|
|
padToBuffer.right_stick_x = 127; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
pad->right_stick_x = getRightStickX(virtualSlot); |
|
|
|
|
padToBuffer.right_stick_x = getRightStickX(virtualSlot); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (getRightStickY(virtualSlot) == 0) { |
|
|
|
|
if (getPressedButtons(virtualSlot) & BTN_VSTICKDOWN) { |
|
|
|
|
pad->right_stick_y = -128; |
|
|
|
|
padToBuffer.right_stick_y = -128; |
|
|
|
|
} else if (getPressedButtons(virtualSlot) & BTN_VSTICKUP) { |
|
|
|
|
pad->right_stick_y = 127; |
|
|
|
|
padToBuffer.right_stick_y = 127; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
pad->right_stick_y = getRightStickY(virtualSlot); |
|
|
|
|
padToBuffer.right_stick_y = getRightStickY(virtualSlot); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Gyro
|
|
|
|
|
pad->gyro_x = getGyroX(virtualSlot); |
|
|
|
|
pad->gyro_y = getGyroY(virtualSlot); |
|
|
|
|
padToBuffer.gyro_x = getGyroX(virtualSlot); |
|
|
|
|
padToBuffer.gyro_y = getGyroY(virtualSlot); |
|
|
|
|
|
|
|
|
|
padBuffer.push_front(padToBuffer); |
|
|
|
|
*pad = padBuffer[std::min(padBuffer.size(), (size_t)CVar_GetS32("gSimulatedInputLag", 0))]; |
|
|
|
|
|
|
|
|
|
while (padBuffer.size() > 6) { |
|
|
|
|
padBuffer.pop_back(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Controller::SetButtonMapping(int32_t virtualSlot, int32_t n64Button, int32_t dwScancode) { |
|
|
|
|