/src/ois/src/OISJoyStick.cpp

https://bitbucket.org/cabalistic/ogredeps/ · C++ · 73 lines · 38 code · 7 blank · 28 comment · 1 complexity · 3f2c3f2be9ff7a1f778c6b4d54e4e19d 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. #include "OISJoyStick.h"
  18. using namespace OIS;
  19. //----------------------------------------------------------------------------//
  20. JoyStick::JoyStick(const std::string &vendor, bool buffered, int devID, InputManager* creator) :
  21. Object(vendor, OISJoyStick, buffered, devID, creator),
  22. mSliders(0),
  23. mPOVs(0),
  24. mListener(0),
  25. mVector3Sensitivity(OIS_JOYSTICK_VECTOR3_DEFAULT)
  26. {
  27. }
  28. //----------------------------------------------------------------------------//
  29. int JoyStick::getNumberOfComponents(ComponentType cType) const
  30. {
  31. switch( cType )
  32. {
  33. case OIS_Button: return (int)mState.mButtons.size();
  34. case OIS_Axis: return (int)mState.mAxes.size();
  35. case OIS_Slider: return mSliders;
  36. case OIS_POV: return mPOVs;
  37. case OIS_Vector3: return (int)mState.mVectors.size();
  38. default: return 0;
  39. }
  40. }
  41. //----------------------------------------------------------------------------//
  42. void JoyStick::setVector3Sensitivity(float degrees)
  43. {
  44. mVector3Sensitivity = degrees;
  45. }
  46. //----------------------------------------------------------------------------//
  47. float JoyStick::getVector3Sensitivity() const
  48. {
  49. return mVector3Sensitivity;
  50. }
  51. //----------------------------------------------------------------------------//
  52. void JoyStick::setEventCallback( JoyStickListener *joyListener )
  53. {
  54. mListener = joyListener;
  55. }
  56. //----------------------------------------------------------------------------//
  57. JoyStickListener* JoyStick::getEventCallback() const
  58. {
  59. return mListener;
  60. }