2020-10-03 15:22:44 +00:00
|
|
|
#include "global.h"
|
2020-05-25 21:18:14 +00:00
|
|
|
|
|
|
|
void PadUtils_Init(Input* input) {
|
|
|
|
bzero(input, sizeof(Input));
|
|
|
|
}
|
|
|
|
|
2021-02-14 00:49:40 +00:00
|
|
|
void func_800FCB70(void) {
|
2020-05-25 21:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PadUtils_ResetPressRel(Input* input) {
|
2020-10-03 15:22:44 +00:00
|
|
|
input->press.button = 0;
|
|
|
|
input->rel.button = 0;
|
2020-05-25 21:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
u32 PadUtils_CheckCurExact(Input* input, u16 value) {
|
2020-10-03 15:22:44 +00:00
|
|
|
return value == input->cur.button;
|
2020-05-25 21:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
u32 PadUtils_CheckCur(Input* input, u16 key) {
|
2020-10-03 15:22:44 +00:00
|
|
|
return key == (input->cur.button & key);
|
2020-05-25 21:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
u32 PadUtils_CheckPressed(Input* input, u16 key) {
|
2020-10-03 15:22:44 +00:00
|
|
|
return key == (input->press.button & key);
|
2020-05-25 21:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
u32 PadUtils_CheckReleased(Input* input, u16 key) {
|
2020-10-03 15:22:44 +00:00
|
|
|
return key == (input->rel.button & key);
|
2020-05-25 21:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
u16 PadUtils_GetCurButton(Input* input) {
|
2020-10-03 15:22:44 +00:00
|
|
|
return input->cur.button;
|
2020-05-25 21:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
u16 PadUtils_GetPressButton(Input* input) {
|
2020-10-03 15:22:44 +00:00
|
|
|
return input->press.button;
|
2020-05-25 21:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
s8 PadUtils_GetCurX(Input* input) {
|
2020-10-03 15:22:44 +00:00
|
|
|
return input->cur.stick_x;
|
2020-05-25 21:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
s8 PadUtils_GetCurY(Input* input) {
|
2020-10-03 15:22:44 +00:00
|
|
|
return input->cur.stick_y;
|
2020-05-25 21:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PadUtils_SetRelXY(Input* input, s32 x, s32 y) {
|
2020-10-03 15:22:44 +00:00
|
|
|
input->rel.stick_x = x;
|
|
|
|
input->rel.stick_y = y;
|
2020-05-25 21:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
s8 PadUtils_GetRelXImpl(Input* input) {
|
2020-10-03 15:22:44 +00:00
|
|
|
return input->rel.stick_x;
|
2020-05-25 21:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
s8 PadUtils_GetRelYImpl(Input* input) {
|
2020-10-03 15:22:44 +00:00
|
|
|
return input->rel.stick_y;
|
2020-05-25 21:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
s8 PadUtils_GetRelX(Input* input) {
|
|
|
|
return PadUtils_GetRelXImpl(input);
|
|
|
|
}
|
|
|
|
|
|
|
|
s8 PadUtils_GetRelY(Input* input) {
|
|
|
|
return PadUtils_GetRelYImpl(input);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PadUtils_UpdateRelXY(Input* input) {
|
2021-02-14 00:49:40 +00:00
|
|
|
s32 curX = PadUtils_GetCurX(input);
|
|
|
|
s32 curY = PadUtils_GetCurY(input);
|
|
|
|
s32 relX;
|
|
|
|
s32 relY;
|
2020-05-25 21:18:14 +00:00
|
|
|
|
|
|
|
if (curX > 7) {
|
|
|
|
relX = (curX < 0x43) ? curX - 7 : 0x43 - 7;
|
|
|
|
} else if (curX < -7) {
|
|
|
|
relX = (curX > -0x43) ? curX + 7 : -0x43 + 7;
|
|
|
|
} else {
|
|
|
|
relX = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (curY > 7) {
|
|
|
|
relY = (curY < 0x43) ? curY - 7 : 0x43 - 7;
|
|
|
|
|
|
|
|
} else if (curY < -7) {
|
|
|
|
relY = (curY > -0x43) ? curY + 7 : -0x43 + 7;
|
|
|
|
} else {
|
|
|
|
relY = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
PadUtils_SetRelXY(input, relX, relY);
|
|
|
|
}
|