mirror of https://github.com/AxioDL/boo.git
Merge branch 'master' of https://github.com/AxioDL/boo
This commit is contained in:
commit
4be38afef3
|
@ -9,19 +9,14 @@ namespace boo
|
|||
* Reference: https://github.com/ToadKing/wii-u-gc-adapter/blob/master/wii-u-gc-adapter.c
|
||||
*/
|
||||
|
||||
DolphinSmashAdapter::DolphinSmashAdapter(DeviceToken* token)
|
||||
: DeviceBase(token)
|
||||
{
|
||||
}
|
||||
DolphinSmashAdapter::DolphinSmashAdapter(DeviceToken* token) : DeviceBase(token) {}
|
||||
|
||||
DolphinSmashAdapter::~DolphinSmashAdapter()
|
||||
{
|
||||
}
|
||||
DolphinSmashAdapter::~DolphinSmashAdapter() {}
|
||||
|
||||
static inline EDolphinControllerType parseType(unsigned char status)
|
||||
{
|
||||
EDolphinControllerType type = EDolphinControllerType(status) &
|
||||
(EDolphinControllerType::Normal | EDolphinControllerType::Wavebird);
|
||||
EDolphinControllerType type =
|
||||
EDolphinControllerType(status) & (EDolphinControllerType::Normal | EDolphinControllerType::Wavebird);
|
||||
switch (type)
|
||||
{
|
||||
case EDolphinControllerType::Normal:
|
||||
|
@ -32,8 +27,7 @@ static inline EDolphinControllerType parseType(unsigned char status)
|
|||
}
|
||||
}
|
||||
|
||||
static inline EDolphinControllerType
|
||||
parseState(DolphinControllerState* stateOut, uint8_t* payload, bool& rumble)
|
||||
static inline EDolphinControllerType parseState(DolphinControllerState* stateOut, uint8_t* payload, bool& rumble)
|
||||
{
|
||||
memset(stateOut, 0, sizeof(DolphinControllerState));
|
||||
unsigned char status = payload[0];
|
||||
|
@ -43,10 +37,10 @@ parseState(DolphinControllerState* stateOut, uint8_t* payload, bool& rumble)
|
|||
|
||||
stateOut->m_btns = (uint16_t)payload[1] << 8 | (uint16_t)payload[2];
|
||||
|
||||
stateOut->m_leftStick[0] = payload[3];
|
||||
stateOut->m_leftStick[1] = payload[4];
|
||||
stateOut->m_rightStick[0] = payload[5];
|
||||
stateOut->m_rightStick[1] = payload[6];
|
||||
stateOut->m_leftStick[0] = payload[4];
|
||||
stateOut->m_leftStick[1] = payload[3];
|
||||
stateOut->m_rightStick[0] = payload[6];
|
||||
stateOut->m_rightStick[1] = payload[5];
|
||||
stateOut->m_analogTriggers[0] = payload[7];
|
||||
stateOut->m_analogTriggers[1] = payload[8];
|
||||
|
||||
|
@ -161,21 +155,26 @@ static uint8_t pad_clampregion[8] = {30, 180, 15, 72, 40, 15, 59, 31};
|
|||
|
||||
static void pad_clampstick(int8_t& px, int8_t& py, int8_t max, int8_t xy, int8_t min)
|
||||
{
|
||||
int32_t x, y, signX, signY, d;
|
||||
int x = px;
|
||||
int y = py;
|
||||
int signX;
|
||||
int signY;
|
||||
int d;
|
||||
|
||||
x = px;
|
||||
y = py;
|
||||
|
||||
if (x >= 0)
|
||||
if (x > 0)
|
||||
{
|
||||
signX = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
signX = -1;
|
||||
x = -x;
|
||||
}
|
||||
|
||||
if (y >= 0)
|
||||
if (y > 0)
|
||||
{
|
||||
signY = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
signY = -1;
|
||||
|
@ -188,40 +187,41 @@ static void pad_clampstick(int8_t& px, int8_t& py, int8_t max, int8_t xy, int8_t
|
|||
x -= min;
|
||||
|
||||
if (y <= min)
|
||||
{
|
||||
y = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
y -= min;
|
||||
}
|
||||
|
||||
if (x || y)
|
||||
if (x == 0 && y == 0)
|
||||
{
|
||||
int32_t xx, yy, maxy;
|
||||
|
||||
xx = x * xy;
|
||||
yy = y * xy;
|
||||
maxy = max * xy;
|
||||
if (yy <= xx)
|
||||
{
|
||||
d = (x * xy + (y * (max - xy)));
|
||||
if (maxy < d)
|
||||
{
|
||||
x *= maxy / d;
|
||||
y *= maxy / d;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
d = (y * xy + (x * (max - xy)));
|
||||
if (maxy < d)
|
||||
{
|
||||
x *= maxy / d;
|
||||
y *= maxy / d;
|
||||
}
|
||||
}
|
||||
px = int8_t(x * signX);
|
||||
py = int8_t(y * signY);
|
||||
}
|
||||
else
|
||||
px = py = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (xy * y <= xy * x)
|
||||
{
|
||||
d = xy * x + (max - xy) * y;
|
||||
if (xy * max < d)
|
||||
{
|
||||
x = int8_t(xy * max * x / d);
|
||||
y = int8_t(xy * max * y / d);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
d = xy * y + (max - xy) * x;
|
||||
if (xy * max < d)
|
||||
{
|
||||
x = int8_t(xy * max * x / d);
|
||||
y = int8_t(xy * max * y / d);
|
||||
}
|
||||
}
|
||||
|
||||
px = int8_t(signX * x);
|
||||
py = int8_t(signY * y);
|
||||
}
|
||||
|
||||
static void pad_clamptrigger(uint8_t& trigger)
|
||||
|
@ -232,11 +232,13 @@ static void pad_clamptrigger(uint8_t& trigger)
|
|||
max = pad_clampregion[1];
|
||||
if (min > trigger)
|
||||
trigger = 0;
|
||||
else if (max < trigger)
|
||||
trigger = max - min;
|
||||
else
|
||||
{
|
||||
if (max < trigger)
|
||||
trigger = max - min;
|
||||
trigger -= min;
|
||||
}
|
||||
}
|
||||
|
||||
void DolphinControllerState::clamp()
|
||||
{
|
||||
|
@ -245,5 +247,4 @@ void DolphinControllerState::clamp()
|
|||
pad_clamptrigger(m_analogTriggers[0]);
|
||||
pad_clamptrigger(m_analogTriggers[1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue