platform: add Set/GetClipboardText calls. Remove unneeded SDL_SetHint call on Android, because Android does not use SDL anymore

This commit is contained in:
Alibek Omarov 2018-10-22 01:25:29 +03:00
parent 96e0167e47
commit 90d2434bb0
4 changed files with 34 additions and 15 deletions

View File

@ -907,9 +907,6 @@ void IN_TouchInit( void )
// input devices cvar
touch_enable = Cvar_Get( "touch_enable", DEFAULT_TOUCH_ENABLE, FCVAR_ARCHIVE, "enable touch controls" );
#if defined(XASH_SDL) && defined(__ANDROID__)
SDL_SetHint( SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH, "1" );
#endif
touch.initialized = true;
}

View File

@ -15,6 +15,7 @@ GNU General Public License for more details.
#include "common.h"
#include "mathlib.h"
#include "platform/platform.h"
#include <time.h>
#include <stdlib.h>
@ -157,18 +158,10 @@ create buffer, that contain clipboard
char *Sys_GetClipboardData( void )
{
static char data[1024];
char *cliptext;
data[0] = '\0';
#ifdef XASH_SDL
cliptext = SDL_GetClipboardText();
if( cliptext )
{
Q_strncpy( data, cliptext, sizeof( data ) );
SDL_free( cliptext );
}
#endif // XASH_SDL
Platform_GetClipboardText( data, sizeof( data ));
return data;
}
@ -182,9 +175,7 @@ write screenshot into clipboard
*/
void Sys_SetClipboardData( const byte *buffer, size_t size )
{
#ifdef XASH_SDL
SDL_SetClipboardText((char *)buffer);
#endif
Platform_SetClipboardText( (char *)buffer, size );
}
/*

View File

@ -43,6 +43,9 @@ void Platform_RunEvents( void );
// Mouse
void Platform_GetMousePos( int *x, int *y );
void Platform_SetMousePos( int x, int y );
// Clipboard
void Platform_GetClipboardText( char *buffer, size_t size );
void Platform_SetClipboardText( char *buffer, size_t size );
/*
==============================================================================

View File

@ -50,6 +50,34 @@ void Platform_SetMousePos( int x, int y )
SDL_WarpMouseInWindow( host.hWnd, x, y );
}
/*
=============
Platform_GetClipobardText
=============
*/
void Platform_GetClipboardText( char *buffer, size_t size )
{
char *sdlbuffer = SDL_GetClipboardText();
if( !sdlbuffer )
return;
Q_strncpy( buffer, sdlbuffer, size );
SDL_free( sdlbuffer );
}
/*
=============
Platform_SetClipobardText
=============
*/
void Platform_SetClipboardText( char *buffer, size_t size )
{
SDL_SetClipboardText( buffer );
}
/*
=============
Platform_Vibrate