Input: evdev fixes and first rumble implementation

This commit is contained in:
Unknown 2017-12-02 11:45:58 +01:00 committed by Ivan
parent 114dd2a723
commit 2dd8a1afdb
2 changed files with 169 additions and 42 deletions

View file

@ -247,6 +247,10 @@ class evdev_joystick_handler final : public PadHandlerBase
std::vector<EvdevButton> axis_right = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } };
int cur_dir = 0;
int cur_type = 0;
int effect_id = -1;
bool has_rumble = false;
u16 force_large = 0;
u16 force_small = 0;
};
const int BUTTON_COUNT = 17;
@ -265,11 +269,13 @@ public:
private:
void TranslateButtonPress(u64 keyCode, bool& pressed, u16& value, bool ignore_threshold = false) override;
EvdevDevice* get_device(const std::string& device);
bool update_device(EvdevDevice& device, bool use_cell = true);
void update_devs(bool use_cell = true);
int add_device(const std::string& device, bool in_settings = false);
int GetButtonInfo(const input_event& evt, libevdev* dev, int& button_code, bool& is_negative);
std::unordered_map<u64, std::pair<u16, bool>> GetButtonValues(libevdev* dev);
int GetButtonInfo(const input_event& evt, const EvdevDevice& device, int& button_code, bool& is_negative);
std::unordered_map<u64, std::pair<u16, bool>> GetButtonValues(const EvdevDevice& device);
void SetRumble(EvdevDevice* device, u16 large, u16 small);
// Search axis_orientations map for the direction by index, returns -1 if not found, 0 for positive and 1 for negative
int FindAxisDirection(const std::unordered_map<int, bool>& map, int index);