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:
arQon 2017-01-25 07:14:23 -08:00
parent 0f89ca6853
commit d8bf2665f5
7 changed files with 819 additions and 921 deletions

View file

@ -395,9 +395,9 @@ $(OBJDIR)/sv_snapshot.o: ../../code/server/sv_snapshot.cpp
$(OBJDIR)/sv_world.o: ../../code/server/sv_world.cpp
@echo $(notdir $<)
$(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 $<)
$(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
@echo $(notdir $<)
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"

View file

@ -393,7 +393,7 @@ local function ApplyExeProjectSettings(exeName, server)
"unix/linux_signals.cpp",
"unix/linux_qgl.c",
"unix/linux_snd.c",
"unix/linux_glimp.c"
"unix/linux_glimp.cpp"
}
AddHeaders("botlib")

View file

@ -59,9 +59,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <GL/gl.h>
#include <GL/glx.h>
#if defined(__FX__)
#include <GL/fxmesa.h>
#endif
#elif defined( __sun )
#include <GL/gl.h>
@ -480,16 +477,6 @@ extern BOOL ( WINAPI * qwglSwapIntervalEXT)( int interval );
#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
extern XVisualInfo * (*qglXChooseVisual)( Display *dpy, int screen, int *attribList );
extern GLXContext (*qglXCreateContext)( Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct );

File diff suppressed because it is too large Load diff

View file

@ -37,11 +37,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <float.h>
#include "unix_glw.h"
// bk001129 - from cvs1.17 (mkv)
#if defined(__FX__)
#include <GL/fxmesa.h>
#endif
#if defined(USE_SDL_VIDEO)
#include <SDL.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"
// 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
#if !defined(USE_SDL_VIDEO)
@ -1138,16 +1123,6 @@ void QGL_Shutdown( void )
qglVertexPointer = 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)
qglXGetProcAddress = NULL;
qglXChooseVisual = NULL;
@ -1564,16 +1539,6 @@ qboolean QGL_Init( const char *dllname )
qglVertexPointer = dllVertexPointer =(void (*)(GLint, GLenum, GLsizei, const GLvoid*))GPA( "glVertexPointer" );
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)
qglXChooseVisual = (XVisualInfo * (*)( Display *dpy, int screen, int *attribList ))GPA("glXChooseVisual");
qglXCreateContext = (GLXContext (*)( Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct ))GPA("glXCreateContext");

View file

@ -30,9 +30,7 @@ typedef struct
{
void *OpenGLLib; // instance of OpenGL library
int desktopWidth, desktopHeight, desktopBPP;
FILE *log_fp;
int desktopWidth, desktopHeight, desktopBPP;
} glwstate_t;
extern glwstate_t glw_state;

View file

@ -32,116 +32,33 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "../qcommon/q_shared.h"
#include "../qcommon/qcommon.h"
//=============================================================================
// Used to determine where to store user-specific files
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()
{
static int curtime;
static int sys_timeBase = 0;
struct timeval tp;
gettimeofday(&tp, NULL);
struct timeval tv;
gettimeofday( &tv, NULL );
if (!sys_timeBase)
{
sys_timeBase = tp.tv_sec;
return tp.tv_usec/1000;
if (!sys_timeBase) {
sys_timeBase = tv.tv_sec;
return tv.tv_usec/1000;
}
curtime = (tp.tv_sec - sys_timeBase)*1000 + tp.tv_usec/1000;
return curtime;
return ((tv.tv_sec - sys_timeBase)*1000 + tv.tv_usec/1000);
}
#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
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)
void Sys_Mkdir( const char* path )
{
int ret, time, test;
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);
mkdir( path, 0777 );
}
//============================================
#define MAX_FOUND_FILES 0x1000
// bk001129 - new in 1.26
@ -305,6 +222,7 @@ void Sys_FreeFileList( char **list ) {
Z_Free( list );
}
const char* Sys_Cwd()
{
static char cwd[MAX_OSPATH];
@ -315,10 +233,6 @@ const char* Sys_Cwd()
return cwd;
}
void Sys_SetDefaultHomePath(const char *path)
{
Q_strncpyz(homePath, path, sizeof(homePath));
}
const char* Sys_DefaultHomePath()
{
@ -343,12 +257,12 @@ const char* Sys_DefaultHomePath()
return ""; // assume current dir
}
//============================================
void Sys_ShowConsole( int visLevel, qboolean quitOnClose )
{
}
const char* Sys_GetCurrentUser()
{
const struct passwd* p;