platformAndroid.h 4.3 KB

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