ezEngine  Milestone 7
Controller.h
1 #pragma once
2 
3 #include <Core/Input/InputDevice.h>
4 
11 class EZ_CORE_DLL ezInputDeviceController : public ezInputDevice
12 {
14 
15 public:
16  enum
17  {
18  MaxControllers = 4,
19  VibrationSamplesPerSecond = 16,
20  VibrationTrackSeconds = 2,
21  MaxVibrationSamples = VibrationSamplesPerSecond * VibrationTrackSeconds, // With constant power-of-two samples some code should get more efficient
22  };
23 
25  struct Motor
26  {
27  enum Enum
28  {
29  LeftMotor,
30  RightMotor,
31  ENUM_COUNT
32  };
33  };
34 
36 
39  void EnableVibration(ezUInt8 uiVirtual, bool bEnable);
40 
42  bool IsVibrationEnabled(ezUInt8 uiVirtual) const;
43 
50  void SetVibrationStrength(ezUInt8 uiVirtual, Motor::Enum eMotor, float fValue);
51 
53  float GetVibrationStrength(ezUInt8 uiVirtual, Motor::Enum eMotor);
54 
67  void SetControllerMapping(ezUInt8 uiVirtualController, ezInt8 iTakeInputFromPhysical);
68 
71  ezInt8 GetControllerMapping(ezUInt8 uiVirtual) const;
72 
75  virtual bool IsControllerConnected(ezUInt8 uiPhysical) const = 0;
76 
91  void AddVibrationTrack(ezUInt8 uiVirtual, Motor::Enum eMotor, float* fVibrationTrackValue, ezUInt32 uiSamples, float fScalingFactor = 1.0f);
92 
93 protected:
99  void UpdateVibration(ezTime tTimeDifference);
100 
101 private:
105  virtual void ApplyVibration(ezUInt8 uiPhysicalController, Motor::Enum eMotor, float fStrength) = 0;
106 
107  ezUInt32 m_uiVibrationTrackPos;
108  float m_fVibrationTracks[MaxControllers][Motor::ENUM_COUNT][MaxVibrationSamples];
109  bool m_bVibrationEnabled[MaxControllers];
110  ezInt8 m_iControllerMapping[MaxControllers];
111  float m_fVibrationStrength[MaxControllers][Motor::ENUM_COUNT];
112 
113 };
114