KeyboardDevice.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #pragma once
  2. #include "device.h"
  3. #include "..\..\common_h\core.h"
  4. #include "..\..\common_h\templates\string.h"
  5. struct IDirectInputDevice8A;
  6. struct IDirectInput8A;
  7. struct DIDEVICEINSTANCEA;
  8. class KeyboardDevice : public IDevice
  9. {
  10. struct Control
  11. {
  12. string name;
  13. float value;
  14. byte diCode;
  15. };
  16. IDirectInputDevice8A *m_Device;
  17. array<Control> m_Controls;
  18. class Controls &m_ControlsService;
  19. void __declspec(dllexport) InitControls();
  20. public:
  21. KeyboardDevice(Controls &ctrlSrv, IDirectInput8A *di, const DIDEVICEINSTANCEA &deviceInst);
  22. ~KeyboardDevice();
  23. //////////////////////////////////////////////////////////////////////////
  24. // IDevice
  25. //////////////////////////////////////////////////////////////////////////
  26. virtual void Update(float DeltaTime);
  27. virtual void EndFrame() {}
  28. virtual long GetIndex(const char *deviceControl);
  29. virtual float GetRawValue(long controlIndex) const;
  30. virtual unsigned int GetControlsCount() const
  31. {
  32. return m_Controls.Size();
  33. }
  34. virtual const char *GetControlName(unsigned int index) const
  35. {
  36. Assert(index < m_Controls.Size());
  37. return m_Controls[index].name.c_str();
  38. }
  39. };