2014-03-15 16:59:03 +00:00
|
|
|
// SONIC ROBO BLAST 2
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
2016-05-18 00:42:11 +00:00
|
|
|
// Copyright (C) 1999-2016 by Sonic Team Junior.
|
2014-03-15 16:59:03 +00:00
|
|
|
//
|
|
|
|
// 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 "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_MOUSEWHEELUP = KEY_DBL2HAT1 + JOYHATS*4,
|
|
|
|
KEY_MOUSEWHEELDOWN = KEY_MOUSEWHEELUP + 1,
|
|
|
|
KEY_2MOUSEWHEELUP = KEY_MOUSEWHEELDOWN + 1,
|
|
|
|
KEY_2MOUSEWHEELDOWN = KEY_2MOUSEWHEELUP + 1,
|
|
|
|
|
|
|
|
NUMINPUTS = KEY_2MOUSEWHEELDOWN + 1,
|
|
|
|
} key_input_e;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
gc_null = 0, // a key/button mapped to gc_null has no effect
|
|
|
|
gc_forward,
|
|
|
|
gc_backward,
|
|
|
|
gc_strafeleft,
|
|
|
|
gc_straferight,
|
|
|
|
gc_turnleft,
|
|
|
|
gc_turnright,
|
|
|
|
gc_weaponnext,
|
|
|
|
gc_weaponprev,
|
|
|
|
gc_wepslot1,
|
|
|
|
gc_wepslot2,
|
|
|
|
gc_wepslot3,
|
|
|
|
gc_wepslot4,
|
|
|
|
gc_wepslot5,
|
|
|
|
gc_wepslot6,
|
|
|
|
gc_wepslot7,
|
|
|
|
gc_wepslot8,
|
|
|
|
gc_wepslot9,
|
|
|
|
gc_wepslot10,
|
|
|
|
gc_fire,
|
|
|
|
gc_firenormal,
|
|
|
|
gc_tossflag,
|
|
|
|
gc_use,
|
|
|
|
gc_camtoggle,
|
|
|
|
gc_camreset,
|
|
|
|
gc_lookup,
|
|
|
|
gc_lookdown,
|
|
|
|
gc_centerview,
|
|
|
|
gc_mouseaiming, // mouse aiming is momentary (toggleable in the menu)
|
|
|
|
gc_talkkey,
|
|
|
|
gc_teamkey,
|
|
|
|
gc_scores,
|
|
|
|
gc_jump,
|
|
|
|
gc_console,
|
|
|
|
gc_pause,
|
2014-03-23 16:00:29 +00:00
|
|
|
gc_custom1, // Lua scriptable
|
|
|
|
gc_custom2, // Lua scriptable
|
|
|
|
gc_custom3, // Lua scriptable
|
2014-03-15 16:59:03 +00:00
|
|
|
num_gamecontrols
|
|
|
|
} gamecontrols_e;
|
|
|
|
|
2018-11-10 22:06:35 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
gcs_custom,
|
|
|
|
gcs_fps,
|
2018-11-12 22:16:54 +00:00
|
|
|
gcs_platform,
|
2018-11-10 22:06:35 +00:00
|
|
|
num_gamecontrolschemes
|
|
|
|
} gamecontrolschemes_e;
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
// mouse values are used once
|
2015-01-01 19:50:31 +00:00
|
|
|
extern consvar_t cv_mousesens, cv_mouseysens;
|
2017-04-14 16:45:27 +00:00
|
|
|
extern consvar_t cv_mousesens2, cv_mouseysens2;
|
2017-04-14 17:02:35 +00:00
|
|
|
extern consvar_t cv_controlperkey;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
extern INT32 mousex, mousey;
|
|
|
|
extern INT32 mlooky; //mousey with mlookSensitivity
|
|
|
|
extern INT32 mouse2x, mouse2y, mlook2y;
|
|
|
|
|
|
|
|
extern INT32 joyxmove[JOYAXISSET], joyymove[JOYAXISSET], joy2xmove[JOYAXISSET], joy2ymove[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[num_gamecontrols][2];
|
|
|
|
extern INT32 gamecontrolbis[num_gamecontrols][2]; // secondary splitscreen player
|
2018-11-10 22:06:35 +00:00
|
|
|
extern INT32 gamecontroldefault[num_gamecontrolschemes][num_gamecontrols][2]; // default control storage, use 0 (gcs_custom) for memory retention
|
2014-03-15 16:59:03 +00:00
|
|
|
#define PLAYER1INPUTDOWN(gc) (gamekeydown[gamecontrol[gc][0]] || gamekeydown[gamecontrol[gc][1]])
|
|
|
|
#define PLAYER2INPUTDOWN(gc) (gamekeydown[gamecontrolbis[gc][0]] || gamekeydown[gamecontrolbis[gc][1]])
|
|
|
|
|
2018-11-11 14:35:15 +00:00
|
|
|
#define num_gclist_tutorial 13
|
|
|
|
#define num_gclist_tutorial_check 6
|
2018-11-11 13:44:08 +00:00
|
|
|
#define num_gclist_movement 4
|
2018-11-11 13:51:51 +00:00
|
|
|
#define num_gclist_camera 2
|
2018-11-11 13:44:08 +00:00
|
|
|
#define num_gclist_jump 1
|
|
|
|
#define num_gclist_use 1
|
|
|
|
|
|
|
|
extern const INT32 gclist_tutorial[num_gclist_tutorial];
|
2018-11-11 14:35:15 +00:00
|
|
|
extern const INT32 gclist_tutorial_check[num_gclist_tutorial_check];
|
2018-11-11 13:44:08 +00:00
|
|
|
extern const INT32 gclist_movement[num_gclist_movement];
|
|
|
|
extern const INT32 gclist_camera[num_gclist_camera];
|
|
|
|
extern const INT32 gclist_jump[num_gclist_jump];
|
|
|
|
extern const INT32 gclist_use[num_gclist_use];
|
2018-11-11 13:19:44 +00:00
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
// 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);
|
|
|
|
|
|
|
|
// 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 Command_Setcontrol_f(void);
|
|
|
|
void Command_Setcontrol2_f(void);
|
2018-11-10 22:06:35 +00:00
|
|
|
void G_DefineDefaultControls(void);
|
2018-11-11 13:44:08 +00:00
|
|
|
INT32 G_GetControlScheme(INT32 (*fromcontrols)[2], const INT32 *gclist, INT32 gclen);
|
|
|
|
void G_CopyControls(INT32 (*setupcontrols)[2], INT32 (*fromcontrols)[2], const INT32 *gclist, INT32 gclen);
|
2018-11-10 22:06:35 +00:00
|
|
|
void G_SaveKeySetting(FILE *f, INT32 (*fromcontrols)[2], INT32 (*fromcontrolsbis)[2]);
|
2014-03-15 16:59:03 +00:00
|
|
|
void G_CheckDoubleUsage(INT32 keynum);
|
|
|
|
|
|
|
|
#endif
|