diff --git a/extras/videoDrivers/SDL2/VideoSDL2.cpp b/extras/videoDrivers/SDL2/VideoSDL2.cpp index afd519c10..ad3ad57df 100644 --- a/extras/videoDrivers/SDL2/VideoSDL2.cpp +++ b/extras/videoDrivers/SDL2/VideoSDL2.cpp @@ -213,29 +213,27 @@ void VideoSDL2::PrintError(const std::string& msg) const void VideoSDL2::HandlePaste() { -#ifdef _WIN32 - if(!IsClipboardFormatAvailable(CF_UNICODETEXT)) + if(!SDL_HasClipboardText()) return; - OpenClipboard(nullptr); - - HANDLE hData = GetClipboardData(CF_UNICODETEXT); - const wchar_t* pData = (const wchar_t*)GlobalLock(hData); + auto* text = SDL_GetClipboardText(); + if(!text) + return; + if(text[0] == '\0') + PrintError(SDL_GetError()); KeyEvent ke = {KeyType::Invalid, 0, false, false, false}; - while(pData && *pData) + auto* p = text; + while(*p) { - ke.c = *(pData++); + ke.c = static_cast(*(p++)); if(ke.c == L' ') ke.kt = KeyType::Space; else ke.kt = KeyType::Char; CallBack->Msg_KeyDown(ke); } - - GlobalUnlock(hData); - CloseClipboard(); -#endif + SDL_free(text); } void VideoSDL2::DestroyScreen()