aboutsummaryrefslogtreecommitdiffstats
path: root/src/jake2/sys
diff options
context:
space:
mode:
authorHolger Zickner <[email protected]>2004-07-08 15:58:48 +0000
committerHolger Zickner <[email protected]>2004-07-08 15:58:48 +0000
commit4f13ea26c4f47e54e66926f0700cf631e7bb3352 (patch)
treea9d434fc462417bb981b1565fd64cea5e7c82c15 /src/jake2/sys
parent76839da3568e20f51220584d1fc92841b216505a (diff)
import of Jake2 version hannover
Diffstat (limited to 'src/jake2/sys')
-rw-r--r--src/jake2/sys/IN.java112
-rw-r--r--src/jake2/sys/RW.java151
-rw-r--r--src/jake2/sys/Sys.java6
3 files changed, 103 insertions, 166 deletions
diff --git a/src/jake2/sys/IN.java b/src/jake2/sys/IN.java
index db88226..5935a0a 100644
--- a/src/jake2/sys/IN.java
+++ b/src/jake2/sys/IN.java
@@ -2,7 +2,7 @@
* IN.java
* Copyright (C) 2003
*
- * $Id: IN.java,v 1.1 2004-07-07 19:59:51 hzi Exp $
+ * $Id: IN.java,v 1.2 2004-07-08 15:58:46 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -26,8 +26,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package jake2.sys;
import jake2.Globals;
+import jake2.client.CL_input;
+import jake2.client.Key;
+import jake2.game.Cmd;
import jake2.game.usercmd_t;
import jake2.qcommon.Cvar;
+import jake2.qcommon.xcommand_t;
import java.awt.*;
@@ -44,9 +48,17 @@ public final class IN extends Globals {
static boolean mouse_avail = true;
static boolean mouse_active = false;
static boolean ignorefirst = false;
+
+ static int mouse_buttonstate;
+ static int mouse_oldbuttonstate;
+
+ static int old_mouse_x;
+ static int old_mouse_y;
+
+ static boolean mlooking;
public static void ActivateMouse() {
- // if (!mouse_avail || c == null) return;
+ if (!mouse_avail || c == null) return;
if (!mouse_active) {
KBD.mx = KBD.my = 0; // don't spazz
install_grabs();
@@ -55,7 +67,7 @@ public final class IN extends Globals {
}
public static void DeactivateMouse() {
- // if (!mouse_avail || c == null) return;
+ // if (!mouse_avail || c == null) return;
if (mouse_active) {
uninstall_grabs();
mouse_active = false;
@@ -78,10 +90,13 @@ public final class IN extends Globals {
}
public static void toggleMouse() {
- if (mouse_active)
+ if (mouse_active) {
+ mouse_avail=false;
DeactivateMouse();
- else
+ } else {
+ mouse_avail=true;
ActivateMouse();
+ }
}
public static void Init() {
@@ -90,25 +105,57 @@ public final class IN extends Globals {
}
public static void Shutdown() {
- RW.IN_Shutdown();
+ mouse_avail = false;
}
public static void Real_IN_Init() {
- RW.IN_Init();
+ // mouse variables
+ Globals.m_filter = Cvar.Get("m_filter", "0", 0);
+ Globals.in_mouse = Cvar.Get("in_mouse", "1", CVAR_ARCHIVE);
+ Globals.freelook = Cvar.Get("freelook", "0", 0 );
+ Globals.lookstrafe = Cvar.Get("lookstrafe", "0", 0);
+ Globals.sensitivity = Cvar.Get("sensitivity", "3", 0);
+ Globals.m_pitch = Cvar.Get("m_pitch", "0.022", 0);
+ Globals.m_yaw = Cvar.Get("m_yaw", "0.022", 0);
+ Globals.m_forward = Cvar.Get("m_forward", "1", 0);
+ Globals.m_side = Cvar.Get("m_side", "0.8", 0);
+
+ Cmd.AddCommand("+mlook", new xcommand_t() {
+ public void execute() {MLookDown();}});
+ Cmd.AddCommand("-mlook", new xcommand_t() {
+ public void execute() {MLookUp();}});
+
+ Cmd.AddCommand ("force_centerview", new xcommand_t() {
+ public void execute() {Force_CenterView_f();}});
+
+ Cmd.AddCommand ("togglemouse", new xcommand_t() {
+ public void execute() {toggleMouse();}});
+
+ IN.mouse_avail = true;
}
public static void Commands() {
- RW.IN_Commands();
+ int i;
+
+ if (!IN.mouse_avail)
+ return;
+
+ for (i=0 ; i<3 ; i++) {
+ if ( (IN.mouse_buttonstate & (1<<i)) != 0 && (IN.mouse_oldbuttonstate & (1<<i)) == 0 )
+ KBD.Do_Key_Event(Key.K_MOUSE1 + i, true);
+
+ if ( (IN.mouse_buttonstate & (1<<i)) == 0 && (IN.mouse_oldbuttonstate & (1<<i)) != 0 )
+ KBD.Do_Key_Event(Key.K_MOUSE1 + i, false);
+ }
+ IN.mouse_oldbuttonstate = IN.mouse_buttonstate;
}
public static void Frame() {
if ( !cl.refresh_prepped || cls.key_dest == key_console || cls.key_dest == key_menu)
- RW.IN_Activate(false);
+ DeactivateMouse();
else
- RW.IN_Activate(true);
-
- RW.IN_Frame();
+ ActivateMouse();
}
public static void CenterView() {
@@ -116,7 +163,46 @@ public final class IN extends Globals {
}
public static void Move(usercmd_t cmd) {
- RW.IN_Move(cmd);
+ if (!IN.mouse_avail)
+ return;
+
+ if (Globals.m_filter.value != 0.0f) {
+ KBD.mx = (KBD.mx + IN.old_mouse_x) / 2;
+ KBD.my = (KBD.my + IN.old_mouse_y) / 2;
+ }
+
+ IN.old_mouse_x = KBD.mx;
+ IN.old_mouse_y = KBD.my;
+
+ KBD.mx = (int)(KBD.mx * Globals.sensitivity.value);
+ KBD.my = (int)(KBD.my * Globals.sensitivity.value);
+
+ // add mouse X/Y movement to cmd
+ if ( (CL_input.in_strafe.state & 1) != 0 || ((Globals.lookstrafe.value != 0) && IN.mlooking )) {
+ cmd.sidemove += Globals.m_side.value * KBD.mx;
+ } else {
+ Globals.cl.viewangles[YAW] -= Globals.m_yaw.value * KBD.mx;
+ }
+
+ if ( (IN.mlooking || Globals.freelook.value != 0.0f) && (CL_input.in_strafe.state & 1) == 0) {
+ Globals.cl.viewangles[PITCH] += Globals.m_pitch.value * KBD.my;
+ } else {
+ cmd.forwardmove -= Globals.m_forward.value * KBD.my;
+ }
+ KBD.mx = KBD.my = 0;
+ }
+
+ static void MLookDown() {
+ mlooking = true;
+ }
+
+ static void MLookUp() {
+ mlooking = false;
+ CenterView();
+ }
+
+ static void Force_CenterView_f() {
+ Globals.cl.viewangles[PITCH] = 0;
}
}
diff --git a/src/jake2/sys/RW.java b/src/jake2/sys/RW.java
deleted file mode 100644
index 31ca7ca..0000000
--- a/src/jake2/sys/RW.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * RW.java
- * Copyright (C) 2004
- *
- * $Id: RW.java,v 1.1 2004-07-07 19:59:52 hzi Exp $
- */
-/*
-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.
-
-*/
-package jake2.sys;
-
-import jake2.Globals;
-import jake2.client.CL;
-import jake2.client.Key;
-import jake2.game.Cmd;
-import jake2.game.usercmd_t;
-import jake2.qcommon.Cvar;
-import jake2.qcommon.xcommand_t;
-
-/**
- * RW
- */
-public final class RW extends Globals {
- static int mouse_buttonstate;
- static int mouse_oldbuttonstate;
- static int old_mouse_x;
- static int old_mouse_y;
- static boolean mlooking;
-
- static void IN_MLookDown() {
- mlooking = true;
- }
-
- static void IN_MLookUp() {
- mlooking = false;
- IN.CenterView();
- }
-
- static void IN_Init(/*in_state_t in_state_p*/) {
- int mtype;
- int i;
-
-// in_state = in_state_p;
-
- // mouse variables
- m_filter = Cvar.Get("m_filter", "0", 0);
- in_mouse = Cvar.Get("in_mouse", "1", CVAR_ARCHIVE);
- freelook = Cvar.Get("freelook", "0", 0 );
- lookstrafe = Cvar.Get("lookstrafe", "0", 0);
- sensitivity = Cvar.Get("sensitivity", "3", 0);
- m_pitch = Cvar.Get("m_pitch", "0.022", 0);
- m_yaw = Cvar.Get("m_yaw", "0.022", 0);
- m_forward = Cvar.Get("m_forward", "1", 0);
- m_side = Cvar.Get("m_side", "0.8", 0);
-
- Cmd.AddCommand("+mlook", new xcommand_t() {
- public void execute() {IN_MLookDown();}});
- Cmd.AddCommand("-mlook", new xcommand_t() {
- public void execute() {IN_MLookUp();}});
-
- Cmd.AddCommand ("force_centerview", new xcommand_t() {
- public void execute() {Force_CenterView_f();}});
-
- IN.mouse_avail = true;
- }
-
- static void Force_CenterView_f() {
- cl.viewangles[PITCH] = 0;
- }
-
- public static void IN_Shutdown() {
- IN.mouse_avail = false;
- }
-
- static void IN_Frame() {
- }
-
- static void IN_Activate(boolean active) {
- if (active)
- IN.ActivateMouse();
- else
- IN.DeactivateMouse ();
- }
-
- static void IN_Commands() {
- int i;
-
- if (!IN.mouse_avail)
- return;
-
- for (i=0 ; i<3 ; i++) {
- if ( (mouse_buttonstate & (1<<i)) != 0 && (mouse_oldbuttonstate & (1<<i)) == 0 )
- KBD.Do_Key_Event(Key.K_MOUSE1 + i, true);
-
- if ( (mouse_buttonstate & (1<<i)) == 0 && (mouse_oldbuttonstate & (1<<i)) != 0 )
- KBD.Do_Key_Event(Key.K_MOUSE1 + i, false);
- }
- mouse_oldbuttonstate = mouse_buttonstate;
- }
-
- /*
- ===========
- IN_Move
- ===========
- */
- static void IN_Move(usercmd_t cmd) {
- if (!IN.mouse_avail)
- return;
-
- if (m_filter.value != 0.0f) {
- KBD.mx = (KBD.mx + old_mouse_x) / 2;
- KBD.my = (KBD.my + old_mouse_y) / 2;
- }
-
- old_mouse_x = KBD.mx;
- old_mouse_y = KBD.my;
-
- KBD.mx = (int)(KBD.mx * sensitivity.value);
- KBD.my = (int)(KBD.my * sensitivity.value);
-
- // add mouse X/Y movement to cmd
- if ( (CL.in_strafe.state & 1) != 0 || ((lookstrafe.value != 0) && mlooking )) {
- cmd.sidemove += m_side.value * KBD.mx;
- } else {
- cl.viewangles[YAW] -= m_yaw.value * KBD.mx;
- }
-
- if ( (mlooking || freelook.value != 0.0f) && (CL.in_strafe.state & 1) == 0) {
- cl.viewangles[PITCH] += m_pitch.value * KBD.my;
- } else {
- cmd.forwardmove -= m_forward.value * KBD.my;
- }
- KBD.mx = KBD.my = 0;
- }
-}
diff --git a/src/jake2/sys/Sys.java b/src/jake2/sys/Sys.java
index 6327531..5e8c0df 100644
--- a/src/jake2/sys/Sys.java
+++ b/src/jake2/sys/Sys.java
@@ -2,7 +2,7 @@
* Sys.java
* Copyright (C) 2003
*
- * $Id: Sys.java,v 1.1 2004-07-07 19:59:52 hzi Exp $
+ * $Id: Sys.java,v 1.2 2004-07-08 15:58:47 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -201,7 +201,9 @@ public final class Sys extends Defines {
secbase = System.currentTimeMillis();
return 0;
}
- return Globals.curtime = (int)(System.currentTimeMillis() - secbase);
+
+ return Globals.curtime = (int) (Globals.slomo.value * (System.currentTimeMillis() - secbase));
+
}
//============================================