platformiOS.h 4.1 KB

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