/src/ois/includes/win32/Win32ForceFeedback.h

https://bitbucket.org/cabalistic/ogredeps/ · C Header · 108 lines · 41 code · 19 blank · 48 comment · 0 complexity · f701c54318d22cf4619b27efeea7692d MD5 · raw file

  1. /*
  2. The zlib/libpng License
  3. Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
  4. This software is provided 'as-is', without any express or implied warranty. In no event will
  5. the authors be held liable for any damages arising from the use of this software.
  6. Permission is granted to anyone to use this software for any purpose, including commercial
  7. applications, and to alter it and redistribute it freely, subject to the following
  8. restrictions:
  9. 1. The origin of this software must not be misrepresented; you must not claim that
  10. you wrote the original software. If you use this software in a product,
  11. an acknowledgment in the product documentation would be appreciated but is
  12. not required.
  13. 2. Altered source versions must be plainly marked as such, and must not be
  14. misrepresented as being the original software.
  15. 3. This notice may not be removed or altered from any source distribution.
  16. */
  17. #ifndef OIS_Win32ForceFeedBack_H
  18. #define OIS_Win32ForceFeedBack_H
  19. #include "OISPrereqs.h"
  20. #include "OISForceFeedback.h"
  21. #include "win32/Win32Prereqs.h"
  22. namespace OIS
  23. {
  24. class Win32ForceFeedback : public ForceFeedback
  25. {
  26. Win32ForceFeedback() {}
  27. public:
  28. Win32ForceFeedback(IDirectInputDevice8* pDIJoy, const DIDEVCAPS* pDIJoyCaps);
  29. ~Win32ForceFeedback();
  30. /** @copydoc ForceFeedback::upload */
  31. void upload( const Effect* effect );
  32. /** @copydoc ForceFeedback::modify */
  33. void modify( const Effect* effect );
  34. /** @copydoc ForceFeedback::remove */
  35. void remove( const Effect* effect );
  36. /** @copydoc ForceFeedback::setMasterGain */
  37. void setMasterGain( float level );
  38. /** @copydoc ForceFeedback::setAutoCenterMode */
  39. void setAutoCenterMode( bool auto_on );
  40. /** @copydoc ForceFeedback::getFFAxesNumber */
  41. short getFFAxesNumber();
  42. /** @copydoc ForceFeedback::getFFMemoryLoad */
  43. unsigned short getFFMemoryLoad();
  44. /**
  45. @remarks
  46. Internal use.. Used during enumeration to build a list of a devices
  47. support effects.
  48. */
  49. void _addEffectSupport( LPCDIEFFECTINFO pdei );
  50. /**
  51. @remarks
  52. Internal use.. Used during axis enumeration to get number of FF axes
  53. support effects.
  54. */
  55. void _addFFAxis();
  56. protected:
  57. //Specific Effect Settings
  58. void _updateConstantEffect( const Effect* effect );
  59. void _updateRampEffect( const Effect* effect );
  60. void _updatePeriodicEffect( const Effect* effect );
  61. void _updateConditionalEffect( const Effect* effect );
  62. void _updateCustomEffect( const Effect* effect );
  63. //Sets the common properties to all effects
  64. void _setCommonProperties( DIEFFECT* diEffect, DWORD* rgdwAxes,
  65. LONG* rglDirection, DIENVELOPE* diEnvelope, DWORD struct_size,
  66. LPVOID struct_type, const Effect* effect, const Envelope* envelope );
  67. //Actually do the upload
  68. void _upload( GUID, DIEFFECT*, const Effect* );
  69. // Map of currently uploaded effects (handle => effect)
  70. typedef std::map<int,LPDIRECTINPUTEFFECT> EffectList;
  71. EffectList mEffectList;
  72. //Simple unique handle creation - allows for upto 2+ billion effects
  73. //during the lifetime of application. Hopefully, that is enough.
  74. int mHandles;
  75. // Joystick device descriptor.
  76. IDirectInputDevice8* mJoyStick;
  77. // Joystick capabilities.
  78. const DIDEVCAPS* mpDIJoyCaps;
  79. // Number of axis supporting FF.
  80. short mFFAxes;
  81. };
  82. }
  83. #endif //OIS_Win32ForceFeedBack_H