Skip to content

Commit

Permalink
InputSystem|Client: Maintain id and name maps for PlayerImpulse lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Nov 7, 2014
1 parent 00bd5a3 commit 0f6cd49
Show file tree
Hide file tree
Showing 2 changed files with 189 additions and 221 deletions.
63 changes: 60 additions & 3 deletions doomsday/client/include/ui/p_control.h
Expand Up @@ -28,11 +28,68 @@
*/
struct PlayerImpulse
{
int id = 0;
impulsetype_t type = IT_NUMERIC;
bool isTriggerable = false; ///< Accepts triggered states in addition to active ones.
int id;
impulsetype_t type;
de::String name;
de::String bindContextName;

short booleanCounts[DDMAXPLAYERS];

#ifdef __CLIENT__
/**
* Double-"clicks" actually mean double activations that occur within the double-click
* threshold. This is to allow double-clicks also from the numeric impulses.
*/
struct DoubleClick
{
enum State
{
None,
Positive,
Negative
};

bool triggered = false; //< True if double-click has been detected.
uint previousClickTime = 0; //< Previous time an activation occurred.
State lastState = None; //< State at the previous time the check was made.
State previousClickState = None; /** Previous click state. When duplicated, triggers
the double click. */
} doubleClicks[DDMAXPLAYERS];
#endif

PlayerImpulse(int id, impulsetype_t type, de::String const &name, de::String bindContextName)
: id (id)
, type (type)
, name (name)
, bindContextName(bindContextName)
{
de::zap(booleanCounts);
}

/**
* Returns @c true if the impulse is triggerable.
*/
inline bool isTriggerable() const {
return (type == IT_NUMERIC_TRIGGERED || type == IT_BOOLEAN);
}

#ifdef __CLIENT__
/**
* Updates the double-click state of an impulse and marks it as double-clicked
* when the double-click condition is met.
*
* @param playerNum Player/console number.
* @param pos State of the impulse.
*/
void maintainDoubleClicks(int playerNum, float pos);

int takeDoubleClick(int playerNum);

/**
* Register the console commands and variables of this module.
*/
static void consoleRegister();
#endif
};

void P_ImpulseShutdown();
Expand Down

0 comments on commit 0f6cd49

Please sign in to comment.