NAP
Classes | Public Member Functions | List of all members
SDLInputService Class Reference

#include <sdlinputservice.h>

Classes

class  SDLController
 

Public Member Functions

 SDLInputService (ServiceConfiguration *configuration)
 
virtual void getDependentServices (std::vector< rtti::TypeInfo > &dependencies) override
 
virtual bool init (utility::ErrorState &error) override
 
virtual void shutdown () override
 
bool isConnected (int controllerNumber) const
 
bool controllerInstanceExists (int instance) const
 
int getControllerNumber (int instance) const
 
bool isGameController (int instance) const
 
- Public Member Functions inherited from Service
UNPREFIXED_MODULE_NAME_INPUTCASE Service (ServiceConfiguration *configuration)
 
virtual void update (double deltaTime) override
 
 Service (ServiceConfiguration *configuration)
 
virtual ~Service ()
 
CoregetCore ()
 
const CoregetCore () const
 
std::string getTypeName () const
 
const ModulegetModule () const
 
 Service (Service &)=delete
 
Serviceoperator= (const Service &)=delete
 
 Service (Service &&)=delete
 
Serviceoperator= (Service &&)=delete
 

Additional Inherited Members

- Protected Member Functions inherited from Service
virtual void registerObjectCreators (rtti::Factory &factory)
 
virtual void created ()
 
virtual void preUpdate (double deltaTime)
 
virtual void update (double deltaTime)
 
virtual void postUpdate (double deltaTime)
 
virtual void preShutdown ()
 
virtual void preResourcesLoaded ()
 
virtual void postResourcesLoaded ()
 
template<typename SERVICE_CONFIG >
SERVICE_CONFIG * getConfiguration ()
 
template<typename SERVICE_CONFIG >
const SERVICE_CONFIG * getConfiguration () const
 
std::string getIniFilePath () const
 
std::string getIniFilePath (const std::string &appendix) const
 

Description

Service that manages connections to external input devices such as a keyboard, mouse, joystick and controller. By default all connections to all available devices are opened automatically, ie: all joysticks, game controllers etc. should be available to the system after initialization. When a controller disconnects it is removed from the system until connected again. This ensures that controllers can be connected / disconnected during sessions.

A Game Controller is a Joystick that makes use of a pre-defined mapping, ie: LeftTrigger etc. Most popular game controllers are supported out of the box such as the xbox live controller etc. If a controller isn't supported natively it is considered to be a Joystick where the user has to interpret the various buttons.

Inheritance diagram for SDLInputService:
[legend]
Collaboration diagram for SDLInputService:
[legend]

Constructor & Destructor Documentation

◆ SDLInputService()

SDLInputService ( ServiceConfiguration configuration)

Member Function Documentation

◆ controllerInstanceExists()

bool controllerInstanceExists ( int  instance) const

This call can be used to ensure a controller is known to the system using a unique controller id. The unique controller id is part of SDL controller and joystick events.

Returns
if a controller with the given unique id exists

◆ getControllerNumber()

int getControllerNumber ( int  instance) const

Returns the physical controller number based on the given unique identifier. This call assumes that a controller with the unique identifier exists!

Parameters
instancethe unique controller instance, part of an SDL controller / joystick event
Returns
the physical controller index for the given instance identifier, fails when not available

◆ getDependentServices()

virtual void getDependentServices ( std::vector< rtti::TypeInfo > &  dependencies)
overridevirtual

This service depends on the default input service

Parameters
dependenciesrtti information of the services this service depends on

Reimplemented from Service.

◆ init()

virtual bool init ( utility::ErrorState error)
overridevirtual

Initializes the SDL input service When initialized the system is able to receive keyboard, mouse and joystick events

Reimplemented from Service.

◆ isConnected()

bool isConnected ( int  controllerNumber) const

Checks if a physical controller with the given number is connected. The number is always associated with a physical joystick or game control device

Parameters
controllerNumberthe number of the controller
Returns
if the controller is online

◆ isGameController()

bool isGameController ( int  instance) const

Checks if the controller is a game controller or joystick. Note that this call assumes the instance exists!

Parameters
instancethe unique controller instance, part of an sdl controller / joystick event
Returns
if the instance is a controller. If not the controller is considered by SDL to be a joystick.

◆ shutdown()

virtual void shutdown ( )
overridevirtual

Shuts down the SDL input service Closes all open connections to external devices

Reimplemented from Service.