ref: 2b6e6d2d238aee049b12464f6dfcfc235de63a93
parent: 2b97c9ff54dc4551cb235a3bb98e2b72989780e4
author: Simon Howard <[email protected]>
date: Sun Jan 3 11:16:43 EST 2016
video: Split out keyboard/mouse code to i_input.c. Although there is some close connection between the video code and the input (keyboard/mouse) code, they are separate enough that it makes sense to put them in separate files. This is also necessary to support handling more complicated input logic.
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -64,6 +64,7 @@
deh_str.c deh_str.h \
i_cdmus.c i_cdmus.h \
i_endoom.c i_endoom.h \
+i_input.c i_input.h \
i_joystick.c i_joystick.h \
i_swap.h \
i_sound.c i_sound.h \
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -54,6 +54,7 @@
#include "p_saveg.h"
#include "i_endoom.h"
+#include "i_input.h"
#include "i_joystick.h"
#include "i_system.h"
#include "i_timer.h"
@@ -429,6 +430,7 @@
I_SetWindowTitle(gamedescription);
I_GraphicsCheckCommandLine();
+ I_InputCheckCommandLine();
I_SetGrabMouseCallback(D_GrabMouseCallback);
I_InitGraphics();
V_EnableLoadingDisk(SCREENWIDTH - LOADING_DISK_W, SCREENHEIGHT - LOADING_DISK_H);
--- a/src/doom/g_game.c
+++ b/src/doom/g_game.c
@@ -37,6 +37,7 @@
#include "m_random.h"
#include "i_system.h"
#include "i_timer.h"
+#include "i_input.h"
#include "i_video.h"
#include "p_setup.h"
--- a/src/heretic/d_main.c
+++ b/src/heretic/d_main.c
@@ -32,6 +32,7 @@
#include "deh_main.h"
#include "d_iwad.h"
#include "i_endoom.h"
+#include "i_input.h"
#include "i_joystick.h"
#include "i_sound.h"
#include "i_system.h"
@@ -242,6 +243,7 @@
debugfile = fopen(filename, "w");
}
I_GraphicsCheckCommandLine();
+ I_InputCheckCommandLine();
I_SetGrabMouseCallback(D_GrabMouseCallback);
I_InitGraphics();
--- a/src/heretic/g_game.c
+++ b/src/heretic/g_game.c
@@ -22,6 +22,7 @@
#include "doomdef.h"
#include "doomkeys.h"
#include "deh_str.h"
+#include "i_input.h"
#include "i_timer.h"
#include "i_system.h"
#include "m_controls.h"
--- a/src/hexen/g_game.c
+++ b/src/hexen/g_game.c
@@ -20,6 +20,7 @@
#include "h2def.h"
#include "s_sound.h"
#include "doomkeys.h"
+#include "i_input.h"
#include "i_video.h"
#include "i_system.h"
#include "i_timer.h"
--- a/src/hexen/h2_main.c
+++ b/src/hexen/h2_main.c
@@ -31,6 +31,7 @@
#include "d_mode.h"
#include "m_misc.h"
#include "s_sound.h"
+#include "i_input.h"
#include "i_joystick.h"
#include "i_system.h"
#include "i_timer.h"
@@ -737,6 +738,7 @@
}
I_SetWindowTitle(gamedescription);
I_GraphicsCheckCommandLine();
+ I_InputCheckCommandLine();
I_SetGrabMouseCallback(D_GrabMouseCallback);
I_InitGraphics();
--- /dev/null
+++ b/src/i_input.c
@@ -1,0 +1,357 @@
+//
+// Copyright(C) 1993-1996 Id Software, Inc.
+// Copyright(C) 2005-2014 Simon Howard
+//
+// 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.
+//
+// DESCRIPTION:
+// SDL implementation of system-specific input interface.
+//
+
+
+#include "SDL.h"
+
+#include "doomkeys.h"
+#include "doomtype.h"
+#include "d_event.h"
+#include "i_input.h"
+#include "m_argv.h"
+#include "m_config.h"
+
+static const int scancode_translate_table[] = SCANCODE_TO_KEYS_ARRAY;
+
+// Lookup table for mapping ASCII characters to their equivalent when
+// shift is pressed on an American layout keyboard:
+
+static const char shiftxform[] =
+{
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
+ 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
+ 31, ' ', '!', '"', '#', '$', '%', '&',
+ '"', // shift-'
+ '(', ')', '*', '+',
+ '<', // shift-,
+ '_', // shift--
+ '>', // shift-.
+ '?', // shift-/
+ ')', // shift-0
+ '!', // shift-1
+ '@', // shift-2
+ '#', // shift-3
+ '$', // shift-4
+ '%', // shift-5
+ '^', // shift-6
+ '&', // shift-7
+ '*', // shift-8
+ '(', // shift-9
+ ':',
+ ':', // shift-;
+ '<',
+ '+', // shift-=
+ '>', '?', '@',
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
+ 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
+ '[', // shift-[
+ '!', // shift-backslash - OH MY GOD DOES WATCOM SUCK
+ ']', // shift-]
+ '"', '_',
+ '\'', // shift-`
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
+ 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
+ '{', '|', '}', '~', 127
+};
+
+// Bit mask of mouse button state.
+static unsigned int mouse_button_state = 0;
+
+// Disallow mouse and joystick movement to cause forward/backward
+// motion. Specified with the '-novert' command line parameter.
+// This is an int to allow saving to config file
+int novert = 0;
+
+// If true, keyboard mapping is ignored, like in Vanilla Doom.
+// The sensible thing to do is to disable this if you have a non-US
+// keyboard.
+
+int vanilla_keyboard_mapping = true;
+
+// Mouse acceleration
+//
+// This emulates some of the behavior of DOS mouse drivers by increasing
+// the speed when the mouse is moved fast.
+//
+// The mouse input values are input directly to the game, but when
+// the values exceed the value of mouse_threshold, they are multiplied
+// by mouse_acceleration to increase the speed.
+float mouse_acceleration = 2.0;
+int mouse_threshold = 10;
+
+//
+// Translates the SDL key
+//
+static int TranslateKey(SDL_Keysym *sym)
+{
+ int scancode = sym->scancode;
+
+ switch (scancode)
+ {
+ case SDL_SCANCODE_LCTRL:
+ case SDL_SCANCODE_RCTRL:
+ return KEY_RCTRL;
+
+ case SDL_SCANCODE_LSHIFT:
+ case SDL_SCANCODE_RSHIFT:
+ return KEY_RSHIFT;
+
+ case SDL_SCANCODE_LALT:
+ return KEY_LALT;
+
+ case SDL_SCANCODE_RALT:
+ return KEY_RALT;
+
+ default:
+ if (scancode >= 0 && scancode < arrlen(scancode_translate_table))
+ {
+ return scancode_translate_table[scancode];
+ }
+ else
+ {
+ return 0;
+ }
+ }
+}
+
+// Get the equivalent ASCII (Unicode?) character for a keypress.
+static int GetTypedChar(SDL_Event *event)
+{
+ // If we're strictly emulating Vanilla, we should always act like
+ // we're using a US layout keyboard (in ev_keydown, data1=data2).
+ // Otherwise we should use the native key mapping.
+ if (vanilla_keyboard_mapping)
+ {
+ int result = TranslateKey(&event->key.keysym);
+
+ // If shift is held down, apply the original uppercase
+ // translation table used under DOS.
+ if ((SDL_GetModState() & KMOD_SHIFT) != 0
+ && result >= 0 && result < arrlen(shiftxform))
+ {
+ result = shiftxform[result];
+ }
+
+ return result;
+ }
+ else
+ {
+ int unicode = event->key.keysym.sym;
+
+ if (unicode < 128)
+ {
+ return unicode;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+}
+
+void I_HandleKeyboardEvent(SDL_Event *sdlevent)
+{
+ event_t event;
+
+ switch (sdlevent->type)
+ {
+ case SDL_KEYDOWN:
+ // data1 has the key pressed, data2 has the character
+ // (shift-translated, etc)
+ event.type = ev_keydown;
+ event.data1 = TranslateKey(&sdlevent->key.keysym);
+ event.data2 = GetTypedChar(sdlevent);
+
+ if (event.data1 != 0)
+ {
+ D_PostEvent(&event);
+ }
+ break;
+
+ case SDL_KEYUP:
+ event.type = ev_keyup;
+ event.data1 = TranslateKey(&sdlevent->key.keysym);
+
+ // data2 is just initialized to zero for ev_keyup.
+ // For ev_keydown it's the shifted Unicode character
+ // that was typed, but if something wants to detect
+ // key releases it should do so based on data1
+ // (key ID), not the printable char.
+
+ event.data2 = 0;
+
+ if (event.data1 != 0)
+ {
+ D_PostEvent(&event);
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+static void UpdateMouseButtonState(unsigned int button, boolean on)
+{
+ event_t event;
+
+ if (button < SDL_BUTTON_LEFT || button > MAX_MOUSE_BUTTONS)
+ {
+ return;
+ }
+
+ // Note: button "0" is left, button "1" is right,
+ // button "2" is middle for Doom. This is different
+ // to how SDL sees things.
+
+ switch (button)
+ {
+ case SDL_BUTTON_LEFT:
+ button = 0;
+ break;
+
+ case SDL_BUTTON_RIGHT:
+ button = 1;
+ break;
+
+ case SDL_BUTTON_MIDDLE:
+ button = 2;
+ break;
+
+ default:
+ // SDL buttons are indexed from 1.
+ --button;
+ break;
+ }
+
+ // Turn bit representing this button on or off.
+
+ if (on)
+ {
+ mouse_button_state |= (1 << button);
+ }
+ else
+ {
+ mouse_button_state &= ~(1 << button);
+ }
+
+ // Post an event with the new button state.
+
+ event.type = ev_mouse;
+ event.data1 = mouse_button_state;
+ event.data2 = event.data3 = 0;
+ D_PostEvent(&event);
+}
+
+void I_HandleMouseEvent(SDL_Event *sdlevent)
+{
+ switch (sdlevent->type)
+ {
+ case SDL_MOUSEBUTTONDOWN:
+ UpdateMouseButtonState(sdlevent->button.button, true);
+ break;
+
+ case SDL_MOUSEBUTTONUP:
+ UpdateMouseButtonState(sdlevent->button.button, false);
+ break;
+
+ default:
+ break;
+ }
+}
+
+static int AccelerateMouse(int val)
+{
+ if (val < 0)
+ return -AccelerateMouse(-val);
+
+ if (val > mouse_threshold)
+ {
+ return (int)((val - mouse_threshold) * mouse_acceleration + mouse_threshold);
+ }
+ else
+ {
+ return val;
+ }
+}
+
+//
+// Read the change in mouse state to generate mouse motion events
+//
+// This is to combine all mouse movement for a tic into one mouse
+// motion event.
+void I_ReadMouse(void)
+{
+ int x, y;
+ event_t ev;
+
+ SDL_GetRelativeMouseState(&x, &y);
+
+ if (x != 0 || y != 0)
+ {
+ ev.type = ev_mouse;
+ ev.data1 = mouse_button_state;
+ ev.data2 = AccelerateMouse(x);
+
+ if (!novert)
+ {
+ ev.data3 = -AccelerateMouse(y);
+ }
+ else
+ {
+ ev.data3 = 0;
+ }
+
+ D_PostEvent(&ev);
+ }
+}
+
+void I_InputCheckCommandLine(void)
+{
+ //!
+ // @category video
+ //
+ // Disable vertical mouse movement.
+ //
+
+ if (M_CheckParm("-novert"))
+ {
+ novert = true;
+ }
+
+ //!
+ // @category video
+ //
+ // Enable vertical mouse movement.
+ //
+
+ if (M_CheckParm("-nonovert"))
+ {
+ novert = false;
+ }
+}
+
+// Bind all variables controlling input options.
+void I_BindInputVariables(void)
+{
+ M_BindFloatVariable("mouse_acceleration", &mouse_acceleration);
+ M_BindIntVariable("mouse_threshold", &mouse_threshold);
+ M_BindIntVariable("vanilla_keyboard_mapping", &vanilla_keyboard_mapping);
+ M_BindIntVariable("novert", &novert);
+}
--- /dev/null
+++ b/src/i_input.h
@@ -1,0 +1,34 @@
+//
+// Copyright(C) 1993-1996 Id Software, Inc.
+// Copyright(C) 2005-2014 Simon Howard
+//
+// 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.
+//
+// DESCRIPTION:
+// System-specific keyboard/mouse input.
+//
+
+
+#ifndef __I_INPUT__
+#define __I_INPUT__
+
+#include "doomtype.h"
+
+#define MAX_MOUSE_BUTTONS 8
+
+extern float mouse_acceleration;
+extern int mouse_threshold;
+
+void I_BindInputVariables(void);
+void I_ReadMouse(void);
+void I_InputCheckCommandLine(void);
+
+#endif
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -34,6 +34,7 @@
#include "deh_str.h"
#include "doomtype.h"
#include "doomkeys.h"
+#include "i_input.h"
#include "i_joystick.h"
#include "i_system.h"
#include "i_swap.h"
@@ -48,50 +49,6 @@
#include "w_wad.h"
#include "z_zone.h"
-static const int scancode_translate_table[] = SCANCODE_TO_KEYS_ARRAY;
-
-// Lookup table for mapping ASCII characters to their equivalent when
-// shift is pressed on an American layout keyboard:
-
-static const char shiftxform[] =
-{
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
- 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
- 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
- 31, ' ', '!', '"', '#', '$', '%', '&',
- '"', // shift-'
- '(', ')', '*', '+',
- '<', // shift-,
- '_', // shift--
- '>', // shift-.
- '?', // shift-/
- ')', // shift-0
- '!', // shift-1
- '@', // shift-2
- '#', // shift-3
- '$', // shift-4
- '%', // shift-5
- '^', // shift-6
- '&', // shift-7
- '*', // shift-8
- '(', // shift-9
- ':',
- ':', // shift-;
- '<',
- '+', // shift-=
- '>', '?', '@',
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
- 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
- '[', // shift-[
- '!', // shift-backslash - OH MY GOD DOES WATCOM SUCK
- ']', // shift-]
- '"', '_',
- '\'', // shift-`
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
- 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
- '{', '|', '}', '~', 127
-};
-
// SDL video driver name
char *video_driver = "";
@@ -143,16 +100,6 @@
static boolean nomouse = false;
int usemouse = 1;
-// Bit mask of mouse button state.
-
-static unsigned int mouse_button_state = 0;
-
-// Disallow mouse and joystick movement to cause forward/backward
-// motion. Specified with the '-novert' command line parameter.
-// This is an int to allow saving to config file
-
-int novert = 0;
-
// Save screenshots in PNG format.
int png_screenshots = 0;
@@ -231,28 +178,6 @@
static unsigned int resize_w, resize_h;
static unsigned int last_resize_time;
-// If true, keyboard mapping is ignored, like in Vanilla Doom.
-// The sensible thing to do is to disable this if you have a non-US
-// keyboard.
-
-int vanilla_keyboard_mapping = true;
-
-// Is the shift key currently down?
-
-static int shiftdown = 0;
-
-// Mouse acceleration
-//
-// This emulates some of the behavior of DOS mouse drivers by increasing
-// the speed when the mouse is moved fast.
-//
-// The mouse input values are input directly to the game, but when
-// the values exceed the value of mouse_threshold, they are multiplied
-// by mouse_acceleration to increase the speed.
-
-float mouse_acceleration = 2.0;
-int mouse_threshold = 10;
-
// Gamma correction level to use
int usegamma = 0;
@@ -325,42 +250,6 @@
}
}
-//
-// Translates the SDL key
-//
-
-static int TranslateKey(SDL_Keysym *sym)
-{
- int scancode = sym->scancode;
-
- switch (scancode)
- {
- case SDL_SCANCODE_LCTRL:
- case SDL_SCANCODE_RCTRL:
- return KEY_RCTRL;
-
- case SDL_SCANCODE_LSHIFT:
- case SDL_SCANCODE_RSHIFT:
- return KEY_RSHIFT;
-
- case SDL_SCANCODE_LALT:
- return KEY_LALT;
-
- case SDL_SCANCODE_RALT:
- return KEY_RALT;
-
- default:
- if (scancode >= 0 && scancode < arrlen(scancode_translate_table))
- {
- return scancode_translate_table[scancode];
- }
- else
- {
- return 0;
- }
- }
-}
-
void I_ShutdownGraphics(void)
{
if (initialized)
@@ -384,132 +273,6 @@
}
-static void UpdateMouseButtonState(unsigned int button, boolean on)
-{
- event_t event;
-
- if (button < SDL_BUTTON_LEFT || button > MAX_MOUSE_BUTTONS)
- {
- return;
- }
-
- // Note: button "0" is left, button "1" is right,
- // button "2" is middle for Doom. This is different
- // to how SDL sees things.
-
- switch (button)
- {
- case SDL_BUTTON_LEFT:
- button = 0;
- break;
-
- case SDL_BUTTON_RIGHT:
- button = 1;
- break;
-
- case SDL_BUTTON_MIDDLE:
- button = 2;
- break;
-
- default:
- // SDL buttons are indexed from 1.
- --button;
- break;
- }
-
- // Turn bit representing this button on or off.
-
- if (on)
- {
- mouse_button_state |= (1 << button);
- }
- else
- {
- mouse_button_state &= ~(1 << button);
- }
-
- // Post an event with the new button state.
-
- event.type = ev_mouse;
- event.data1 = mouse_button_state;
- event.data2 = event.data3 = 0;
- D_PostEvent(&event);
-}
-
-static int AccelerateMouse(int val)
-{
- if (val < 0)
- return -AccelerateMouse(-val);
-
- if (val > mouse_threshold)
- {
- return (int)((val - mouse_threshold) * mouse_acceleration + mouse_threshold);
- }
- else
- {
- return val;
- }
-}
-
-// Get the equivalent ASCII (Unicode?) character for a keypress.
-static int GetTypedChar(SDL_Event *event)
-{
- // If we're strictly emulating Vanilla, we should always act like
- // we're using a US layout keyboard (in ev_keydown, data1=data2).
- // Otherwise we should use the native key mapping.
- if (vanilla_keyboard_mapping)
- {
- int result = TranslateKey(&event->key.keysym);
-
- // If shift is held down, apply the original uppercase
- // translation table used under DOS.
- if ((SDL_GetModState() & KMOD_SHIFT) != 0
- && result >= 0 && result < arrlen(shiftxform))
- {
- result = shiftxform[result];
- }
-
- return result;
- }
- else
- {
- int unicode = event->key.keysym.sym;
-
- if (unicode < 128)
- {
- return unicode;
- }
- else
- {
- return 0;
- }
- }
-}
-
-static void UpdateShiftStatus(SDL_Event *event)
-{
- int change;
-
- if (event->type == SDL_KEYDOWN)
- {
- change = 1;
- }
- else if (event->type == SDL_KEYUP)
- {
- change = -1;
- }
- else
- {
- return;
- }
-
- if (event->key.keysym.sym == SDLK_LSHIFT
- || event->key.keysym.sym == SDLK_RSHIFT)
- {
- shiftdown += change;
- }
-}
-
static void HandleWindowEvent(SDL_WindowEvent *event)
{
switch (event->event)
@@ -565,98 +328,42 @@
void I_GetEvent(void)
{
+ extern void I_HandleKeyboardEvent(SDL_Event *sdlevent);
+ extern void I_HandleMouseEvent(SDL_Event *sdlevent);
SDL_Event sdlevent;
- event_t event;
- // possibly not needed
-
SDL_PumpEvents();
- // put event-grabbing stuff in here
-
while (SDL_PollEvent(&sdlevent))
{
- // ignore mouse events when the window is not focused
-
- if (!window_focused
- && (sdlevent.type == SDL_MOUSEMOTION
- || sdlevent.type == SDL_MOUSEBUTTONDOWN
- || sdlevent.type == SDL_MOUSEBUTTONUP))
- {
- continue;
- }
-
- if (screensaver_mode && sdlevent.type == SDL_QUIT)
- {
- I_Quit();
- }
-
- UpdateShiftStatus(&sdlevent);
-
- // process event
-
switch (sdlevent.type)
{
case SDL_KEYDOWN:
- // data1 has the key pressed, data2 has the character
- // (shift-translated, etc)
- event.type = ev_keydown;
- event.data1 = TranslateKey(&sdlevent.key.keysym);
- event.data2 = GetTypedChar(&sdlevent);
+ case SDL_KEYUP:
+ I_HandleKeyboardEvent(&sdlevent);
+ break;
- if (event.data1 != 0)
+ case SDL_MOUSEBUTTONDOWN:
+ case SDL_MOUSEBUTTONUP:
+ if (usemouse && !nomouse && window_focused)
{
- D_PostEvent(&event);
+ I_HandleMouseEvent(&sdlevent);
}
break;
- case SDL_KEYUP:
- event.type = ev_keyup;
- event.data1 = TranslateKey(&sdlevent.key.keysym);
-
- // data2 is just initialized to zero for ev_keyup.
- // For ev_keydown it's the shifted Unicode character
- // that was typed, but if something wants to detect
- // key releases it should do so based on data1
- // (key ID), not the printable char.
-
- event.data2 = 0;
-
- if (event.data1 != 0)
+ case SDL_QUIT:
+ if (screensaver_mode)
{
+ I_Quit();
+ }
+ else
+ {
+ event_t event;
+ event.type = ev_quit;
D_PostEvent(&event);
}
break;
- /*
- case SDL_MOUSEMOTION:
- event.type = ev_mouse;
- event.data1 = mouse_button_state;
- event.data2 = AccelerateMouse(sdlevent.motion.xrel);
- event.data3 = -AccelerateMouse(sdlevent.motion.yrel);
- D_PostEvent(&event);
- break;
- */
-
- case SDL_MOUSEBUTTONDOWN:
- if (usemouse && !nomouse)
- {
- UpdateMouseButtonState(sdlevent.button.button, true);
- }
- break;
-
- case SDL_MOUSEBUTTONUP:
- if (usemouse && !nomouse)
- {
- UpdateMouseButtonState(sdlevent.button.button, false);
- }
- break;
-
- case SDL_QUIT:
- event.type = ev_quit;
- D_PostEvent(&event);
- break;
-
case SDL_WINDOWEVENT:
if (sdlevent.window.windowID == SDL_GetWindowID(screen))
{
@@ -671,38 +378,6 @@
}
//
-// Read the change in mouse state to generate mouse motion events
-//
-// This is to combine all mouse movement for a tic into one mouse
-// motion event.
-
-static void I_ReadMouse(void)
-{
- int x, y;
- event_t ev;
-
- SDL_GetRelativeMouseState(&x, &y);
-
- if (x != 0 || y != 0)
- {
- ev.type = ev_mouse;
- ev.data1 = mouse_button_state;
- ev.data2 = AccelerateMouse(x);
-
- if (!novert)
- {
- ev.data3 = -AccelerateMouse(y);
- }
- else
- {
- ev.data3 = 0;
- }
-
- D_PostEvent(&ev);
- }
-}
-
-//
// I_StartTic
//
void I_StartTic (void)
@@ -1216,28 +891,6 @@
{
SetScaleFactor(3);
}
-
- //!
- // @category video
- //
- // Disable vertical mouse movement.
- //
-
- if (M_CheckParm("-novert"))
- {
- novert = true;
- }
-
- //!
- // @category video
- //
- // Enable vertical mouse movement.
- //
-
- if (M_CheckParm("-nonovert"))
- {
- novert = false;
- }
}
// Check if we have been invoked as a screensaver by xscreensaver.
@@ -1541,7 +1194,6 @@
// Bind all variables controlling video options into the configuration
// file system.
-
void I_BindVideoVariables(void)
{
M_BindIntVariable("use_mouse", &usemouse);
@@ -1552,13 +1204,9 @@
M_BindIntVariable("screen_width", &screen_width);
M_BindIntVariable("screen_height", &screen_height);
M_BindIntVariable("grabmouse", &grabmouse);
- M_BindFloatVariable("mouse_acceleration", &mouse_acceleration);
- M_BindIntVariable("mouse_threshold", &mouse_threshold);
M_BindStringVariable("video_driver", &video_driver);
M_BindStringVariable("window_position", &window_position);
M_BindIntVariable("usegamma", &usegamma);
- M_BindIntVariable("vanilla_keyboard_mapping", &vanilla_keyboard_mapping);
- M_BindIntVariable("novert", &novert);
M_BindIntVariable("png_screenshots", &png_screenshots);
// Disable fullscreen by default on OS X, as there is an SDL bug
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -35,8 +35,6 @@
#define SCREENHEIGHT_4_3 240
-#define MAX_MOUSE_BUTTONS 8
-
typedef boolean (*grabmouse_callback_t)(void);
// Called by D_DoomMain,
@@ -87,8 +85,6 @@
extern char *video_driver;
extern boolean screenvisible;
-extern float mouse_acceleration;
-extern int mouse_threshold;
extern int vanilla_keyboard_mapping;
extern boolean screensaver_mode;
extern int usegamma;
--- a/src/strife/d_main.c
+++ b/src/strife/d_main.c
@@ -56,6 +56,7 @@
#include "p_dialog.h" // haleyjd [STRIFE]
#include "i_endoom.h"
+#include "i_input.h"
#include "i_joystick.h"
#include "i_system.h"
#include "i_timer.h"
@@ -1674,6 +1675,7 @@
M_CreateSaveDirs(savegamedir);
I_GraphicsCheckCommandLine();
+ I_InputCheckCommandLine();
// haleyjd 20110206 [STRIFE] Startup the introduction sequence
D_InitIntroSequence();
--- a/src/strife/g_game.c
+++ b/src/strife/g_game.c
@@ -34,6 +34,7 @@
#include "m_misc.h"
#include "m_saves.h" // STRIFE
#include "m_random.h"
+#include "i_input.h"
#include "i_system.h"
#include "i_timer.h"
#include "i_video.h"
--- a/src/v_video.c
+++ b/src/v_video.c
@@ -28,6 +28,7 @@
#include "doomtype.h"
#include "deh_str.h"
+#include "i_input.h"
#include "i_swap.h"
#include "i_video.h"
#include "m_bbox.h"