Class InputSystem
Represents an instance of the input system that listens for MonoGame input devices.
public class InputSystem : IInputSystem, IEnumerable<IInputDeviceListener>, IEnumerable, IInitializable, IUpdateableInput
- Inheritance
-
InputSystem
- Implements
- Inherited Members
- Extension Methods
Constructors
InputSystem(Game)
Initializes a new instance of the InputSystem class.
public InputSystem(Game game)
Parameters
gameGameAn instance of the game to access input API.
Properties
Clipboard
Gets the service for the platform clipboard implementation.
public IClipboard Clipboard { get; }
Property Value
Events
Gets the service that provides input events for the UI elements.
public IInputEventSystem Events { get; }
Property Value
Gamepad
Gets the listener for the gamepad events.
public IGamepadInput? Gamepad { get; }
Property Value
Remarks
Note that this UI framework doesn't define multiple gamepad support, so only main gamepad input will be received. You can implement it by yourself if it's necessary for your game. However, it will require multiple focus support. For that purposes, you'll have to make your own control focus system.
IsInitialized
Gets a value indicating whether the object has been initialized.
public bool IsInitialized { get; }
Property Value
Keyboard
Gets the listener for the keyboard events.
public IKeyboardInput? Keyboard { get; }
Property Value
Mouse
Gets the listener for the mouse events.
public IMouseInput Mouse { get; }
Property Value
Touch
Gets the service for the touch events.
public ITouchInput? Touch { get; }
Property Value
Methods
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<IInputDeviceListener> GetEnumerator()
Returns
- IEnumerator<IInputDeviceListener>
An enumerator that can be used to iterate through the collection.
GetInputDevice<T>()
Gets an input device listener for the specified type.
public T GetInputDevice<T>() where T : IInputDeviceListener
Returns
- T
An input device listener for the specified device type.
Type Parameters
TType of the device to get listener for.
Exceptions
- KeyNotFoundException
Occurs when the device for the specified type is not connected.
Initialize()
Initializes an instance of an object.
public void Initialize()
IsDeviceAvailable<T>()
Determines whether the specified input device listener is connected to the input system.
public bool IsDeviceAvailable<T>() where T : IInputDeviceListener
Returns
Type Parameters
TType of the input device listener.
TryGetInputDevice<T>(out T?)
Tries to get a listener for the specified input device.
public bool TryGetInputDevice<T>(out T? device) where T : IInputDeviceListener
Parameters
deviceTListener for the specified device.
Returns
Type Parameters
TType of the device to get a listener for.
Update(TimeSpan)
Performs the update for the component.
public void Update(TimeSpan elapsed)
Parameters
elapsedTimeSpan