rpcsx/rpcs3/Input/evdev_gun_handler.h

62 lines
912 B
C
Raw Normal View History

#pragma once
#ifdef HAVE_LIBEVDEV
2022-11-27 12:20:05 +01:00
#include <array>
#include <map>
2022-11-30 00:25:09 +01:00
#include "Utilities/mutex.h"
2022-11-27 12:20:05 +01:00
enum class gun_button
{
2022-11-27 12:20:05 +01:00
btn_left,
btn_right,
btn_middle,
btn_1,
btn_2,
btn_3,
btn_4,
btn_5
};
class evdev_gun_handler
{
public:
evdev_gun_handler();
~evdev_gun_handler();
bool init();
2022-11-27 12:20:05 +01:00
bool is_init() const;
u32 get_num_guns() const;
int get_button(u32 gunno, gun_button button) const;
int get_axis_x(u32 gunno) const;
int get_axis_y(u32 gunno) const;
int get_axis_x_max(u32 gunno) const;
int get_axis_y_max(u32 gunno) const;
2022-11-27 12:20:05 +01:00
void poll(u32 index);
shared_mutex mutex;
private:
2022-11-27 12:20:05 +01:00
atomic_t<bool> m_is_init{false};
struct udev* m_udev = nullptr;
2022-11-27 12:20:05 +01:00
struct evdev_axis
{
int value = 0;
int min = 0;
int max = 0;
};
struct evdev_gun
{
2022-11-30 00:25:09 +01:00
struct libevdev* device = nullptr;
2022-11-27 12:20:05 +01:00
std::map<int, int> buttons;
std::map<int, evdev_axis> axis;
};
std::vector<evdev_gun> m_devices;
};
#endif