Table of Contents

Class Keybind.Combination

Namespace
MLEM.Input
Assembly
MLEM.dll

A key combination is a combination of a set of modifier keys and a key. All of the keys are GenericInput instances, so they can be keyboard-, mouse- or gamepad-based. Note that this class implements IComparable and IComparable<T>, which allows two combinations to be ordered based on how many Modifiers they have.

[DataContract]
public class Keybind.Combination : IComparable<Keybind.Combination>, IComparable
Inheritance
Keybind.Combination
Implements
Inherited Members

Constructors

Combination()

Creates a new empty combination using the default GenericInput with the None input type and no Modifiers or InverseModifiers.

public Combination()

Combination(GenericInput, params GenericInput[])

Creates a new combination with the given settings. To add a combination to a Keybind, use Add(GenericInput, params GenericInput[]) instead.

public Combination(GenericInput key, params GenericInput[] modifiers)

Parameters

key GenericInput

The key.

modifiers GenericInput[]

The modifiers.

Combination(GenericInput, GenericInput[], GenericInput[])

Creates a new combination with the given settings. To add a combination to a Keybind, use Add(GenericInput, params GenericInput[]) instead. Note that inputs are automatically removed from inverseModifiers if they are also present in modifiers, or if they are the main key.

public Combination(GenericInput key, GenericInput[] modifiers, GenericInput[] inverseModifiers)

Parameters

key GenericInput

The key.

modifiers GenericInput[]

The modifiers, or null to use no modifiers.

inverseModifiers GenericInput[]

The inverse modifiers, or null to use no modifiers.

Fields

InverseModifiers

The inputs that have to be up for this combination to be valid, which is queried in IsModifierDown(InputHandler, int) and WasModifierDown(InputHandler, int). If this collection is empty, there are no required inverse modifiers.

[DataMember]
public readonly GenericInput[] InverseModifiers

Field Value

GenericInput[]

Key

The input that has to be down (or pressed) for this combination to be considered down (or pressed). Note that Modifiers needs to be empty, or all of its values need to be down, as well.

[DataMember]
public readonly GenericInput Key

Field Value

GenericInput

Modifiers

The inputs that have to be held down for this combination to be valid, which is queried in IsModifierDown(InputHandler, int) and WasModifierDown(InputHandler, int). If this collection is empty, there are no required modifiers.

[DataMember]
public readonly GenericInput[] Modifiers

Field Value

GenericInput[]

Methods

CompareTo(Combination)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

public int CompareTo(Keybind.Combination other)

Parameters

other Keybind.Combination

An object to compare with this instance.

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

 <table><thead><tr><th class="term"> Value</th><th class="description"> Meaning</th></tr></thead><tbody><tr><td class="term"> Less than zero</td><td class="description"> This instance precedes <code class="paramref">other</code> in the sort order.</td></tr><tr><td class="term"> Zero</td><td class="description"> This instance occurs in the same position in the sort order as <code class="paramref">other</code>.</td></tr><tr><td class="term"> Greater than zero</td><td class="description"> This instance follows <code class="paramref">other</code> in the sort order.</td></tr></tbody></table>

CompareTo(object)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

public int CompareTo(object obj)

Parameters

obj object

An object to compare with this instance.

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

 <table><thead><tr><th class="term"> Value</th><th class="description"> Meaning</th></tr></thead><tbody><tr><td class="term"> Less than zero</td><td class="description"> This instance precedes <code class="paramref">obj</code> in the sort order.</td></tr><tr><td class="term"> Zero</td><td class="description"> This instance occurs in the same position in the sort order as <code class="paramref">obj</code>.</td></tr><tr><td class="term"> Greater than zero</td><td class="description"> This instance follows <code class="paramref">obj</code> in the sort order.</td></tr></tbody></table>

Exceptions

ArgumentException

obj is not the same type as this instance.

IsDown(InputHandler, int)

Returns whether this combination is currently down. See IsDown(GenericInput, int) for more information.

public bool IsDown(InputHandler handler, int gamepadIndex = -1)

Parameters

handler InputHandler

The input handler to query the keys with

gamepadIndex int

The index of the gamepad to query, or -1 to query all gamepads

Returns

bool

Whether this combination is down

IsModifierDown(InputHandler, int)

Returns whether all of this combination's Modifiers are currently down and InverseModifiers are currently up.

public bool IsModifierDown(InputHandler handler, int gamepadIndex = -1)

Parameters

handler InputHandler

The input handler to query the keys with

gamepadIndex int

The index of the gamepad to query, or -1 to query all gamepads

Returns

bool

Whether this combination's modifiers are down

IsPressed(InputHandler, int)

Returns whether this combination is currently pressed. See IsPressed(GenericInput, int) for more information.

public bool IsPressed(InputHandler handler, int gamepadIndex = -1)

Parameters

handler InputHandler

The input handler to query the keys with

gamepadIndex int

The index of the gamepad to query, or -1 to query all gamepads

Returns

bool

Whether this combination is pressed

IsPressedAvailable(InputHandler, int)

Returns whether this combination is currently pressed and has not been consumed yet using TryConsumePressed(InputHandler, int). See IsPressedAvailable(GenericInput, int) for more information.

public bool IsPressedAvailable(InputHandler handler, int gamepadIndex = -1)

Parameters

handler InputHandler

The input handler to query the keys with

gamepadIndex int

The index of the gamepad to query, or -1 to query all gamepads

Returns

bool

Whether this combination is pressed

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

ToString(string, Func<GenericInput, string>)

Converts this combination into an easily human-readable string. When using ToString(), this method is used with joiner set to " + ".

public string ToString(string joiner, Func<GenericInput, string> inputName = null)

Parameters

joiner string

The string to use to join this combination's Modifiers and Key together

inputName Func<GenericInput, string>

The function to use for determining the display name of a GenericInput. If this is null, the generic input's default ToString() method is used.

Returns

string

A human-readable string representing this combination

TryConsumePressed(InputHandler, int)

Returns whether this combination is currently pressed and the press has not been consumed yet. A combination is considered consumed if this method has already returned true previously since the last Update() call. See TryConsumePressed(GenericInput, int) for more information.

public bool TryConsumePressed(InputHandler handler, int gamepadIndex = -1)

Parameters

handler InputHandler

The input handler to query the keys with

gamepadIndex int

The index of the gamepad to query, or -1 to query all gamepads

Returns

bool

Whether this combination is pressed

WasDown(InputHandler, int)

Returns whether this combination was down in the last upate call. See WasDown(GenericInput, int) for more information.

public bool WasDown(InputHandler handler, int gamepadIndex = -1)

Parameters

handler InputHandler

The input handler to query the keys with

gamepadIndex int

The index of the gamepad to query, or -1 to query all gamepads

Returns

bool

Whether this combination was down

WasModifierDown(InputHandler, int)

Returns whether all of this combination's Modifiers were down and InverseModifiers were up in the last update call.

public bool WasModifierDown(InputHandler handler, int gamepadIndex = -1)

Parameters

handler InputHandler

The input handler to query the keys with

gamepadIndex int

The index of the gamepad to query, or -1 to query all gamepads

Returns

bool

Whether this combination's modifiers were down