Browse Source

engine: platform: updated clipboard read/write functions

pull/2/head
SNMetamorph 3 years ago committed by a1batross
parent
commit
15eb6808c4
  1. 2
      engine/common/system.c
  2. 4
      engine/platform/platform.h
  3. 17
      engine/platform/sdl/in_sdl.c

2
engine/common/system.c

@ -91,7 +91,7 @@ write screenshot into clipboard @@ -91,7 +91,7 @@ write screenshot into clipboard
*/
void Sys_SetClipboardData( const char *buffer, size_t size )
{
Platform_SetClipboardText( buffer, size );
Platform_SetClipboardText( buffer );
}
#endif // XASH_DEDICATED

4
engine/platform/platform.h

@ -80,8 +80,8 @@ void Platform_SetMousePos( int x, int y ); @@ -80,8 +80,8 @@ void Platform_SetMousePos( int x, int y );
void Platform_PreCreateMove( void );
void Platform_MouseMove( float *x, float *y );
// Clipboard
void Platform_GetClipboardText( char *buffer, size_t size );
void Platform_SetClipboardText( const char *buffer, size_t size );
int Platform_GetClipboardText( char *buffer, size_t size );
void Platform_SetClipboardText( const char *buffer );
#if XASH_SDL == 12
#define SDL_SetWindowGrab( wnd, state ) SDL_WM_GrabInput( (state) )

17
engine/platform/sdl/in_sdl.c

@ -71,19 +71,28 @@ Platform_GetClipobardText @@ -71,19 +71,28 @@ Platform_GetClipobardText
=============
*/
void Platform_GetClipboardText( char *buffer, size_t size )
int Platform_GetClipboardText( char *buffer, size_t size )
{
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
int textLength;
char *sdlbuffer = SDL_GetClipboardText();
if( !sdlbuffer )
return;
return 0;
Q_strncpy( buffer, sdlbuffer, size );
if (buffer && size > 0)
{
textLength = Q_strncpy( buffer, sdlbuffer, size );
}
else {
textLength = Q_strlen( sdlbuffer );
}
SDL_free( sdlbuffer );
return textLength;
#else // SDL_VERSION_ATLEAST( 2, 0, 0 )
buffer[0] = 0;
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
return 0;
}
/*
@ -92,7 +101,7 @@ Platform_SetClipobardText @@ -92,7 +101,7 @@ Platform_SetClipobardText
=============
*/
void Platform_SetClipboardText( const char *buffer, size_t size )
void Platform_SetClipboardText( const char *buffer )
{
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
SDL_SetClipboardText( buffer );

Loading…
Cancel
Save