mirror of
https://github.com/open-goal/jak-project
synced 2026-06-05 19:28:31 -04:00
6faa7530f9
The current event-based approach is very difficult to get right, and it depends on no events ever being missed. This changes the keyboard/mouse handling code to a polling-based approach. Other fixes: - an issue where modifier keys were not able to be successfully bound (like Left Shift to `X`) - improves cursor hiding (except when you use the start menu, this seems like an SDL issue, see comment) - Better discarding of kb/mouse inputs when imgui intercepts input - properly swap bindings when an already set key is assigned, even if it crosses the distinction of an analog vs normal button Fixes #2800
31 lines
1.0 KiB
C++
31 lines
1.0 KiB
C++
#pragma once
|
|
|
|
#include "input_device.h"
|
|
|
|
// https://wiki.libsdl.org/SDL2/CategoryGameController
|
|
class GameController : public InputDevice {
|
|
public:
|
|
GameController(int sdl_device_id, std::shared_ptr<game_settings::InputSettings> settings);
|
|
~GameController() { close_device(); }
|
|
|
|
void process_event(const SDL_Event& event,
|
|
const CommandBindingGroups& commands,
|
|
std::shared_ptr<PadData> data,
|
|
std::optional<InputBindAssignmentMeta>& bind_assignment) override;
|
|
void close_device() override;
|
|
int update_rumble(const u8 low_rumble, const u8 high_rumble);
|
|
std::string get_name() const { return m_device_name; }
|
|
bool has_led() { return m_has_led; }
|
|
bool has_rumble() { return m_has_rumble; }
|
|
void set_led(const u8 red, const u8 green, const u8 blue);
|
|
std::string get_guid() { return m_guid; }
|
|
|
|
private:
|
|
int m_sdl_instance_id = -1;
|
|
SDL_GameController* m_device_handle;
|
|
std::string m_device_name = "";
|
|
bool m_has_led;
|
|
bool m_has_rumble;
|
|
std::string m_guid = "";
|
|
};
|