TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
tbu_input_device_manager.hpp
1 
9 #ifndef _TurtleBrainsUnstable_ControllerManager_hpp
10 #define _TurtleBrainsUnstable_ControllerManager_hpp
11 
12 #include <turtle_brains/core/tb_configuration.hpp>
13 #include <turtle_brains/core/tb_noncopyable.hpp>
14 #include <turtle_brains/core/tb_types.hpp>
15 
17 
18 namespace tbImplementation { class InputDeviceManagerCreator; }
19 
20 namespace TurtleBrains
21 {
22  namespace System
23  {
24  namespace Unstable
25  {
26 
27  typedef tbCore::uint8 ButtonIdentifier;
28  typedef tbCore::uint8 AxisIdentifier;
29  typedef tbCore::int32 AxisValue;
30 
31  static const tbCore::uint8 kMaximumDevices = 8;
32  typedef tbCore::uint8 DeviceHandle;
33  DeviceHandle InvalidDeviceHandle(void);
34  ButtonIdentifier InvalidButton(void);
35  AxisIdentifier InvalidAxis(void);
36 
37  class InputDeviceManager : public tbCore::Noncopyable
38  {
39  public:
40  int ConnectWithDevices(void);
41  void DisconnectFromDevices(void);
42  void PollInputDevices(void);
43 
44  size_t GetAxisCount(const DeviceHandle& device) const;
45  size_t GetButtonCount(const DeviceHandle& device) const;
46 
47  bool IsButtonPressed(const DeviceHandle& device, const ButtonIdentifier& button) const;
48  bool IsButtonReleased(const DeviceHandle& device, const ButtonIdentifier& button) const;
49  bool IsButtonDown(const DeviceHandle& device, const ButtonIdentifier& button) const;
50 
59  AxisValue GetCurrentAxisValue(const DeviceHandle& device, const AxisIdentifier& axis) const;
60 
61  //May need two versions of this, one to be a value from -1 to 1, and the other from 0 to 1.
62  enum class PercentageRange { kZeroToPositiveOne, kNegativeToPositiveOne };
63  float GetAxisPercentage(const DeviceHandle& device, const AxisIdentifier& axis, const PercentageRange& range = PercentageRange::kZeroToPositiveOne) const;
64 
65  private:
70  InputDeviceManager(void);
71 
76  ~InputDeviceManager(void);
77 
78  friend class tbImplementation::InputDeviceManagerCreator;
79  };
80 
85  extern InputDeviceManager& theInputDeviceManager;
86 
87  }; /* namespace Unstable */
88  }; /* namespace System */
89 }; /* namespace TurtleBrains */
90 
92 
93 namespace tbSystem = TurtleBrains::System;
94 
95 #endif /* _TurtleBrainsUnstable_ControllerManager_hpp */
Definition: tb_noncopyable.hpp:22
Here is some information about the primary namespace.
Definition: tb_application_dialog.hpp:21
int32_t int32
Signed integer with a size of 32 bits. Supports values from -2147483648 to 2147483647.
Definition: tb_types.hpp:27
Definition: tb_system_timer.hpp:14
uint8_t uint8
Unsigned integer with a size of 8 bits. Supports values from 0 to 255.
Definition: tb_types.hpp:23
Definition: tb_application_dialog.hpp:19