Skip to content

Commit

Permalink
update to latest sdl3
Browse files Browse the repository at this point in the history
  • Loading branch information
loicmagne committed Dec 16, 2024
1 parent 6348bae commit 2848132
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
BUILD_DIR = build

# Targets
all: configure install
all: configure build install

# Pull both main and submodules
pull:
Expand All @@ -10,11 +8,14 @@ pull:

# Run CMake configuration
configure:
cmake -S . -B $(BUILD_DIR) -DCMAKE_CXX_FLAGS="-Wall"
cmake --preset linux-x86_64 -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=lib/x86_64-linux-gnu

build:
cmake --build --preset linux-x86_64

# Build the project
install:
sudo cmake --build $(BUILD_DIR) --target install
sudo cmake --install build_x86_64

# Clean the build directory
clean:
Expand Down
9 changes: 4 additions & 5 deletions src/input_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void gamepad_manager::setup_file()
for (int i = 0; i < SDL_GAMEPAD_BUTTON_TOUCHPAD; ++i) {
m_file << button_to_string((SDL_GamepadButton)i) << ",";
}
for (int i = 0; i < SDL_GAMEPAD_AXIS_MAX; ++i) {
for (int i = 0; i < SDL_GAMEPAD_AXIS_COUNT; ++i) {
m_file << axis_to_string((SDL_GamepadAxis)i) << ",";
}
m_file << std::endl;
Expand All @@ -133,12 +133,11 @@ void gamepad_manager::save_gamepad_state()
for (i = 0; i < SDL_GAMEPAD_BUTTON_TOUCHPAD; ++i) {
const SDL_GamepadButton button = (SDL_GamepadButton)i;
const bool pressed =
SDL_GetGamepadButton(gamepad, button) ==
SDL_PRESSED;
SDL_GetGamepadButton(gamepad, button) == true;
m_file << pressed << ",";
}

for (i = 0; i < SDL_GAMEPAD_AXIS_MAX; ++i) {
for (i = 0; i < SDL_GAMEPAD_AXIS_COUNT; ++i) {
const SDL_GamepadAxis axis = (SDL_GamepadAxis)i;
int16_t value = SDL_GetGamepadAxis(gamepad, axis);
value = (value < AXIS_DEADZONE &&
Expand Down Expand Up @@ -191,7 +190,7 @@ int gamepad_manager::get_gamepad_idx(SDL_JoystickID joystickid)
SDL_Joystick *joystick =
SDL_GetGamepadJoystick(m_gamepads[i]);
if (joystick &&
SDL_GetJoystickInstanceID(joystick) == joystickid) {
SDL_GetJoystickID(joystick) == joystickid) {
return static_cast<int>(i);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ std::string button_to_string(SDL_GamepadButton button)
return "MISC5";
case SDL_GAMEPAD_BUTTON_MISC6:
return "MISC6";
case SDL_GAMEPAD_BUTTON_MAX:
case SDL_GAMEPAD_BUTTON_COUNT:
return "MAX";
default:
return "UNKNOWN";
Expand Down

0 comments on commit 2848132

Please sign in to comment.