Browse Source

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

pull/2/head
Alibek Omarov 6 years ago
parent
commit
90d2434bb0
  1. 3
      engine/client/in_touch.c
  2. 15
      engine/common/system.c
  3. 3
      engine/platform/platform.h
  4. 28
      engine/platform/sdl/in_sdl.c

3
engine/client/in_touch.c

@ -907,9 +907,6 @@ void IN_TouchInit( void ) @@ -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;
}

15
engine/common/system.c

@ -15,6 +15,7 @@ GNU General Public License for more details. @@ -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 @@ -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 @@ -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 );
}
/*

3
engine/platform/platform.h

@ -43,6 +43,9 @@ void Platform_RunEvents( void ); @@ -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 );
/*
==============================================================================

28
engine/platform/sdl/in_sdl.c

@ -50,6 +50,34 @@ void Platform_SetMousePos( int x, int y ) @@ -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

Loading…
Cancel
Save