Files
mm/src/boot_O2/padutils.c
T
Anghelo Carvajal 4fa13e4132 Move libultra function declarations to libultra headers (#1196)
* Delete unused headers

* Move PR and io to ultra64

* move headers to ultra64

* more cleanups

* more reorganizing

* i think that should be all

* format

* ifdef guards cleanup

* Add IO_READ and IO_WRITE macros for future use

* warnings

* review

Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com>

* warnings again

* warn

* ifdef guards

* fix merge

* fix merge

* fix merge

* bss

* padutils.h

* bss

* bss

* bss

* fix merge

* bss

* bss

* bss

* fix merge

* fixes

* fixes

* bss

* bss

* fix merge

* fix

* fix

* fix includepaths

* fix paths

* bss

* fix

* ultra64/ -> PR/

* header guards

* fix ehader guards

* fix

* fix++

* format

* bss is borken

* prevent 2

* :despair:

* bss

* rename assert to dbg_hungup

* fix

* a

* fix

* bss

* fix

* bss

* bss

---------

Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com>
2023-09-02 15:34:29 -04:00

93 lines
1.9 KiB
C

#include "padutils.h"
void PadUtils_Init(Input* input) {
bzero(input, sizeof(Input));
}
void func_80085150(void) {
}
void PadUtils_ResetPressRel(Input* input) {
input->press.button = 0;
input->rel.button = 0;
}
u32 PadUtils_CheckCurExact(Input* input, u16 value) {
return value == input->cur.button;
}
u32 PadUtils_CheckCur(Input* input, u16 key) {
return key == (input->cur.button & key);
}
u32 PadUtils_CheckPressed(Input* input, u16 key) {
return key == (input->press.button & key);
}
u32 PadUtils_CheckReleased(Input* input, u16 key) {
return key == (input->rel.button & key);
}
u16 PadUtils_GetCurButton(Input* input) {
return input->cur.button;
}
u16 PadUtils_GetPressButton(Input* input) {
return input->press.button;
}
s8 PadUtils_GetCurX(Input* input) {
return input->cur.stick_x;
}
s8 PadUtils_GetCurY(Input* input) {
return input->cur.stick_y;
}
void PadUtils_SetRelXY(Input* input, s32 x, s32 y) {
input->rel.stick_x = x;
input->rel.stick_y = y;
}
s8 PadUtils_GetRelXImpl(Input* input) {
return input->rel.stick_x;
}
s8 PadUtils_GetRelYImpl(Input* input) {
return input->rel.stick_y;
}
s8 PadUtils_GetRelX(Input* input) {
return PadUtils_GetRelXImpl(input);
}
s8 PadUtils_GetRelY(Input* input) {
return PadUtils_GetRelYImpl(input);
}
void PadUtils_UpdateRelXY(Input* input) {
s32 curX = PadUtils_GetCurX(input);
s32 curY = PadUtils_GetCurY(input);
s32 relX;
s32 relY;
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);
}