razerHydraData.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 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 _RAZERHYDRADATA_H_
  23. #define _RAZERHYDRADATA_H_
  24. #include "console/consoleTypes.h"
  25. #include "math/mMathFn.h"
  26. #include "math/mMatrix.h"
  27. #include "math/mQuat.h"
  28. #include "sixense.h"
  29. struct RazerHyrdaControllerData
  30. {
  31. enum DataDifferences {
  32. DIFF_NONE = 0,
  33. DIFF_POSX = (1<<0),
  34. DIFF_POSY = (1<<1),
  35. DIFF_POSZ = (1<<2),
  36. DIFF_ROT = (1<<3),
  37. DIFF_ROTAXISX = (1<<4),
  38. DIFF_ROTAXISY = (1<<5),
  39. DIFF_AXISX = (1<<6),
  40. DIFF_AXISY = (1<<7),
  41. DIFF_TRIGGER = (1<<8),
  42. DIFF_BUTTON1 = (1<<9),
  43. DIFF_BUTTON2 = (1<<10),
  44. DIFF_BUTTON3 = (1<<11),
  45. DIFF_BUTTON4 = (1<<12),
  46. DIFF_BUTTON_START = (1<<13),
  47. DIFF_BUTTON_SHOULDER = (1<<14),
  48. DIFF_BUTTON_THUMB = (1<<15),
  49. DIFF_POS = (DIFF_POSX | DIFF_POSY | DIFF_POSZ),
  50. DIFF_AXIS = (DIFF_AXISX | DIFF_AXISY),
  51. DIFF_ROTAXIS = (DIFF_ROTAXISX | DIFF_ROTAXISY),
  52. };
  53. enum MetaDataDifferences {
  54. METADIFF_NONE = 0,
  55. METADIFF_DOCKED = (1<<0),
  56. };
  57. bool mDataSet;
  58. // Position
  59. F32 mRawPos[3];
  60. S32 mPos[3];
  61. Point3F mPosPoint;
  62. // Rotation
  63. MatrixF mRot;
  64. QuatF mRotQuat;
  65. // Controller rotation as axis x, y
  66. Point2F mRotAxis;
  67. // Thumb stick x, y and trigger
  68. F32 mThumbStick[2];
  69. F32 mTrigger;
  70. // Buttons
  71. bool mShoulder;
  72. bool mThumb;
  73. bool mStart;
  74. bool mButton1;
  75. bool mButton2;
  76. bool mButton3;
  77. bool mButton4;
  78. // Other data
  79. bool mIsDocked;
  80. // Sequence number from sixense
  81. U32 mSequenceNum;
  82. RazerHyrdaControllerData();
  83. /// Reset controller data
  84. void reset();
  85. /// Set position based on sixense controller data
  86. void setData(const sixenseControllerData& data, const F32& maxAxisRadius);
  87. /// Compare this data and given and return differences
  88. U32 compare(RazerHyrdaControllerData* other);
  89. /// Compare meta data between this and given and return differences
  90. U32 compareMeta(RazerHyrdaControllerData* other);
  91. };
  92. #endif // _RAZERHYDRADATA_H_