|
|
@ -21,10 +21,6 @@ GNU General Public License for more details. |
|
|
|
#include "keydefs.h" |
|
|
|
#include "keydefs.h" |
|
|
|
#include "ref_common.h" |
|
|
|
#include "ref_common.h" |
|
|
|
#include "input.h" |
|
|
|
#include "input.h" |
|
|
|
#ifdef XASH_SDL |
|
|
|
|
|
|
|
#include <SDL.h> |
|
|
|
|
|
|
|
static SDL_Cursor* s_pDefaultCursor[20]; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
#include "platform/platform.h" |
|
|
|
#include "platform/platform.h" |
|
|
|
|
|
|
|
|
|
|
|
static enum VGUI_KeyCode s_pVirtualKeyTrans[256]; |
|
|
|
static enum VGUI_KeyCode s_pVirtualKeyTrans[256]; |
|
|
@ -32,20 +28,6 @@ static enum VGUI_DefaultCursor s_currentCursor; |
|
|
|
static HINSTANCE s_pVGuiSupport; // vgui_support library
|
|
|
|
static HINSTANCE s_pVGuiSupport; // vgui_support library
|
|
|
|
static convar_t *vgui_utf8 = NULL; |
|
|
|
static convar_t *vgui_utf8 = NULL; |
|
|
|
|
|
|
|
|
|
|
|
// Helper functions for vgui backend
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*void VGUI_HideCursor( void )
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
host.mouse_visible = false; |
|
|
|
|
|
|
|
SDL_HideCursor(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void VGUI_ShowCursor( void ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
host.mouse_visible = true; |
|
|
|
|
|
|
|
SDL_ShowCursor(); |
|
|
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void GAME_EXPORT *VGUI_EngineMalloc(size_t size) |
|
|
|
void GAME_EXPORT *VGUI_EngineMalloc(size_t size) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return Z_Malloc( size ); |
|
|
|
return Z_Malloc( size ); |
|
|
@ -66,63 +48,9 @@ void GAME_EXPORT VGUI_GetMousePos( int *_x, int *_y ) |
|
|
|
*_x = x / xscale, *_y = y / yscale; |
|
|
|
*_x = x / xscale, *_y = y / yscale; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void VGUI_InitCursors( void ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// load up all default cursors
|
|
|
|
|
|
|
|
#if SDL_VERSION_ATLEAST( 2, 0, 0 ) |
|
|
|
|
|
|
|
s_pDefaultCursor[dc_none] = NULL; |
|
|
|
|
|
|
|
s_pDefaultCursor[dc_arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW); |
|
|
|
|
|
|
|
s_pDefaultCursor[dc_ibeam] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM); |
|
|
|
|
|
|
|
s_pDefaultCursor[dc_hourglass]= SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAIT); |
|
|
|
|
|
|
|
s_pDefaultCursor[dc_crosshair]= SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_CROSSHAIR); |
|
|
|
|
|
|
|
s_pDefaultCursor[dc_up] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW); |
|
|
|
|
|
|
|
s_pDefaultCursor[dc_sizenwse] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE); |
|
|
|
|
|
|
|
s_pDefaultCursor[dc_sizenesw] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW); |
|
|
|
|
|
|
|
s_pDefaultCursor[dc_sizewe] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE); |
|
|
|
|
|
|
|
s_pDefaultCursor[dc_sizens] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS); |
|
|
|
|
|
|
|
s_pDefaultCursor[dc_sizeall] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL); |
|
|
|
|
|
|
|
s_pDefaultCursor[dc_no] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NO); |
|
|
|
|
|
|
|
s_pDefaultCursor[dc_hand] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void GAME_EXPORT VGUI_CursorSelect( enum VGUI_DefaultCursor cursor ) |
|
|
|
void GAME_EXPORT VGUI_CursorSelect( enum VGUI_DefaultCursor cursor ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
qboolean visible; |
|
|
|
Platform_SetCursorType( cursor ); |
|
|
|
|
|
|
|
|
|
|
|
if( cls.key_dest != key_game || cl.paused ) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch( cursor ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
case dc_user: |
|
|
|
|
|
|
|
case dc_none: |
|
|
|
|
|
|
|
visible = false; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
visible = true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
host.mouse_visible = visible; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if SDL_VERSION_ATLEAST( 2, 0, 0 ) |
|
|
|
|
|
|
|
/// TODO: platform cursors
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( CVAR_TO_BOOL( touch_emulate ) ) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( host.mouse_visible ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SDL_SetCursor( s_pDefaultCursor[cursor] ); |
|
|
|
|
|
|
|
SDL_ShowCursor( true ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SDL_ShowCursor( false ); |
|
|
|
|
|
|
|
Key_EnableTextInput( false, true ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
s_currentCursor = cursor; |
|
|
|
s_currentCursor = cursor; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -134,7 +62,7 @@ byte GAME_EXPORT VGUI_GetColor( int i, int j) |
|
|
|
// Define and initialize vgui API
|
|
|
|
// Define and initialize vgui API
|
|
|
|
int GAME_EXPORT VGUI_UtfProcessChar( int in ) |
|
|
|
int GAME_EXPORT VGUI_UtfProcessChar( int in ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( CVAR_TO_BOOL( vgui_utf8 ) ) |
|
|
|
if( CVAR_TO_BOOL( vgui_utf8 )) |
|
|
|
return Con_UtfProcessCharForce( in ); |
|
|
|
return Con_UtfProcessCharForce( in ); |
|
|
|
else |
|
|
|
else |
|
|
|
return in; |
|
|
|
return in; |
|
|
@ -163,6 +91,9 @@ vguiapi_t vgui = |
|
|
|
NULL, |
|
|
|
NULL, |
|
|
|
VGUI_GetMousePos, |
|
|
|
VGUI_GetMousePos, |
|
|
|
VGUI_UtfProcessChar, |
|
|
|
VGUI_UtfProcessChar, |
|
|
|
|
|
|
|
Platform_GetClipboardText, |
|
|
|
|
|
|
|
Platform_SetClipboardText, |
|
|
|
|
|
|
|
Platform_GetKeyModifiers, |
|
|
|
NULL, |
|
|
|
NULL, |
|
|
|
NULL, |
|
|
|
NULL, |
|
|
|
NULL, |
|
|
|
NULL, |
|
|
@ -170,6 +101,7 @@ vguiapi_t vgui = |
|
|
|
NULL, |
|
|
|
NULL, |
|
|
|
NULL, |
|
|
|
NULL, |
|
|
|
NULL, |
|
|
|
NULL, |
|
|
|
|
|
|
|
NULL |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
qboolean VGui_IsActive( void ) |
|
|
|
qboolean VGui_IsActive( void ) |
|
|
@ -478,8 +410,9 @@ void VGui_KeyEvent( int key, int down ) |
|
|
|
switch( key ) |
|
|
|
switch( key ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
case K_MOUSE1: |
|
|
|
case K_MOUSE1: |
|
|
|
if( down && host.mouse_visible ) |
|
|
|
if( down && host.mouse_visible ) { |
|
|
|
Key_EnableTextInput( true, false ); |
|
|
|
Key_EnableTextInput(true, false); |
|
|
|
|
|
|
|
} |
|
|
|
vgui.Mouse( down ? MA_PRESSED : MA_RELEASED, MOUSE_LEFT ); |
|
|
|
vgui.Mouse( down ? MA_PRESSED : MA_RELEASED, MOUSE_LEFT ); |
|
|
|
return; |
|
|
|
return; |
|
|
|
case K_MOUSE2: |
|
|
|
case K_MOUSE2: |
|
|
@ -515,7 +448,7 @@ void VGui_MouseMove( int x, int y ) |
|
|
|
|
|
|
|
|
|
|
|
void VGui_Paint( void ) |
|
|
|
void VGui_Paint( void ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(vgui.initialized) |
|
|
|
if( vgui.initialized ) |
|
|
|
vgui.Paint(); |
|
|
|
vgui.Paint(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -531,3 +464,9 @@ void *GAME_EXPORT VGui_GetPanel( void ) |
|
|
|
return vgui.GetPanel(); |
|
|
|
return vgui.GetPanel(); |
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void VGui_ReportTextInput( const char *text ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if ( vgui.initialized ) |
|
|
|
|
|
|
|
vgui.TextInput( text ); |
|
|
|
|
|
|
|
} |
|
|
|