Subversion Repositories eduke32

Compare Revisions

Ignore whitespace Rev 7992 → Rev 7991

/source/mact/include/control.h
159,12 → 159,6
GAMECONTROLLER_AXIS_MAX
};
 
enum class LastSeenInput : unsigned char
{
Keyboard,
Joystick,
};
 
//***************************************************************************
//
// GLOBALS
180,9 → 174,7
extern uint64_t CONTROL_ButtonState;
extern uint64_t CONTROL_ButtonHeldState;
 
extern LastSeenInput CONTROL_LastSeenInput;
 
 
//***************************************************************************
//
// PROTOTYPES
/source/mact/src/control.cpp
29,8 → 29,6
uint64_t CONTROL_ButtonState = 0;
uint64_t CONTROL_ButtonHeldState = 0;
 
LastSeenInput CONTROL_LastSeenInput;
 
float CONTROL_MouseSensitivity = DEFAULTMOUSESENSITIVITY;
static int32_t CONTROL_NumMouseButtons = 0;
static int32_t CONTROL_NumMouseAxes = 0;
478,7 → 476,7
i = NORMALAXISSCALE;
}
 
static int DoGetDeviceButtons(
static void DoGetDeviceButtons(
int32_t buttons, int32_t tm,
int32_t NumButtons,
int32_t *DeviceButtonState,
489,7 → 487,6
)
{
int32_t i=NumButtons-1;
int retval = 0;
 
for (; i>=0; i--)
{
500,8 → 497,6
 
if (bs)
{
retval = 1;
 
if (ButtonClicked[i] == FALSE)
{
ButtonClicked[i] = TRUE;
531,8 → 526,6
 
ButtonClicked[i] = FALSE;
}
 
return retval;
}
 
static void CONTROL_GetDeviceButtons(void)
554,7 → 547,7
 
if (CONTROL_JoystickEnabled)
{
int retval = DoGetDeviceButtons(
DoGetDeviceButtons(
JOYSTICK_GetButtons(), t,
CONTROL_NumJoyButtons,
CONTROL_JoyButtonState,
563,12 → 556,10
CONTROL_JoyButtonClicked,
CONTROL_JoyButtonClickedCount
);
if (retval)
CONTROL_LastSeenInput = LastSeenInput::Joystick;
}
}
 
static int CONTROL_DigitizeAxis(int axis, controldevice device)
static void CONTROL_DigitizeAxis(int axis, controldevice device)
{
controlaxistype *set, *lastset;
 
584,7 → 575,7
lastset = CONTROL_LastJoyAxes;
break;
 
default: return 0;
default: return;
}
 
set[axis].digitalClearedN = lastset[axis].digitalClearedN;
598,8 → 589,6
set[axis].digital = 1;
else
set[axis].digitalClearedP = 0;
 
return 1;
}
else if (set[axis].analog < 0)
{
609,8 → 598,6
set[axis].digital = -1;
else
set[axis].digitalClearedN = 0;
 
return 1;
}
else
{
617,8 → 604,6
set[axis].digitalClearedN = 0;
set[axis].digitalClearedP = 0;
}
 
return 0;
}
 
static void CONTROL_ScaleAxis(int axis, controldevice device)
712,8 → 697,7
{
CONTROL_JoyAxes[i].analog = joystick.pAxis[i];
 
if (CONTROL_DigitizeAxis(i, controldevice_joystick))
CONTROL_LastSeenInput = LastSeenInput::Joystick;
CONTROL_DigitizeAxis(i, controldevice_joystick);
CONTROL_ScaleAxis(i, controldevice_joystick);
LIMITCONTROL(&CONTROL_JoyAxes[i].analog);
CONTROL_ApplyAxis(i, info, controldevice_joystick);
723,10 → 707,9
CONTROL_GetDeviceButtons();
}
 
static int CONTROL_HandleAxisFunction(int32_t *p1, controlaxistype *axes, controlaxismaptype *axismap, int numAxes)
static void CONTROL_HandleAxisFunction(int32_t *p1, controlaxistype *axes, controlaxismaptype *axismap, int numAxes)
{
int axis = numAxes - 1;
int retval = 0;
 
do
{
736,14 → 719,9
int const j = (axes[axis].digital < 0) ? axismap[axis].minmap : axismap[axis].maxmap;
 
if (j != AXISUNDEFINED)
{
p1[j] = 1;
retval = 1;
}
}
while (axis--);
 
return retval;
}
 
static void CONTROL_AxisFunctionState(int32_t *p1)
752,10 → 730,7
CONTROL_HandleAxisFunction(p1, CONTROL_MouseAxes, CONTROL_MouseAxesMap, CONTROL_NumMouseAxes);
 
if (CONTROL_NumJoyAxes)
{
if (CONTROL_HandleAxisFunction(p1, CONTROL_JoyAxes, CONTROL_JoyAxesMap, CONTROL_NumJoyAxes))
CONTROL_LastSeenInput = LastSeenInput::Joystick;
}
CONTROL_HandleAxisFunction(p1, CONTROL_JoyAxes, CONTROL_JoyAxesMap, CONTROL_NumJoyAxes);
}
 
static void CONTROL_ButtonFunctionState(int32_t *p1)
793,30 → 768,18
if (CONTROL_NumJoyButtons)
{
int i=CONTROL_NumJoyButtons-1, j;
int retval = 0;
 
do
{
j = CONTROL_JoyButtonMapping[i].doubleclicked;
if (j != KEYUNDEFINED)
{
auto const state = CONTROL_JoyButtonClickedState[i];
p1[j] |= state;
retval |= state;
}
p1[j] |= CONTROL_JoyButtonClickedState[i];
 
j = CONTROL_JoyButtonMapping[i].singleclicked;
if (j != KEYUNDEFINED)
{
auto const state = CONTROL_JoyButtonState[i];
p1[j] |= state;
retval |= state;
}
p1[j] |= CONTROL_JoyButtonState[i];
}
while (i--);
 
if (retval)
CONTROL_LastSeenInput = LastSeenInput::Joystick;
}
}
 
882,15 → 845,10
{
if (CONTROL_KeyBinds[i].cmdstr)
{
auto const keyPressed = KB_KeyPressed(i);
 
if (keyPressed && (CONTROL_KeyBinds[i].repeat || (CONTROL_KeyBinds[i].laststate == 0)))
{
CONTROL_LastSeenInput = LastSeenInput::Keyboard;
if (KB_KeyPressed(i) && (CONTROL_KeyBinds[i].repeat || (CONTROL_KeyBinds[i].laststate == 0)))
OSD_Dispatch(CONTROL_KeyBinds[i].cmdstr);
}
 
CONTROL_KeyBinds[i].laststate = keyPressed;
CONTROL_KeyBinds[i].laststate = KB_KeyPressed(i);
}
}
while (i--);