RobLoach / raygui-container

Adds state to raygui, allowing for gamepad/keyboard-only support.
zlib License
2 stars 1 forks source link

configurable input #5

Open konsumer opened 1 year ago

konsumer commented 1 year ago

The default key/joystick input seems sensible, but I could see it being really useful if it was more configurable (like for different input schemes and things.) How would you feel about removing the input management code here so the user can just do that externally?

So, basically the user could call this in their loop:

   if (IsKeyPressed(KEY_UP) || IsGamepadButtonPressed(0, GAMEPAD_BUTTON_LEFT_FACE_UP)) {
        SetNextActiveGuiElement(gui, UP);
    }
    else if (IsKeyPressed(KEY_DOWN) || IsGamepadButtonPressed(0, GAMEPAD_BUTTON_LEFT_FACE_DOWN)) {
        SetNextActiveGuiElement(gui, DOWN);
    }
    else if (IsKeyPressed(KEY_RIGHT) || IsGamepadButtonPressed(0, GAMEPAD_BUTTON_LEFT_FACE_RIGHT)) {
        SetNextActiveGuiElement(gui, RIGHT);
    }
    else if (IsKeyPressed(KEY_LEFT) || IsGamepadButtonPressed(0, GAMEPAD_BUTTON_LEFT_FACE_LEFT)) {
        SetNextActiveGuiElement(gui, LEFT);
    }
    UpdateGuiContainer(&gui);

We could also maybe drop the TAB-keys stuff and just control it in that input-code, if needed. We could maybe also put the current code in a DefaultInputHandlers(gui) so the users don't have to put a lot of extra code in their loop, if they want the basic input-scheme.