PolyEmscriptenCore.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. Copyright (C) 2011 by Ivan Safrin
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17. THE SOFTWARE.
  18. */
  19. #pragma once
  20. #include "PolyGlobals.h"
  21. #include "PolyCore.h"
  22. #include <vector>
  23. #include <pthread.h>
  24. #include <time.h>
  25. // #include <SDL2/SDL.h>
  26. #ifndef NO_PAUDIO
  27. #include "polycode/core/PolyPAAudioInterface.h"
  28. #endif
  29. #define POLYCODE_CORE EmscriptenCore
  30. struct SDL_mutex;
  31. namespace Polycode {
  32. class PolycodeView;
  33. class RenderThread;
  34. class _PolyExport EmscriptenCoreMutex : public CoreMutex {
  35. public:
  36. void lock();
  37. void unlock();
  38. pthread_mutex_t pMutex;
  39. };
  40. class _PolyExport EmscriptenCore : public Core {
  41. public:
  42. EmscriptenCore(PolycodeView *view, int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, int frameRate, int monitorIndex=-1, bool retinaSupport=false);
  43. ~EmscriptenCore();
  44. void enableMouse(bool newval);
  45. void captureMouse(bool);
  46. unsigned int getTicks();
  47. bool systemUpdate();
  48. void Render();
  49. void flushRenderContext();
  50. void handleVideoModeChange(VideoModeChangeInfo *modeInfo);
  51. void setVideoMode(int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, bool retinaSupport = true);
  52. void createThread(Threaded *target);
  53. std::vector<Rectangle> getVideoModes();
  54. bool systemParseFolder(const String& pathString, bool showHidden, std::vector<OSFileEntry> &targetVector);
  55. void setCursor(int cursorType);
  56. void warpCursor(int x, int y);
  57. //void lockMutex(CoreMutex *mutex);
  58. //void unlockMutex(CoreMutex *mutex);
  59. CoreMutex *createMutex();
  60. void copyStringToClipboard(const String& str);
  61. String getClipboardString();
  62. void createFolder(const String& folderPath);
  63. void copyDiskItem(const String& itemPath, const String& destItemPath);
  64. void moveDiskItem(const String& itemPath, const String& destItemPath);
  65. void removeDiskItem(const String& itemPath);
  66. String openFolderPicker();
  67. std::vector<String> openFilePicker(std::vector<CoreFileExtension> extensions, bool allowMultiple);
  68. String saveFilePicker(std::vector<CoreFileExtension> extensions);
  69. void resizeTo(int xRes, int yRes);
  70. String executeExternalCommand(String command, String args, String inDirectory="");
  71. void openURL(String url);
  72. private:
  73. bool checkSpecialKeyEvents(PolyKEY key);
  74. uint32_t flags;
  75. bool resizableWindow;
  76. String* windowTitle;
  77. RenderThread *renderThread;
  78. int lastMouseX;
  79. int lastMouseY;
  80. };
  81. }