2
0

winDirectInput.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _WINDIRECTINPUT_H_
  23. #define _WINDIRECTINPUT_H_
  24. #ifndef _PLATFORMWIN32_H_
  25. #include "platformWin32/platformWin32.h"
  26. #endif
  27. #ifndef _PLATFORMINPUT_H_
  28. #include "platform/platformInput.h"
  29. #endif
  30. #ifndef _WINDINPUTDEVICE_H_
  31. #include "platformWin32/winDInputDevice.h"
  32. #endif
  33. #define DIRECTINPUT_VERSION 0x0800
  34. #include <dinput.h>
  35. struct InputEvent;
  36. //------------------------------------------------------------------------------
  37. class DInputManager : public InputManager
  38. {
  39. private:
  40. typedef SimGroup Parent;
  41. HMODULE mDInputLib;
  42. LPDIRECTINPUT8 mDInputInterface;
  43. static bool smKeyboardEnabled;
  44. static bool smMouseEnabled;
  45. static bool smJoystickEnabled;
  46. bool mKeyboardActive;
  47. bool mMouseActive;
  48. bool mJoystickActive;
  49. void enumerateDevices();
  50. static BOOL CALLBACK EnumDevicesProc( const DIDEVICEINSTANCE *pddi, LPVOID pvRef );
  51. bool acquire( U8 deviceType, U8 deviceID );
  52. void unacquire( U8 deviceType, U8 deviceID );
  53. public:
  54. DInputManager();
  55. bool enable();
  56. void disable();
  57. void onDeleteNotify( SimObject* object );
  58. bool onAdd();
  59. void onRemove();
  60. void process();
  61. // DirectInput functions:
  62. static void init();
  63. static bool enableKeyboard();
  64. static void disableKeyboard();
  65. static bool isKeyboardEnabled();
  66. bool activateKeyboard();
  67. void deactivateKeyboard();
  68. bool isKeyboardActive() { return( mKeyboardActive ); }
  69. static bool enableMouse();
  70. static void disableMouse();
  71. static bool isMouseEnabled();
  72. bool activateMouse();
  73. void deactivateMouse();
  74. bool isMouseActive() { return( mMouseActive ); }
  75. static bool enableJoystick();
  76. static void disableJoystick();
  77. static bool isJoystickEnabled();
  78. bool activateJoystick();
  79. void deactivateJoystick();
  80. bool isJoystickActive() { return( mJoystickActive ); }
  81. // Console interface:
  82. const char* getJoystickAxesString( U32 deviceID );
  83. };
  84. #endif // _H_WINDIRECTINPUT_