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
|
* Reference: https://github.com/ToadKing/wii-u-gc-adapter/blob/master/wii-u-gc-adapter.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DolphinSmashAdapter::DolphinSmashAdapter(DeviceToken* token)
|
DolphinSmashAdapter::DolphinSmashAdapter(DeviceToken* token) : DeviceBase(token) {}
|
||||||
: DeviceBase(token)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
DolphinSmashAdapter::~DolphinSmashAdapter()
|
DolphinSmashAdapter::~DolphinSmashAdapter() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline EDolphinControllerType parseType(unsigned char status)
|
static inline EDolphinControllerType parseType(unsigned char status)
|
||||||
{
|
{
|
||||||
EDolphinControllerType type = EDolphinControllerType(status) &
|
EDolphinControllerType type =
|
||||||
(EDolphinControllerType::Normal | EDolphinControllerType::Wavebird);
|
EDolphinControllerType(status) & (EDolphinControllerType::Normal | EDolphinControllerType::Wavebird);
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case EDolphinControllerType::Normal:
|
case EDolphinControllerType::Normal:
|
||||||
|
@ -32,8 +27,7 @@ static inline EDolphinControllerType parseType(unsigned char status)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline EDolphinControllerType
|
static inline EDolphinControllerType parseState(DolphinControllerState* stateOut, uint8_t* payload, bool& rumble)
|
||||||
parseState(DolphinControllerState* stateOut, uint8_t* payload, bool& rumble)
|
|
||||||
{
|
{
|
||||||
memset(stateOut, 0, sizeof(DolphinControllerState));
|
memset(stateOut, 0, sizeof(DolphinControllerState));
|
||||||
unsigned char status = payload[0];
|
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_btns = (uint16_t)payload[1] << 8 | (uint16_t)payload[2];
|
||||||
|
|
||||||
stateOut->m_leftStick[0] = payload[3];
|
stateOut->m_leftStick[0] = payload[4];
|
||||||
stateOut->m_leftStick[1] = payload[4];
|
stateOut->m_leftStick[1] = payload[3];
|
||||||
stateOut->m_rightStick[0] = payload[5];
|
stateOut->m_rightStick[0] = payload[6];
|
||||||
stateOut->m_rightStick[1] = payload[6];
|
stateOut->m_rightStick[1] = payload[5];
|
||||||
stateOut->m_analogTriggers[0] = payload[7];
|
stateOut->m_analogTriggers[0] = payload[7];
|
||||||
stateOut->m_analogTriggers[1] = payload[8];
|
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)
|
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;
|
if (x > 0)
|
||||||
y = py;
|
{
|
||||||
|
|
||||||
if (x >= 0)
|
|
||||||
signX = 1;
|
signX = 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
signX = -1;
|
signX = -1;
|
||||||
x = -x;
|
x = -x;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y >= 0)
|
if (y > 0)
|
||||||
|
{
|
||||||
signY = 1;
|
signY = 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
signY = -1;
|
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;
|
x -= min;
|
||||||
|
|
||||||
if (y <= min)
|
if (y <= min)
|
||||||
|
{
|
||||||
y = 0;
|
y = 0;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
y -= min;
|
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;
|
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)
|
static void pad_clamptrigger(uint8_t& trigger)
|
||||||
|
@ -232,11 +232,13 @@ static void pad_clamptrigger(uint8_t& trigger)
|
||||||
max = pad_clampregion[1];
|
max = pad_clampregion[1];
|
||||||
if (min > trigger)
|
if (min > trigger)
|
||||||
trigger = 0;
|
trigger = 0;
|
||||||
else if (max < trigger)
|
|
||||||
trigger = max - min;
|
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (max < trigger)
|
||||||
|
trigger = max - min;
|
||||||
trigger -= min;
|
trigger -= min;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DolphinControllerState::clamp()
|
void DolphinControllerState::clamp()
|
||||||
{
|
{
|
||||||
|
@ -245,5 +247,4 @@ void DolphinControllerState::clamp()
|
||||||
pad_clamptrigger(m_analogTriggers[0]);
|
pad_clamptrigger(m_analogTriggers[0]);
|
||||||
pad_clamptrigger(m_analogTriggers[1]);
|
pad_clamptrigger(m_analogTriggers[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue