XBoxDevice.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #pragma once
  2. #include "device.h"
  3. #include "..\..\common_h\core.h"
  4. #include "..\..\common_h\templates\string.h"
  5. #include "ControlsIniParser.h"
  6. #define XBOX360_DEVICE "XBox 360 Device"
  7. class XBoxDevice : public IJoystick
  8. {
  9. struct Control
  10. {
  11. enum Type { Slider, Axis, Button, POV_H, POV_V };
  12. Type type;
  13. float value;
  14. string name;
  15. bool inverted;
  16. };
  17. DWORD dwPacketNumber;
  18. unsigned int m_Controller;
  19. array<Control> m_Controls;
  20. long indexStart;
  21. void InitControls(const ControlsIniParser::Table &table);
  22. public:
  23. XBoxDevice(unsigned int ctrlIndex, const ControlsIniParser &parser);
  24. ~XBoxDevice();
  25. //////////////////////////////////////////////////////////////////////////
  26. // IDevice
  27. //////////////////////////////////////////////////////////////////////////
  28. virtual void Update(float DeltaTime);
  29. virtual void EndFrame();
  30. virtual long GetIndex(const char *deviceControl);
  31. virtual float GetRawValue(long controlIndex) const;
  32. virtual unsigned int GetControlsCount() const
  33. {
  34. return m_Controls.Size();
  35. }
  36. virtual const char *GetControlName(unsigned int index) const
  37. {
  38. Assert(index < m_Controls.Size());
  39. return m_Controls[index].name.c_str();
  40. }
  41. ///////////////////////////
  42. // IJoystick
  43. ///////////////////////////
  44. virtual bool IsStartPressed() const;
  45. virtual bool IsDisconnected() const;
  46. virtual bool SetValues(ValueType type, const void *values, long nBytes);
  47. };