Path: blob/main/RSDKv4/Input.hpp
817 views
#ifndef INPUT_H1#define INPUT_H23enum InputButtons {4INPUT_UP,5INPUT_DOWN,6INPUT_LEFT,7INPUT_RIGHT,8INPUT_BUTTONA,9INPUT_BUTTONB,10INPUT_BUTTONC,11INPUT_BUTTONX,12INPUT_BUTTONY,13INPUT_BUTTONZ,14INPUT_BUTTONL,15INPUT_BUTTONR,16INPUT_START,17INPUT_SELECT,18INPUT_ANY,19INPUT_BUTTONCOUNT,20};2122struct InputData {23bool up;24bool down;25bool left;26bool right;27bool A;28bool B;29bool C;30bool X;31bool Y;32bool Z;33bool L;34bool R;35bool start;36bool select;37};3839struct InputButton {40bool press, hold;41int keyMappings, contMappings;4243inline void setHeld()44{45press = !hold;46hold = true;47}48inline void setReleased()49{50press = false;51hold = false;52}5354inline bool down() { return (press || hold); }55};5657enum DefaultHapticIDs {58HAPTIC_NONE = -2,59HAPTIC_STOP = -1,60};6162extern InputData keyPress;63extern InputData keyDown;6465extern int touchDown[8];66extern int touchX[8];67extern int touchY[8];68extern int touchID[8];69extern float touchXF[8];70extern float touchYF[8];71extern int touches;7273extern int hapticEffectNum;7475#if !RETRO_USE_ORIGINAL_CODE76extern InputButton inputDevice[INPUT_BUTTONCOUNT];77extern int inputType;7879extern float LSTICK_DEADZONE;80extern float RSTICK_DEADZONE;81extern float LTRIGGER_DEADZONE;82extern float RTRIGGER_DEADZONE;8384extern int mouseHideTimer;85extern int lastMouseX;86extern int lastMouseY;87#endif8889#if !RETRO_USE_ORIGINAL_CODE90#if RETRO_USING_SDL291// Easier this way92enum ExtraSDLButtons {93SDL_CONTROLLER_BUTTON_ZL = SDL_CONTROLLER_BUTTON_MAX + 1,94SDL_CONTROLLER_BUTTON_ZR,95SDL_CONTROLLER_BUTTON_LSTICK_UP,96SDL_CONTROLLER_BUTTON_LSTICK_DOWN,97SDL_CONTROLLER_BUTTON_LSTICK_LEFT,98SDL_CONTROLLER_BUTTON_LSTICK_RIGHT,99SDL_CONTROLLER_BUTTON_RSTICK_UP,100SDL_CONTROLLER_BUTTON_RSTICK_DOWN,101SDL_CONTROLLER_BUTTON_RSTICK_LEFT,102SDL_CONTROLLER_BUTTON_RSTICK_RIGHT,103SDL_CONTROLLER_BUTTON_MAX_EXTRA,104};105106void controllerInit(int controllerID);107void controllerClose(int controllerID);108#endif109110#if RETRO_USING_SDL1111extern byte keyState[SDLK_LAST];112113extern SDL_Joystick *controller;114#endif115116void InitInputDevices();117void ReleaseInputDevices();118119void ProcessInput();120#endif121122void CheckKeyPress(InputData *input);123void CheckKeyDown(InputData *input);124125int CheckTouchRect(float x1, float y1, float x2, float y2);126int CheckTouchRectMatrix(void *m, float x1, float y1, float x2, float y2);127128#if RETRO_USE_HAPTICS129inline int GetHapticEffectNum()130{131int num = hapticEffectNum;132hapticEffectNum = HAPTIC_NONE;133return num;134}135void HapticEffect(int *id, int *a2, int *a3, int *a4);136#endif137138#endif // !INPUT_H139140