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