Table of Contents

Struct InputKey

Namespace
PopcorningGuineaPig.Engine.Input
Assembly
PopcorningGuineaPig.Engine.dll

Represents a unique input key combining device type, key code, modifiers, and device index. Uses value semantics for efficient dictionary lookups and comparisons.

public struct InputKey : IEquatable<InputKey>
Implements
Inherited Members

Properties

Code

The specific key/button code for this input.

public readonly int Code { get; }

Property Value

int

DeviceIndex

Device index for multiple devices (primarily used for gamepads).

public readonly int DeviceIndex { get; }

Property Value

int

Modifiers

Input modifiers (Ctrl, Shift, Alt) applied to this input.

public readonly InputModifiers Modifiers { get; }

Property Value

InputModifiers

Type

The type of input device (Keyboard, Mouse, Gamepad).

public readonly InputType Type { get; }

Property Value

InputType

Methods

Equals(InputKey)

Checks equality between two InputKey instances.

public bool Equals(InputKey other)

Parameters

other InputKey

Returns

bool

Equals(object)

Checks equality with any object.

public override bool Equals(object obj)

Parameters

obj object

Returns

bool

Gamepad(GamepadButton, int)

Creates a gamepad input key.

public static InputKey Gamepad(GamepadButton button, int deviceIndex = 0)

Parameters

button GamepadButton

The gamepad button

deviceIndex int

The gamepad device index (0-3)

Returns

InputKey

A new InputKey representing the gamepad input

GamepadAxis(GamepadAxis, int)

Gamepad axis as a digital key (pressed while past threshold). Used for triggers.

public static InputKey GamepadAxis(GamepadAxis axis, int deviceIndex = 0)

Parameters

axis GamepadAxis
deviceIndex int

Returns

InputKey

GetHashCode()

Generates a hash code for efficient dictionary lookups.

public override int GetHashCode()

Returns

int

Keyboard(KeyboardKey, InputModifiers)

Creates a keyboard input key.

public static InputKey Keyboard(KeyboardKey key, InputModifiers modifiers = InputModifiers.None)

Parameters

key KeyboardKey

The keyboard key

modifiers InputModifiers

Optional modifiers (Ctrl, Shift, Alt)

Returns

InputKey

A new InputKey representing the keyboard input

Mouse(MouseButton, InputModifiers)

Creates a mouse input key.

public static InputKey Mouse(MouseButton button, InputModifiers modifiers = InputModifiers.None)

Parameters

button MouseButton

The mouse button

modifiers InputModifiers

Optional modifiers (Ctrl, Shift, Alt)

Returns

InputKey

A new InputKey representing the mouse input

ToString()

Returns a string representation of the input key.

public override string ToString()

Returns

string

Operators

operator ==(InputKey, InputKey)

Equality operator.

public static bool operator ==(InputKey left, InputKey right)

Parameters

left InputKey
right InputKey

Returns

bool

operator !=(InputKey, InputKey)

Inequality operator.

public static bool operator !=(InputKey left, InputKey right)

Parameters

left InputKey
right InputKey

Returns

bool