mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-17 01:11:45 +00:00
Sun-specific code is dead. Sun boxes should work fine with -x11 and -glx
as it is. Left snd_sun, which looks useful for something.
This commit is contained in:
parent
11257134c0
commit
515f449a39
4 changed files with 0 additions and 3374 deletions
|
@ -1,276 +0,0 @@
|
|||
/*
|
||||
in_sun.c
|
||||
|
||||
@description@
|
||||
|
||||
Copyright (C) 1996-1997 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:
|
||||
|
||||
Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/keysym.h>
|
||||
|
||||
|
||||
|
||||
//
|
||||
// typedefs and defines
|
||||
//
|
||||
|
||||
#define MOUSE_SCALE 4
|
||||
|
||||
//
|
||||
// externs
|
||||
//
|
||||
|
||||
extern Display *x_disp;
|
||||
extern int x_screen, x_screen_width, x_screen_height;
|
||||
extern int x_center_height, x_center_width;
|
||||
extern int x_std_event_mask;
|
||||
extern Window x_win, x_root_win;
|
||||
extern qboolean x_fullscreen;
|
||||
extern qboolean x_focus;
|
||||
extern int global_dx, global_dy;
|
||||
|
||||
//
|
||||
// globals
|
||||
//
|
||||
|
||||
cvar_t *m_filter;
|
||||
cvar_t *_windowed_mouse;
|
||||
int x_root, y_root;
|
||||
int x_root_old, y_root_old;
|
||||
|
||||
//
|
||||
// locals
|
||||
//
|
||||
|
||||
static int x_mouse_num, x_mouse_denom, x_mouse_thresh;
|
||||
|
||||
|
||||
static qboolean x_grabbed = false;
|
||||
|
||||
//
|
||||
// IN_CenterMouse - center the mouse in the screen
|
||||
//
|
||||
|
||||
void
|
||||
IN_CenterMouse (void)
|
||||
{
|
||||
CheckMouseState ();
|
||||
|
||||
if (!x_grabbed)
|
||||
return;
|
||||
|
||||
XSelectInput (x_disp, x_win, x_std_event_mask & ~PointerMotionMask);
|
||||
XWarpPointer (x_disp, None, x_root_win, 0, 0, 0, 0, x_center_width,
|
||||
x_center_height);
|
||||
XSelectInput (x_disp, x_win, x_std_event_mask);
|
||||
}
|
||||
|
||||
//
|
||||
// Check to see if we have grabbed the mouse or not and deal with it
|
||||
// appropriately
|
||||
//
|
||||
static void
|
||||
CheckMouseState (void)
|
||||
{
|
||||
if (x_focus && _windowed_mouse->int_val && !x_grabbed) {
|
||||
x_grabbed = true;
|
||||
printf ("fooling with mouse!\n");
|
||||
if (XGetPointerControl
|
||||
(x_disp, &x_mouse_num, &x_mouse_denom,
|
||||
&x_mouse_thresh)) printf ("XGetPointerControl failed!\n");
|
||||
// printf( "mouse %d/%d thresh %d\n", x_mouse_num, x_mouse_denom,
|
||||
// x_mouse_thresh );
|
||||
|
||||
// make input rawer
|
||||
XAutoRepeatOff (x_disp);
|
||||
XGrabKeyboard (x_disp, x_win, True, GrabModeAsync, GrabModeAsync,
|
||||
CurrentTime);
|
||||
XGrabPointer (x_disp, x_win, True,
|
||||
PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
|
||||
GrabModeAsync, GrabModeAsync, None, None, CurrentTime);
|
||||
|
||||
// if (XChangePointerControl( x_disp, True, True, 1, MOUSE_SCALE, x_mouse_thresh ))
|
||||
// printf( "XChangePointerControl failed!\n" );
|
||||
|
||||
IN_CenterMouse ();
|
||||
|
||||
// safe initial values
|
||||
x_root = x_root_old = vid.width >> 1;
|
||||
y_root = y_root_old = vid.height >> 1;
|
||||
} else if (x_grabbed && (!_windowed_mouse->int_val || !x_focus)) {
|
||||
printf ("fooling with mouse!\n");
|
||||
x_grabbed = false;
|
||||
// undo mouse warp
|
||||
if (XChangePointerControl
|
||||
(x_disp, True, True, x_mouse_num, x_mouse_denom, x_mouse_thresh))
|
||||
printf ("XChangePointerControl failed!\n");
|
||||
|
||||
XUngrabPointer (x_disp, CurrentTime);
|
||||
XUngrabKeyboard (x_disp, CurrentTime);
|
||||
XAutoRepeatOn (x_disp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// IN_Init - setup mouse input
|
||||
//
|
||||
|
||||
void
|
||||
IN_Init (void)
|
||||
{
|
||||
if (!x_disp)
|
||||
Sys_Error ("X display not open!\n");
|
||||
|
||||
_windowed_mouse = Cvar_Get ("_windowed_mouse", "0", CVAR_ARCHIVE, NULL,
|
||||
"None");
|
||||
|
||||
// we really really want to clean these up...
|
||||
atexit (IN_Shutdown);
|
||||
}
|
||||
|
||||
//
|
||||
// IN_Shutdown - clean up mouse settings (must be done from signal handler too!)
|
||||
//
|
||||
|
||||
void
|
||||
IN_Shutdown (void)
|
||||
{
|
||||
if (!x_disp)
|
||||
return;
|
||||
|
||||
// undo mouse warp
|
||||
if (XChangePointerControl
|
||||
(x_disp, True, True, x_mouse_num, x_mouse_denom,
|
||||
x_mouse_thresh)) printf ("XChangePointerControl failed!\n");
|
||||
|
||||
XUngrabPointer (x_disp, CurrentTime);
|
||||
XUngrabKeyboard (x_disp, CurrentTime);
|
||||
XAutoRepeatOn (x_disp);
|
||||
}
|
||||
|
||||
//
|
||||
// IN_Commands - process buttons
|
||||
//
|
||||
|
||||
void
|
||||
IN_Commands (void)
|
||||
{
|
||||
// done in X event handler
|
||||
}
|
||||
|
||||
//
|
||||
// IN_Move - process mouse moves
|
||||
//
|
||||
|
||||
void
|
||||
IN_Move (void)
|
||||
{
|
||||
static int last_dx, last_dy;
|
||||
static long long last_movement;
|
||||
long long now, gethrtime ();
|
||||
|
||||
int dx, dy;
|
||||
|
||||
CheckMouseState ();
|
||||
|
||||
|
||||
if (!x_grabbed)
|
||||
return; // no mouse movement
|
||||
|
||||
|
||||
now = gethrtime ();
|
||||
|
||||
dx = global_dx;
|
||||
global_dx = 0;
|
||||
|
||||
dy = global_dy;
|
||||
global_dy = 0;
|
||||
|
||||
// printf("GOT: dx %d dy %d\n", dx, dy);
|
||||
|
||||
dx *= sensitivity->value;
|
||||
dy *= sensitivity->value;
|
||||
|
||||
//
|
||||
// implement low pass filter to smooth motion a bit
|
||||
//
|
||||
if (now - last_movement > 100000000) {
|
||||
dx = .6 * dx;
|
||||
dy = .6 * dy;
|
||||
}
|
||||
last_movement = now;
|
||||
|
||||
dx = .6 * dx + .4 * last_dx;
|
||||
dy = .6 * dy + .4 * last_dy;
|
||||
|
||||
|
||||
last_dx = dx;
|
||||
last_dy = dy;
|
||||
|
||||
if (!dx && !dy) {
|
||||
if (in_mlook.state & 1)
|
||||
V_StopPitchDrift ();
|
||||
return;
|
||||
}
|
||||
// add mouse X/Y movement to cmd
|
||||
if ((in_strafe.state & 1) || (lookstrafe->int_val && (in_mlook.state & 1)))
|
||||
viewdelta.position[0] += dx;
|
||||
else
|
||||
viewdelta.angles[YAW] -= dx;
|
||||
|
||||
if ((in_mlook.state & 1) && !(in_strafe.state & 1)) {
|
||||
viewdelta.angles[PITCH] += dy;
|
||||
} else {
|
||||
if (in_strafe.state & 1)
|
||||
viewdelta.position[1] -= dy;
|
||||
else
|
||||
viewdelta.position[2] -= dy;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
IN_HandlePause (qboolean pause)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
IN_LL_ClearStates (void)
|
||||
{
|
||||
}
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,375 +0,0 @@
|
|||
/*
|
||||
sys_sun.c
|
||||
|
||||
@description@
|
||||
|
||||
Copyright (C) 1996-1997 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:
|
||||
|
||||
Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include "errno.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/param.h>
|
||||
#include <fcntl.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <stdio.h>
|
||||
|
||||
qboolean isDedicated;
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
||||
FILE IO
|
||||
|
||||
===============================================================================
|
||||
*/
|
||||
|
||||
#define MAX_HANDLES 10
|
||||
|
||||
typedef struct {
|
||||
VFile *hFile;
|
||||
char *pMap;
|
||||
int nLen;
|
||||
int nPos;
|
||||
} MEMFILE;
|
||||
|
||||
MEMFILE sys_handles[MAX_HANDLES];
|
||||
|
||||
int
|
||||
findhandle (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 1; i < MAX_HANDLES; i++)
|
||||
if (!sys_handles[i].hFile)
|
||||
return i;
|
||||
Sys_Error ("out of handles");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
filelength
|
||||
================
|
||||
*/
|
||||
int
|
||||
filelength (VFile *f)
|
||||
{
|
||||
int pos;
|
||||
int end;
|
||||
|
||||
pos = ftell (f);
|
||||
fseek (f, 0, SEEK_END);
|
||||
end = ftell (f);
|
||||
fseek (f, pos, SEEK_SET);
|
||||
|
||||
return end;
|
||||
}
|
||||
|
||||
int
|
||||
Sys_FileOpenRead (char *path, int *hndl)
|
||||
{
|
||||
VFile *f;
|
||||
int i;
|
||||
|
||||
i = findhandle ();
|
||||
|
||||
f = Qopen (path, "rb");
|
||||
if (!f) {
|
||||
*hndl = -1;
|
||||
return -1;
|
||||
}
|
||||
sys_handles[i].hFile = f;
|
||||
sys_handles[i].nLen = filelength (f);
|
||||
sys_handles[i].nPos = 0;
|
||||
sys_handles[i].pMap =
|
||||
mmap (0, sys_handles[i].nLen, PROT_READ, MAP_SHARED,
|
||||
fileno (sys_handles[i].hFile), 0);
|
||||
if (!sys_handles[i].pMap || (sys_handles[i].pMap == (char *) -1)) {
|
||||
printf ("mmap %s failed!", path);
|
||||
sys_handles[i].pMap = NULL;
|
||||
}
|
||||
|
||||
*hndl = i;
|
||||
|
||||
return (sys_handles[i].nLen);
|
||||
}
|
||||
|
||||
int
|
||||
Sys_FileOpenWrite (char *path)
|
||||
{
|
||||
VFile *f;
|
||||
int i;
|
||||
|
||||
i = findhandle ();
|
||||
|
||||
f = Qopen (path, "wb");
|
||||
if (!f)
|
||||
Sys_Error ("Error opening %s: %s", path, strerror (errno));
|
||||
sys_handles[i].hFile = f;
|
||||
sys_handles[i].nLen = 0;
|
||||
sys_handles[i].nPos = 0;
|
||||
sys_handles[i].pMap = NULL;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
void
|
||||
Sys_FileClose (int handle)
|
||||
{
|
||||
if (sys_handles[handle].pMap)
|
||||
if (munmap (sys_handles[handle].pMap, sys_handles[handle].nLen) != 0)
|
||||
printf ("failed to unmap handle %d\n", handle);
|
||||
|
||||
Qclose (sys_handles[handle].hFile);
|
||||
sys_handles[handle].hFile = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
Sys_FileSeek (int handle, int position)
|
||||
{
|
||||
if (sys_handles[handle].pMap) {
|
||||
sys_handles[handle].nPos = position;
|
||||
} else
|
||||
fseek (sys_handles[handle].hFile, position, SEEK_SET);
|
||||
}
|
||||
|
||||
int
|
||||
Sys_FileRead (int handle, void *dest, int count)
|
||||
{
|
||||
if (sys_handles[handle].pMap) {
|
||||
int nPos = sys_handles[handle].nPos;
|
||||
|
||||
if (count < 0)
|
||||
count = 0;
|
||||
if (nPos + count > sys_handles[handle].nLen)
|
||||
count = sys_handles[handle].nLen - nPos;
|
||||
memcpy (dest, &sys_handles[handle].pMap[nPos], count);
|
||||
sys_handles[handle].nPos = nPos + count;
|
||||
return (count);
|
||||
} else
|
||||
return fread (dest, 1, count, sys_handles[handle].hFile);
|
||||
}
|
||||
|
||||
int
|
||||
Sys_FileWrite (int handle, void *data, int count)
|
||||
{
|
||||
if (sys_handles[handle].pMap)
|
||||
Sys_Error ("Attempted to write to read-only file %d!\n", handle);
|
||||
return fwrite (data, 1, count, sys_handles[handle].hFile);
|
||||
}
|
||||
|
||||
int
|
||||
Sys_FileTime (char *path)
|
||||
{
|
||||
VFile *f;
|
||||
|
||||
f = Qopen (path, "rb");
|
||||
if (f) {
|
||||
Qclose (f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
Sys_mkdir (char *path)
|
||||
{
|
||||
mkdir (path, 0777);
|
||||
}
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
||||
SYSTEM IO
|
||||
|
||||
===============================================================================
|
||||
*/
|
||||
|
||||
void
|
||||
Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length)
|
||||
{
|
||||
|
||||
int r;
|
||||
unsigned long addr;
|
||||
int psize = getpagesize ();
|
||||
|
||||
addr = (startaddr & ~(psize - 1)) - psize;
|
||||
|
||||
// fprintf(stderr, "writable code %lx(%lx)-%lx, length=%lx\n", startaddr,
|
||||
// addr, startaddr+length, length);
|
||||
|
||||
r = mprotect ((char *) addr, length + startaddr - addr + psize, 7);
|
||||
|
||||
if (r < 0)
|
||||
Sys_Error ("Protection change failed\n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Sys_Error (char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
|
||||
printf ("Sys_Error: ");
|
||||
va_start (argptr, error);
|
||||
vprintf (error, argptr);
|
||||
va_end (argptr);
|
||||
printf ("\n");
|
||||
Host_Shutdown ();
|
||||
exit (1);
|
||||
}
|
||||
|
||||
void
|
||||
Sys_Printf (char *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
|
||||
va_start (argptr, fmt);
|
||||
vprintf (fmt, argptr);
|
||||
va_end (argptr);
|
||||
}
|
||||
|
||||
void
|
||||
Sys_Quit (void)
|
||||
{
|
||||
Host_Shutdown ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
double
|
||||
Sys_DoubleTime (void)
|
||||
{
|
||||
struct timeval tp;
|
||||
struct timezone tzp;
|
||||
static int secbase;
|
||||
|
||||
gettimeofday (&tp, &tzp);
|
||||
|
||||
if (!secbase) {
|
||||
secbase = tp.tv_sec;
|
||||
return tp.tv_usec / 1000000.0;
|
||||
}
|
||||
|
||||
return (tp.tv_sec - secbase) + tp.tv_usec / 1000000.0;
|
||||
}
|
||||
|
||||
char *
|
||||
Sys_ConsoleInput (void)
|
||||
{
|
||||
static char text[256];
|
||||
int len;
|
||||
fd_set readfds;
|
||||
int ready;
|
||||
struct timeval timeout;
|
||||
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 0;
|
||||
FD_ZERO (&readfds);
|
||||
FD_SET (0, &readfds);
|
||||
ready = select (1, &readfds, 0, 0, &timeout);
|
||||
|
||||
if (ready > 0) {
|
||||
len = read (0, text, sizeof (text));
|
||||
if (len >= 1) {
|
||||
text[len - 1] = 0; // rip off the /n and terminate
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
Sys_Sleep (void)
|
||||
{
|
||||
}
|
||||
|
||||
#ifndef USE_INTEL_ASM
|
||||
void
|
||||
Sys_HighFPPrecision (void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Sys_LowFPPrecision (void)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void
|
||||
Sys_Init (void)
|
||||
{
|
||||
#ifdef USE_INTEL_ASM
|
||||
Sys_SetFPCW ();
|
||||
#endif
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
static quakeparms_t parms;
|
||||
float time, oldtime, newtime;
|
||||
|
||||
parms.memsize = 16 * 1024 * 1024;
|
||||
parms.membase = malloc (parms.memsize);
|
||||
parms.basedir = ".";
|
||||
parms.cachedir = NULL;
|
||||
|
||||
COM_InitArgv (argc, argv);
|
||||
|
||||
parms.argc = com_argc;
|
||||
parms.argv = com_argv;
|
||||
|
||||
printf ("Host_Init\n");
|
||||
Host_Init (&parms);
|
||||
|
||||
Sys_Init ();
|
||||
|
||||
// unroll the simulation loop to give the video side a chance to see
|
||||
// _vid_default_mode
|
||||
Host_Frame (0.1);
|
||||
VID_SetDefaultMode ();
|
||||
|
||||
oldtime = Sys_DoubleTime ();
|
||||
while (1) {
|
||||
newtime = Sys_DoubleTime ();
|
||||
Host_Frame (newtime - oldtime);
|
||||
oldtime = newtime;
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue