mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 11:35:05 +08:00
engine: platform: make most input platform functions optional, patch fbdev/evdev to compile
This commit is contained in:
@@ -80,27 +80,11 @@ void Platform_RunEvents( void )
|
||||
|
||||
}
|
||||
|
||||
void GAME_EXPORT Platform_GetMousePos( int *x, int *y )
|
||||
{
|
||||
*x = *y = 0;
|
||||
}
|
||||
|
||||
|
||||
void GAME_EXPORT Platform_SetMousePos(int x, int y)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Platform_EnableTextInput( qboolean enable )
|
||||
{
|
||||
keystate.chars = enable;
|
||||
}
|
||||
|
||||
void Platform_PreCreateMove( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Platform_MouseMove( float *x, float *y )
|
||||
{
|
||||
static int lx,ly;
|
||||
|
||||
@@ -15,24 +15,11 @@ GNU General Public License for more details.
|
||||
|
||||
#include "platform/platform.h"
|
||||
#include <dos.h>
|
||||
void Platform_GetClipboardText( char *buffer, size_t size )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Platform_SetClipboardText( const char *buffer, size_t size )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Platform_Vibrate(float life, char flags)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Platform_ShellExecute( const char *path, const char *parms )
|
||||
{
|
||||
}
|
||||
|
||||
volatile int ticks=0;
|
||||
|
||||
#if XASH_TIMER == TIMER_DOS
|
||||
|
||||
@@ -179,7 +179,7 @@ void Evdev_Autodetect_f( void )
|
||||
|
||||
for( i = 0; i < evdev.devices; i++ )
|
||||
{
|
||||
if( !Q_strncmp( evdev.paths[i], path, sizeof( evdev.paths[i] ))
|
||||
if( !Q_strncmp( evdev.paths[i], path, sizeof( evdev.paths[i] )))
|
||||
goto next;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ qboolean R_Init_Video( const int type )
|
||||
|
||||
if( fb.fd < 0 )
|
||||
{
|
||||
Con_Printf( S_ERROR, "failed to open framebuffer device: %s\n", strerror(errno));
|
||||
Con_Printf( S_ERROR "failed to open framebuffer device: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
if( Sys_CheckParm( "-ttygfx" ) )
|
||||
@@ -134,7 +134,7 @@ rserr_t R_ChangeDisplaySettings( int width, int height, window_mode_t window_mod
|
||||
Con_Reportf( "%s: forced resolution to %dx%d)\n", __func__, width, height );
|
||||
|
||||
VID_SetDisplayTransform( &render_w, &render_h );
|
||||
R_SaveVideoMode( width, height, render_w, render_h );
|
||||
R_SaveVideoMode( width, height, render_w, render_h, false );
|
||||
|
||||
return rserr_ok;
|
||||
}
|
||||
@@ -246,41 +246,4 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint *
|
||||
return true;
|
||||
}
|
||||
|
||||
// unrelated stubs
|
||||
void Platform_GetClipboardText( char *buffer, size_t size )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Platform_SetClipboardText( const char *buffer, size_t size )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Platform_PreCreateMove( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// will be implemented later
|
||||
void Platform_RunEvents( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GAME_EXPORT Platform_GetMousePos( int *x, int *y )
|
||||
{
|
||||
*x = *y = 0;
|
||||
}
|
||||
|
||||
|
||||
void GAME_EXPORT Platform_SetMousePos(int x, int y)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Platform_Vibrate( float life, char flags )
|
||||
{
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -207,8 +207,13 @@ static inline void Sys_RestoreCrashHandler( void )
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
#if XASH_SDL >= 2
|
||||
void Platform_Vibrate( float life, char flags ); // left for compatibility
|
||||
void Platform_Vibrate2( float time, int low_freq, int high_freq, uint flags );
|
||||
#else
|
||||
static inline void Platform_Vibrate( float life, char flags ) {}
|
||||
static inline void Platform_Vibrate2( float time, int low_freq, int high_freq, uint flags ) {}
|
||||
#endif
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
@@ -217,47 +222,58 @@ void Platform_Vibrate2( float time, int low_freq, int high_freq, uint flags );
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
// Gamepad support
|
||||
#if XASH_SDL
|
||||
int Platform_JoyInit( void ); // returns number of connected gamepads, negative if error
|
||||
void Platform_JoyShutdown( void );
|
||||
void Platform_CalibrateGamepadGyro( void );
|
||||
#if XASH_SDL // only SDL based backends implements these functions
|
||||
void Platform_PreCreateMove( void );
|
||||
void GAME_EXPORT Platform_GetMousePos( int *x, int *y );
|
||||
void GAME_EXPORT Platform_SetMousePos( int x, int y );
|
||||
qboolean Platform_GetMouseGrab( void );
|
||||
void Platform_SetMouseGrab( qboolean enable );
|
||||
void Platform_SetCursorType( VGUI_DefaultCursor type );
|
||||
int Platform_GetClipboardText( char *buffer, size_t size );
|
||||
void Platform_SetClipboardText( const char *buffer );
|
||||
#else
|
||||
static inline int Platform_JoyInit( void )
|
||||
static inline void Platform_PreCreateMove( void ) { }
|
||||
static inline void GAME_EXPORT Platform_SetMousePos( int x, int y ) { }
|
||||
static inline void Platform_SetMouseGrab( qboolean enable ) { }
|
||||
static inline void Platform_SetCursorType( VGUI_DefaultCursor type ) { }
|
||||
static inline int Platform_GetClipboardText( char *buffer, size_t size ) { return 0; }
|
||||
static inline void Platform_SetClipboardText( const char *buffer ) { }
|
||||
static inline qboolean Platform_GetMouseGrab( void ) { return false; }
|
||||
static inline void GAME_EXPORT Platform_GetMousePos( int *x, int *y )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void Platform_JoyShutdown( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static inline void Platform_CalibrateGamepadGyro( void )
|
||||
{
|
||||
|
||||
if( x ) *x = 0;
|
||||
if( y ) *y = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Text input
|
||||
void Platform_EnableTextInput( qboolean enable );
|
||||
key_modifier_t Platform_GetKeyModifiers( void );
|
||||
// System events
|
||||
#if XASH_SDL || XASH_DOS
|
||||
void Platform_RunEvents( void );
|
||||
// Mouse
|
||||
void Platform_GetMousePos( int *x, int *y );
|
||||
void Platform_SetMousePos( int x, int y );
|
||||
void Platform_PreCreateMove( void );
|
||||
void Platform_MouseMove( float *x, float *y );
|
||||
void Platform_SetCursorType( VGUI_DefaultCursor type );
|
||||
qboolean Platform_GetMouseGrab( void );
|
||||
void Platform_SetMouseGrab( qboolean enable );
|
||||
// Clipboard
|
||||
int Platform_GetClipboardText( char *buffer, size_t size );
|
||||
void Platform_SetClipboardText( const char *buffer );
|
||||
#else
|
||||
static inline void Platform_RunEvents( void ) { }
|
||||
static inline void Platform_MouseMove( float *x, float *y )
|
||||
{
|
||||
if( x ) *x = 0.0f;
|
||||
if( y ) *y = 0.0f;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if XASH_SDL == 1
|
||||
#define SDL_IsTextInputActive() host.textmode
|
||||
#if XASH_SDL >= 2 || XASH_PSVITA || XASH_DOS || XASH_USE_EVDEV
|
||||
void Platform_EnableTextInput( qboolean enable );
|
||||
#else
|
||||
static inline void Platform_EnableTextInput( qboolean enable ) { }
|
||||
#endif
|
||||
|
||||
#if XASH_SDL >= 2
|
||||
int Platform_JoyInit( void ); // returns number of connected gamepads, negative if error
|
||||
void Platform_JoyShutdown( void );
|
||||
void Platform_CalibrateGamepadGyro( void );
|
||||
key_modifier_t Platform_GetKeyModifiers( void );
|
||||
#else
|
||||
static inline int Platform_JoyInit( void ) { return 0; }
|
||||
static inline void Platform_JoyShutdown( void ) { }
|
||||
static inline void Platform_CalibrateGamepadGyro( void ) { }
|
||||
static inline key_modifier_t Platform_GetKeyModifiers( void ) { return KeyModifier_None; }
|
||||
#endif
|
||||
|
||||
static inline void Platform_SetTimer( float time )
|
||||
|
||||
@@ -98,7 +98,7 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key )
|
||||
int down = key.state != SDL_RELEASED;
|
||||
int keynum = key.keysym.sym;
|
||||
|
||||
if( SDL_IsTextInputActive( ) && down )
|
||||
if( host.textmode && down )
|
||||
{
|
||||
// this is how engine understands ctrl+c, ctrl+v and other hotkeys
|
||||
if( cls.key_dest != key_game && FBitSet( SDL_GetModState(), KMOD_CTRL ))
|
||||
|
||||
@@ -95,17 +95,6 @@ void Platform_SetClipboardText( const char *buffer )
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
Platform_EnableTextInput
|
||||
|
||||
=============
|
||||
*/
|
||||
void Platform_EnableTextInput( qboolean enable )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
========================
|
||||
Platform_SetCursorType
|
||||
@@ -163,14 +152,3 @@ void Platform_SetMouseGrab( qboolean enable )
|
||||
{
|
||||
SDL_WM_GrabInput( enable ? SDL_GRAB_ON : SDL_GRAB_OFF );
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
Platform_GetKeyModifiers
|
||||
|
||||
========================
|
||||
*/
|
||||
key_modifier_t Platform_GetKeyModifiers( void )
|
||||
{
|
||||
return KeyModifier_None;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user