9GuiTrigger::GuiTrigger() :
13 conditionMask(INPUT_BTN_NONE)
17 type = TRIGGER_TYPE::SIMPLE;
18 action = TRIGGER_ACTION::PRIMARY;
20 conditionMask = INPUT_BTN_NONE;
24 type = TRIGGER_TYPE::BUTTON_ONLY;
25 action = TRIGGER_ACTION::SECONDARY;
27 conditionMask = INPUT_BTN_NONE;
31 type = TRIGGER_TYPE::SIMPLE;
32 action = TRIGGER_ACTION::NONE;
34 conditionMask = buttonMask;
38 type = TRIGGER_TYPE::HELD;
39 action = TRIGGER_ACTION::NONE;
41 conditionMask = buttonMask;
45 type = TRIGGER_TYPE::BUTTON_ONLY;
46 action = TRIGGER_ACTION::NONE;
48 conditionMask = buttonMask;
52 type = TRIGGER_TYPE::BUTTON_ONLY_IN_FOCUS;
53 action = TRIGGER_ACTION::NONE;
55 conditionMask = buttonMask;
58uint32_t GuiTrigger::resolveMask(
const InputController* controller)
const {
59 if (action == TRIGGER_ACTION::PRIMARY) {
60 return controller->isSideways() ? INPUT_BTN_2 : INPUT_BTN_A;
62 else if (action == TRIGGER_ACTION::SECONDARY) {
63 return controller->
isSideways() ? INPUT_BTN_1 : INPUT_BTN_B;
73 return INPUT_BTN_NONE;
74 if (action == TRIGGER_ACTION::PRIMARY)
76 if (action == TRIGGER_ACTION::SECONDARY)
78 return INPUT_BTN_NONE;
82 if (!controller || (chan != -1 && controller->getChannel() != chan)) {
86 return ((d.
buttons_d & resolveMask(controller)) |
87 (d.
hw_buttons_d[INPUT_HW_DRC] & UnrotatedHwMask(action, controller))) != 0;
91 if (!controller || (chan != -1 && controller->getChannel() != chan)) {
95 return ((d.
buttons_h & resolveMask(controller)) |
96 (d.
hw_buttons_h[INPUT_HW_DRC] & UnrotatedHwMask(action, controller))) != 0;
100 if (!controller || (chan != -1 && controller->getChannel() != chan)) {
104 return ((d.
buttons_r & resolveMask(controller)) |
105 (d.
hw_buttons_r[INPUT_HW_DRC] & UnrotatedHwMask(action, controller))) != 0;
Umbrella header for the platform-agnostic libgui core.
void setSimpleTrigger(int ch, uint32_t buttonMask)
Sets a simple trigger.
bool isReleased(const InputController *controller) const
void setButtonOnlyInFocusTrigger(int ch, uint32_t buttonMask)
Sets a button-only trigger.
bool isClicked(const InputController *controller) const
bool isHeld(const InputController *controller) const
void setPrimaryTrigger(int ch=-1)
Semantic Triggers.
void setHeldTrigger(int ch, uint32_t buttonMask)
Sets a held trigger.
void setButtonOnlyTrigger(int ch, uint32_t buttonMask)
Sets a button-only trigger.
void setSecondaryTrigger(int ch=-1)
TRIGGER_TYPE
How a GuiTrigger matches input: simple, held, button-only, or button-only-in-focus.
TRIGGER_ACTION
Whether a GuiTrigger uses an explicit button mask or a semantic primary (Accept) / secondary (Cancel)...