aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDesour <vorunbekannt75@web.de>2022-09-14 20:38:49 +0200
committersfan5 <sfan5@live.de>2023-03-24 17:59:06 +0100
commit8da1bcf58bd8ff4d08d93c26599f8e22e68a8df4 (patch)
tree183a3fa6b0d104c0585e3bf488d800542d434ad2
parentd86abb40c1276ec74c72caef664d8efe3915c190 (diff)
downloadirrlicht-8da1bcf58bd8ff4d08d93c26599f8e22e68a8df4.tar.xz
SDL: Support clipboard
-rw-r--r--source/Irrlicht/COSOperator.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/source/Irrlicht/COSOperator.cpp b/source/Irrlicht/COSOperator.cpp
index 906035a..4f44178 100644
--- a/source/Irrlicht/COSOperator.cpp
+++ b/source/Irrlicht/COSOperator.cpp
@@ -17,7 +17,9 @@
#endif
#endif
-#if defined(_IRR_COMPILE_WITH_X11_DEVICE_)
+#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
+#include <SDL_clipboard.h>
+#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_)
#include "CIrrDeviceLinux.h"
#endif
#if defined(_IRR_COMPILE_WITH_OSX_DEVICE_)
@@ -59,8 +61,10 @@ void COSOperator::copyToClipboard(const c8 *text) const
if (strlen(text)==0)
return;
-// Windows version
-#if defined(_IRR_WINDOWS_API_)
+#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
+ SDL_SetClipboardText(text);
+
+#elif defined(_IRR_WINDOWS_API_)
if (!OpenClipboard(NULL) || text == 0)
return;
@@ -117,7 +121,14 @@ void COSOperator::copyToPrimarySelection(const c8 *text) const
//! gets text from the clipboard
const c8* COSOperator::getTextFromClipboard() const
{
-#if defined(_IRR_WINDOWS_API_)
+#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
+ static char *text = nullptr;
+ if (text)
+ SDL_free(text);
+ text = SDL_GetClipboardText();
+ return text;
+
+#elif defined(_IRR_WINDOWS_API_)
if (!OpenClipboard(NULL))
return 0;