Commit 9221df25 authored by Richard Gobeille's avatar Richard Gobeille
Browse files

mact: minor formatting/cleanup

parent cc7d7b21
......@@ -44,30 +44,20 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
extern "C" {
#endif
//****************************************************************************
//
// DEFINES
//
//****************************************************************************
#define AXISUNDEFINED 0x7f
#define BUTTONUNDEFINED 0x7f
#define KEYUNDEFINED 0x7f
#define THRESHOLD (0x200 * 32767 / 10000)
#define MINTHRESHOLD (0x80 * 32767 / 10000)
#define DIGITALAXISANALOGTHRESHOLD (0x200 * 32767 / 10000)
#define MINDIGITALAXISANALOGTHRESHOLD (0x80 * 32767 / 10000)
#define DEFAULTMOUSESENSITIVITY 4 // 0x7000+MINIMUMMOUSESENSITIVITY
#define INSTANT_ONOFF 0
#define TOGGLE_ONOFF 1
#define MAXCONTROLVALUE 0x1ffff
// Number of Mouse buttons
//#define MAXMOUSEBUTTONS 10
// this is higher than the -32767 to 32767 range of the axis
#define MAXSCALEDCONTROLVALUE 0x1ffff
// Number of JOY buttons
// KEEPINSYNC duke3d/src/gamedefs.h, build/src/sdlayer.cpp
......@@ -79,60 +69,13 @@ extern "C" {
#define MAXJOYAXES 9
#define MAXJOYDIGITAL (MAXJOYAXES*2)
// NORMAL axis scale
#define NORMALAXISSCALE 65536
#define DEFAULTAXISSCALE 65536
#define BUTTONSET(x, value) (CONTROL_ButtonState |= ((uint64_t)value << ((uint64_t)(x))))
#define BUTTONCLEAR(x) (CONTROL_ButtonState &= ~((uint64_t)1 << ((uint64_t)(x))))
#define BUTTONSET(x, value) (CONTROL_ButtonState |= ((uint64_t)value << ((uint64_t)(x))))
#define BUTTONCLEAR(x) (CONTROL_ButtonState &= ~((uint64_t)1 << ((uint64_t)(x))))
#define BUTTONHELDSET(x, value) (CONTROL_ButtonHeldState |= (uint64_t)(value << ((uint64_t)(x))))
#define LIMITCONTROL(x) (*x = clamp(*x, -MAXCONTROLVALUE, MAXCONTROLVALUE))
//****************************************************************************
//
// TYPEDEFS
//
//****************************************************************************
typedef enum
{
motion_Left = -1,
motion_Up = -1,
motion_None = 0,
motion_Right = 1,
motion_Down = 1
} motion;
typedef struct
{
int32_t joyMinX;
int32_t joyMinY;
int32_t threshMinX;
int32_t threshMinY;
int32_t threshMaxX;
int32_t threshMaxY;
int32_t joyMaxX;
int32_t joyMaxY;
int32_t joyMultXL;
int32_t joyMultYL;
int32_t joyMultXH;
int32_t joyMultYH;
} JoystickDef;
// int32_t ThrottleMin;
// int32_t RudderMin;
// int32_t ThrottlethreshMin;
// int32_t RudderthreshMin;
// int32_t ThrottlethreshMax;
// int32_t RudderthreshMax;
// int32_t ThrottleMax;
// int32_t RudderMax;
// int32_t ThrottleMultL;
// int32_t RudderMultL;
// int32_t ThrottleMultH;
// int32_t RudderMultH;
typedef struct
{
uint8_t active;
......@@ -170,13 +113,6 @@ typedef struct
int8_t digitalClearedN, digitalClearedP;
} controlaxistype;
//***************************************************************************
//
// PROTOTYPES
//
//***************************************************************************
#ifdef __cplusplus
}
#endif
......
......@@ -41,91 +41,79 @@ extern "C" {
#include "mouse.h"
//***************************************************************************
//
// DEFINES
//
//***************************************************************************
#define MAXGAMEBUTTONS 64
#define BUTTON(x) ((CONTROL_ButtonState >> ((uint64_t)(x))) & 1)
#define BUTTON(x) ((CONTROL_ButtonState >> ((uint64_t)(x))) & 1)
#define BUTTONHELD(x) ((CONTROL_ButtonHeldState >> ((uint64_t)(x))) & 1)
#define BUTTONJUSTPRESSED(x) (BUTTON(x) && !BUTTONHELD(x))
#define BUTTONRELEASED(x) (!BUTTON(x) && BUTTONHELD(x))
#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;
{
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;
{
analog_turning,
analog_strafing,
analog_lookingupanddown,
analog_elevation,
analog_rolling,
analog_moving,
analog_maxtype
} analogcontrol;
typedef enum
{
dir_North,
dir_NorthEast,
dir_East,
dir_SouthEast,
dir_South,
dir_SouthWest,
dir_West,
dir_NorthWest,
dir_None
} direction;
{
dir_North,
dir_NorthEast,
dir_East,
dir_SouthEast,
dir_South,
dir_SouthWest,
dir_West,
dir_NorthWest,
dir_None
} direction;
typedef struct
{
int32_t button0;
int32_t button1;
direction dir;
} UserInput;
{
int32_t button0;
int32_t button1;
direction dir;
} UserInput;
typedef struct
{
int32_t dx;
int32_t dy;
int32_t dz;
int32_t dyaw;
int32_t dpitch;
int32_t droll;
int32_t mousex;
int32_t mousey;
} ControlInfo;
{
int32_t dx;
int32_t dy;
int32_t dz;
int32_t dyaw;
int32_t dpitch;
int32_t droll;
int32_t mousex;
int32_t mousey;
} ControlInfo;
typedef enum
{
controltype_keyboard,
controltype_keyboardandmouse,
controltype_keyboardandjoystick
} controltype;
{
controltype_keyboard,
controltype_keyboardandmouse,
controltype_keyboardandjoystick
} controltype;
typedef enum
{
controldevice_keyboard,
controldevice_mouse,
controldevice_joystick
} controldevice;
{
controldevice_keyboard,
controldevice_mouse,
controldevice_joystick
} controldevice;
enum GameControllerButton : int
{
......@@ -171,12 +159,7 @@ enum class LastSeenInput : unsigned char
Joystick,
};
//***************************************************************************
//
// GLOBALS
//
//***************************************************************************
extern bool CONTROL_Started;
extern bool CONTROL_MousePresent;
extern bool CONTROL_JoyPresent;
......@@ -189,12 +172,7 @@ extern uint64_t CONTROL_ButtonHeldState;
extern LastSeenInput CONTROL_LastSeenInput;
//***************************************************************************
//
// PROTOTYPES
//
//***************************************************************************
void CONTROL_MapKey( int32_t which, kb_scancode key1, kb_scancode key2 );
void CONTROL_MapButton(int whichfunction, int whichbutton, int doubleclicked, controldevice device);
void CONTROL_DefineFlag( int which, int toggle );
......
......@@ -43,10 +43,6 @@ extern "C" {
#define WHEELUP_MOUSE 16
#define WHEELDOWN_MOUSE 32
#define LEFT_MOUSE_PRESSED(button) (((button)&LEFT_MOUSE) != 0)
#define RIGHT_MOUSE_PRESSED(button) (((button)&RIGHT_MOUSE) != 0)
#define MIDDLE_MOUSE_PRESSED(button) (((button)&MIDDLE_MOUSE) != 0)
extern int32_t CONTROL_MouseAxesScale[2];
extern float CONTROL_MouseSensitivity;
......@@ -56,10 +52,10 @@ static inline bool MOUSE_Startup(void)
return ((inputdevices & 2) == 2);
}
static inline void MOUSE_Shutdown(void) { mouseUninit(); }
static inline int32_t MOUSE_GetButtons(void) { return mouseReadButtons(); }
static inline void MOUSE_ClearButton(int32_t b) { g_mouseBits &= ~b; }
static inline void MOUSE_ClearAllButtons(void) { g_mouseBits = 0; }
static inline void MOUSE_Shutdown(void) { mouseUninit(); }
static inline int32_t MOUSE_GetButtons(void) { return mouseReadButtons(); }
static inline void MOUSE_ClearButton(int32_t b) { g_mouseBits &= ~b; }
static inline void MOUSE_ClearAllButtons(void) { g_mouseBits = 0; }
#ifdef __cplusplus
}
......
......@@ -32,199 +32,27 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
extern "C" {
#endif
/*
==============
=
= SCRIPT_Init
=
==============
*/
int32_t SCRIPT_Init( char const * name );
/*
==============
=
= SCRIPT_Free
=
==============
*/
void SCRIPT_Free( int32_t scripthandle );
/*
==============
=
= SCRIPT_Load
=
==============
*/
int32_t SCRIPT_Load ( char const * filename );
/*
==============
=
= SCRIPT_Save
=
==============
*/
void SCRIPT_Save (int32_t scripthandle, char const * filename);
/*
==============
=
= SCRIPT_NumberSections
=
==============
*/
int32_t SCRIPT_NumberSections( int32_t scripthandle );
/*
==============
=
= SCRIPT_Section
=
==============
*/
char const * SCRIPT_Section( int32_t scripthandle, int32_t which );
/*
==============
=
= SCRIPT_NumberEntries
=
==============
*/
int32_t SCRIPT_NumberEntries( int32_t scripthandle, char const * sectionname );
/*
==============
=
= SCRIPT_Entry
=
==============
*/
char const * SCRIPT_Entry( int32_t scripthandle, char const * sectionname, int32_t which );
/*
==============
=
= SCRIPT_GetRaw
=
==============
*/
char const * SCRIPT_GetRaw(int32_t scripthandle, char const * sectionname, char const * entryname);
/*
==============
=
= SCRIPT_GetString
=
==============
*/
int32_t SCRIPT_GetStringPtr(int32_t scripthandle, char const *sectionname, char const *entryname, char **dest);
int32_t SCRIPT_GetString(int32_t scripthandle, char const *sectionname, char const *entryname, char *dest);
/*
==============
=
= SCRIPT_GetDoubleString
=
==============
*/
int32_t SCRIPT_GetDoubleString(int32_t scripthandle, const char *sectionname, const char *entryname, char *dest1,
char *dest2);
/*
==============
=
= SCRIPT_GetNumber
=
==============
*/
int32_t SCRIPT_GetNumber(int32_t scripthandle, const char *sectionname, const char *entryname, int32_t *number);
/*
==============
=
= SCRIPT_GetBoolean
=
==============
*/
int32_t SCRIPT_GetBoolean(int32_t scripthandle, char const *sectionname, char const *entryname, int32_t *boole);
/*
==============
=
= SCRIPT_PutSection
=
==============
*/
void SCRIPT_PutSection( int32_t scripthandle, char const * sectionname );
/*
==============
=
= SCRIPT_PutRaw
=
==============
*/
void SCRIPT_PutRaw(int32_t scripthandle, char const * sectionname, char const * entryname, char const * raw);
/*
==============
=
= SCRIPT_PutString
=
==============
*/
void SCRIPT_PutString(int32_t scripthandle, char const *sectionname, char const *entryname, const char *string);
/*
==============
=
= SCRIPT_PutDoubleString
=
==============
*/
void SCRIPT_PutDoubleString(int32_t scripthandle, const char *sectionname, const char *entryname, const char *string1,
const char *string2);
/*
==============
=
= SCRIPT_PutNumber
=
==============
*/
void SCRIPT_PutNumber(int32_t scripthandle, const char *sectionname, const char *entryname, int32_t number,
int32_t hexadecimal, int32_t defaultvalue);
/*
==============
=
= SCRIPT_PutBoolean
=
==============
*/
void SCRIPT_PutBoolean(int32_t scripthandle, char *sectionname, char *entryname, int32_t boole);
/*
==============
=
= SCRIPT_PutDouble
=
==============
*/
void SCRIPT_PutDouble(int32_t scripthandle, char *sectionname, char *entryname, double number, int32_t defaultvalue);
int32_t SCRIPT_Init(char const *name);
void SCRIPT_Free(int32_t scripthandle);
int32_t SCRIPT_Load(char const *filename);
void SCRIPT_Save(int32_t scripthandle, char const *filename);
int32_t SCRIPT_NumberSections(int32_t scripthandle);
char const *SCRIPT_Section(int32_t scripthandle, int32_t which);
int32_t SCRIPT_NumberEntries(int32_t scripthandle, char const *sectionname);
char const *SCRIPT_Entry(int32_t scripthandle, char const *sectionname, int32_t which);
char const *SCRIPT_GetRaw(int32_t scripthandle, char const *sectionname, char const *entryname);
int32_t SCRIPT_GetStringPtr(int32_t scripthandle, char const *sectionname, char const *entryname, char **dest);
int32_t SCRIPT_GetString(int32_t scripthandle, char const *sectionname, char const *entryname, char *dest);
int32_t SCRIPT_GetDoubleString(int32_t scripthandle, const char *sectionname, const char *entryname, char *dest1, char *dest2);
int32_t SCRIPT_GetNumber(int32_t scripthandle, const char *sectionname, const char *entryname, int32_t *number);
int32_t SCRIPT_GetBoolean(int32_t scripthandle, char const *sectionname, char const *entryname, int32_t *boole);
void SCRIPT_PutSection(int32_t scripthandle, char const *sectionname);
void SCRIPT_PutRaw(int32_t scripthandle, char const *sectionname, char const *entryname, char const *raw);
void SCRIPT_PutString(int32_t scripthandle, char const *sectionname, char const *entryname, const char *string);
void SCRIPT_PutDoubleString(int32_t scripthandle, const char *sectionname, const char *entryname, const char *string1, const char *string2);
void SCRIPT_PutNumber(int32_t scripthandle, const char *sectionname, const char *entryname, int32_t number, int32_t hexadecimal, int32_t defaultvalue);
void SCRIPT_PutBoolean(int32_t scripthandle, char *sectionname, char *entryname, int32_t boole);
void SCRIPT_PutDouble(int32_t scripthandle, char *sectionname, char *entryname, double number, int32_t defaultvalue);
#ifdef __cplusplus
}
......
......@@ -35,173 +35,68 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
extern "C" {
#endif
#define SCRIPTSECTIONSTART ('[')
#define SCRIPTSECTIONEND (']')
#define SCRIPTENTRYSEPARATOR ('=')
#define SCRIPTCOMMENT (';')
#define SCRIPTEOL ('\n')
#define SCRIPTNULL ('\0')
#define SCRIPTSECTIONSTART ('[')
#define SCRIPTSECTIONEND (']')
#define SCRIPTENTRYSEPARATOR ('=')
#define SCRIPTCOMMENT (';')
#define SCRIPTEOL ('\n')
#define SCRIPTNULL ('\0')
#define SCRIPTSTRINGSEPARATOR ('"')
#define SCRIPTHEXFIRST ('0')
#define SCRIPTHEXSECOND ('x')
#define SCRIPTSPACE (' ')
#define SCRIPTDEFAULTVALUE ('~')
#define SCRIPTHEXFIRST ('0')
#define SCRIPTHEXSECOND ('x')
#define SCRIPTSPACE (' ')
#define SCRIPTDEFAULTVALUE ('~')
#define MAXSCRIPTFILES 20
#define SCRIPT(scripthandle,item) (scriptfiles[(scripthandle)]->item)
typedef enum
{
linetype_comment,
linetype_section,
linetype_entry
} linetype_t;
{
linetype_comment,
linetype_section,
linetype_entry
} linetype_t;
typedef struct scriptline
{
int32_t type;
void * ptr;
struct scriptline *nextline;
struct scriptline *prevline;
} ScriptLineType;
{
int32_t type;
void * ptr;
struct scriptline *nextline;
struct scriptline *prevline;
} ScriptLineType;
typedef struct scriptentry
{
char * name;
char * value;
struct scriptentry *nextentry;
struct scriptentry *preventry;
} ScriptEntryType;
{
char * name;
char * value;
struct scriptentry *nextentry;
struct scriptentry *preventry;
} ScriptEntryType;
typedef struct scriptsection
{
char * name;
ScriptEntryType *entries;
ScriptLineType *lastline;
struct scriptsection *nextsection;
struct scriptsection *prevsection;
} ScriptSectionType;
{
char * name;
ScriptEntryType * entries;
ScriptLineType * lastline;
struct scriptsection *nextsection;
struct scriptsection *prevsection;
} ScriptSectionType;
typedef struct
{
ScriptSectionType * apScript;
ScriptSectionType * lastsection;
ScriptLineType * scriptlines;
char scriptfilename[128];
} script_t;
/*
==============
=
= SCRIPT_New
=
==============
*/
int32_t SCRIPT_New( void );<