3#include <cgv/gui/key_event.h>
4#include <cgv/gui/throttle_event.h>
5#include <cgv/gui/stick_event.h>
6#include <cgv/gui/window.h>
7#include <cgv/signal/signal.h>
8#include <cgv/signal/bool_signal.h>
9#include <gamepad/gamepad.h>
31 void stream_out(std::ostream& os)
const;
45 float _x,
float _dx,
unsigned _player_index = 0,
unsigned _controller_index = 0,
unsigned _throttle_index = 0,
double _time = 0);
51 void stream_out(std::ostream& os)
const;
65 StickAction _action,
float _x,
float _y,
float _dx,
float _dy,
66 unsigned _player_index = 0,
unsigned _controller_index = 0,
unsigned _stick_index = 0,
double _time = 0);
91 double last_device_scan;
92 double device_scan_interval;
93 std::vector<gamepad::gamepad_state> last_states;
94 std::vector<void*> device_handles;
103 void set_device_scan_interval(
double duration);
105 void check_and_emit_events(
double time);
107 cgv::signal::bool_signal<cgv::gui::event&>
on_event;
120#include <cgv/config/lib_end.h>
gamepad_key_event(void *_device_handle, const gamepad::gamepad_state &_state, unsigned short _key=0, KeyAction _action=KA_PRESS, unsigned char _char=0, double _time=0)
construct a key event from its textual description
const gamepad::gamepad_state & get_state() const
access to current gamepad state
void * get_device_handle() const
return the device id, by default returns 0
const gamepad::gamepad_state & state
public access to game state allows skipping of library dependency
void * device_handle
store id of gamepad
cgv::signal::bool_signal< cgv::gui::event & > on_event
signal emitted to dispatch events
cgv::signal::signal< void *, bool > on_device_change
signal emitted to notify about device changes, first argument is device handle and second whether dev...
GamepadEventTypeFlags get_event_type_flags() const
query the currently set event type flags
gamepad_server()
construct server with default configuration
void stream_out(std::ostream &os) const
write to stream
const gamepad::gamepad_state & get_state() const
access to current gamepad state
void * device_handle
store id of gamepad
void * get_device_handle() const
return the device id, by default returns 0
const gamepad::gamepad_state & state
public access to game state allows skipping of library dependency
gamepad_stick_event(void *_device_handle, gamepad::gamepad_state &_state, StickAction _action, float _x, float _y, float _dx, float _dy, unsigned _player_index=0, unsigned _controller_index=0, unsigned _stick_index=0, double _time=0)
construct a key event from its textual description
const gamepad::gamepad_state & get_state() const
access to current gamepad state
const gamepad::gamepad_state & state
public access to game state allows skipping of library dependency
void * get_device_handle() const
return the device id, by default returns 0
gamepad_throttle_event(void *_device_handle, gamepad::gamepad_state &_state, float _x, float _dx, unsigned _player_index=0, unsigned _controller_index=0, unsigned _throttle_index=0, double _time=0)
construct a key event from its textual description
void * device_handle
store id of gamepad
class to represent all possible keyboard events with the EID_KEY
class to represent stick events with the EID_STICK
class to represent events that inform on a change in a one axis controller with the EID_THROTTLE
namespace that holds the abstract gui interface
data::ref_ptr< window > window_ptr
ref counted pointer to &window
KeyAction
different actions that a key can perform
@ KA_PRESS
key press action
gamepad_server & ref_gamepad_server()
return a reference to gamepad server singleton
StickAction
different actions that a stick can perform
GamepadEventTypeFlags
flags to define which events should be generated by server
void connect_gamepad_server(cgv::gui::window_ptr w)
connect the gamepad server to the given window or the first window of the application,...
this header is dependency free
see https://upload.wikimedia.org/wikipedia/commons/2/2c/360_controller.svg for an explanation of the ...