TurtleBrains  0.3.1
High quality, portable, C++ framework for rapid 2D game development.
tbu_input_device_manager.h
1 
9 #ifndef _TurtleBrainsUnstable_ControllerManager_h_
10 #define _TurtleBrainsUnstable_ControllerManager_h_
11 
12 #include "../../core/tb_configuration.h"
13 #if defined(tb_with_input_devices)
14 
15 #include "../../core/tb_noncopyable.h"
16 #include "../../core/tb_types.h"
17 
19 
20 namespace tbImplementation { class InputDeviceManagerCreator; }
21 
22 namespace TurtleBrains
23 {
24  namespace System
25  {
26  namespace Unstable
27  {
28 
29  typedef tbCore::uint8 ButtonIdentifier;
30  typedef tbCore::uint8 AxisIdentifier;
31  typedef tbCore::int32 AxisValue;
32 
33  static const tbCore::uint8 kMaximumDevices = 8;
34  typedef tbCore::uint8 DeviceHandle;
35  DeviceHandle InvalidDeviceHandle(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 /* tb_with_input_devices */
96 #endif /* _TurtleBrainsUnstable_ControllerManager_h_ */
Definition: tb_noncopyable.h:22
Here is some information about the primary namespace.
Definition: tb_application_dialog.h:21
int32_t int32
Signed integer with a size of 32 bits. Supports values from -2147483648 to 2147483647.
Definition: tb_types.h:27
Definition: tb_system_timer.h:14
uint8_t uint8
Unsigned integer with a size of 8 bits. Supports values from 0 to 255.
Definition: tb_types.h:23
Definition: tb_application_dialog.h:19