2006-04-13 20:47:06 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 1996, 2003 - 3D Realms Entertainment
|
|
|
|
|
|
|
|
This file is part of Duke Nukem 3D version 1.5 - Atomic Edition
|
|
|
|
|
|
|
|
Duke Nukem 3D 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
|
2014-07-20 08:55:56 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
Original Source: 1996 - Todd Replogle
|
|
|
|
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
|
2012-03-12 04:47:04 +00:00
|
|
|
Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
|
2006-04-13 20:47:06 +00:00
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
//***************************************************************************
|
|
|
|
//
|
|
|
|
// Public header for CONTROL.C.
|
|
|
|
//
|
|
|
|
//***************************************************************************
|
|
|
|
|
2016-03-14 00:07:34 +00:00
|
|
|
#pragma once
|
|
|
|
|
2014-11-22 12:32:56 +00:00
|
|
|
#ifndef control_public_h_
|
|
|
|
#define control_public_h_
|
2014-11-26 04:39:23 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
2006-04-13 20:47:06 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
//***************************************************************************
|
|
|
|
//
|
|
|
|
// DEFINES
|
|
|
|
//
|
|
|
|
//***************************************************************************
|
|
|
|
|
|
|
|
#define MAXGAMEBUTTONS 64
|
|
|
|
|
2009-09-09 07:19:14 +00:00
|
|
|
#define BUTTON(x) ((CONTROL_ButtonState>> ((uint64_t)(x)) ) & 1)
|
|
|
|
#define BUTTONHELD(x) ((CONTROL_ButtonHeldState>> ((uint64_t)(x)) ) & 1)
|
2008-11-21 12:14:05 +00:00
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
#define BUTTONJUSTPRESSED(x) \
|
|
|
|
( BUTTON( x ) && !BUTTONHELD( x ) )
|
|
|
|
#define BUTTONRELEASED(x) \
|
|
|
|
( !BUTTON( x ) && BUTTONHELD( x ) )
|
|
|
|
#define BUTTONSTATECHANGED(x) \
|
|
|
|
( BUTTON( x ) != BUTTONHELD( x ) )
|
|
|
|
|
|
|
|
|
|
|
|
//***************************************************************************
|
|
|
|
//
|
|
|
|
// TYPEDEFS
|
|
|
|
//
|
|
|
|
//***************************************************************************
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
axis_up,
|
|
|
|
axis_down,
|
|
|
|
axis_left,
|
|
|
|
axis_right
|
|
|
|
} axisdirection;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
analog_turning=0,
|
|
|
|
analog_strafing=1,
|
|
|
|
analog_lookingupanddown=2,
|
|
|
|
analog_elevation=3,
|
|
|
|
analog_rolling=4,
|
|
|
|
analog_moving=5,
|
|
|
|
analog_maxtype
|
|
|
|
} analogcontrol;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
dir_North,
|
|
|
|
dir_NorthEast,
|
|
|
|
dir_East,
|
|
|
|
dir_SouthEast,
|
|
|
|
dir_South,
|
|
|
|
dir_SouthWest,
|
|
|
|
dir_West,
|
|
|
|
dir_NorthWest,
|
|
|
|
dir_None
|
|
|
|
} direction;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2009-04-26 05:57:42 +00:00
|
|
|
int32_t button0;
|
|
|
|
int32_t button1;
|
2006-04-13 20:47:06 +00:00
|
|
|
direction dir;
|
|
|
|
} UserInput;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2009-04-26 05:57:42 +00:00
|
|
|
int32_t dx;
|
|
|
|
int32_t dy;
|
|
|
|
int32_t dz;
|
|
|
|
int32_t dyaw;
|
|
|
|
int32_t dpitch;
|
|
|
|
int32_t droll;
|
2006-04-13 20:47:06 +00:00
|
|
|
} ControlInfo;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
controltype_keyboard,
|
|
|
|
controltype_keyboardandmouse,
|
|
|
|
controltype_keyboardandjoystick
|
|
|
|
} controltype;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
controldevice_keyboard,
|
|
|
|
controldevice_mouse,
|
|
|
|
controldevice_joystick
|
|
|
|
} controldevice;
|
|
|
|
|
|
|
|
|
|
|
|
//***************************************************************************
|
|
|
|
//
|
|
|
|
// GLOBALS
|
|
|
|
//
|
|
|
|
//***************************************************************************
|
|
|
|
|
2009-12-05 09:22:43 +00:00
|
|
|
extern int32_t CONTROL_Started;
|
2009-04-26 05:57:42 +00:00
|
|
|
extern int32_t CONTROL_MousePresent;
|
|
|
|
extern int32_t CONTROL_JoyPresent;
|
|
|
|
extern int32_t CONTROL_MouseEnabled;
|
|
|
|
extern int32_t CONTROL_JoystickEnabled;
|
2009-09-09 07:19:14 +00:00
|
|
|
extern uint64_t CONTROL_ButtonState;
|
|
|
|
extern uint64_t CONTROL_ButtonHeldState;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
//***************************************************************************
|
|
|
|
//
|
|
|
|
// PROTOTYPES
|
|
|
|
//
|
|
|
|
//***************************************************************************
|
|
|
|
|
2012-11-06 23:06:34 +00:00
|
|
|
//void CONTROL_MapKey( int32_t which, kb_scancode key1, kb_scancode key2 );
|
2017-07-07 22:50:37 +00:00
|
|
|
void CONTROL_MapButton(int whichfunction, int whichbutton, int doubleclicked, controldevice device);
|
|
|
|
void CONTROL_DefineFlag( int which, int toggle );
|
|
|
|
int CONTROL_FlagActive( int which );
|
2006-04-13 20:47:06 +00:00
|
|
|
void CONTROL_ClearAssignments( void );
|
2012-08-20 21:24:54 +00:00
|
|
|
// void CONTROL_GetFunctionInput( void );
|
2006-04-13 20:47:06 +00:00
|
|
|
void CONTROL_GetInput( ControlInfo *info );
|
2009-04-26 05:57:42 +00:00
|
|
|
void CONTROL_ClearButton( int32_t whichbutton );
|
2012-05-17 23:54:43 +00:00
|
|
|
extern float CONTROL_MouseSensitivity;
|
2012-11-17 16:48:11 +00:00
|
|
|
int32_t CONTROL_Startup(controltype which, int32_t ( *TimeFunction )( void ), int32_t ticspersecond);
|
2006-04-13 20:47:06 +00:00
|
|
|
void CONTROL_Shutdown( void );
|
|
|
|
|
2009-04-26 05:57:42 +00:00
|
|
|
void CONTROL_SetDoubleClickDelay(int32_t delay);
|
|
|
|
int32_t CONTROL_GetDoubleClickDelay(void);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2017-07-07 22:50:37 +00:00
|
|
|
void CONTROL_MapAnalogAxis(int whichaxis, int whichanalog, controldevice device);
|
2012-11-17 16:48:11 +00:00
|
|
|
void CONTROL_MapDigitalAxis(int32_t whichaxis, int32_t whichfunction, int32_t direction, controldevice device);
|
|
|
|
void CONTROL_SetAnalogAxisScale(int32_t whichaxis, int32_t axisscale, controldevice device);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2012-11-18 15:44:18 +00:00
|
|
|
//void CONTROL_PrintKeyMap(void);
|
|
|
|
//void CONTROL_PrintControlFlag(int32_t which);
|
|
|
|
//void CONTROL_PrintAxes( void );
|
|
|
|
|
|
|
|
|
|
|
|
////////// KEY/MOUSE BIND STUFF //////////
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2012-11-17 16:48:11 +00:00
|
|
|
#define MAXBOUNDKEYS MAXKEYBOARDSCAN
|
2012-11-18 15:44:18 +00:00
|
|
|
#define MAXMOUSEBUTTONS 10
|
2008-06-29 10:40:37 +00:00
|
|
|
|
|
|
|
typedef struct binding {
|
2012-11-18 15:44:18 +00:00
|
|
|
const char *key; // always set to const char *
|
|
|
|
char *cmdstr; // alloc'd
|
2008-06-29 10:40:37 +00:00
|
|
|
char repeat;
|
|
|
|
char laststate;
|
|
|
|
} keybind;
|
|
|
|
|
2012-11-18 15:44:18 +00:00
|
|
|
// Direct use DEPRECATED:
|
2017-07-05 05:42:54 +00:00
|
|
|
extern keybind CONTROL_KeyBinds[MAXBOUNDKEYS+MAXMOUSEBUTTONS];
|
2012-11-17 16:47:47 +00:00
|
|
|
extern int32_t CONTROL_BindsEnabled;
|
2008-06-29 10:40:37 +00:00
|
|
|
|
2012-11-18 15:44:18 +00:00
|
|
|
void CONTROL_ClearAllBinds(void);
|
2017-07-07 22:50:37 +00:00
|
|
|
void CONTROL_BindKey(int i, char const * const cmd, int repeat, char const * const keyname);
|
|
|
|
void CONTROL_BindMouse(int i, char const * const cmd, int repeat, char const * const keyname);
|
|
|
|
void CONTROL_FreeKeyBind(int i);
|
|
|
|
void CONTROL_FreeMouseBind(int i);
|
2012-11-18 15:44:18 +00:00
|
|
|
|
|
|
|
static inline int32_t CONTROL_KeyIsBound(int32_t i)
|
|
|
|
{
|
|
|
|
return (CONTROL_KeyBinds[i].cmdstr && CONTROL_KeyBinds[i].key);
|
|
|
|
}
|
|
|
|
|
2008-06-29 10:40:37 +00:00
|
|
|
void CONTROL_ProcessBinds(void);
|
|
|
|
|
2012-11-18 15:44:18 +00:00
|
|
|
////////////////////
|
|
|
|
|
2008-06-29 12:29:42 +00:00
|
|
|
#define CONTROL_NUM_FLAGS 64
|
2012-11-17 16:47:47 +00:00
|
|
|
extern int32_t CONTROL_OSDInput[CONTROL_NUM_FLAGS];
|
|
|
|
extern int32_t CONTROL_SmoothMouse;
|
2008-06-29 12:29:42 +00:00
|
|
|
|
2014-11-26 04:39:23 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
#endif
|
|
|
|
#endif
|