8#include "InputController.h"
13void InitUserInputControllers()
15 for(
int i = 0; i < 4; i++)
26 internalScrollTimer(0.0f)
33 internalScrollTimer += deltaTime;
36 if (currentData.buttons_h == 0 &&
37 std::abs(currentData.stickX) < STICK_DEADZONE &&
38 std::abs(currentData.stickY) < STICK_DEADZONE) {
39 internalScrollTimer = 0.0f;
43bool InputController::processDirection(uint32_t logicalButtonMask,
float stickAxis,
bool isPositiveAxis)
const {
44 bool isPressedDown = (currentData.
buttons_d & logicalButtonMask);
46 bool isStickActive = isPositiveAxis ? (stickAxis > STICK_DEADZONE) : (stickAxis < -STICK_DEADZONE);
50 internalScrollTimer = 0.0f;
55 if (
isHeld || isStickActive) {
56 if (internalScrollTimer >= SCROLL_DELAY_INITIAL) {
58 internalScrollTimer -= SCROLL_DELAY_LOOP;
67 uint32_t targetBtn = sideways ? INPUT_BTN_2 : INPUT_BTN_A;
68 return (currentData.buttons_d & targetBtn);
72 uint32_t targetBtn = sideways ? INPUT_BTN_1 : INPUT_BTN_B;
73 return (currentData.buttons_d & targetBtn);
77 return (currentData.buttons_d & logicalButtonMask);
81 return (currentData.buttons_h & logicalButtonMask);
85 uint32_t targetBtn = sideways ? INPUT_BTN_RIGHT : INPUT_BTN_UP;
86 return processDirection(targetBtn, currentData.stickY,
true);
90 uint32_t targetBtn = sideways ? INPUT_BTN_LEFT : INPUT_BTN_DOWN;
91 return processDirection(targetBtn, currentData.stickY,
false);
95 uint32_t targetBtn = sideways ? INPUT_BTN_UP : INPUT_BTN_LEFT;
96 return processDirection(targetBtn, currentData.stickX,
false);
100 uint32_t targetBtn = sideways ? INPUT_BTN_DOWN : INPUT_BTN_RIGHT;
101 return processDirection(targetBtn, currentData.stickX,
true);
105 platform->getInput()->setContinuousRumble(channel, continuous);