using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Robust.Client.UserInterface;
using Robust.Shared.Input;
using Robust.Shared.Input.Binding;
using Robust.Shared.Map;
namespace Robust.Client.Input
{
///
/// Manages key bindings, input commands and other misc. input systems.
///
[NotContentImplementable]
public interface IInputManager
{
bool Enabled { get; set; }
///
/// Relay a key event that hit a viewport further down the input stack.
///
///
/// This is ONLY intended to be used in key handler from viewport controls.
///
/// The viewport control that relayed the input.
/// The key event args triggering the input.
void ViewportKeyEvent(Control? control, BoundKeyEventArgs eventArgs);
///
/// The position and window of the mouse.
///
ScreenCoordinates MouseScreenPosition { get; }
BoundKeyMap NetworkBindMap { get; }
IInputContextContainer Contexts { get; }
void Initialize();
void SaveToUserData();
void KeyDown(KeyEventArgs e);
void KeyUp(KeyEventArgs e);
IKeyBinding RegisterBinding(in KeyBindingRegistration reg, bool markModified=true, bool invalid=false);
void RemoveBinding(IKeyBinding binding, bool markModified=true);
///
/// Gets a key binding according to the function it is bound to.
///
///
/// Which keybind is returned if there are multiple for a key function is unspecified.
///
/// The function the key binding is bound to.
/// The key binding.
///
/// Thrown if no there is no keybind for the specified function.
///
IKeyBinding GetKeyBinding(BoundKeyFunction function);
///
/// Which keybind is returned if there are multiple for a key function is unspecified.
///
bool TryGetKeyBinding(BoundKeyFunction function, [NotNullWhen(true)] out IKeyBinding? binding);
///
/// Returns the input command bound to a key function.
///
/// The key function to find the bound input command for.
/// An input command, if any. Null if no command is set.
InputCmdHandler? GetInputCommand(BoundKeyFunction function);
void SetInputCommand(BoundKeyFunction function, InputCmdHandler? cmdHandler);
///
/// UIKeyBindStateChanged is called when a keybind is found.
///
event Func UIKeyBindStateChanged;
///
/// Called to check if the UI is considered "focused".
///
///
/// This is effectively similar to the return value of ,
/// but may be called at different times.
///
event Func CheckUIIsFocused;
///
/// If UIKeyBindStateChanged did not handle the BoundKeyEvent, KeyBindStateChanged is called.
///
event Action? KeyBindStateChanged;
IEnumerable DownKeyFunctions { get; }
///
/// Gets the name of the key on the keyboard, based on the current input method and language.
///
string GetKeyName(Keyboard.Key key);
///
/// Gets a user-presentable, localized & keyboard-adjusted string for which combination
/// of buttons is bound to the specified key function.
///
string GetKeyFunctionButtonString(BoundKeyFunction function);
///
/// Gets all the key bindings currently registered into the manager.
///
IEnumerable AllBindings { get; }
///
/// An event that gets fired before everything else when a key event comes in.
/// For key down events, the event can be handled to block it.
///
///
/// Do not use this for regular input handling.
/// This is a low-level API intended solely for stuff like the key rebinding menu.
///
event KeyEventAction FirstChanceOnKeyEvent;
event Action OnKeyBindingAdded;
event Action OnKeyBindingRemoved;
event Action OnInputModeChanged;
///
/// Gets all the keybinds bound to a specific function.
///
IReadOnlyList GetKeyBindings(BoundKeyFunction function);
///
/// Resets the bindings for a specific BoundKeyFunction to the defaults from the resource files.
///
/// The key function to reset the bindings for.
void ResetBindingsFor(BoundKeyFunction function);
///
/// Resets ALL the keybinds to the defaults from the resource files.
///
void ResetAllBindings();
bool IsKeyFunctionModified(BoundKeyFunction function);
bool IsKeyDown(Keyboard.Key key);
void InputModeChanged();
}
}