platformAndroid.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 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 _PLATFORMANDROID_H_
  23. #define _PLATFORMANDROID_H_
  24. #include "platform/platform.h"
  25. #include "math/mMath.h"
  26. #include "platformAndroid/AndroidEvents.h"
  27. #include "platformAndroid/AndroidOGLVideo.h"
  28. #include "platformAndroid/T2DActivity.h"
  29. // Mich Note: Do not try to spend too much time analyzing this class.
  30. // It is planned to refactor the Android platform layer and replace this
  31. // with a platform state similar to what OS X uses.
  32. class AndroidPlatState
  33. {
  34. public:
  35. bool captureDisplay;
  36. bool fadeWindows;
  37. struct engine *engine;
  38. char appWindowTitle[256];
  39. bool quit;
  40. bool ctxNeedsUpdate;
  41. bool portrait;
  42. S32 desktopBitsPixel;
  43. S32 desktopWidth;
  44. S32 desktopHeight;
  45. U32 currentTime;
  46. bool fullscreen;
  47. U32 osVersion;
  48. bool tsmActive;
  49. U32 firstThreadId;
  50. U32 torqueThreadId;
  51. void* alertSemaphore;
  52. S32 alertHit;
  53. // DialogRef alertDlg;
  54. // EventQueueRef mainEventQueue;
  55. RandomLCG platRandom;
  56. bool mouseLocked;
  57. bool backgrounded;
  58. bool minimized;
  59. U32 sleepTicks;
  60. U32 lastTimeTick;
  61. Point2I windowSize;
  62. U32 appReturn;
  63. U32 argc;
  64. const char** argv;
  65. StringTableEntry mainDotCsDir;
  66. //-Mat
  67. bool multipleTouchesEnabled;
  68. AndroidPlatState();
  69. };
  70. /// Global singleton that encapsulates a lot of mac platform state & globals.
  71. extern AndroidPlatState platState;
  72. /// @name Misc Mac Plat Functions
  73. /// Functions that are used by multiple files in the mac plat, but too trivial
  74. /// to require their own header file.
  75. /// @{
  76. /// Fills gGLState with info about this gl renderer's capabilities.
  77. void getGLCapabilities(void);
  78. /// Display a file dialog.
  79. /// calls FileDialog::Execute() on \p dialog
  80. /// @param dialog The FileDialog object to Execute. A void* is used to cut down on header dependencies.
  81. /// @see platform/nativeDialogs/fileDialog.h
  82. void AndroidShowDialog(void* dialog);
  83. /// Translates a Mac keycode to a Torque keycode
  84. U8 TranslateOSKeyCode(U8 vcode);
  85. /// @}
  86. /// @name Misc Mac Plat constants
  87. /// @{
  88. /// earlier versions of OSX don't have these convinience macros, so manually stick them here.
  89. #ifndef IntToFixed
  90. #define IntToFixed(a) ((Fixed)(a) <<16)
  91. #define FixedToInt(a) ((short)(((Fixed)(a) + fixed1/2) >> 16))
  92. #endif
  93. /// mouse wheel sensitivity factor
  94. const S32 kTMouseWheelMagnificationFactor = 25;
  95. /// @}
  96. #endif //_PLATFORMANDROID_H_