reflexion 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.doc/ext/reflex/application.cpp +16 -0
- data/.doc/ext/reflex/device.cpp +46 -3
- data/.doc/ext/reflex/device_event.cpp +62 -0
- data/.doc/ext/reflex/key_event.cpp +49 -19
- data/.doc/ext/reflex/midi.cpp +82 -0
- data/.doc/ext/reflex/native.cpp +10 -4
- data/.doc/ext/reflex/note_event.cpp +121 -0
- data/.doc/ext/reflex/reflex.cpp +30 -8
- data/.doc/ext/reflex/view.cpp +11 -16
- data/.doc/ext/reflex/window.cpp +24 -0
- data/ChangeLog.md +16 -0
- data/Rakefile +7 -0
- data/VERSION +1 -1
- data/ext/reflex/application.cpp +18 -0
- data/ext/reflex/device.cpp +48 -3
- data/ext/reflex/device_event.cpp +65 -0
- data/ext/reflex/key_event.cpp +49 -19
- data/ext/reflex/midi.cpp +87 -0
- data/ext/reflex/native.cpp +10 -4
- data/ext/reflex/note_event.cpp +130 -0
- data/ext/reflex/reflex.cpp +31 -8
- data/ext/reflex/view.cpp +11 -16
- data/ext/reflex/window.cpp +27 -0
- data/include/reflex/application.h +4 -0
- data/include/reflex/defs.h +58 -21
- data/include/reflex/device.h +22 -0
- data/include/reflex/event.h +64 -2
- data/include/reflex/gamepad.h +175 -0
- data/include/reflex/midi.h +53 -0
- data/include/reflex/reflex.h +2 -0
- data/include/reflex/ruby/application.h +18 -0
- data/include/reflex/ruby/device.h +40 -0
- data/include/reflex/ruby/event.h +22 -0
- data/include/reflex/ruby/midi.h +84 -0
- data/include/reflex/ruby/window.h +27 -0
- data/include/reflex/view.h +9 -1
- data/include/reflex/window.h +6 -0
- data/lib/reflex/note_event.rb +34 -0
- data/lib/reflex/view.rb +2 -1
- data/lib/reflex.rb +9 -8
- data/reflex.gemspec +3 -3
- data/src/application.cpp +70 -0
- data/src/application.h +9 -0
- data/src/device.cpp +24 -0
- data/src/event.cpp +133 -7
- data/src/event.h +5 -0
- data/src/gamepad.cpp +176 -0
- data/src/gamepad.h +74 -0
- data/src/ios/app_delegate.mm +2 -2
- data/src/ios/application.mm +0 -25
- data/src/ios/event.h +0 -5
- data/src/ios/event.mm +11 -87
- data/src/ios/gamepad.mm +314 -0
- data/src/ios/reflex.mm +0 -5
- data/src/midi.cpp +379 -0
- data/src/midi.h +32 -0
- data/src/osx/app_delegate.mm +2 -2
- data/src/osx/application.mm +0 -25
- data/src/osx/event.h +0 -5
- data/src/osx/event.mm +9 -86
- data/src/osx/gamepad.mm +40 -0
- data/src/osx/gamepad_gc.mm +299 -0
- data/src/osx/gamepad_hid.mm +567 -0
- data/src/osx/reflex.mm +0 -5
- data/src/queue.h +71 -0
- data/src/reflex.cpp +18 -0
- data/src/timer.cpp +3 -10
- data/src/view.cpp +39 -0
- data/src/view.h +2 -0
- data/src/win32/application.cpp +5 -26
- data/src/win32/event.cpp +6 -89
- data/src/win32/event.h +1 -1
- data/src/win32/gamepad.cpp +110 -0
- data/src/win32/gamepad.h +20 -0
- data/src/win32/window.cpp +2 -1
- data/src/window.cpp +61 -10
- data/src/window.h +2 -0
- data/test/test_capture_event.rb +20 -16
- data/test/test_key_event.rb +8 -1
- data/test/test_note_event.rb +43 -0
- data/test/test_view.rb +24 -12
- metadata +43 -14
data/ext/reflex/reflex.cpp
CHANGED
@@ -3,21 +3,31 @@
|
|
3
3
|
|
4
4
|
#include "reflex/ruby/view.h"
|
5
5
|
#include "reflex/ruby/timer.h"
|
6
|
+
#include "reflex/ruby/midi.h"
|
6
7
|
#include "../../src/window.h"
|
7
8
|
#include "../../src/timer.h"
|
9
|
+
#include "../../src/midi.h"
|
8
10
|
#include "defs.h"
|
9
11
|
|
10
12
|
|
11
13
|
static Reflex::View*
|
12
14
|
create_root_view ()
|
13
15
|
{
|
14
|
-
return new Reflex::RubyView<Reflex::View
|
16
|
+
return new Reflex::RubyView<Reflex::View>();
|
15
17
|
}
|
16
18
|
|
17
19
|
static Reflex::Timer*
|
18
20
|
create_timer ()
|
19
21
|
{
|
20
|
-
return new Reflex::RubyTimer<Reflex::Timer
|
22
|
+
return new Reflex::RubyTimer<Reflex::Timer>();
|
23
|
+
}
|
24
|
+
|
25
|
+
static Reflex::MIDI*
|
26
|
+
create_midi ()
|
27
|
+
{
|
28
|
+
Reflex::MIDI* midi = new Reflex::RubyMIDI<Reflex::MIDI>();
|
29
|
+
value(midi);// apply MIDI class to ClassWrapper's value
|
30
|
+
return midi;
|
21
31
|
}
|
22
32
|
|
23
33
|
|
@@ -27,6 +37,7 @@ RUCY_DEF0(init)
|
|
27
37
|
Reflex::init();
|
28
38
|
Reflex::Window_set_create_root_view_fun(create_root_view);
|
29
39
|
Reflex::Timer_set_create_fun(create_timer);
|
40
|
+
Reflex::MIDI_set_create_fun(create_midi);
|
30
41
|
|
31
42
|
return self;
|
32
43
|
}
|
@@ -37,12 +48,22 @@ RUCY_DEF0(fin)
|
|
37
48
|
{
|
38
49
|
Reflex::Window_set_create_root_view_fun(NULL);
|
39
50
|
Reflex::Timer_set_create_fun(NULL);
|
51
|
+
Reflex::MIDI_set_create_fun(NULL);
|
40
52
|
Reflex::fin();
|
41
53
|
|
42
54
|
return self;
|
43
55
|
}
|
44
56
|
RUCY_END
|
45
57
|
|
58
|
+
static
|
59
|
+
RUCY_DEF0(process_events)
|
60
|
+
{
|
61
|
+
Reflex::process_events();
|
62
|
+
|
63
|
+
return self;
|
64
|
+
}
|
65
|
+
RUCY_END
|
66
|
+
|
46
67
|
|
47
68
|
static Module mReflex;
|
48
69
|
|
@@ -52,6 +73,7 @@ Init_reflex ()
|
|
52
73
|
mReflex = define_module("Reflex");
|
53
74
|
mReflex.define_singleton_method("init!", init);
|
54
75
|
mReflex.define_singleton_method("fin!", fin);
|
76
|
+
mReflex.define_singleton_method("process_events!", process_events);
|
55
77
|
|
56
78
|
using namespace Reflex;
|
57
79
|
|
@@ -261,16 +283,17 @@ Init_reflex ()
|
|
261
283
|
DEFINE_CONST(KEY_GAMEPAD_X);
|
262
284
|
DEFINE_CONST(KEY_GAMEPAD_Y);
|
263
285
|
|
264
|
-
DEFINE_CONST(
|
265
|
-
DEFINE_CONST(
|
266
|
-
DEFINE_CONST(
|
267
|
-
DEFINE_CONST(
|
268
|
-
DEFINE_CONST(
|
269
|
-
DEFINE_CONST(
|
286
|
+
DEFINE_CONST(KEY_GAMEPAD_LSHOULDER);
|
287
|
+
DEFINE_CONST(KEY_GAMEPAD_RSHOULDER);
|
288
|
+
DEFINE_CONST(KEY_GAMEPAD_LTRIGGER);
|
289
|
+
DEFINE_CONST(KEY_GAMEPAD_RTRIGGER);
|
290
|
+
DEFINE_CONST(KEY_GAMEPAD_LTHUMB);
|
291
|
+
DEFINE_CONST(KEY_GAMEPAD_RTHUMB);
|
270
292
|
|
271
293
|
DEFINE_CONST(KEY_GAMEPAD_HOME);
|
272
294
|
DEFINE_CONST(KEY_GAMEPAD_MENU);
|
273
295
|
DEFINE_CONST(KEY_GAMEPAD_OPTION);
|
296
|
+
DEFINE_CONST(KEY_GAMEPAD_SHARE);
|
274
297
|
DEFINE_CONST(KEY_GAMEPAD_START);
|
275
298
|
DEFINE_CONST(KEY_GAMEPAD_SELECT);
|
276
299
|
|
data/ext/reflex/view.cpp
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
#include <vector>
|
5
|
+
#include <ranges>
|
5
6
|
#include <rays/ruby/point.h>
|
6
7
|
#include <rays/ruby/bounds.h>
|
7
8
|
#include <rays/ruby/polygon.h>
|
@@ -25,16 +26,6 @@ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::View)
|
|
25
26
|
#define CALL(fun) RUCY_CALL_SUPER(THIS, fun)
|
26
27
|
|
27
28
|
|
28
|
-
template <typename T>
|
29
|
-
static inline Value
|
30
|
-
array (T begin, T end)
|
31
|
-
{
|
32
|
-
std::vector<Value> v;
|
33
|
-
for (T it = begin; it != end; ++it) v.push_back(value(*it));
|
34
|
-
return array(&v[0], v.size());
|
35
|
-
}
|
36
|
-
|
37
|
-
|
38
29
|
static
|
39
30
|
RUCY_DEF_ALLOC(alloc, klass)
|
40
31
|
{
|
@@ -213,8 +204,9 @@ RUCY_DEFN(find_children)
|
|
213
204
|
|
214
205
|
bool recursive = (argc >= 2) ? to<bool>(argv[1]) : true;
|
215
206
|
|
216
|
-
|
217
|
-
THIS->find_children(to<Reflex::Selector>(argv[0]), recursive)
|
207
|
+
auto children =
|
208
|
+
THIS->find_children(to<Reflex::Selector>(argv[0]), recursive) |
|
209
|
+
std::views::transform([](auto& ref) {return value(ref);});
|
218
210
|
return array(children.begin(), children.end());
|
219
211
|
}
|
220
212
|
RUCY_END
|
@@ -273,8 +265,9 @@ RUCY_DEFN(find_styles)
|
|
273
265
|
|
274
266
|
bool recursive = (argc >= 2) ? to<bool>(argv[1]) : false;
|
275
267
|
|
276
|
-
|
277
|
-
THIS->find_styles(to<Reflex::Selector>(argv[0]), recursive)
|
268
|
+
auto styles =
|
269
|
+
THIS->find_styles(to<Reflex::Selector>(argv[0]), recursive) |
|
270
|
+
std::views::transform([](auto& ref) {return value(ref);});
|
278
271
|
return array(styles.begin(), styles.end());
|
279
272
|
}
|
280
273
|
RUCY_END
|
@@ -358,8 +351,9 @@ RUCY_DEFN(find_shapes)
|
|
358
351
|
CHECK;
|
359
352
|
check_arg_count(__FILE__, __LINE__, "View#find_shapes", argc, 1);
|
360
353
|
|
361
|
-
|
362
|
-
THIS->find_shapes(to<Reflex::Selector>(argv[0]))
|
354
|
+
auto shapes =
|
355
|
+
THIS->find_shapes(to<Reflex::Selector>(argv[0])) |
|
356
|
+
std::views::transform([](auto& ref) {return value(ref);});
|
363
357
|
return array(shapes.begin(), shapes.end());
|
364
358
|
}
|
365
359
|
RUCY_END
|
@@ -1352,6 +1346,7 @@ Init_reflex_view ()
|
|
1352
1346
|
cView.define_const("CAPTURE_NONE", Reflex::View::CAPTURE_NONE);
|
1353
1347
|
cView.define_const("CAPTURE_KEY", Reflex::View::CAPTURE_KEY);
|
1354
1348
|
cView.define_const("CAPTURE_POINTER", Reflex::View::CAPTURE_POINTER);
|
1349
|
+
cView.define_const("CAPTURE_NOTE", Reflex::View::CAPTURE_NOTE);
|
1355
1350
|
cView.define_const("CAPTURE_ALL", Reflex::View::CAPTURE_ALL);
|
1356
1351
|
|
1357
1352
|
define_selector_methods<Reflex::View>(cView);
|
data/ext/reflex/window.cpp
CHANGED
@@ -413,6 +413,30 @@ RUCY_DEF1(on_wheel, event)
|
|
413
413
|
}
|
414
414
|
RUCY_END
|
415
415
|
|
416
|
+
static
|
417
|
+
RUCY_DEF1(on_note, event)
|
418
|
+
{
|
419
|
+
CHECK;
|
420
|
+
CALL(on_note(to<Reflex::NoteEvent*>(event)));
|
421
|
+
}
|
422
|
+
RUCY_END
|
423
|
+
|
424
|
+
static
|
425
|
+
RUCY_DEF1(on_note_on, event)
|
426
|
+
{
|
427
|
+
CHECK;
|
428
|
+
CALL(on_note_on(to<Reflex::NoteEvent*>(event)));
|
429
|
+
}
|
430
|
+
RUCY_END
|
431
|
+
|
432
|
+
static
|
433
|
+
RUCY_DEF1(on_note_off, event)
|
434
|
+
{
|
435
|
+
CHECK;
|
436
|
+
CALL(on_note_off(to<Reflex::NoteEvent*>(event)));
|
437
|
+
}
|
438
|
+
RUCY_END
|
439
|
+
|
416
440
|
|
417
441
|
static Class cWindow;
|
418
442
|
|
@@ -466,6 +490,9 @@ Init_reflex_window ()
|
|
466
490
|
cWindow.define_method("on_pointer_move", on_pointer_move);
|
467
491
|
cWindow.define_method("on_pointer_cancel", on_pointer_cancel);
|
468
492
|
cWindow.define_method("on_wheel", on_wheel);
|
493
|
+
cWindow.define_method("on_note", on_note);
|
494
|
+
cWindow.define_method("on_note_on", on_note_on);
|
495
|
+
cWindow.define_method("on_note_off", on_note_off);
|
469
496
|
|
470
497
|
cWindow.define_const("ORIENTATION_PORTRAIT", Reflex::Window::FLAG_PORTRAIT);
|
471
498
|
cWindow.define_const("ORIENTATION_LANDSCAPE", Reflex::Window::FLAG_LANDSCAPE);
|
@@ -53,6 +53,10 @@ namespace Reflex
|
|
53
53
|
|
54
54
|
virtual void on_quit (Event* e);
|
55
55
|
|
56
|
+
virtual void on_device_connect (DeviceEvent* e);
|
57
|
+
|
58
|
+
virtual void on_device_disconnect (DeviceEvent* e);
|
59
|
+
|
56
60
|
virtual void on_motion (MotionEvent* e);
|
57
61
|
|
58
62
|
virtual void on_preference (Event* e);
|
data/include/reflex/defs.h
CHANGED
@@ -278,27 +278,64 @@ namespace Reflex
|
|
278
278
|
#undef NATIVE_VK
|
279
279
|
|
280
280
|
KEY_GAMEPAD_LEFT = 0x100,
|
281
|
-
KEY_GAMEPAD_RIGHT
|
282
|
-
KEY_GAMEPAD_UP
|
283
|
-
KEY_GAMEPAD_DOWN
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
281
|
+
KEY_GAMEPAD_RIGHT,
|
282
|
+
KEY_GAMEPAD_UP,
|
283
|
+
KEY_GAMEPAD_DOWN,
|
284
|
+
|
285
|
+
KEY_GAMEPAD_LSTICK_LEFT,
|
286
|
+
KEY_GAMEPAD_LSTICK_RIGHT,
|
287
|
+
KEY_GAMEPAD_LSTICK_UP,
|
288
|
+
KEY_GAMEPAD_LSTICK_DOWN,
|
289
|
+
|
290
|
+
KEY_GAMEPAD_RSTICK_LEFT,
|
291
|
+
KEY_GAMEPAD_RSTICK_RIGHT,
|
292
|
+
KEY_GAMEPAD_RSTICK_UP,
|
293
|
+
KEY_GAMEPAD_RSTICK_DOWN,
|
294
|
+
|
295
|
+
KEY_GAMEPAD_A,
|
296
|
+
KEY_GAMEPAD_B,
|
297
|
+
KEY_GAMEPAD_X,
|
298
|
+
KEY_GAMEPAD_Y,
|
299
|
+
|
300
|
+
KEY_GAMEPAD_LSHOULDER,
|
301
|
+
KEY_GAMEPAD_RSHOULDER,
|
302
|
+
KEY_GAMEPAD_LTRIGGER,
|
303
|
+
KEY_GAMEPAD_RTRIGGER,
|
304
|
+
KEY_GAMEPAD_LTHUMB,
|
305
|
+
KEY_GAMEPAD_RTHUMB,
|
306
|
+
|
307
|
+
KEY_GAMEPAD_LPADDLE_0,
|
308
|
+
KEY_GAMEPAD_LPADDLE_1,
|
309
|
+
KEY_GAMEPAD_RPADDLE_0,
|
310
|
+
KEY_GAMEPAD_RPADDLE_1,
|
311
|
+
|
312
|
+
KEY_GAMEPAD_HOME,
|
313
|
+
KEY_GAMEPAD_MENU,
|
314
|
+
KEY_GAMEPAD_OPTION,
|
315
|
+
KEY_GAMEPAD_SHARE,
|
316
|
+
KEY_GAMEPAD_START,
|
317
|
+
KEY_GAMEPAD_SELECT,
|
318
|
+
|
319
|
+
KEY_GAMEPAD_BUTTON_TOUCH,
|
320
|
+
|
321
|
+
KEY_GAMEPAD_BUTTON_0,
|
322
|
+
KEY_GAMEPAD_BUTTON_1,
|
323
|
+
KEY_GAMEPAD_BUTTON_2,
|
324
|
+
KEY_GAMEPAD_BUTTON_3,
|
325
|
+
KEY_GAMEPAD_BUTTON_4,
|
326
|
+
KEY_GAMEPAD_BUTTON_5,
|
327
|
+
KEY_GAMEPAD_BUTTON_6,
|
328
|
+
KEY_GAMEPAD_BUTTON_7,
|
329
|
+
KEY_GAMEPAD_BUTTON_8,
|
330
|
+
KEY_GAMEPAD_BUTTON_9,
|
331
|
+
KEY_GAMEPAD_BUTTON_10,
|
332
|
+
KEY_GAMEPAD_BUTTON_11,
|
333
|
+
KEY_GAMEPAD_BUTTON_12,
|
334
|
+
KEY_GAMEPAD_BUTTON_13,
|
335
|
+
KEY_GAMEPAD_BUTTON_14,
|
336
|
+
KEY_GAMEPAD_BUTTON_15,
|
337
|
+
|
338
|
+
KEY_GAMEPAD_BUTTON_MAX
|
302
339
|
|
303
340
|
};// KeyCode
|
304
341
|
|
data/include/reflex/device.h
CHANGED
@@ -4,10 +4,32 @@
|
|
4
4
|
#define __REFLEX_DEVICE_H__
|
5
5
|
|
6
6
|
|
7
|
+
#include <xot/ref.h>
|
8
|
+
#include <reflex/defs.h>
|
9
|
+
|
10
|
+
|
7
11
|
namespace Reflex
|
8
12
|
{
|
9
13
|
|
10
14
|
|
15
|
+
class Device : public Xot::RefCountable<>
|
16
|
+
{
|
17
|
+
|
18
|
+
public:
|
19
|
+
|
20
|
+
typedef Xot::Ref<Device> Ref;
|
21
|
+
|
22
|
+
virtual ~Device ();
|
23
|
+
|
24
|
+
virtual const char* name () const = 0;
|
25
|
+
|
26
|
+
virtual operator bool () const;
|
27
|
+
|
28
|
+
bool operator ! () const;
|
29
|
+
|
30
|
+
};// Device
|
31
|
+
|
32
|
+
|
11
33
|
void vibrate ();
|
12
34
|
|
13
35
|
|
data/include/reflex/event.h
CHANGED
@@ -17,6 +17,7 @@ namespace Reflex
|
|
17
17
|
{
|
18
18
|
|
19
19
|
|
20
|
+
class Device;
|
20
21
|
class Shape;
|
21
22
|
class View;
|
22
23
|
|
@@ -26,7 +27,7 @@ namespace Reflex
|
|
26
27
|
|
27
28
|
public:
|
28
29
|
|
29
|
-
Event ();
|
30
|
+
Event (double time = -1);
|
30
31
|
|
31
32
|
~Event ();
|
32
33
|
|
@@ -47,6 +48,30 @@ namespace Reflex
|
|
47
48
|
};// Event
|
48
49
|
|
49
50
|
|
51
|
+
class DeviceEvent : public Event
|
52
|
+
{
|
53
|
+
|
54
|
+
public:
|
55
|
+
|
56
|
+
DeviceEvent (Device* device = NULL);
|
57
|
+
|
58
|
+
DeviceEvent dup () const;
|
59
|
+
|
60
|
+
Device* device ();
|
61
|
+
|
62
|
+
const Device* device () const;
|
63
|
+
|
64
|
+
struct Data;
|
65
|
+
|
66
|
+
Xot::PSharedImpl<Data> self;
|
67
|
+
|
68
|
+
private:
|
69
|
+
|
70
|
+
DeviceEvent (const DeviceEvent* src);
|
71
|
+
|
72
|
+
};// DeviceEvent
|
73
|
+
|
74
|
+
|
50
75
|
class UpdateEvent : public Event
|
51
76
|
{
|
52
77
|
|
@@ -238,7 +263,7 @@ namespace Reflex
|
|
238
263
|
|
239
264
|
KeyEvent (
|
240
265
|
Action action, const char* chars, int code,
|
241
|
-
uint modifiers = 0, int repeat = 0);
|
266
|
+
uint modifiers = 0, int repeat = 0, double time = -1);
|
242
267
|
|
243
268
|
KeyEvent dup () const;
|
244
269
|
|
@@ -329,6 +354,43 @@ namespace Reflex
|
|
329
354
|
};// WheelEvent
|
330
355
|
|
331
356
|
|
357
|
+
class NoteEvent : public Event
|
358
|
+
{
|
359
|
+
|
360
|
+
public:
|
361
|
+
|
362
|
+
enum Action {ACTION_NONE = 0, ON, OFF};
|
363
|
+
|
364
|
+
NoteEvent ();
|
365
|
+
|
366
|
+
NoteEvent (
|
367
|
+
Action action, int channel, int note, float velocity, double time);
|
368
|
+
|
369
|
+
NoteEvent dup () const;
|
370
|
+
|
371
|
+
Action action () const;
|
372
|
+
|
373
|
+
int channel () const;
|
374
|
+
|
375
|
+
int note () const;
|
376
|
+
|
377
|
+
float frequency () const;
|
378
|
+
|
379
|
+
float velocity () const;
|
380
|
+
|
381
|
+
bool is_captured () const;
|
382
|
+
|
383
|
+
struct Data;
|
384
|
+
|
385
|
+
Xot::PSharedImpl<Data> self;
|
386
|
+
|
387
|
+
private:
|
388
|
+
|
389
|
+
NoteEvent (const NoteEvent* src);
|
390
|
+
|
391
|
+
};// NoteEvent
|
392
|
+
|
393
|
+
|
332
394
|
class CaptureEvent : public Event
|
333
395
|
{
|
334
396
|
|
@@ -0,0 +1,175 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __REFLEX_GAMEPAD_H__
|
4
|
+
#define __REFLEX_GAMEPAD_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <xot/ref.h>
|
8
|
+
#include <xot/pimpl.h>
|
9
|
+
#include <xot/util.h>
|
10
|
+
#include <reflex/device.h>
|
11
|
+
#include <reflex/event.h>
|
12
|
+
|
13
|
+
|
14
|
+
namespace Reflex
|
15
|
+
{
|
16
|
+
|
17
|
+
|
18
|
+
class Gamepad : public Device
|
19
|
+
{
|
20
|
+
|
21
|
+
public:
|
22
|
+
|
23
|
+
typedef Xot::Ref<Gamepad> Ref;
|
24
|
+
|
25
|
+
typedef std::vector<Ref> List;
|
26
|
+
|
27
|
+
enum Index
|
28
|
+
{
|
29
|
+
|
30
|
+
INDEX_LEFT = 0, INDEX_RIGHT, INDEX_MAX
|
31
|
+
|
32
|
+
};// Index
|
33
|
+
|
34
|
+
enum Button
|
35
|
+
{
|
36
|
+
|
37
|
+
LEFT = Xot::bit<ulonglong>(0),
|
38
|
+
|
39
|
+
RIGHT = Xot::bit<ulonglong>(1),
|
40
|
+
|
41
|
+
UP = Xot::bit<ulonglong>(2),
|
42
|
+
|
43
|
+
DOWN = Xot::bit<ulonglong>(3),
|
44
|
+
|
45
|
+
LSTICK_LEFT = Xot::bit<ulonglong>(4),
|
46
|
+
|
47
|
+
LSTICK_RIGHT = Xot::bit<ulonglong>(5),
|
48
|
+
|
49
|
+
LSTICK_UP = Xot::bit<ulonglong>(6),
|
50
|
+
|
51
|
+
LSTICK_DOWN = Xot::bit<ulonglong>(7),
|
52
|
+
|
53
|
+
RSTICK_LEFT = Xot::bit<ulonglong>(8),
|
54
|
+
|
55
|
+
RSTICK_RIGHT = Xot::bit<ulonglong>(9),
|
56
|
+
|
57
|
+
RSTICK_UP = Xot::bit<ulonglong>(10),
|
58
|
+
|
59
|
+
RSTICK_DOWN = Xot::bit<ulonglong>(11),
|
60
|
+
|
61
|
+
BUTTON_A = Xot::bit<ulonglong>(12),
|
62
|
+
|
63
|
+
BUTTON_B = Xot::bit<ulonglong>(13),
|
64
|
+
|
65
|
+
BUTTON_X = Xot::bit<ulonglong>(14),
|
66
|
+
|
67
|
+
BUTTON_Y = Xot::bit<ulonglong>(15),
|
68
|
+
|
69
|
+
LSHOULDER = Xot::bit<ulonglong>(16),
|
70
|
+
|
71
|
+
RSHOULDER = Xot::bit<ulonglong>(17),
|
72
|
+
|
73
|
+
LTRIGGER = Xot::bit<ulonglong>(18),
|
74
|
+
|
75
|
+
RTRIGGER = Xot::bit<ulonglong>(19),
|
76
|
+
|
77
|
+
LTHUMB = Xot::bit<ulonglong>(20),
|
78
|
+
|
79
|
+
RTHUMB = Xot::bit<ulonglong>(21),
|
80
|
+
|
81
|
+
LPADDLE_0 = Xot::bit<ulonglong>(22),
|
82
|
+
|
83
|
+
LPADDLE_1 = Xot::bit<ulonglong>(23),
|
84
|
+
|
85
|
+
RPADDLE_0 = Xot::bit<ulonglong>(24),
|
86
|
+
|
87
|
+
RPADDLE_1 = Xot::bit<ulonglong>(25),
|
88
|
+
|
89
|
+
HOME = Xot::bit<ulonglong>(26),
|
90
|
+
|
91
|
+
MENU = Xot::bit<ulonglong>(27),
|
92
|
+
|
93
|
+
OPTION = Xot::bit<ulonglong>(28),
|
94
|
+
|
95
|
+
SHARE = Xot::bit<ulonglong>(29),
|
96
|
+
|
97
|
+
START = Xot::bit<ulonglong>(30),
|
98
|
+
|
99
|
+
SELECT = Xot::bit<ulonglong>(31),
|
100
|
+
|
101
|
+
BUTTON_TOUCH = Xot::bit<ulonglong>(32),
|
102
|
+
|
103
|
+
BUTTON_0 = Xot::bit<ulonglong>(33),
|
104
|
+
|
105
|
+
BUTTON_1 = Xot::bit<ulonglong>(34),
|
106
|
+
|
107
|
+
BUTTON_2 = Xot::bit<ulonglong>(35),
|
108
|
+
|
109
|
+
BUTTON_3 = Xot::bit<ulonglong>(36),
|
110
|
+
|
111
|
+
BUTTON_4 = Xot::bit<ulonglong>(37),
|
112
|
+
|
113
|
+
BUTTON_5 = Xot::bit<ulonglong>(38),
|
114
|
+
|
115
|
+
BUTTON_6 = Xot::bit<ulonglong>(39),
|
116
|
+
|
117
|
+
BUTTON_7 = Xot::bit<ulonglong>(40),
|
118
|
+
|
119
|
+
BUTTON_8 = Xot::bit<ulonglong>(41),
|
120
|
+
|
121
|
+
BUTTON_9 = Xot::bit<ulonglong>(42),
|
122
|
+
|
123
|
+
BUTTON_10 = Xot::bit<ulonglong>(43),
|
124
|
+
|
125
|
+
BUTTON_11 = Xot::bit<ulonglong>(44),
|
126
|
+
|
127
|
+
BUTTON_12 = Xot::bit<ulonglong>(45),
|
128
|
+
|
129
|
+
BUTTON_13 = Xot::bit<ulonglong>(46),
|
130
|
+
|
131
|
+
BUTTON_14 = Xot::bit<ulonglong>(47),
|
132
|
+
|
133
|
+
BUTTON_15 = Xot::bit<ulonglong>(48),
|
134
|
+
|
135
|
+
};// Button
|
136
|
+
|
137
|
+
Gamepad ();
|
138
|
+
|
139
|
+
virtual ~Gamepad ();
|
140
|
+
|
141
|
+
virtual const char* name () const;
|
142
|
+
|
143
|
+
virtual ulonglong buttons () const;
|
144
|
+
|
145
|
+
virtual const Point& stick (size_t index = INDEX_LEFT) const;
|
146
|
+
|
147
|
+
virtual float trigger (size_t index = INDEX_LEFT) const;
|
148
|
+
|
149
|
+
const Gamepad* prev () const;
|
150
|
+
|
151
|
+
virtual void on_key (KeyEvent* e);
|
152
|
+
|
153
|
+
virtual void on_key_down (KeyEvent* e);
|
154
|
+
|
155
|
+
virtual void on_key_up (KeyEvent* e);
|
156
|
+
|
157
|
+
//virtual void on_stick (StickEvent* e);
|
158
|
+
|
159
|
+
//virtual void on_trigger (TriggerEvent* e);
|
160
|
+
|
161
|
+
virtual operator bool () const;
|
162
|
+
|
163
|
+
static const List& all ();
|
164
|
+
|
165
|
+
struct Data;
|
166
|
+
|
167
|
+
Xot::PImpl<Data> self;
|
168
|
+
|
169
|
+
};// Gamepad
|
170
|
+
|
171
|
+
|
172
|
+
}// Reflex
|
173
|
+
|
174
|
+
|
175
|
+
#endif//EOH
|
@@ -0,0 +1,53 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __REFLEX_MIDI_H__
|
4
|
+
#define __REFLEX_MIDI_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <vector>
|
8
|
+
#include <xot/ref.h>
|
9
|
+
#include <xot/pimpl.h>
|
10
|
+
#include <reflex/device.h>
|
11
|
+
#include <reflex/event.h>
|
12
|
+
|
13
|
+
|
14
|
+
namespace Reflex
|
15
|
+
{
|
16
|
+
|
17
|
+
|
18
|
+
class MIDI : public Device
|
19
|
+
{
|
20
|
+
|
21
|
+
public:
|
22
|
+
|
23
|
+
typedef Xot::Ref<MIDI> Ref;
|
24
|
+
|
25
|
+
typedef std::vector<Ref> List;
|
26
|
+
|
27
|
+
MIDI ();
|
28
|
+
|
29
|
+
virtual ~MIDI ();
|
30
|
+
|
31
|
+
virtual const char* name () const;
|
32
|
+
|
33
|
+
virtual void on_note (NoteEvent* e);
|
34
|
+
|
35
|
+
virtual void on_note_on (NoteEvent* e);
|
36
|
+
|
37
|
+
virtual void on_note_off (NoteEvent* e);
|
38
|
+
|
39
|
+
virtual operator bool () const;
|
40
|
+
|
41
|
+
static const List& all ();
|
42
|
+
|
43
|
+
struct Data;
|
44
|
+
|
45
|
+
Xot::PImpl<Data> self;
|
46
|
+
|
47
|
+
};// MIDI
|
48
|
+
|
49
|
+
|
50
|
+
}// Reflex
|
51
|
+
|
52
|
+
|
53
|
+
#endif//EOH
|
data/include/reflex/reflex.h
CHANGED
@@ -65,6 +65,24 @@ namespace Reflex
|
|
65
65
|
return Super::on_quit(e);
|
66
66
|
}
|
67
67
|
|
68
|
+
virtual void on_device_connect (DeviceEvent* e)
|
69
|
+
{
|
70
|
+
RUCY_SYM(on_device_connect);
|
71
|
+
if (this->is_overridable())
|
72
|
+
this->value.call(on_device_connect, Rucy::value(e));
|
73
|
+
else
|
74
|
+
return Super::on_device_connect(e);
|
75
|
+
}
|
76
|
+
|
77
|
+
virtual void on_device_disconnect (DeviceEvent* e)
|
78
|
+
{
|
79
|
+
RUCY_SYM(on_device_disconnect);
|
80
|
+
if (this->is_overridable())
|
81
|
+
this->value.call(on_device_disconnect, Rucy::value(e));
|
82
|
+
else
|
83
|
+
return Super::on_device_disconnect(e);
|
84
|
+
}
|
85
|
+
|
68
86
|
virtual void on_motion (MotionEvent* e)
|
69
87
|
{
|
70
88
|
RUCY_SYM(on_motion);
|