Classes¶
Input
Brief descriptions¶
Structures |
|
Provides an interface for platform-dependent access to the input source |
|
Classes |
|
Manages input sources |
|
Provides an interface for input serialization to Datablock. |
|
Provides an interface for platform-dependent access to the input device. |
|
Provides a proxy interface for platform-independent access to the input device. |
|
Encapsulates input signal generic properties. |
|
Provides input signal interface allowing to access signal state, values and nested inout signals. |
|
Provides input action interface which can exhibit user-defined behavior depending on the state change of the associated signal with context support. |
|
Provides a general interface for managing input signals, actions and contexts. |
Detailed information¶
InputSource¶
engine/core/modules/input/include/nau/input_system.h
-
struct InputSource¶
Provides an interface for platform-dependent access to the input source.
IInputSourceManager¶
engine/core/modules/input/include/nau/input_system.h
-
class IInputSourceManager¶
Manages input sources.
Public Functions
Set callback which provide sources to input system.
- Parameters:
Callback – [in] with ref to sources vector
IInputSerializable¶
engine/core/modules/input/include/nau/input_system.h
-
class IInputSerializable¶
Provides an interface for input serialization to Datablock.
Subclassed by nau::IInputAction, nau::IInputSignal
Public Functions
-
virtual void serialize(DataBlock *blk) const = 0¶
Serializes the object into the DataBlock.
- Parameters:
Output – [out] datablock.
-
virtual bool deserialize(const DataBlock *blk) = 0¶
Deserializes the object from the DataBlock.
- Parameters:
blk – [in] A pointer to the DataBlock to load the data from.
- Returns:
true
on success,false
otherwise.
-
virtual void serialize(DataBlock *blk) const = 0¶
IInputDevice¶
engine/core/modules/input/include/nau/input_system.h
-
class IInputDevice¶
Provides an interface for platform-dependent access to the input device.
Public Types
-
enum Type¶
Determines possible types of input devices.
Values:
-
enumerator Unsupported¶
Indicates that the input device has not been recognized and is not supported.
-
enumerator Keyboard¶
-
enumerator Mouse¶
-
enumerator Joystick¶
Indicates that the input device has been recognized as a joystick or a gamepad.
-
enumerator Touch¶
Indicates that the input device has been recognized as a touchpad.
-
enumerator Other¶
Indicates that the input device is supported and yet has not been recognized as any other supported type of input device.
-
enumerator Unsupported¶
Public Functions
-
virtual eastl::string getName() const = 0¶
Retrieves the name of the input device.
- Returns:
Name of the input device.
-
virtual Type getType() const = 0¶
Retrieves the type of the input device.
- Returns:
Type of the input device.
-
virtual unsigned getKeysNum() const = 0¶
Retrieves the number of keys that the input device supports.
- Returns:
Number of supported keys.
-
virtual unsigned getAxisNum() const = 0¶
Retrieves the number of axes the input device supports.
- Returns:
Number of supported axes.
-
virtual eastl::string getKeyName(unsigned keyId) const = 0¶
Retrieves axis name by its index.
- Parameters:
keyId – [in] Index of the key.
- Returns:
Name of the key.
-
virtual eastl::string getAxisName(unsigned axisId) const = 0¶
Retrieves the axis name by its index.
- Parameters:
axisId – [in] Index of the axis.
- Returns:
Name of the axis.
-
virtual unsigned getKeyByName(const eastl::string_view keyName) const = 0¶
Retrieves the key index by its name.
- Parameters:
keyName – [in] Name of the key.
- Returns:
Index of the key.
-
virtual unsigned getAxisByName(const eastl::string_view axisName) const = 0¶
Retrieves the axis index by its name.
- Parameters:
axisName – [in] Name of the axis.
- Returns:
Index of the axis.
-
virtual KeyState getKeyState(unsigned keyId) const = 0¶
Retrieves the state of the key.
- Parameters:
keyId – [in] Index of the key.
- Returns:
State of the key.
-
virtual float getAxisState(unsigned axisId) const = 0¶
Retrieves the state of the axis.
- Parameters:
axisId – [in] Index of the axis.
- Returns:
State of the axis.
-
enum Type¶
IInputController¶
engine/core/modules/input/include/nau/input_system.h
-
class IInputController¶
Provides a proxy interface for platform-independent access to the input device.
Public Functions
-
virtual eastl::string getName() const = 0¶
Retrieves the name of the actual input device.
- Returns:
Name of the input device.
-
virtual IInputDevice *getDevice() = 0¶
Retrieves a pointer to the actual input device.
- Returns:
A pointer to the actual input device.
-
virtual void update(float dt) = 0¶
Called on frame update.
- Parameters:
dt – [in] Delta time.
-
virtual eastl::string getName() const = 0¶
InputSignalProperties¶
engine/core/modules/input/include/nau/input_system.h
-
class InputSignalProperties¶
Encapsulates input signal generic properties.
Public Functions
-
template<typename T>
inline void set(const eastl::string &key, const T &value)¶ Assigns value to the signal property.
- Template Parameters:
T – Type of the signal property value. It has to be one of the following:
float
,int
,unsigned int
,char
,eastl::string
.- Parameters:
key – [in] Key under which the property was registered. If the property has not yet been added, use add method.
value – [in] Value to assign.
-
template<typename T>
inline Result<T> get(const eastl::string &key) const¶ Retrieves the signal property value.
- Parameters:
key – [in] Key of the property to retrieve the value of.
- Returns:
A Result<T> object storing the requested value.
-
inline bool isChanged(bool setTo = false)¶
Checks whether signal properties have been modified since last update of the signal state.
- Parameters:
setTo – [in] Optional value to assign to
m_changed
.- Returns:
true
if the properties have been changed,false
otherwise. The return value is adequate at the moment of the function call.
Private Functions
-
template<typename T>
inline void add(const eastl::string &key, const T &value)¶ Registers the signal property.
- Template Parameters:
T – Type of the signal property value. It has to be one of the following:
float
,int
,unsigned int
,char
,eastl::string
.- Parameters:
key – [in] Key to register the property under.
value – [in] Initial value of the property.
Private Members
-
eastl::unordered_map<eastl::string, RuntimeValue::Ptr> m_properties¶
Stores signal properties and provides access to their values by their names.
-
bool m_changed = false¶
Indicates whether signal properties have been change and the signal state require update.
Friends
- friend class InputSignalImpl
-
template<typename T>
IInputSignal¶
engine/core/modules/input/include/nau/input_system.h
-
class IInputSignal : public nau::IInputSerializable¶
Provides input signal interface allowing to access signal state, values and nested inout signals.
Supported signal values are: float, float2, float3 and float4.
Curently supported signal types are:
’pressed’ signals get promoted to ‘high’ state on key press;
’released’ signals get promoted to ‘high’ state on key release;
’move’ signals get promoted to ‘high’ state on axis value change; absolute axis value can be retrieved;
’move_relative’ signals get promoted to ‘high’ state on axis value change; axis offset from its value in the previous frame can be retrieved;
’or’ signals get promoted to ‘high’ state as soon as any of the nested signals get promoted;
’and’ signals get promoted to ‘high’ state as soon as each nested signal gets promoted;
’not’ signals get promoted to ‘high’ state as soon as the nested state gets demoted to ‘low’ state;
’key_axis’ signals get promoted to ‘high’ state on key press or release; the key state is converted to an axis value and can be retrieved;
’delay’ signals get promoted to ‘high’ as soon as the key has been pressed for a time period;
’multiple’ signals get promoted as soon as the key has been pressed a number of times;
’scale’ signal scales its nested signals values by a factor defined through its properties;
’dead_zone’ signal nulls its nested signals values in case they are inside a square area defined through its properties;
’clamp’ signal clamps its nested signals values between two boundaries that are defined through its properties.
Public Types
Public Functions
-
virtual const eastl::string &getName() const = 0¶
Retrieves the signal name.
- Returns:
Name of the signal.
-
virtual const eastl::string &getType() const = 0¶
Retrieves the signal type.
For more information on signal types, see IInputSignal.
- Returns:
Type of the signal as a string.
-
virtual IInputController *getController() = 0¶
Retrieves a pointer to the input controller, which this signal is attached to.
- Returns:
A pointer to the input controller.
-
virtual void setController(IInputController*) = 0¶
Attaches the signal to the controller.
@pram [in] controller A pointer to the input controller to attach the signal to.
-
virtual State getState() const = 0¶
Retrieves the current state of the signal.
- Returns:
Signal current state.
-
virtual State getPreviousState() const = 0¶
Retrieves the previous state of the signal.
- Returns:
Signal state in the previous frame.
-
virtual float getValue() const = 0¶
Retrieves the signal float value.
- Returns:
Signal value.
-
virtual math::vec2 getVector2() const = 0¶
Retrieves the signal vector2 value.
- Returns:
Signal value.
-
virtual math::vec3 getVector3() const = 0¶
Retrieves the signal vector3 value.
- Returns:
Signal value.
-
virtual math::vec4 getVector4() const = 0¶
Retrieves the signal vector4 value.
- Returns:
Signal value.
-
virtual void addInput(IInputSignal *source) = 0¶
Adds a nested signal as input.
-
virtual IInputSignal *getInput(unsigned idx) = 0¶
Retrieves a nested input signal.
- Parameters:
idx – [in] Index of the nested signal to retrieve.
- Returns:
A pointer to the nested signal.
-
virtual unsigned maxInputs() const = 0¶
Retrieves the maximal number of nested input signals.
The output depends on the signal type.
- Returns:
Maximal number of nested input signals.
-
virtual InputSignalProperties &Properties() = 0¶
Provides access to the signal properties.
- Returns:
A reference to the InputSignalProperties object storing properties of the signal.
-
virtual const InputSignalProperties &Properties() const = 0¶
Retrieves the signal properties.
- Returns:
A const reference to the InputSignalProperties object storing properties of the signal.
-
virtual void update(float dt) = 0¶
Called each frame.
The method can be used to modify values, nested signals or state of the signal.
- Parameters:
dt – [in] Delta time.
IInputAction¶
engine/core/modules/input/include/nau/input_system.h
-
class IInputAction : public nau::IInputSerializable¶
Provides input action interface which can exhibit user-defined behavior depending on the state change of the associated signal with context support.
Public Types
-
enum Type¶
Determines the action response to the associated signal state change.
See IInputSignal for more information.
Values:
-
enumerator Trigger¶
Actions of this type are triggered as soon as the associated signal transitions from ‘low’ to ‘high’ state.
Such actions may be used, for example, to react to a button press/release.
-
enumerator Continuous¶
Actions of this type are triggered each frame the associated signal is in ‘high’ state.
Such actions may be used, for example, to react to a button hold or a cursor move.
-
enumerator Trigger¶
Public Functions
-
virtual eastl::string getName() const = 0¶
Retrieves the name of the action.
- Returns:
Name of the action.
-
virtual IInputSignal *getSignal() = 0¶
Retrives the signal associated with this action.
- Returns:
A pointer to the associated signal.
-
virtual void addContextTag(const eastl::string &tag) = 0¶
Attaches string tag to the action.
Multiple tags can be attached to a single action.
- Parameters:
tag – [in] Tag to attach to the action.
-
virtual void removeContextTag(const eastl::string &tag) = 0¶
Detaches the tag from the action.
- Parameters:
tag – [in] Tag to detach from the action.
-
virtual bool isContextTag(const eastl::string &tag) const = 0¶
Checks if the tag is attached to the action.
- Parameters:
tag – [in] Tag to inquire about.
- Returns:
true
if the tag is attached to the action,false
otherwise.
-
virtual void update(float dt) = 0¶
Updates the associated signal and exhibits the user-defined behavior if necessary.
The function is run on per-frame basis.
-
enum Type¶
IInputSystem¶
engine/core/modules/input/include/nau/input_system.h
-
class IInputSystem¶
Provides a general interface for managing input signals, actions and contexts.
Public Functions
-
virtual eastl::shared_ptr<IInputAction> addAction(const eastl::string &name, IInputAction::Type type, IInputSignal *signal, nau::Functor<void(IInputSignal*)> actionCallback) = 0¶
Creates an input action and registers it in the system.
- Parameters:
name – [in] Name of the action.
type – [in] Type of the action.
signal – [in] A pointer to the signal that is to be associated with the new action.
actionCallback – [in] A functor that is to be called upon action trigger.
- Returns:
A pointer to the created action.
-
virtual eastl::shared_ptr<IInputAction> addAction(const eastl::string &serialized, nau::Functor<void(IInputSignal*)> actionCallback) = 0¶
Creates an input action and registers it in the system.
- Parameters:
serialized – [in] A string view of the DataBlock to create the action from.
actionCallback – [in] A functor that is to be called upon action trigger.
- Returns:
A pointer to the created action.
Removes the action from the system.
- Parameters:
action – [in] A reference to the action to remove.
- Returns:
true
on success,false
otherwise.
-
virtual eastl::shared_ptr<IInputAction> loadAction(const io::FsPath &filePath, nau::Functor<void(IInputSignal*)> actionCallback) = 0¶
Creates an input action from the .blk file and registers it in the system.
- Parameters:
filePath – [in] Path to the source .blk file.
actionCallback – [in] A functor that is to be called upon action trigger.
- Returns:
A pointer to the created action.
Outputs the action (as DataBlock) into the .blk file.
- Parameters:
action – [in] A pointer to the action to save.
filePath – [in] Path to the .blk file to ouput the action to.
- Returns:
true
on success,false
otherwise.
Retrieves actions that have been registered in the system.
- Parameters:
actions – [out] Output actions vector.
-
virtual IInputSignal *createSignal(const eastl::string &signalType) = 0¶
Creates a signal.
- Parameters:
signalType – [in] String type of the signal. For list of supported types see IInputSignal.
- Returns:
A pointer to the created signal.
-
virtual IInputSignal *createSignal(const eastl::string &signalType, const eastl::string &controllerName, nau::Functor<void(IInputSignal*)> signal) = 0¶
Creates a signal.
- Parameters:
signalType – [in] String type of the signal. For list of supported types see IInputSignal.
controllerName – [in] Name of the controller to associate this signal with.
signal – [in] Functor that is to be called at signal creation. You may use this functor to set properties, values or nested input signals of the created signal.
- Returns:
A pointer to the created signal.
-
virtual void setContext(const eastl::string &context) = 0¶
Resets the system active context list to a single active context.
To add an active context and keep existing active contexts use addContext method.
- Parameters:
context – [in] Name of the context to add.
-
virtual void addContext(const eastl::string &context) = 0¶
Adds the context to the system active context list.
- Parameters:
context – [in] Name of the context to add.
-
virtual void removeContext(const eastl::string &context) = 0¶
Removes the context from the system active context list.
Actions from the removed contexts are not triggered.
- Parameters:
context – [in] Name of the context to remove.
-
virtual eastl::vector<IInputDevice*> getDevices() = 0¶
Retrieves all connected input devices.
- Returns:
A vector of connected input devices.
-
virtual IInputController *getController(const eastl::string &controllerDesc) = 0¶
Retrieves the input controller (i.e. platform-independent input device abstraction) that matches the description.
- Parameters:
controllerDesc – [in] Definition of the requested controller registered in the system.
- Returns:
A pointer to the matching controller or
NULL
if none has been found.
-
virtual void setInputSource(const eastl::string &source) = 0¶
Set current input source.
Source valid until next setInputSource call
- Parameters:
source – [in] Name of the source
-
virtual eastl::shared_ptr<IInputAction> addAction(const eastl::string &name, IInputAction::Type type, IInputSignal *signal, nau::Functor<void(IInputSignal*)> actionCallback) = 0¶