diff options
Diffstat (limited to 'src/input_common/gcadapter/gc_adapter.h')
| -rw-r--r-- | src/input_common/gcadapter/gc_adapter.h | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/input_common/gcadapter/gc_adapter.h b/src/input_common/gcadapter/gc_adapter.h index b1c2a1958..3586c8bda 100644 --- a/src/input_common/gcadapter/gc_adapter.h +++ b/src/input_common/gcadapter/gc_adapter.h | |||
| @@ -8,17 +8,14 @@ | |||
| 8 | #include <mutex> | 8 | #include <mutex> |
| 9 | #include <thread> | 9 | #include <thread> |
| 10 | #include <unordered_map> | 10 | #include <unordered_map> |
| 11 | #include <libusb.h> | ||
| 12 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 13 | #include "common/threadsafe_queue.h" | 12 | #include "common/threadsafe_queue.h" |
| 14 | 13 | ||
| 15 | namespace GCAdapter { | 14 | struct libusb_context; |
| 15 | struct libusb_device; | ||
| 16 | struct libusb_device_handle; | ||
| 16 | 17 | ||
| 17 | enum { | 18 | namespace GCAdapter { |
| 18 | PAD_USE_ORIGIN = 0x0080, | ||
| 19 | PAD_GET_ORIGIN = 0x2000, | ||
| 20 | PAD_ERR_STATUS = 0x8000, | ||
| 21 | }; | ||
| 22 | 19 | ||
| 23 | enum class PadButton { | 20 | enum class PadButton { |
| 24 | PAD_BUTTON_LEFT = 0x0001, | 21 | PAD_BUTTON_LEFT = 0x0001, |
| @@ -97,14 +94,19 @@ public: | |||
| 97 | void BeginConfiguration(); | 94 | void BeginConfiguration(); |
| 98 | void EndConfiguration(); | 95 | void EndConfiguration(); |
| 99 | 96 | ||
| 97 | /// Returns true if there is a device connected to port | ||
| 98 | bool DeviceConnected(std::size_t port); | ||
| 99 | |||
| 100 | std::array<Common::SPSCQueue<GCPadStatus>, 4>& GetPadQueue(); | 100 | std::array<Common::SPSCQueue<GCPadStatus>, 4>& GetPadQueue(); |
| 101 | const std::array<Common::SPSCQueue<GCPadStatus>, 4>& GetPadQueue() const; | 101 | const std::array<Common::SPSCQueue<GCPadStatus>, 4>& GetPadQueue() const; |
| 102 | 102 | ||
| 103 | std::array<GCState, 4>& GetPadState(); | 103 | std::array<GCState, 4>& GetPadState(); |
| 104 | const std::array<GCState, 4>& GetPadState() const; | 104 | const std::array<GCState, 4>& GetPadState() const; |
| 105 | 105 | ||
| 106 | int GetOriginValue(int port, int axis) const; | ||
| 107 | |||
| 106 | private: | 108 | private: |
| 107 | GCPadStatus GetPadStatus(int port, const std::array<u8, 37>& adapter_payload); | 109 | GCPadStatus GetPadStatus(std::size_t port, const std::array<u8, 37>& adapter_payload); |
| 108 | 110 | ||
| 109 | void PadToState(const GCPadStatus& pad, GCState& state); | 111 | void PadToState(const GCPadStatus& pad, GCState& state); |
| 110 | 112 | ||
| @@ -116,11 +118,8 @@ private: | |||
| 116 | /// Stop scanning for the adapter | 118 | /// Stop scanning for the adapter |
| 117 | void StopScanThread(); | 119 | void StopScanThread(); |
| 118 | 120 | ||
| 119 | /// Returns true if there is a device connected to port | ||
| 120 | bool DeviceConnected(int port); | ||
| 121 | |||
| 122 | /// Resets status of device connected to port | 121 | /// Resets status of device connected to port |
| 123 | void ResetDeviceType(int port); | 122 | void ResetDeviceType(std::size_t port); |
| 124 | 123 | ||
| 125 | /// Returns true if we successfully gain access to GC Adapter | 124 | /// Returns true if we successfully gain access to GC Adapter |
| 126 | bool CheckDeviceAccess(libusb_device* device); | 125 | bool CheckDeviceAccess(libusb_device* device); |
| @@ -156,6 +155,8 @@ private: | |||
| 156 | 155 | ||
| 157 | std::array<Common::SPSCQueue<GCPadStatus>, 4> pad_queue; | 156 | std::array<Common::SPSCQueue<GCPadStatus>, 4> pad_queue; |
| 158 | std::array<GCState, 4> state; | 157 | std::array<GCState, 4> state; |
| 158 | std::array<bool, 4> get_origin; | ||
| 159 | std::array<GCPadStatus, 4> origin_status; | ||
| 159 | }; | 160 | }; |
| 160 | 161 | ||
| 161 | } // namespace GCAdapter | 162 | } // namespace GCAdapter |