mlooky basically just took the place of mousey, which did nothing before, but is a better name
166 lines
5.0 KiB
C
166 lines
5.0 KiB
C
// SONIC ROBO BLAST 2
|
|
//-----------------------------------------------------------------------------
|
|
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
|
// Copyright (C) 1999-2018 by Sonic Team Junior.
|
|
//
|
|
// This program is free software distributed under the
|
|
// terms of the GNU General Public License, version 2.
|
|
// See the 'LICENSE' file for more details.
|
|
//-----------------------------------------------------------------------------
|
|
/// \file g_input.h
|
|
/// \brief handle mouse/keyboard/joystick inputs,
|
|
/// maps inputs to game controls (forward, spin, jump...)
|
|
|
|
#ifndef __G_INPUT__
|
|
#define __G_INPUT__
|
|
|
|
#include "d_event.h"
|
|
#include "doomstat.h"
|
|
#include "keys.h"
|
|
#include "command.h"
|
|
|
|
// number of total 'button' inputs, include keyboard keys, plus virtual
|
|
// keys (mousebuttons and joybuttons becomes keys)
|
|
#define NUMKEYS 256
|
|
|
|
#define MOUSEBUTTONS 8
|
|
#define JOYBUTTONS 32 // 32 buttons
|
|
#define JOYHATS 4 // 4 hats
|
|
#define JOYAXISSET 4 // 4 Sets of 2 axises
|
|
|
|
//
|
|
// mouse and joystick buttons are handled as 'virtual' keys
|
|
//
|
|
typedef enum
|
|
{
|
|
KEY_MOUSE1 = NUMKEYS,
|
|
KEY_JOY1 = KEY_MOUSE1 + MOUSEBUTTONS,
|
|
KEY_HAT1 = KEY_JOY1 + JOYBUTTONS,
|
|
|
|
KEY_DBLMOUSE1 = KEY_HAT1 + JOYHATS*4, // double clicks
|
|
KEY_DBLJOY1 = KEY_DBLMOUSE1 + MOUSEBUTTONS,
|
|
KEY_DBLHAT1 = KEY_DBLJOY1 + JOYBUTTONS,
|
|
|
|
KEY_2MOUSE1 = KEY_DBLHAT1 + JOYHATS*4,
|
|
KEY_2JOY1 = KEY_2MOUSE1 + MOUSEBUTTONS,
|
|
KEY_2HAT1 = KEY_2JOY1 + JOYBUTTONS,
|
|
|
|
KEY_DBL2MOUSE1 = KEY_2HAT1 + JOYHATS*4,
|
|
KEY_DBL2JOY1 = KEY_DBL2MOUSE1 + MOUSEBUTTONS,
|
|
KEY_DBL2HAT1 = KEY_DBL2JOY1 + JOYBUTTONS,
|
|
|
|
KEY_3JOY1 = KEY_DBL2HAT1 + JOYHATS*4,
|
|
KEY_3HAT1 = KEY_3JOY1 + JOYBUTTONS,
|
|
|
|
KEY_DBL3JOY1 = KEY_3HAT1 + JOYHATS*4,
|
|
KEY_DBL3HAT1 = KEY_DBL3JOY1 + JOYBUTTONS,
|
|
|
|
KEY_4JOY1 = KEY_DBL3HAT1 + JOYHATS*4,
|
|
KEY_4HAT1 = KEY_4JOY1 + JOYBUTTONS,
|
|
|
|
KEY_DBL4JOY1 = KEY_4HAT1 + JOYHATS*4,
|
|
KEY_DBL4HAT1 = KEY_DBL4JOY1 + JOYBUTTONS,
|
|
|
|
KEY_MOUSEWHEELUP = KEY_DBL4HAT1 + JOYHATS*4,
|
|
KEY_MOUSEWHEELDOWN = KEY_MOUSEWHEELUP + 1,
|
|
KEY_2MOUSEWHEELUP = KEY_MOUSEWHEELDOWN + 1,
|
|
KEY_2MOUSEWHEELDOWN = KEY_2MOUSEWHEELUP + 1,
|
|
|
|
NUMINPUTS = KEY_2MOUSEWHEELDOWN + 1, // FIXME: all the mouse 2 stuff should be removed, but it screws up mappings somehow
|
|
} key_input_e;
|
|
|
|
typedef enum
|
|
{
|
|
gc_null = 0, // a key/button mapped to gc_null has no effect
|
|
gc_aimforward,
|
|
gc_aimbackward,
|
|
gc_turnleft,
|
|
gc_turnright,
|
|
gc_accelerate,
|
|
gc_drift,
|
|
gc_brake,
|
|
gc_fire,
|
|
gc_lookback,
|
|
gc_camreset,
|
|
gc_camtoggle,
|
|
gc_spectate,
|
|
gc_lookup,
|
|
gc_lookdown,
|
|
gc_centerview,
|
|
gc_talkkey,
|
|
gc_teamkey,
|
|
gc_scores,
|
|
gc_console,
|
|
gc_pause,
|
|
gc_systemmenu,
|
|
gc_screenshot,
|
|
gc_recordgif,
|
|
gc_viewpoint,
|
|
gc_custom1, // Lua scriptable
|
|
gc_custom2, // Lua scriptable
|
|
gc_custom3, // Lua scriptable
|
|
gc_director,
|
|
gc_freecam, // Toggle for freecam while ingame
|
|
gc_camfloat, // alternative button for raising cam
|
|
gc_camsink, // alternative button for sinking
|
|
gc_strafeleft,
|
|
gc_straferight,
|
|
num_gamecontrols
|
|
} gamecontrols_e;
|
|
|
|
// mouse values are used once
|
|
extern consvar_t cv_mousexsens, cv_mouseysens;
|
|
extern consvar_t cv_controlperkey;
|
|
extern consvar_t cv_turnsmooth[MAXSPLITSCREENPLAYERS];
|
|
extern consvar_t cv_rumble[MAXSPLITSCREENPLAYERS];
|
|
extern consvar_t cv_rumblestrength[MAXSPLITSCREENPLAYERS];
|
|
extern consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS];
|
|
|
|
extern INT32 mousex, mousey;
|
|
|
|
extern INT32 joyxmove[MAXSPLITSCREENPLAYERS][JOYAXISSET], joyymove[MAXSPLITSCREENPLAYERS][JOYAXISSET];
|
|
|
|
// current state of the keys: true if pushed
|
|
extern UINT8 gamekeydown[NUMINPUTS];
|
|
|
|
// two key codes (or virtual key) per game control
|
|
extern INT32 gamecontrol[MAXSPLITSCREENPLAYERS][num_gamecontrols][2];
|
|
|
|
#define PLAYER1INPUTDOWN(gc) (gamekeydown[gamecontrol[0][gc][0]] || gamekeydown[gamecontrol[0][gc][1]])
|
|
#define PLAYER2INPUTDOWN(gc) (gamekeydown[gamecontrol[1][gc][0]] || gamekeydown[gamecontrol[1][gc][1]])
|
|
#define PLAYER3INPUTDOWN(gc) (gamekeydown[gamecontrol[2][gc][0]] || gamekeydown[gamecontrol[2][gc][1]])
|
|
#define PLAYER4INPUTDOWN(gc) (gamekeydown[gamecontrol[3][gc][0]] || gamekeydown[gamecontrol[3][gc][1]])
|
|
|
|
UINT8 G_GetSkinColorForGamepad(INT32 playernum);
|
|
void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT8 color);
|
|
void G_DeviceLEDTick(void);
|
|
void G_ResetDeviceLED(void);
|
|
|
|
void G_ResetAllDeviceRumbles(void);
|
|
void G_PlayerDeviceRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength, UINT32 duration);
|
|
void G_DeviceRumbleTick(void);
|
|
|
|
// peace to my little coder fingers!
|
|
// check a gamecontrol being active or not
|
|
|
|
// remaps the input event to a game control.
|
|
void G_MapEventsToControls(event_t *ev);
|
|
void G_ResetControls(void);
|
|
|
|
// returns the name of a key
|
|
const char *G_KeynumToString(INT32 keynum);
|
|
INT32 G_KeyStringtoNum(const char *keystr);
|
|
|
|
// detach any keys associated to the given game control
|
|
void G_ClearControlKeys(INT32 (*setupcontrols)[2], INT32 control);
|
|
void G_ClearAllControlKeys(void);
|
|
void Command_Setcontrol_f(void);
|
|
void Command_Setcontrol2_f(void);
|
|
void Command_Setcontrol3_f(void);
|
|
void Command_Setcontrol4_f(void);
|
|
void G_Controldefault(UINT8 player);
|
|
void G_SaveKeySetting(FILE *f);
|
|
INT32 G_CheckDoubleUsage(INT32 keynum, boolean modify);
|
|
|
|
#endif
|