/src/ois/src/win32/extras/WiiMote/OISWiiMoteFactoryCreator.h

https://bitbucket.org/cabalistic/ogredeps/ · C Header · 103 lines · 41 code · 20 blank · 42 comment · 0 complexity · 5b15b5b873d40dd4278b205b83339ac6 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. #ifndef OIS_WiiMoteFactoryCreator_H
  20. #define OIS_WiiMoteFactoryCreator_H
  21. #include "OISPrereqs.h"
  22. #include "OISFactoryCreator.h"
  23. #include <deque>
  24. //Forward declare boost classes used
  25. namespace boost
  26. {
  27. class thread;
  28. class mutex;
  29. }
  30. namespace OIS
  31. {
  32. //Forward declare local classes
  33. class WiiMote;
  34. //! Max amount of Wiis we will attempt to find
  35. #define OIS_cWiiMote_MAX_WIIS 4
  36. /** WiiMote Factory Creator Class */
  37. class _OISExport WiiMoteFactoryCreator : public FactoryCreator
  38. {
  39. public:
  40. WiiMoteFactoryCreator();
  41. ~WiiMoteFactoryCreator();
  42. //FactoryCreator Overrides
  43. /** @copydoc FactoryCreator::deviceList */
  44. DeviceList freeDeviceList();
  45. /** @copydoc FactoryCreator::totalDevices */
  46. int totalDevices(Type iType);
  47. /** @copydoc FactoryCreator::freeDevices */
  48. int freeDevices(Type iType);
  49. /** @copydoc FactoryCreator::vendorExist */
  50. bool vendorExist(Type iType, const std::string & vendor);
  51. /** @copydoc FactoryCreator::createObject */
  52. Object* createObject(InputManager* creator, Type iType, bool bufferMode, const std::string & vendor = "");
  53. /** @copydoc FactoryCreator::destroyObject */
  54. void destroyObject(Object* obj);
  55. //! Local method used to return controller to pool
  56. void _returnWiiMote(int id);
  57. protected:
  58. //! Internal - threaded method
  59. bool _updateWiiMotesThread();
  60. //! String name of this vendor
  61. std::string mVendorName;
  62. //! queue of open wiimotes (int represents index into hid device)
  63. std::deque<int> mFreeWiis;
  64. //! Number of total wiimotes
  65. int mCount;
  66. //! Boost thread execution object (only alive when at least 1 wiimote is alive)
  67. boost::thread *mtThreadHandler;
  68. //! Gaurds access to the Active WiiMote List
  69. boost::mutex *mtWiiMoteListMutex;
  70. //! List of created (active) WiiMotes
  71. std::vector<WiiMote*> mtInUseWiiMotes;
  72. //! Used to signal thread running or not
  73. volatile bool mtThreadRunning;
  74. };
  75. }
  76. #endif //OIS_WiiMoteFactoryCreator_H
  77. #endif