2023-11-12 19:47:38 +00:00
|
|
|
#include "patches.h"
|
|
|
|
#include "input.h"
|
|
|
|
|
|
|
|
u32 sPlayerItemButtons[] = {
|
|
|
|
BTN_B,
|
|
|
|
BTN_CLEFT,
|
|
|
|
BTN_CDOWN,
|
|
|
|
BTN_CRIGHT,
|
|
|
|
};
|
|
|
|
|
2023-12-01 15:56:20 +00:00
|
|
|
u32 sPlayerItemButtonsDualAnalog[] = {
|
|
|
|
BTN_B,
|
|
|
|
BTN_DLEFT,
|
|
|
|
BTN_DDOWN,
|
|
|
|
BTN_DRIGHT
|
|
|
|
};
|
|
|
|
|
2023-11-24 22:10:21 +00:00
|
|
|
u32 prev_item_buttons = 0;
|
|
|
|
u32 cur_item_buttons = 0;
|
|
|
|
u32 pressed_item_buttons = 0;
|
|
|
|
u32 released_item_buttons = 0;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
EQUIP_SLOT_EX_DEKU = -2,
|
|
|
|
EQUIP_SLOT_EX_GORON = -3,
|
|
|
|
EQUIP_SLOT_EX_ZORA = -4,
|
|
|
|
EQUIP_SLOT_EX_OCARINA = -5
|
|
|
|
} EquipSlotEx;
|
|
|
|
|
|
|
|
void GameState_GetInput(GameState* gameState) {
|
|
|
|
PadMgr_GetInput(gameState->input, true);
|
|
|
|
|
2023-12-01 15:56:20 +00:00
|
|
|
if (recomp_camera_mode == RECOMP_CAMERA_DUALANALOG) {
|
|
|
|
gameState->input[0].cur.button &= ~BTN_CUP;
|
|
|
|
gameState->input[0].press.button &= ~BTN_CUP;
|
|
|
|
gameState->input[0].rel.button &= ~BTN_CUP;
|
|
|
|
}
|
2023-11-24 22:10:21 +00:00
|
|
|
|
|
|
|
prev_item_buttons = cur_item_buttons;
|
|
|
|
recomp_get_item_inputs(&cur_item_buttons);
|
|
|
|
u32 button_diff = prev_item_buttons ^ cur_item_buttons;
|
|
|
|
pressed_item_buttons = cur_item_buttons & button_diff;
|
|
|
|
released_item_buttons = prev_item_buttons & button_diff;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SlotMap {
|
|
|
|
u32 button;
|
|
|
|
EquipSlotEx slot;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SlotMap exSlotMapping[] = {
|
|
|
|
{BTN_DLEFT, EQUIP_SLOT_EX_GORON},
|
|
|
|
{BTN_DRIGHT, EQUIP_SLOT_EX_ZORA},
|
|
|
|
{BTN_DUP, EQUIP_SLOT_EX_DEKU},
|
|
|
|
{BTN_DDOWN, EQUIP_SLOT_EX_OCARINA},
|
|
|
|
};
|
|
|
|
|
|
|
|
// D-Pad items
|
|
|
|
// TODO restore this once UI is made
|
|
|
|
// Return currently-pressed button, in order of priority D-Pad, B, CLEFT, CDOWN, CRIGHT.
|
2023-12-01 15:56:20 +00:00
|
|
|
|
2023-11-12 19:47:38 +00:00
|
|
|
EquipSlot func_8082FDC4(void) {
|
|
|
|
EquipSlot i;
|
2023-11-24 22:10:21 +00:00
|
|
|
|
2023-12-01 15:56:20 +00:00
|
|
|
// for (int mapping_index = 0; mapping_index < ARRAY_COUNT(exSlotMapping); mapping_index++) {
|
|
|
|
// if (pressed_item_buttons & exSlotMapping[mapping_index].button) {
|
|
|
|
// return (EquipSlot)exSlotMapping[mapping_index].slot;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
u32* button_map = recomp_camera_mode == RECOMP_CAMERA_DUALANALOG ? sPlayerItemButtonsDualAnalog : sPlayerItemButtons;
|
2023-11-12 19:47:38 +00:00
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_COUNT(sPlayerItemButtons); i++) {
|
2023-12-01 15:56:20 +00:00
|
|
|
if (CHECK_BTN_ALL(pressed_item_buttons, button_map[i])) {
|
2023-11-12 19:47:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
2023-12-01 15:56:20 +00:00
|
|
|
/*
|
2023-11-24 22:10:21 +00:00
|
|
|
ItemId Player_GetItemOnButton(PlayState* play, Player* player, EquipSlot slot) {
|
|
|
|
if (slot >= EQUIP_SLOT_A) {
|
|
|
|
return ITEM_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (slot <= EQUIP_SLOT_EX_DEKU) {
|
|
|
|
ItemId dpad_item = ITEM_NONE;
|
|
|
|
switch ((EquipSlotEx)slot) {
|
|
|
|
case EQUIP_SLOT_EX_DEKU:
|
|
|
|
dpad_item = ITEM_MASK_DEKU;
|
|
|
|
break;
|
|
|
|
case EQUIP_SLOT_EX_GORON:
|
|
|
|
dpad_item = ITEM_MASK_GORON;
|
|
|
|
break;
|
|
|
|
case EQUIP_SLOT_EX_ZORA:
|
|
|
|
dpad_item = ITEM_MASK_ZORA;
|
|
|
|
break;
|
|
|
|
case EQUIP_SLOT_EX_OCARINA:
|
|
|
|
dpad_item = ITEM_OCARINA_OF_TIME;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((dpad_item != ITEM_NONE) && (INV_CONTENT(dpad_item) == dpad_item)) {
|
|
|
|
recomp_printf("Used dpad item %d\n", dpad_item);
|
|
|
|
return dpad_item;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return ITEM_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (slot == EQUIP_SLOT_B) {
|
|
|
|
ItemId item = Inventory_GetBtnBItem(play);
|
|
|
|
|
|
|
|
if (item >= ITEM_FD) {
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((player->currentMask == PLAYER_MASK_BLAST) && (play->interfaceCtx.bButtonDoAction == DO_ACTION_EXPLODE)) {
|
|
|
|
return ITEM_F0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((player->currentMask == PLAYER_MASK_BREMEN) && (play->interfaceCtx.bButtonDoAction == DO_ACTION_MARCH)) {
|
|
|
|
return ITEM_F1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((player->currentMask == PLAYER_MASK_KAMARO) && (play->interfaceCtx.bButtonDoAction == DO_ACTION_DANCE)) {
|
|
|
|
return ITEM_F2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (slot == EQUIP_SLOT_C_LEFT) {
|
|
|
|
return C_BTN_ITEM(EQUIP_SLOT_C_LEFT);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (slot == EQUIP_SLOT_C_DOWN) {
|
|
|
|
return C_BTN_ITEM(EQUIP_SLOT_C_DOWN);
|
|
|
|
}
|
|
|
|
|
|
|
|
// EQUIP_SLOT_C_RIGHT
|
|
|
|
|
|
|
|
return C_BTN_ITEM(EQUIP_SLOT_C_RIGHT);
|
|
|
|
}
|
|
|
|
*/
|