Skip to content

Commit

Permalink
ruby: add rumble support to sdl driver
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeUsher committed Aug 9, 2023
1 parent dad3db5 commit 862bfec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion ruby/input/joypad/sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ struct InputJoypadSDL {
}
}

auto rumble(u64 id, bool enable) -> bool {
for(auto& jp : joypads) {
if(jp.hid->id() != id) continue;

SDL_JoystickRumble(jp.handle, enable ? 65535 : 0, enable ? 65535 : 0, 0);
return true;
}

return false;
}

auto initialize() -> bool {
terminate();
SDL_Init(SDL_INIT_EVENTS);
Expand Down Expand Up @@ -94,7 +105,7 @@ struct InputJoypadSDL {
for(u32 n : range(axes)) jp.hid->axes().append(n);
for(u32 n : range(hats)) jp.hid->hats().append(n);
for(u32 n : range(buttons)) jp.hid->buttons().append(n);
jp.hid->setRumble(false);
jp.hid->setRumble(true);

joypads.append(jp);
}
Expand Down
2 changes: 1 addition & 1 deletion ruby/input/sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct InputSDL : InputDriver {
}

auto rumble(u64 id, bool enable) -> bool override {
return false;
return joypad.rumble(id, enable);
}

private:
Expand Down

0 comments on commit 862bfec

Please sign in to comment.