Quake: mouse capture fixed.

git-svn-id: svn://kolibrios.org@9878 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
turbocat 2022-10-10 21:05:53 +00:00
parent 669c8fa38a
commit bf08f5cf52
2 changed files with 30 additions and 17 deletions

View File

@ -11,7 +11,6 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
#include <kos32sys.h>
#if !defined(__WIN32__) && !defined(_KOLIBRI) #if !defined(__WIN32__) && !defined(_KOLIBRI)
#include <sys/ipc.h> #include <sys/ipc.h>
#include <sys/shm.h> #include <sys/shm.h>
@ -20,6 +19,11 @@
#include <sys/mman.h> #include <sys/mman.h>
#endif #endif
#ifdef _KOLIBRI
#include <sys/ksys.h>
#include <libgen.h>
#endif
#include "quakedef.h" #include "quakedef.h"
qboolean isDedicated; qboolean isDedicated;
@ -270,7 +274,7 @@ void Sys_mkdir (char *path)
#ifdef __WIN32__ #ifdef __WIN32__
mkdir (path); mkdir (path);
#else #else
//mkdir (path, 0777); mkdir (path, 0777);
#endif #endif
} }
@ -293,11 +297,11 @@ double Sys_FloatTime (void)
#if defined(_KOLIBRI) #if defined(_KOLIBRI)
static int starttime = 0; static int starttime = 0;
if ( ! starttime ) if (!starttime) {
__asm__ __volatile__("int $0x40" : "=a"(starttime) : "a"(26), "b"(9)); starttime = _ksys_get_tick_count();
}
int curtime; int curtime = _ksys_get_tick_count();
__asm__ __volatile__("int $0x40" : "=a"(curtime) : "a"(26), "b"(9));
return (curtime-starttime)*0.01; return (curtime-starttime)*0.01;
#elif defined(__WIN32__) #elif defined(__WIN32__)
@ -364,7 +368,7 @@ void Sys_LineRefresh(void)
void Sys_Sleep(void) void Sys_Sleep(void)
{ {
#ifdef _KOLIBRI #ifdef _KOLIBRI
delay(1); _ksys_delay(1);
#else #else
SDL_Delay(1); SDL_Delay(1);
#endif #endif
@ -384,12 +388,7 @@ void moncontrol(int x)
int main (int c, char **v) int main (int c, char **v)
{ {
#ifdef _KOLIBRI double time, oldtime, newtime;
#include "kolibri.h"
_ksys_setcwd(dirname(v[0]));
#endif
double time, oldtime, newtime;
quakeparms_t parms; quakeparms_t parms;
extern int vcrFile; extern int vcrFile;
extern qboolean recording; extern qboolean recording;
@ -400,6 +399,8 @@ int main (int c, char **v)
#ifndef _KOLIBRI #ifndef _KOLIBRI
// signal(SIGFPE, floating_point_exception_handler); // signal(SIGFPE, floating_point_exception_handler);
signal(SIGFPE, SIG_IGN); signal(SIGFPE, SIG_IGN);
#else
basedir = dirname(v[0]);
#endif #endif
parms.memsize = 8*1024*1024; parms.memsize = 8*1024*1024;
@ -429,7 +430,7 @@ int main (int c, char **v)
if (time < sys_ticrate.value && (vcrFile == -1 || recording) ) if (time < sys_ticrate.value && (vcrFile == -1 || recording) )
{ {
#ifdef _KOLIBRI #ifdef _KOLIBRI
delay(1); _ksys_delay(1);
#else #else
SDL_Delay (1); SDL_Delay (1);
#endif #endif

View File

@ -4,6 +4,11 @@
#include "quakedef.h" #include "quakedef.h"
#include "d_local.h" #include "d_local.h"
#ifdef _KOLIBRI
#include <sys/ksys.h>
#endif
viddef_t vid; // global video state viddef_t vid; // global video state
unsigned short d_8to16table[256]; unsigned short d_8to16table[256];
@ -78,10 +83,12 @@ void VID_Init (unsigned char *palette)
Sys_Error("VID: Bad window width/height\n"); Sys_Error("VID: Bad window width/height\n");
} }
// Set video width, height and flags
flags = (SDL_SWSURFACE|SDL_HWPALETTE); flags = (SDL_SWSURFACE|SDL_HWPALETTE);
#ifndef _KOLIBRI
// Set video width, height and flags
if ( COM_CheckParm ("-fullscreen") ) if ( COM_CheckParm ("-fullscreen") )
flags |= SDL_FULLSCREEN; flags |= SDL_FULLSCREEN;
#endif
// Initialize display // Initialize display
if (!(screen = SDL_SetVideoMode(vid.width, vid.height, 8, flags))) if (!(screen = SDL_SetVideoMode(vid.width, vid.height, 8, flags)))
@ -323,12 +330,15 @@ void IN_Init (void)
{ {
if ( COM_CheckParm ("-nomouse") ) if ( COM_CheckParm ("-nomouse") )
return; return;
SDL_WM_GrabInput(SDL_GRAB_ON);
mouse_x = mouse_y = 0.0; mouse_x = mouse_y = 0.0;
mouse_avail = 1; mouse_avail = 1;
} }
void IN_Shutdown (void) void IN_Shutdown (void)
{ {
SDL_WM_GrabInput(SDL_GRAB_OFF);
mouse_avail = 0; mouse_avail = 0;
} }
@ -338,7 +348,9 @@ void IN_Commands (void)
int mouse_buttonstate; int mouse_buttonstate;
if (!mouse_avail) return; if (!mouse_avail) return;
SDL_WM_GrabInput(SDL_GRAB_ON);
i = SDL_GetMouseState(NULL, NULL); i = SDL_GetMouseState(NULL, NULL);
/* Quake swaps the second and third buttons */ /* Quake swaps the second and third buttons */
mouse_buttonstate = (i & ~0x06) | ((i & 0x02)<<1) | ((i & 0x04)>>1); mouse_buttonstate = (i & ~0x06) | ((i & 0x02)<<1) | ((i & 0x04)>>1);
@ -356,7 +368,7 @@ void IN_Move (usercmd_t *cmd)
{ {
if (!mouse_avail) if (!mouse_avail)
return; return;
mouse_x *= sensitivity.value; mouse_x *= sensitivity.value;
mouse_y *= sensitivity.value; mouse_y *= sensitivity.value;