2009-03-05 09:03:26 +00:00
|
|
|
/*
|
2010-10-18 14:56:30 +00:00
|
|
|
* Copyright (C) 1997-2001 Id Software, Inc.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or (at
|
|
|
|
* your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*
|
|
|
|
* See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* =======================================================================
|
|
|
|
*
|
|
|
|
* This is the "heart" of the id Tech 2 refresh engine. This file
|
|
|
|
* implements the main window in which Quake II is running. The window
|
|
|
|
* itself is created by the SDL backend, but here the refresh module is
|
|
|
|
* loaded, initialized and it's interaction with the operating system
|
|
|
|
* implemented. This code is also the interconnect between the input
|
|
|
|
* system (the mouse) and the keyboard system, both are here tied
|
|
|
|
* together with the refresher. The direct interaction between the
|
|
|
|
* refresher and those subsystems are the main cause for the very
|
|
|
|
* acurate and precise input controls of the id Tech 2.
|
|
|
|
*
|
|
|
|
* =======================================================================
|
|
|
|
*/
|
2009-03-05 09:03:26 +00:00
|
|
|
|
|
|
|
#include <assert.h>
|
2010-10-18 14:56:30 +00:00
|
|
|
#include <dlfcn.h>
|
2009-03-05 09:03:26 +00:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
2009-03-05 14:51:44 +00:00
|
|
|
#include "../../client/header/client.h"
|
2010-10-18 13:28:14 +00:00
|
|
|
#include "../header/unix.h"
|
2009-03-05 09:03:26 +00:00
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
/* Structure containing functions exported from refresh DLL */
|
|
|
|
refexport_t re;
|
2009-03-05 09:03:26 +00:00
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
/* Console variables that we need to access from this module */
|
|
|
|
cvar_t *vid_gamma;
|
|
|
|
cvar_t *vid_ref; /* Name of Refresh DLL loaded */
|
|
|
|
cvar_t *vid_xpos; /* X coordinate of window position */
|
|
|
|
cvar_t *vid_ypos; /* Y coordinate of window position */
|
|
|
|
cvar_t *vid_fullscreen;
|
2009-03-05 09:03:26 +00:00
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
/* Global variables used internally by this module */
|
|
|
|
viddef_t viddef; /* global video state; used by other modules */
|
|
|
|
void *reflib_library; /* Handle to refresh DLL */
|
|
|
|
qboolean reflib_active = 0;
|
2009-03-05 09:03:26 +00:00
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
#define VID_NUM_MODES ( sizeof ( vid_modes ) / sizeof ( vid_modes [ 0 ] ) )
|
2009-03-05 09:03:26 +00:00
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
/* KEYBOARD */
|
|
|
|
void Do_Key_Event ( int key, qboolean down );
|
|
|
|
void ( *KBD_Update_fp )( void );
|
|
|
|
void ( *KBD_Init_fp )( Key_Event_fp_t fp );
|
|
|
|
void ( *KBD_Close_fp )( void );
|
2009-03-05 09:03:26 +00:00
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
/* MOUSE */
|
2009-03-05 09:03:26 +00:00
|
|
|
in_state_t in_state;
|
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
void ( *RW_IN_Init_fp )( in_state_t *in_state_p );
|
|
|
|
void ( *RW_IN_Shutdown_fp )( void );
|
|
|
|
void ( *RW_IN_Activate_fp )( qboolean active );
|
|
|
|
void ( *RW_IN_Commands_fp )( void );
|
|
|
|
void ( *RW_IN_Move_fp )( usercmd_t *cmd );
|
|
|
|
void ( *RW_IN_Frame_fp )( void );
|
2009-03-05 09:03:26 +00:00
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
void IN_Init ( void );
|
2009-03-05 09:03:26 +00:00
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
/* CLIPBOARD */
|
|
|
|
char *( *RW_Sys_GetClipboardData_fp )(void);
|
2009-03-05 09:03:26 +00:00
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
extern void VID_MenuShutdown ( void );
|
2009-03-05 09:03:26 +00:00
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
/* DLL GLUE */
|
2009-03-05 09:03:26 +00:00
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
#define MAXPRINTMSG 4096
|
2009-03-05 09:03:26 +00:00
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
void
|
|
|
|
VID_Printf ( int print_level, char *fmt, ... )
|
2009-03-05 09:03:26 +00:00
|
|
|
{
|
2010-10-18 14:56:30 +00:00
|
|
|
va_list argptr;
|
|
|
|
char msg [ MAXPRINTMSG ];
|
|
|
|
|
|
|
|
va_start( argptr, fmt );
|
|
|
|
vsnprintf( msg, MAXPRINTMSG, fmt, argptr );
|
|
|
|
va_end( argptr );
|
|
|
|
|
|
|
|
if ( print_level == PRINT_ALL )
|
|
|
|
{
|
|
|
|
Com_Printf( "%s", msg );
|
|
|
|
}
|
2009-03-05 09:03:26 +00:00
|
|
|
else
|
2010-10-18 14:56:30 +00:00
|
|
|
{
|
|
|
|
Com_DPrintf( "%s", msg );
|
|
|
|
}
|
2009-03-05 09:03:26 +00:00
|
|
|
}
|
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
void
|
|
|
|
VID_Error ( int err_level, char *fmt, ... )
|
2009-03-05 09:03:26 +00:00
|
|
|
{
|
2010-10-18 14:56:30 +00:00
|
|
|
va_list argptr;
|
|
|
|
char msg [ MAXPRINTMSG ];
|
2009-03-05 09:03:26 +00:00
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
va_start( argptr, fmt );
|
|
|
|
vsnprintf( msg, MAXPRINTMSG, fmt, argptr );
|
|
|
|
va_end( argptr );
|
|
|
|
|
|
|
|
Com_Error( err_level, "%s", msg );
|
|
|
|
}
|
2009-03-05 09:03:26 +00:00
|
|
|
|
|
|
|
/*
|
2010-10-18 14:56:30 +00:00
|
|
|
* Console command to re-start the video mode and refresh DLL. We do this
|
|
|
|
* simply by setting the modified flag for the vid_ref variable, which will
|
|
|
|
* cause the entire video mode and refresh DLL to be reset on the next frame.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
VID_Restart_f ( void )
|
2009-03-05 09:03:26 +00:00
|
|
|
{
|
|
|
|
vid_ref->modified = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct vidmode_s
|
|
|
|
{
|
|
|
|
const char *description;
|
2010-10-18 14:56:30 +00:00
|
|
|
int width, height;
|
|
|
|
int mode;
|
2009-03-05 09:03:26 +00:00
|
|
|
} vidmode_t;
|
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
/* This must be the same as in menu.c! */
|
|
|
|
vidmode_t vid_modes[] = {
|
2009-03-05 09:03:26 +00:00
|
|
|
{ "Mode 0: 320x240", 320, 240, 0 },
|
|
|
|
{ "Mode 1: 400x300", 400, 300, 1 },
|
|
|
|
{ "Mode 2: 512x384", 512, 384, 2 },
|
2010-01-08 15:38:19 +00:00
|
|
|
{ "Mode 3: 640x400", 640, 400, 3 },
|
|
|
|
{ "Mode 4: 640x480", 640, 480, 4 },
|
|
|
|
{ "Mode 5: 800x500", 800, 500, 5 },
|
|
|
|
{ "Mode 6: 800x600", 800, 600, 6 },
|
|
|
|
{ "Mode 7: 960x720", 960, 720, 7 },
|
|
|
|
{ "Mode 8: 1024x480", 1024, 480, 8 },
|
|
|
|
{ "Mode 9: 1024x640", 1024, 640, 9 },
|
|
|
|
{ "Mode 10: 1024x768", 1024, 768, 10 },
|
|
|
|
{ "Mode 11: 1152x768", 1152, 768, 11 },
|
|
|
|
{ "Mode 12: 1152x864", 1152, 864, 12 },
|
2010-10-18 14:56:30 +00:00
|
|
|
{ "Mode 13: 1280x800", 1280, 800, 13 },
|
2010-01-08 15:38:19 +00:00
|
|
|
{ "Mode 14: 1280x854", 1280, 854, 14 },
|
|
|
|
{ "Mode 15: 1280x1024", 1280, 1024, 15 },
|
|
|
|
{ "Mode 16: 1600x1200", 1600, 1200, 16 },
|
2010-10-18 14:56:30 +00:00
|
|
|
{ "Mode 17: 1680x1050", 1680, 1050, 17 },
|
|
|
|
{ "Mode 18: 1920x1200", 1920, 1200, 18 },
|
2010-01-08 15:38:19 +00:00
|
|
|
{ "Mode 19: 2048x1536", 2048, 1536, 19 },
|
2009-03-05 09:03:26 +00:00
|
|
|
};
|
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
qboolean
|
|
|
|
VID_GetModeInfo ( int *width, int *height, int mode )
|
2009-03-05 09:03:26 +00:00
|
|
|
{
|
2010-10-18 14:56:30 +00:00
|
|
|
if ( ( mode < 0 ) || ( mode >= VID_NUM_MODES ) )
|
|
|
|
{
|
|
|
|
return ( false );
|
|
|
|
}
|
2009-03-05 09:03:26 +00:00
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
*width = vid_modes [ mode ].width;
|
|
|
|
*height = vid_modes [ mode ].height;
|
2009-03-05 09:03:26 +00:00
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
return ( true );
|
2009-03-05 09:03:26 +00:00
|
|
|
}
|
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
void
|
|
|
|
VID_NewWindow ( int width, int height )
|
2009-03-05 09:03:26 +00:00
|
|
|
{
|
|
|
|
viddef.width = width;
|
|
|
|
viddef.height = height;
|
|
|
|
}
|
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
void
|
|
|
|
VID_FreeReflib ( void )
|
2009-03-05 09:03:26 +00:00
|
|
|
{
|
2010-10-18 14:56:30 +00:00
|
|
|
if ( reflib_library )
|
|
|
|
{
|
|
|
|
if ( KBD_Close_fp )
|
|
|
|
{
|
2009-03-05 09:03:26 +00:00
|
|
|
KBD_Close_fp();
|
2010-10-18 14:56:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( RW_IN_Shutdown_fp )
|
|
|
|
{
|
2009-03-05 09:03:26 +00:00
|
|
|
RW_IN_Shutdown_fp();
|
2010-10-18 14:56:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dlclose( reflib_library );
|
2009-03-05 09:03:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
KBD_Init_fp = NULL;
|
|
|
|
KBD_Update_fp = NULL;
|
|
|
|
KBD_Close_fp = NULL;
|
|
|
|
RW_IN_Init_fp = NULL;
|
|
|
|
RW_IN_Shutdown_fp = NULL;
|
|
|
|
RW_IN_Activate_fp = NULL;
|
|
|
|
RW_IN_Commands_fp = NULL;
|
|
|
|
RW_IN_Move_fp = NULL;
|
|
|
|
RW_IN_Frame_fp = NULL;
|
|
|
|
RW_Sys_GetClipboardData_fp = NULL;
|
2010-10-18 14:56:30 +00:00
|
|
|
|
|
|
|
memset( &re, 0, sizeof ( re ) );
|
2009-03-05 09:03:26 +00:00
|
|
|
reflib_library = NULL;
|
|
|
|
reflib_active = false;
|
|
|
|
}
|
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
qboolean
|
|
|
|
VID_LoadRefresh ( char *name )
|
2009-03-05 09:03:26 +00:00
|
|
|
{
|
2010-10-18 14:56:30 +00:00
|
|
|
refimport_t ri;
|
|
|
|
GetRefAPI_t GetRefAPI;
|
|
|
|
char fn [ MAX_OSPATH ];
|
|
|
|
char *path;
|
2009-03-05 09:03:26 +00:00
|
|
|
struct stat st;
|
|
|
|
extern uid_t saved_euid;
|
2010-10-18 14:56:30 +00:00
|
|
|
|
2009-03-05 09:03:26 +00:00
|
|
|
if ( reflib_active )
|
|
|
|
{
|
2010-10-18 14:56:30 +00:00
|
|
|
if ( KBD_Close_fp )
|
|
|
|
{
|
2009-03-05 09:03:26 +00:00
|
|
|
KBD_Close_fp();
|
2010-10-18 14:56:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( RW_IN_Shutdown_fp )
|
|
|
|
{
|
2009-03-05 09:03:26 +00:00
|
|
|
RW_IN_Shutdown_fp();
|
2010-10-18 14:56:30 +00:00
|
|
|
}
|
|
|
|
|
2009-03-05 09:03:26 +00:00
|
|
|
KBD_Close_fp = NULL;
|
|
|
|
RW_IN_Shutdown_fp = NULL;
|
|
|
|
re.Shutdown();
|
2010-10-18 14:56:30 +00:00
|
|
|
VID_FreeReflib();
|
2009-03-05 09:03:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Com_Printf( "------- Loading %s -------\n", name );
|
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
/* regain root */
|
|
|
|
seteuid( saved_euid );
|
2009-03-05 09:03:26 +00:00
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
path = Cvar_Get( "basedir", ".", CVAR_NOSET )->string;
|
2009-03-05 09:03:26 +00:00
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
snprintf( fn, MAX_OSPATH, "%s/%s", path, name );
|
|
|
|
|
|
|
|
if ( stat( fn, &st ) == -1 )
|
|
|
|
{
|
|
|
|
Com_Printf( "LoadLibrary(\"%s\") failed: %s\n", name, strerror( errno ) );
|
|
|
|
return ( false );
|
2009-03-05 09:03:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( ( reflib_library = dlopen( fn, RTLD_LAZY ) ) == 0 )
|
|
|
|
{
|
2010-10-18 14:56:30 +00:00
|
|
|
Com_Printf( "LoadLibrary(\"%s\") failed: %s\n", name, dlerror() );
|
|
|
|
return ( false );
|
2009-03-05 09:03:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Com_Printf( "LoadLibrary(\"%s\")\n", fn );
|
|
|
|
|
|
|
|
ri.Cmd_AddCommand = Cmd_AddCommand;
|
|
|
|
ri.Cmd_RemoveCommand = Cmd_RemoveCommand;
|
|
|
|
ri.Cmd_Argc = Cmd_Argc;
|
|
|
|
ri.Cmd_Argv = Cmd_Argv;
|
|
|
|
ri.Cmd_ExecuteText = Cbuf_ExecuteText;
|
|
|
|
ri.Con_Printf = VID_Printf;
|
|
|
|
ri.Sys_Error = VID_Error;
|
|
|
|
ri.FS_LoadFile = FS_LoadFile;
|
|
|
|
ri.FS_FreeFile = FS_FreeFile;
|
|
|
|
ri.FS_Gamedir = FS_Gamedir;
|
|
|
|
ri.Cvar_Get = Cvar_Get;
|
|
|
|
ri.Cvar_Set = Cvar_Set;
|
|
|
|
ri.Cvar_SetValue = Cvar_SetValue;
|
|
|
|
ri.Vid_GetModeInfo = VID_GetModeInfo;
|
|
|
|
ri.Vid_MenuInit = VID_MenuInit;
|
|
|
|
ri.Vid_NewWindow = VID_NewWindow;
|
|
|
|
|
|
|
|
if ( ( GetRefAPI = (void *) dlsym( reflib_library, "GetRefAPI" ) ) == 0 )
|
2010-10-18 14:56:30 +00:00
|
|
|
{
|
2009-03-05 09:03:26 +00:00
|
|
|
Com_Error( ERR_FATAL, "dlsym failed on %s", name );
|
2010-10-18 14:56:30 +00:00
|
|
|
}
|
2009-03-05 09:03:26 +00:00
|
|
|
|
|
|
|
re = GetRefAPI( ri );
|
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
if ( re.api_version != API_VERSION )
|
2009-03-05 09:03:26 +00:00
|
|
|
{
|
2010-10-18 14:56:30 +00:00
|
|
|
VID_FreeReflib();
|
|
|
|
Com_Error( ERR_FATAL, "%s has incompatible api_version", name );
|
2009-03-05 09:03:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Init IN (Mouse) */
|
|
|
|
in_state.IN_CenterView_fp = IN_CenterView;
|
|
|
|
in_state.Key_Event_fp = Do_Key_Event;
|
|
|
|
in_state.viewangles = cl.viewangles;
|
|
|
|
in_state.in_strafe_state = &in_strafe.state;
|
|
|
|
in_state.in_speed_state = &in_speed.state;
|
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
if ( ( ( RW_IN_Init_fp = dlsym( reflib_library, "RW_IN_Init" ) ) == NULL ) ||
|
|
|
|
( ( RW_IN_Shutdown_fp = dlsym( reflib_library, "RW_IN_Shutdown" ) ) == NULL ) ||
|
|
|
|
( ( RW_IN_Commands_fp = dlsym( reflib_library, "RW_IN_Commands" ) ) == NULL ) ||
|
2010-10-18 16:06:40 +00:00
|
|
|
( ( RW_IN_Move_fp = dlsym( reflib_library, "RW_IN_Move" ) ) == NULL ) )
|
2010-10-18 14:56:30 +00:00
|
|
|
{
|
|
|
|
Sys_Error( "No RW_IN functions in REF.\n" );
|
|
|
|
}
|
2009-03-05 09:03:26 +00:00
|
|
|
|
|
|
|
/* this one is optional */
|
2010-10-18 14:56:30 +00:00
|
|
|
RW_Sys_GetClipboardData_fp = dlsym( reflib_library, "RW_Sys_GetClipboardData" );
|
|
|
|
|
2010-07-13 18:04:07 +00:00
|
|
|
IN_Init();
|
2009-03-05 09:03:26 +00:00
|
|
|
|
|
|
|
if ( re.Init( 0, 0 ) == -1 )
|
|
|
|
{
|
|
|
|
re.Shutdown();
|
2010-10-18 14:56:30 +00:00
|
|
|
VID_FreeReflib();
|
|
|
|
return ( false );
|
2009-03-05 09:03:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Init KBD */
|
2010-10-18 14:56:30 +00:00
|
|
|
if ( ( ( KBD_Init_fp = dlsym( reflib_library, "KBD_Init" ) ) == NULL ) ||
|
|
|
|
( ( KBD_Update_fp = dlsym( reflib_library, "KBD_Update" ) ) == NULL ) ||
|
|
|
|
( ( KBD_Close_fp = dlsym( reflib_library, "KBD_Close" ) ) == NULL ) )
|
|
|
|
{
|
|
|
|
Sys_Error( "No KBD functions in REF.\n" );
|
|
|
|
}
|
2009-03-05 09:03:26 +00:00
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
KBD_Init_fp( Do_Key_Event );
|
2009-03-05 09:03:26 +00:00
|
|
|
Key_ClearStates();
|
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
/* give up root now */
|
|
|
|
setreuid( getuid(), getuid() );
|
|
|
|
setegid( getgid() );
|
|
|
|
|
|
|
|
Com_Printf( "------------------------------------\n" );
|
2009-03-05 09:03:26 +00:00
|
|
|
reflib_active = true;
|
2010-10-18 14:56:30 +00:00
|
|
|
return ( true );
|
2009-03-05 09:03:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2010-10-18 14:56:30 +00:00
|
|
|
* This function gets called once just before drawing each frame, and
|
|
|
|
* it's sole purpose in life is to check to see if any of the video mode
|
|
|
|
* parameters have changed, and if they have to update the rendering DLL
|
|
|
|
* and/or video mode to match.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
VID_CheckChanges ( void )
|
2009-03-05 09:03:26 +00:00
|
|
|
{
|
2010-10-18 14:56:30 +00:00
|
|
|
char name [ 100 ];
|
2009-03-05 09:03:26 +00:00
|
|
|
|
|
|
|
if ( vid_ref->modified )
|
|
|
|
{
|
|
|
|
S_StopAllSounds();
|
|
|
|
}
|
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
while ( vid_ref->modified )
|
2009-03-05 09:03:26 +00:00
|
|
|
{
|
2010-10-18 14:56:30 +00:00
|
|
|
/* refresh has changed */
|
2009-03-05 09:03:26 +00:00
|
|
|
vid_ref->modified = false;
|
|
|
|
vid_fullscreen->modified = true;
|
|
|
|
cl.refresh_prepped = false;
|
|
|
|
cls.disable_screen = true;
|
|
|
|
|
|
|
|
sprintf( name, "ref_%s.so", vid_ref->string );
|
2010-10-18 14:56:30 +00:00
|
|
|
|
2009-03-05 09:03:26 +00:00
|
|
|
if ( !VID_LoadRefresh( name ) )
|
|
|
|
{
|
2010-10-18 14:56:30 +00:00
|
|
|
Cvar_Set( "vid_ref", "gl" );
|
|
|
|
}
|
|
|
|
|
2009-03-05 09:03:26 +00:00
|
|
|
cls.disable_screen = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
VID_Init ( void )
|
2009-03-05 09:03:26 +00:00
|
|
|
{
|
|
|
|
/* Create the video variables so we know how to start the graphics drivers */
|
2010-10-18 14:56:30 +00:00
|
|
|
vid_ref = Cvar_Get( "vid_ref", "gl", CVAR_ARCHIVE );
|
|
|
|
|
|
|
|
vid_xpos = Cvar_Get( "vid_xpos", "3", CVAR_ARCHIVE );
|
|
|
|
vid_ypos = Cvar_Get( "vid_ypos", "22", CVAR_ARCHIVE );
|
|
|
|
vid_fullscreen = Cvar_Get( "vid_fullscreen", "0", CVAR_ARCHIVE );
|
2009-03-05 09:03:26 +00:00
|
|
|
vid_gamma = Cvar_Get( "vid_gamma", "1", CVAR_ARCHIVE );
|
|
|
|
|
|
|
|
/* Add some console commands that we want to handle */
|
2010-10-18 14:56:30 +00:00
|
|
|
Cmd_AddCommand( "vid_restart", VID_Restart_f );
|
2009-03-05 09:03:26 +00:00
|
|
|
|
|
|
|
/* Start the graphics mode and load refresh DLL */
|
|
|
|
VID_CheckChanges();
|
|
|
|
}
|
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
void
|
|
|
|
VID_Shutdown ( void )
|
2009-03-05 09:03:26 +00:00
|
|
|
{
|
|
|
|
if ( reflib_active )
|
|
|
|
{
|
2010-10-18 14:56:30 +00:00
|
|
|
if ( KBD_Close_fp )
|
|
|
|
{
|
2009-03-05 09:03:26 +00:00
|
|
|
KBD_Close_fp();
|
2010-10-18 14:56:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( RW_IN_Shutdown_fp )
|
|
|
|
{
|
2009-03-05 09:03:26 +00:00
|
|
|
RW_IN_Shutdown_fp();
|
2010-10-18 14:56:30 +00:00
|
|
|
}
|
|
|
|
|
2009-03-05 09:03:26 +00:00
|
|
|
KBD_Close_fp = NULL;
|
|
|
|
RW_IN_Shutdown_fp = NULL;
|
2010-10-18 14:56:30 +00:00
|
|
|
re.Shutdown();
|
|
|
|
VID_FreeReflib();
|
2009-03-05 09:03:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VID_MenuShutdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2010-10-18 14:56:30 +00:00
|
|
|
* Checks to see if the given ref_NAME.so exists.
|
|
|
|
* Placed here to avoid complicating other code if the library .so files
|
|
|
|
* ever have their names changed.
|
|
|
|
*/
|
|
|
|
qboolean
|
|
|
|
VID_CheckRefExists ( const char *ref )
|
2009-03-05 09:03:26 +00:00
|
|
|
{
|
2010-10-18 14:56:30 +00:00
|
|
|
char fn [ MAX_OSPATH ];
|
|
|
|
char *path;
|
2009-03-05 09:03:26 +00:00
|
|
|
struct stat st;
|
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
path = Cvar_Get( "basedir", ".", CVAR_NOSET )->string;
|
|
|
|
snprintf( fn, MAX_OSPATH, "%s/ref_%s.so", path, ref );
|
|
|
|
|
|
|
|
if ( stat( fn, &st ) == 0 )
|
|
|
|
{
|
|
|
|
return ( true );
|
|
|
|
}
|
2009-03-05 09:03:26 +00:00
|
|
|
else
|
2010-10-18 14:56:30 +00:00
|
|
|
{
|
|
|
|
return ( false );
|
|
|
|
}
|
2009-03-05 09:03:26 +00:00
|
|
|
}
|
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
/* INPUT */
|
|
|
|
void
|
|
|
|
IN_Init ( void )
|
2009-03-05 09:03:26 +00:00
|
|
|
{
|
2010-10-18 14:56:30 +00:00
|
|
|
if ( RW_IN_Init_fp )
|
|
|
|
{
|
|
|
|
RW_IN_Init_fp( &in_state );
|
|
|
|
}
|
2009-03-05 09:03:26 +00:00
|
|
|
}
|
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
void
|
|
|
|
IN_Shutdown ( void )
|
2009-03-05 09:03:26 +00:00
|
|
|
{
|
2010-10-18 14:56:30 +00:00
|
|
|
if ( RW_IN_Shutdown_fp )
|
|
|
|
{
|
2009-03-05 09:03:26 +00:00
|
|
|
RW_IN_Shutdown_fp();
|
2010-10-18 14:56:30 +00:00
|
|
|
}
|
2009-03-05 09:03:26 +00:00
|
|
|
}
|
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
void
|
|
|
|
IN_Commands ( void )
|
2009-03-05 09:03:26 +00:00
|
|
|
{
|
2010-10-18 14:56:30 +00:00
|
|
|
if ( RW_IN_Commands_fp )
|
|
|
|
{
|
2009-03-05 09:03:26 +00:00
|
|
|
RW_IN_Commands_fp();
|
2010-10-18 14:56:30 +00:00
|
|
|
}
|
2009-03-05 09:03:26 +00:00
|
|
|
}
|
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
void
|
|
|
|
IN_Move ( usercmd_t *cmd )
|
2009-03-05 09:03:26 +00:00
|
|
|
{
|
2010-10-18 14:56:30 +00:00
|
|
|
if ( RW_IN_Move_fp )
|
|
|
|
{
|
|
|
|
RW_IN_Move_fp( cmd );
|
|
|
|
}
|
2009-03-05 09:03:26 +00:00
|
|
|
}
|
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
void
|
|
|
|
IN_Frame ( void )
|
2009-03-05 09:03:26 +00:00
|
|
|
{
|
2010-10-18 14:56:30 +00:00
|
|
|
if ( RW_IN_Activate_fp )
|
2009-03-05 09:03:26 +00:00
|
|
|
{
|
2010-10-18 14:56:30 +00:00
|
|
|
if ( !cl.refresh_prepped || ( cls.key_dest == key_console ) || ( cls.key_dest == key_menu ) )
|
|
|
|
{
|
|
|
|
RW_IN_Activate_fp( false );
|
|
|
|
}
|
2009-03-05 09:03:26 +00:00
|
|
|
else
|
2010-10-18 14:56:30 +00:00
|
|
|
{
|
|
|
|
RW_IN_Activate_fp( true );
|
|
|
|
}
|
2009-03-05 09:03:26 +00:00
|
|
|
}
|
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
if ( RW_IN_Frame_fp )
|
|
|
|
{
|
2009-03-05 09:03:26 +00:00
|
|
|
RW_IN_Frame_fp();
|
2010-10-18 14:56:30 +00:00
|
|
|
}
|
2009-03-05 09:03:26 +00:00
|
|
|
}
|
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
void
|
|
|
|
Do_Key_Event ( int key, qboolean down )
|
2009-03-05 09:03:26 +00:00
|
|
|
{
|
2010-10-18 14:56:30 +00:00
|
|
|
Key_Event( key, down, Sys_Milliseconds() );
|
2009-03-05 09:03:26 +00:00
|
|
|
}
|
|
|
|
|
2010-10-18 14:56:30 +00:00
|
|
|
char *
|
|
|
|
Sys_GetClipboardData ( void )
|
2009-03-05 09:03:26 +00:00
|
|
|
{
|
2010-10-18 14:56:30 +00:00
|
|
|
if ( RW_Sys_GetClipboardData_fp )
|
|
|
|
{
|
|
|
|
return ( RW_Sys_GetClipboardData_fp() );
|
|
|
|
}
|
2009-03-05 09:03:26 +00:00
|
|
|
else
|
2010-10-18 14:56:30 +00:00
|
|
|
{
|
|
|
|
return ( NULL );
|
|
|
|
}
|
2009-03-05 09:03:26 +00:00
|
|
|
}
|
|
|
|
|