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>
11 #include "lib_begin.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);
68 void* get_device_handle()
const;
72 void stream_out(std::ostream& os)
const;
87 class CGV_API gamepad_server
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;
109 cgv::signal::signal<void*, bool> on_device_change;
120 #include <cgv/config/lib_end.h>
StickAction
different actions that a stick can perform
Definition: stick_event.h:15
const gamepad::gamepad_state & get_state() const
access to current gamepad state
Definition: gamepad_server.h:29
class to represent all possible keyboard events with the EID_KEY
Definition: key_event.h:23
void * device_handle
store id of gamepad
Definition: gamepad_server.h:39
class to represent events that inform on a change in a one axis controller with the EID_THROTTLE
Definition: throttle_event.h:15
gamepad extension of stick events
Definition: gamepad_server.h:56
see https://upload.wikimedia.org/wikipedia/commons/2/2c/360_controller.svg for an explanation of the ...
Definition: gamepad.h:152
gamepad extension of throttle events
Definition: gamepad_server.h:36
KeyAction
different actions that a key can perform
Definition: key_event.h:12
const gamepad::gamepad_state & state
public access to game state allows skipping of library dependency
Definition: gamepad_server.h:22
void * get_device_handle() const
return the device id, by default returns 0
Definition: gamepad_server.h:47
const gamepad::gamepad_state & state
public access to game state allows skipping of library dependency
Definition: gamepad_server.h:41
const gamepad::gamepad_state & state
public access to game state allows skipping of library dependency
Definition: gamepad_server.h:61
void connect_gamepad_server(cgv::gui::window_ptr w)
connect the gamepad server to the given window or the first window of the application,...
Definition: gamepad_server.cxx:247
@ KA_PRESS
key press action
Definition: key_event.h:14
GamepadEventTypeFlags
flags to define which events should be generated by server
Definition: gamepad_server.h:77
void * device_handle
store id of gamepad
Definition: gamepad_server.h:20
class to represent stick events with the EID_STICK
Definition: stick_event.h:29
const gamepad::gamepad_state & get_state() const
access to current gamepad state
Definition: gamepad_server.h:49
the cgv namespace
Definition: vr_calib.cxx:9
gamepad key events use the key codes defined in gamepad::GamepadKeys
Definition: gamepad_server.h:17
void * device_handle
store id of gamepad
Definition: gamepad_server.h:59
void * get_device_handle() const
return the device id, by default returns 0
Definition: gamepad_server.h:27
gamepad_server & ref_gamepad_server()
return a reference to gamepad server singleton
Definition: gamepad_server.cxx:230