mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-11 14:42: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 )
|
void Platform_EnableTextInput( qboolean enable )
|
||||||
{
|
{
|
||||||
keystate.chars = enable;
|
keystate.chars = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Platform_PreCreateMove( void )
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Platform_MouseMove( float *x, float *y )
|
void Platform_MouseMove( float *x, float *y )
|
||||||
{
|
{
|
||||||
static int lx,ly;
|
static int lx,ly;
|
||||||
|
|||||||
@@ -15,24 +15,11 @@ GNU General Public License for more details.
|
|||||||
|
|
||||||
#include "platform/platform.h"
|
#include "platform/platform.h"
|
||||||
#include <dos.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 )
|
void Platform_ShellExecute( const char *path, const char *parms )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
volatile int ticks=0;
|
volatile int ticks=0;
|
||||||
|
|
||||||
#if XASH_TIMER == TIMER_DOS
|
#if XASH_TIMER == TIMER_DOS
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ void Evdev_Autodetect_f( void )
|
|||||||
|
|
||||||
for( i = 0; i < evdev.devices; i++ )
|
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;
|
goto next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ qboolean R_Init_Video( const int type )
|
|||||||
|
|
||||||
if( fb.fd < 0 )
|
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" ) )
|
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 );
|
Con_Reportf( "%s: forced resolution to %dx%d)\n", __func__, width, height );
|
||||||
|
|
||||||
VID_SetDisplayTransform( &render_w, &render_h );
|
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;
|
return rserr_ok;
|
||||||
}
|
}
|
||||||
@@ -246,41 +246,4 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint *
|
|||||||
return true;
|
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
|
#endif
|
||||||
|
|||||||
+49
-33
@@ -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_Vibrate( float life, char flags ); // left for compatibility
|
||||||
void Platform_Vibrate2( float time, int low_freq, int high_freq, uint flags );
|
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 // only SDL based backends implements these functions
|
||||||
#if XASH_SDL
|
void Platform_PreCreateMove( void );
|
||||||
int Platform_JoyInit( void ); // returns number of connected gamepads, negative if error
|
void GAME_EXPORT Platform_GetMousePos( int *x, int *y );
|
||||||
void Platform_JoyShutdown( void );
|
void GAME_EXPORT Platform_SetMousePos( int x, int y );
|
||||||
void Platform_CalibrateGamepadGyro( void );
|
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
|
#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;
|
if( x ) *x = 0;
|
||||||
}
|
if( y ) *y = 0;
|
||||||
|
|
||||||
static inline void Platform_JoyShutdown( void )
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void Platform_CalibrateGamepadGyro( void )
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Text input
|
#if XASH_SDL || XASH_DOS
|
||||||
void Platform_EnableTextInput( qboolean enable );
|
|
||||||
key_modifier_t Platform_GetKeyModifiers( void );
|
|
||||||
// System events
|
|
||||||
void Platform_RunEvents( void );
|
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_MouseMove( float *x, float *y );
|
||||||
void Platform_SetCursorType( VGUI_DefaultCursor type );
|
#else
|
||||||
qboolean Platform_GetMouseGrab( void );
|
static inline void Platform_RunEvents( void ) { }
|
||||||
void Platform_SetMouseGrab( qboolean enable );
|
static inline void Platform_MouseMove( float *x, float *y )
|
||||||
// Clipboard
|
{
|
||||||
int Platform_GetClipboardText( char *buffer, size_t size );
|
if( x ) *x = 0.0f;
|
||||||
void Platform_SetClipboardText( const char *buffer );
|
if( y ) *y = 0.0f;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if XASH_SDL == 1
|
#if XASH_SDL >= 2 || XASH_PSVITA || XASH_DOS || XASH_USE_EVDEV
|
||||||
#define SDL_IsTextInputActive() host.textmode
|
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
|
#endif
|
||||||
|
|
||||||
static inline void Platform_SetTimer( float time )
|
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 down = key.state != SDL_RELEASED;
|
||||||
int keynum = key.keysym.sym;
|
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
|
// this is how engine understands ctrl+c, ctrl+v and other hotkeys
|
||||||
if( cls.key_dest != key_game && FBitSet( SDL_GetModState(), KMOD_CTRL ))
|
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
|
Platform_SetCursorType
|
||||||
@@ -163,14 +152,3 @@ void Platform_SetMouseGrab( qboolean enable )
|
|||||||
{
|
{
|
||||||
SDL_WM_GrabInput( enable ? SDL_GRAB_ON : SDL_GRAB_OFF );
|
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