/src/ois/src/win32/extras/WiiMote/OISWiiMoteForceFeedback.cpp

https://bitbucket.org/cabalistic/ogredeps/ · C++ · 76 lines · 35 code · 9 blank · 32 comment · 11 complexity · 788f445235957e5b03871d1bfc3b952f MD5 · raw file

  1. #include "OISConfig.h"
  2. #ifdef OIS_WIN32_WIIMOTE_SUPPORT
  3. /*
  4. The zlib/libpng License
  5. Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
  6. This software is provided 'as-is', without any express or implied warranty. In no event will
  7. the authors be held liable for any damages arising from the use of this software.
  8. Permission is granted to anyone to use this software for any purpose, including commercial
  9. applications, and to alter it and redistribute it freely, subject to the following
  10. restrictions:
  11. 1. The origin of this software must not be misrepresented; you must not claim that
  12. you wrote the original software. If you use this software in a product,
  13. an acknowledgment in the product documentation would be appreciated but is
  14. not required.
  15. 2. Altered source versions must be plainly marked as such, and must not be
  16. misrepresented as being the original software.
  17. 3. This notice may not be removed or altered from any source distribution.
  18. */
  19. #include "OISWiiMoteForceFeedback.h"
  20. #include "OISEffect.h"
  21. using namespace OIS;
  22. //-----------------------------------------------------------------------------------//
  23. WiiMoteForceFeedback::WiiMoteForceFeedback(cWiiMote &wiiMote) : mWiiMote(wiiMote), mHandle(-1)
  24. {
  25. //One and only supported effect
  26. _addEffectTypes( OIS::Effect::ConstantForce, OIS::Effect::Constant );
  27. }
  28. //-----------------------------------------------------------------------------------//
  29. WiiMoteForceFeedback::~WiiMoteForceFeedback()
  30. {
  31. mWiiMote.SetVibration(false);
  32. }
  33. //-----------------------------------------------------------------------------------//
  34. void WiiMoteForceFeedback::upload( const Effect* effect )
  35. {
  36. if( effect )
  37. {
  38. //Multiple effects are useless, just return
  39. if( mHandle != -1 || effect->_handle != -1) return;
  40. //Ok, so we are uploading a fresh effect
  41. effect->_handle = mHandle = 1;
  42. mWiiMote.SetVibration(true);
  43. }
  44. }
  45. //-----------------------------------------------------------------------------------//
  46. void WiiMoteForceFeedback::modify( const Effect* effect )
  47. {
  48. //Nothing to modify
  49. }
  50. //-----------------------------------------------------------------------------------//
  51. void WiiMoteForceFeedback::remove( const Effect* effect )
  52. {
  53. //We have no effects uploaded, so just return
  54. if( mHandle == -1 || effect == 0) return;
  55. if( mHandle == effect->_handle )
  56. {
  57. mWiiMote.SetVibration(false);
  58. mHandle = effect->_handle = -1;
  59. }
  60. }
  61. #endif