1 #ifndef _library__gamepad__hpp__included__
2 #define _library__gamepad__hpp__included__
14 pad(const JSON::node
& state
, unsigned jnum
);
15 pad(const std::string
& _name
, unsigned jnum
);
17 unsigned add_axis(uint64_t id
, int64_t min
, int64_t max
, bool pressure
, const std::string
& name
);
18 unsigned add_button(uint64_t id
, const std::string
& name
);
19 unsigned add_hat(uint64_t id
, const std::string
& name
);
20 unsigned add_hat(uint64_t idx
, uint64_t idy
, int64_t mindev
, const std::string
& namex
,
21 const std::string
& namey
);
22 unsigned axes() { return next_axis
; }
23 unsigned buttons() { return next_button
; }
24 unsigned hats() { return next_hat
; }
25 void calibrate_axis(unsigned num
, int64_t minus
, int64_t zero
, int64_t plus
, int64_t neutral
,
26 double threshold
, bool pressure
, bool disabled
);
27 void get_calibration(unsigned num
, int64_t& minus
, int64_t& zero
, int64_t& plus
, int64_t& neutral
,
28 double& threshold
, bool& pressure
, bool& disabled
);
29 double get_tolerance(unsigned num
);
30 int get_mode(unsigned num
);
31 std::set
<unsigned> online_axes();
32 std::set
<unsigned> online_buttons();
33 std::set
<unsigned> online_hats();
34 void axis_status(unsigned num
, int64_t& raw
, int16_t& scaled
);
35 int button_status(unsigned num
);
36 int hat_status(unsigned num
);
37 void report_axis(uint64_t id
, int64_t val
);
38 void report_button(uint64_t id
, bool val
);
39 void report_hat(uint64_t id
, int angle
);
40 void set_online(bool status
);
41 bool online() { return online_flag
; }
42 const std::string
& name() { return _name
; }
43 void set_axis_cb(std::function
<void(unsigned jnum
, unsigned num
, int16_t val
)> fn
)
47 void set_button_cb(std::function
<void(unsigned jnum
, unsigned num
, bool val
)> fn
) { button_fn
= fn
; }
48 void set_hat_cb(std::function
<void(unsigned jnum
, unsigned num
, unsigned val
)> fn
) { hat_fn
= fn
; }
49 void set_axismode_cb(std::function
<void(unsigned jnum
, unsigned num
, int mode
, double tolerance
)> fn
)
53 void set_newitem_cb(std::function
<void(unsigned jnum
, unsigned num
, int type
)> fn
) { newitem_fn
= fn
; }
54 void load(const JSON::node
& state
);
56 std::string
get_summary();
95 pad
& operator=(const pad
&);
96 std::function
<void(unsigned jnum
, unsigned num
, int16_t val
)> axis_fn
;
97 std::function
<void(unsigned jnum
, unsigned num
, bool val
)> button_fn
;
98 std::function
<void(unsigned jnum
, unsigned num
, unsigned val
)> hat_fn
;
99 std::function
<void(unsigned jnum
, unsigned num
, int mode
, double tolerance
)> amode_fn
;
100 std::function
<void(unsigned jnum
, unsigned num
, int type
)> newitem_fn
;
103 std::map
<uint64_t, axis_info
> _axes
;
104 std::map
<uint64_t, hat_info
*> _axes_hat
;
105 std::map
<uint64_t, button_info
> _buttons
;
106 std::map
<uint64_t, hat_info
> _hats
;
108 unsigned next_button
;
119 void load(const JSON::node
& state
);
122 pad
& operator[](unsigned gpnum
);
123 unsigned add(const std::string
& name
);
124 void set_axis_cb(std::function
<void(unsigned jnum
, unsigned num
, int16_t val
)> fn
);
125 void set_button_cb(std::function
<void(unsigned jnum
, unsigned num
, bool val
)> fn
);
126 void set_hat_cb(std::function
<void(unsigned jnum
, unsigned num
, unsigned val
)> fn
);
127 void set_axismode_cb(std::function
<void(unsigned jnum
, unsigned num
, int mode
, double tolerance
)> fn
);
128 void set_newitem_cb(std::function
<void(unsigned jnum
, unsigned num
, int type
)> fn
);
129 std::string
get_summary();
133 set
& operator=(const set
&);
134 std::function
<void(unsigned jnum
, unsigned num
, int16_t val
)> axis_fn
;
135 std::function
<void(unsigned jnum
, unsigned num
, bool val
)> button_fn
;
136 std::function
<void(unsigned jnum
, unsigned num
, unsigned val
)> hat_fn
;
137 std::function
<void(unsigned jnum
, unsigned num
, int mode
, double tolerance
)> amode_fn
;
138 std::function
<void(unsigned jnum
, unsigned num
, int type
)> newitem_fn
;
139 std::vector
<pad
*> _gamepads
;