API.Service.Input - JuDelCo/Core GitHub Wiki

Namespaces: Ju.Services & Ju.Input

IInputService

This service provides a high level (players, actions) and a low level (direct access to raw data) input API.

IEnumerable<IInputPlayer> Players;
IMouseController Mouse;
IKeyboardController Keyboard;
IEnumerable<IGamepadController> Gamepads;
IEnumerable<IGamepadController> CustomControllers;

IInputPlayer AddPlayer(string playerId);
void RemovePlayer(IInputPlayer player);

void AddCustomController(IGamepadController controller);
void RemoveCustomController(IGamepadController controller);

bool IsAnyPressed();

IInputPlayer

string Id;
IEnumerable<IInputAction> Actions;
IEnumerable<IController> Controllers;

IInputAction AddAction(string actionId);
IInputAction GetAction(string actionId);
void RemoveAction(IInputAction action);

void BindController(IController controller);
void UnbindController(IController controller);

IInputAction

string Id;
IInputPlayer Player;
bool Enabled;

IEnumerable<MouseButton> MouseButtonBindings;
IEnumerable<KeyboardKey> KeyboardKeyBindings;
IEnumerable<GamepadButton> GamepadButtonBindings;
IEnumerable<GamepadAxis> GamepadAxisBindings;

void ResetBindings();

IInputAction AddBinding(MouseButton button);
IInputAction AddBinding(MouseButton positiveButton, MouseButton negativeButton);
IInputAction AddBinding(KeyboardKey key);
IInputAction AddBinding(KeyboardKey positiveKey, KeyboardKey negativeKey);
IInputAction AddBinding(GamepadButton button);
IInputAction AddBinding(GamepadButton positiveButton, GamepadButton negativeButton);
void RemoveBinding(MouseButton button);
void RemoveBinding(KeyboardKey key);
void RemoveBinding(GamepadButton button);
bool IsPressed();
bool IsHeld();
float HeldDuration();
bool IsReleased();

IInputAction AddBinding(GamepadAxis axis);
void RemoveBinding(GamepadAxis axis);
float GetAxisValue();
void GetAxisRawValue(out float axisX, out float axisY);

IAIInputAction

string Id;

void ResetState();
void CheckState(float deltaTime);

void Set(bool value);
void Set(float value);
void Set(float valueX, float valueY);

IController

string Id;

IKeyboardController : IController

bool IsAnyKeyPressed();
bool IsKeyPressed(KeyboardKey key);
bool IsKeyHeld(KeyboardKey key);
bool IsKeyReleased(KeyboardKey key);

KeyboardKey FirstPressedKey();
string GetInputString();

IMouseController : IController

MouseLockMode LockMode;
bool Visible;

bool IsAnyButtonPressed();
bool IsButtonPressed(MouseButton button);
bool IsButtonHeld(MouseButton button);
bool IsButtonReleased(MouseButton button);

MouseButton FirstPressedButton();
void GetPosition(out int mouseX, out int mouseY);
void GetPositionDelta(out float mouseX, out float mouseY);
float GetWheelDelta();

IGamepadController : IController

bool Enabled;
float Deadzone;

bool IsAnyButtonPressed();
bool IsButtonPressed(GamepadButton button);
bool IsButtonPressed(GamepadButtonRaw button);
bool IsButtonHeld(GamepadButton button);
bool IsButtonHeld(GamepadButtonRaw button);
bool IsButtonReleased(GamepadButton button);
bool IsButtonReleased(GamepadButtonRaw button);

GamepadButton FirstPressedButton();
bool IsAnyAxisPressed();
float GetAxis(GamepadAxis axis);
float GetAxis(GamepadAxisRaw axis);
void GetAxisRaw(GamepadAxis axis, out float axisX, out float axisY);
GamepadAxis FirstPressedAxis();

CustomController : IGamepadController

Abstract virtual class, you can implement it to create custom virtual controllers.

Events

InputGamepadConnectedEvent(IGamepadController controller);
InputGamepadDisconnectedEvent(IGamepadController controller);

InputActionPressedEvent(IInputAction action);
InputActionHeldEvent(IInputAction action);
InputActionReleased(IInputAction action);