/******************************************************************************************* * * raylib [core_inputactionInputs] example - presents a simple API for remapping input to actions * * Example complexity rating: [★☆☆☆] 1/4 * * Example originally created with raylib 5.5, last time updated with raylib 5.6 * * Example contributed by MonstersGoBoom and reviewed by Ramon Santamaria (@raysan5) * * Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, * BSD-like license that allows static linking with closed source software * * Copyright (c) 2025 MonstersGoBoom * ********************************************************************************************/ /* Simple example for decoding input as actions, allowing remapping of input to different keys or gamepad buttons. for example instead of IsKeyDown(KEY_LEFT) you'd use IsActionDown(ACTION_LEFT) which can be reassigned to e.g. KEY_A and also assigned to a gamepad button. the action will trigger with either gamepad or keys */ #include #include #include #include "raylib.h" // add your own action types here typedef enum ActionType { NO_ACTION, ACTION_UP, ACTION_DOWN, ACTION_LEFT, ACTION_RIGHT, ACTION_FIRE, MAX_ACTION } ActionType; // struct for key and button inputs typedef struct ActionInput { int key; int button; } ActionInput; // gamepad index, change this if you have multiple gamepads. int gamepadIndex = 0; static ActionInput actionInputs[MAX_ACTION] = {0}; // combines IsKeyPressed and IsGameButtonPressed to one action bool isActionPressed(int action) { if (action