mirror of https://bitbucket.org/CPMADevs/cnq3
rewrite most of the linux mouse code: support (and prefer) xinput2 and raw support, default to the master pointer and add m_device to choose one explicitly.
This commit is contained in:
parent
0f89ca6853
commit
d8bf2665f5
|
@ -395,9 +395,9 @@ $(OBJDIR)/sv_snapshot.o: ../../code/server/sv_snapshot.cpp
|
||||||
$(OBJDIR)/sv_world.o: ../../code/server/sv_world.cpp
|
$(OBJDIR)/sv_world.o: ../../code/server/sv_world.cpp
|
||||||
@echo $(notdir $<)
|
@echo $(notdir $<)
|
||||||
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||||
$(OBJDIR)/linux_glimp.o: ../../code/unix/linux_glimp.c
|
$(OBJDIR)/linux_glimp.o: ../../code/unix/linux_glimp.cpp
|
||||||
@echo $(notdir $<)
|
@echo $(notdir $<)
|
||||||
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||||
$(OBJDIR)/linux_joystick.o: ../../code/unix/linux_joystick.c
|
$(OBJDIR)/linux_joystick.o: ../../code/unix/linux_joystick.c
|
||||||
@echo $(notdir $<)
|
@echo $(notdir $<)
|
||||||
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
|
||||||
|
|
|
@ -393,7 +393,7 @@ local function ApplyExeProjectSettings(exeName, server)
|
||||||
"unix/linux_signals.cpp",
|
"unix/linux_signals.cpp",
|
||||||
"unix/linux_qgl.c",
|
"unix/linux_qgl.c",
|
||||||
"unix/linux_snd.c",
|
"unix/linux_snd.c",
|
||||||
"unix/linux_glimp.c"
|
"unix/linux_glimp.cpp"
|
||||||
}
|
}
|
||||||
|
|
||||||
AddHeaders("botlib")
|
AddHeaders("botlib")
|
||||||
|
|
|
@ -59,9 +59,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <GL/glx.h>
|
#include <GL/glx.h>
|
||||||
#if defined(__FX__)
|
|
||||||
#include <GL/fxmesa.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#elif defined( __sun )
|
#elif defined( __sun )
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
|
@ -480,16 +477,6 @@ extern BOOL ( WINAPI * qwglSwapIntervalEXT)( int interval );
|
||||||
|
|
||||||
#if ( (defined __linux__ ) || (defined __FreeBSD__ ) || (defined __sun) )
|
#if ( (defined __linux__ ) || (defined __FreeBSD__ ) || (defined __sun) )
|
||||||
|
|
||||||
//FX Mesa Functions
|
|
||||||
#if defined (__FX__)
|
|
||||||
extern fxMesaContext (*qfxMesaCreateContext)(GLuint win, GrScreenResolution_t, GrScreenRefresh_t, const GLint attribList[]);
|
|
||||||
extern fxMesaContext (*qfxMesaCreateBestContext)(GLuint win, GLint width, GLint height, const GLint attribList[]);
|
|
||||||
extern void (*qfxMesaDestroyContext)(fxMesaContext ctx);
|
|
||||||
extern void (*qfxMesaMakeCurrent)(fxMesaContext ctx);
|
|
||||||
extern fxMesaContext (*qfxMesaGetCurrentContext)(void);
|
|
||||||
extern void (*qfxMesaSwapBuffers)(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//GLX Functions
|
//GLX Functions
|
||||||
extern XVisualInfo * (*qglXChooseVisual)( Display *dpy, int screen, int *attribList );
|
extern XVisualInfo * (*qglXChooseVisual)( Display *dpy, int screen, int *attribList );
|
||||||
extern GLXContext (*qglXCreateContext)( Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct );
|
extern GLXContext (*qglXCreateContext)( Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct );
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -37,11 +37,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include "unix_glw.h"
|
#include "unix_glw.h"
|
||||||
|
|
||||||
// bk001129 - from cvs1.17 (mkv)
|
|
||||||
#if defined(__FX__)
|
|
||||||
#include <GL/fxmesa.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(USE_SDL_VIDEO)
|
#if defined(USE_SDL_VIDEO)
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_opengl.h>
|
#include <SDL_opengl.h>
|
||||||
|
@ -51,16 +46,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
#include "../renderer/tr_local.h"
|
#include "../renderer/tr_local.h"
|
||||||
|
|
||||||
// bk001129 - from cvs1.17 (mkv)
|
|
||||||
#if defined(__FX__)
|
|
||||||
//FX Mesa Functions
|
|
||||||
fxMesaContext (*qfxMesaCreateContext)(GLuint win, GrScreenResolution_t, GrScreenRefresh_t, const GLint attribList[]);
|
|
||||||
fxMesaContext (*qfxMesaCreateBestContext)(GLuint win, GLint width, GLint height, const GLint attribList[]);
|
|
||||||
void (*qfxMesaDestroyContext)(fxMesaContext ctx);
|
|
||||||
void (*qfxMesaMakeCurrent)(fxMesaContext ctx);
|
|
||||||
fxMesaContext (*qfxMesaGetCurrentContext)(void);
|
|
||||||
void (*qfxMesaSwapBuffers)(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//GLX Functions
|
//GLX Functions
|
||||||
#if !defined(USE_SDL_VIDEO)
|
#if !defined(USE_SDL_VIDEO)
|
||||||
|
@ -1138,16 +1123,6 @@ void QGL_Shutdown( void )
|
||||||
qglVertexPointer = NULL;
|
qglVertexPointer = NULL;
|
||||||
qglViewport = NULL;
|
qglViewport = NULL;
|
||||||
|
|
||||||
// bk001129 - from cvs1.17 (mkv)
|
|
||||||
#if defined(__FX__)
|
|
||||||
qfxMesaCreateContext = NULL;
|
|
||||||
qfxMesaCreateBestContext = NULL;
|
|
||||||
qfxMesaDestroyContext = NULL;
|
|
||||||
qfxMesaMakeCurrent = NULL;
|
|
||||||
qfxMesaGetCurrentContext = NULL;
|
|
||||||
qfxMesaSwapBuffers = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(USE_SDL_VIDEO)
|
#if !defined(USE_SDL_VIDEO)
|
||||||
qglXGetProcAddress = NULL;
|
qglXGetProcAddress = NULL;
|
||||||
qglXChooseVisual = NULL;
|
qglXChooseVisual = NULL;
|
||||||
|
@ -1564,16 +1539,6 @@ qboolean QGL_Init( const char *dllname )
|
||||||
qglVertexPointer = dllVertexPointer =(void (*)(GLint, GLenum, GLsizei, const GLvoid*))GPA( "glVertexPointer" );
|
qglVertexPointer = dllVertexPointer =(void (*)(GLint, GLenum, GLsizei, const GLvoid*))GPA( "glVertexPointer" );
|
||||||
qglViewport = dllViewport =(void (*)(GLint, GLint, GLsizei, GLsizei))GPA( "glViewport" );
|
qglViewport = dllViewport =(void (*)(GLint, GLint, GLsizei, GLsizei))GPA( "glViewport" );
|
||||||
|
|
||||||
// bk001129 - from cvs1.17 (mkv)
|
|
||||||
#if defined(__FX__)
|
|
||||||
qfxMesaCreateContext = GPA("fxMesaCreateContext");
|
|
||||||
qfxMesaCreateBestContext = GPA("fxMesaCreateBestContext");
|
|
||||||
qfxMesaDestroyContext = GPA("fxMesaDestroyContext");
|
|
||||||
qfxMesaMakeCurrent = GPA("fxMesaMakeCurrent");
|
|
||||||
qfxMesaGetCurrentContext = GPA("fxMesaGetCurrentContext");
|
|
||||||
qfxMesaSwapBuffers = GPA("fxMesaSwapBuffers");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(USE_SDL_VIDEO)
|
#if !defined(USE_SDL_VIDEO)
|
||||||
qglXChooseVisual = (XVisualInfo * (*)( Display *dpy, int screen, int *attribList ))GPA("glXChooseVisual");
|
qglXChooseVisual = (XVisualInfo * (*)( Display *dpy, int screen, int *attribList ))GPA("glXChooseVisual");
|
||||||
qglXCreateContext = (GLXContext (*)( Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct ))GPA("glXCreateContext");
|
qglXCreateContext = (GLXContext (*)( Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct ))GPA("glXCreateContext");
|
||||||
|
|
|
@ -30,9 +30,7 @@ typedef struct
|
||||||
{
|
{
|
||||||
void *OpenGLLib; // instance of OpenGL library
|
void *OpenGLLib; // instance of OpenGL library
|
||||||
|
|
||||||
int desktopWidth, desktopHeight, desktopBPP;
|
int desktopWidth, desktopHeight, desktopBPP;
|
||||||
|
|
||||||
FILE *log_fp;
|
|
||||||
} glwstate_t;
|
} glwstate_t;
|
||||||
|
|
||||||
extern glwstate_t glw_state;
|
extern glwstate_t glw_state;
|
||||||
|
|
|
@ -32,116 +32,33 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#include "../qcommon/q_shared.h"
|
#include "../qcommon/q_shared.h"
|
||||||
#include "../qcommon/qcommon.h"
|
#include "../qcommon/qcommon.h"
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
// Used to determine where to store user-specific files
|
// Used to determine where to store user-specific files
|
||||||
static char homePath[MAX_OSPATH];
|
static char homePath[MAX_OSPATH];
|
||||||
|
|
||||||
/*
|
|
||||||
================
|
|
||||||
Sys_Milliseconds
|
|
||||||
================
|
|
||||||
*/
|
|
||||||
/* base time in seconds, that's our origin
|
|
||||||
timeval:tv_sec is an int:
|
|
||||||
assuming this wraps every 0x7fffffff - ~68 years since the Epoch (1970) - we're safe till 2038
|
|
||||||
using unsigned long data type to work right with Sys_XTimeToSysTime */
|
|
||||||
unsigned long sys_timeBase = 0;
|
|
||||||
/* current time in ms, using sys_timeBase as origin
|
|
||||||
NOTE: sys_timeBase*1000 + curtime -> ms since the Epoch
|
|
||||||
0x7fffffff ms - ~24 days
|
|
||||||
although timeval:tv_usec is an int, I'm not sure wether it is actually used as an unsigned int
|
|
||||||
(which would affect the wrap period)
|
|
||||||
*/
|
|
||||||
int Sys_Milliseconds()
|
int Sys_Milliseconds()
|
||||||
{
|
{
|
||||||
static int curtime;
|
static int sys_timeBase = 0;
|
||||||
|
|
||||||
struct timeval tp;
|
struct timeval tv;
|
||||||
gettimeofday(&tp, NULL);
|
gettimeofday( &tv, NULL );
|
||||||
|
|
||||||
if (!sys_timeBase)
|
if (!sys_timeBase) {
|
||||||
{
|
sys_timeBase = tv.tv_sec;
|
||||||
sys_timeBase = tp.tv_sec;
|
return tv.tv_usec/1000;
|
||||||
return tp.tv_usec/1000;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
curtime = (tp.tv_sec - sys_timeBase)*1000 + tp.tv_usec/1000;
|
return ((tv.tv_sec - sys_timeBase)*1000 + tv.tv_usec/1000);
|
||||||
|
|
||||||
return curtime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (defined(__linux__) || defined(__FreeBSD__) || defined(__sun)) && !defined(DEDICATED)
|
|
||||||
/*
|
|
||||||
================
|
|
||||||
Sys_XTimeToSysTime
|
|
||||||
sub-frame timing of events returned by X
|
|
||||||
X uses the Time typedef - unsigned long
|
|
||||||
disable with in_subframe 0
|
|
||||||
|
|
||||||
sys_timeBase*1000 is the number of ms since the Epoch of our origin
|
void Sys_Mkdir( const char* path )
|
||||||
xtime is in ms and uses the Epoch as origin
|
|
||||||
Time data type is an unsigned long: 0xffffffff ms - ~49 days period
|
|
||||||
I didn't find much info in the XWindow documentation about the wrapping
|
|
||||||
we clamp sys_timeBase*1000 to unsigned long, that gives us the current origin for xtime
|
|
||||||
the computation will still work if xtime wraps (at ~49 days period since the Epoch) after we set sys_timeBase
|
|
||||||
|
|
||||||
================
|
|
||||||
*/
|
|
||||||
extern cvar_t *in_subframe;
|
|
||||||
int Sys_XTimeToSysTime (unsigned long xtime)
|
|
||||||
{
|
{
|
||||||
int ret, time, test;
|
mkdir( path, 0777 );
|
||||||
|
|
||||||
if (!in_subframe->value)
|
|
||||||
{
|
|
||||||
// if you don't want to do any event times corrections
|
|
||||||
return Sys_Milliseconds();
|
|
||||||
}
|
|
||||||
|
|
||||||
// test the wrap issue
|
|
||||||
#if 0
|
|
||||||
// reference values for test: sys_timeBase 0x3dc7b5e9 xtime 0x541ea451 (read these from a test run)
|
|
||||||
// xtime will wrap in 0xabe15bae ms >~ 0x2c0056 s (33 days from Nov 5 2002 -> 8 Dec)
|
|
||||||
// NOTE: date -d '1970-01-01 UTC 1039384002 seconds' +%c
|
|
||||||
// use sys_timeBase 0x3dc7b5e9+0x2c0056 = 0x3df3b63f
|
|
||||||
// after around 5s, xtime would have wrapped around
|
|
||||||
// we get 7132, the formula handles the wrap safely
|
|
||||||
unsigned long xtime_aux,base_aux;
|
|
||||||
int test;
|
|
||||||
// Com_Printf("sys_timeBase: %p\n", sys_timeBase);
|
|
||||||
// Com_Printf("xtime: %p\n", xtime);
|
|
||||||
xtime_aux = 500; // 500 ms after wrap
|
|
||||||
base_aux = 0x3df3b63f; // the base a few seconds before wrap
|
|
||||||
test = xtime_aux - (unsigned long)(base_aux*1000);
|
|
||||||
Com_Printf("xtime wrap test: %d\n", test);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// some X servers (like suse 8.1's) report weird event times
|
|
||||||
// if the game is loading, resolving DNS, etc. we are also getting old events
|
|
||||||
// so we only deal with subframe corrections that look 'normal'
|
|
||||||
ret = xtime - (unsigned long)(sys_timeBase*1000);
|
|
||||||
time = Sys_Milliseconds();
|
|
||||||
test = time - ret;
|
|
||||||
//printf("delta: %d\n", test);
|
|
||||||
if (test < 0 || test > 30) // in normal conditions I've never seen this go above
|
|
||||||
{
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
void Sys_Mkdir( const char *path )
|
|
||||||
{
|
|
||||||
mkdir (path, 0777);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================
|
|
||||||
|
|
||||||
#define MAX_FOUND_FILES 0x1000
|
#define MAX_FOUND_FILES 0x1000
|
||||||
|
|
||||||
// bk001129 - new in 1.26
|
// bk001129 - new in 1.26
|
||||||
|
@ -239,7 +156,7 @@ char **Sys_ListFiles( const char *directory, const char *extension, const char *
|
||||||
}
|
}
|
||||||
|
|
||||||
extLen = strlen( extension );
|
extLen = strlen( extension );
|
||||||
|
|
||||||
// search
|
// search
|
||||||
nfiles = 0;
|
nfiles = 0;
|
||||||
|
|
||||||
|
@ -258,7 +175,7 @@ char **Sys_ListFiles( const char *directory, const char *extension, const char *
|
||||||
|
|
||||||
if (*extension) {
|
if (*extension) {
|
||||||
if ( strlen( d->d_name ) < strlen( extension ) ||
|
if ( strlen( d->d_name ) < strlen( extension ) ||
|
||||||
Q_stricmp(
|
Q_stricmp(
|
||||||
d->d_name + strlen( d->d_name ) - strlen( extension ),
|
d->d_name + strlen( d->d_name ) - strlen( extension ),
|
||||||
extension ) ) {
|
extension ) ) {
|
||||||
continue; // didn't match
|
continue; // didn't match
|
||||||
|
@ -305,6 +222,7 @@ void Sys_FreeFileList( char **list ) {
|
||||||
Z_Free( list );
|
Z_Free( list );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char* Sys_Cwd()
|
const char* Sys_Cwd()
|
||||||
{
|
{
|
||||||
static char cwd[MAX_OSPATH];
|
static char cwd[MAX_OSPATH];
|
||||||
|
@ -315,10 +233,6 @@ const char* Sys_Cwd()
|
||||||
return cwd;
|
return cwd;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sys_SetDefaultHomePath(const char *path)
|
|
||||||
{
|
|
||||||
Q_strncpyz(homePath, path, sizeof(homePath));
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* Sys_DefaultHomePath()
|
const char* Sys_DefaultHomePath()
|
||||||
{
|
{
|
||||||
|
@ -334,7 +248,7 @@ const char* Sys_DefaultHomePath()
|
||||||
Q_strcat(homePath, sizeof(homePath), "/.q3a");
|
Q_strcat(homePath, sizeof(homePath), "/.q3a");
|
||||||
#endif
|
#endif
|
||||||
if (mkdir(homePath, 0777)) {
|
if (mkdir(homePath, 0777)) {
|
||||||
if (errno != EEXIST)
|
if (errno != EEXIST)
|
||||||
Sys_Error("Unable to create directory \"%s\", error is %s(%d)\n", homePath, strerror(errno), errno);
|
Sys_Error("Unable to create directory \"%s\", error is %s(%d)\n", homePath, strerror(errno), errno);
|
||||||
}
|
}
|
||||||
return homePath;
|
return homePath;
|
||||||
|
@ -343,12 +257,12 @@ const char* Sys_DefaultHomePath()
|
||||||
return ""; // assume current dir
|
return ""; // assume current dir
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================
|
|
||||||
|
|
||||||
void Sys_ShowConsole( int visLevel, qboolean quitOnClose )
|
void Sys_ShowConsole( int visLevel, qboolean quitOnClose )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char* Sys_GetCurrentUser()
|
const char* Sys_GetCurrentUser()
|
||||||
{
|
{
|
||||||
const struct passwd* p;
|
const struct passwd* p;
|
||||||
|
|
Loading…
Reference in New Issue