reflexion 0.3.4 → 0.3.6

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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/reflex/application.cpp +16 -0
  3. data/.doc/ext/reflex/device.cpp +46 -3
  4. data/.doc/ext/reflex/device_event.cpp +62 -0
  5. data/.doc/ext/reflex/key_event.cpp +50 -0
  6. data/.doc/ext/reflex/native.cpp +6 -4
  7. data/.doc/ext/reflex/reflex.cpp +24 -0
  8. data/.github/PULL_REQUEST_TEMPLATE.md +12 -0
  9. data/CONTRIBUTING.md +7 -0
  10. data/ChangeLog.md +20 -0
  11. data/README.md +46 -2
  12. data/VERSION +1 -1
  13. data/ext/reflex/application.cpp +18 -0
  14. data/ext/reflex/device.cpp +48 -3
  15. data/ext/reflex/device_event.cpp +65 -0
  16. data/ext/reflex/extconf.rb +3 -3
  17. data/ext/reflex/key_event.cpp +50 -0
  18. data/ext/reflex/native.cpp +6 -4
  19. data/ext/reflex/reflex.cpp +24 -0
  20. data/include/reflex/application.h +4 -0
  21. data/include/reflex/defs.h +60 -0
  22. data/include/reflex/device.h +22 -0
  23. data/include/reflex/event.h +25 -0
  24. data/include/reflex/gamepad.h +175 -0
  25. data/include/reflex/ruby/application.h +18 -0
  26. data/include/reflex/ruby/device.h +40 -0
  27. data/include/reflex/ruby/event.h +11 -0
  28. data/reflex.gemspec +3 -3
  29. data/src/application.cpp +67 -0
  30. data/src/application.h +9 -0
  31. data/src/device.cpp +24 -0
  32. data/src/event.cpp +38 -0
  33. data/src/gamepad.cpp +176 -0
  34. data/src/gamepad.h +74 -0
  35. data/src/ios/app_delegate.mm +2 -2
  36. data/src/ios/application.mm +0 -25
  37. data/src/ios/event.mm +2 -3
  38. data/src/ios/gamepad.mm +313 -0
  39. data/src/osx/app_delegate.mm +2 -2
  40. data/src/osx/application.mm +0 -25
  41. data/src/osx/event.h +3 -0
  42. data/src/osx/event.mm +11 -3
  43. data/src/osx/gamepad.mm +40 -0
  44. data/src/osx/gamepad_gc.mm +299 -0
  45. data/src/osx/gamepad_hid.mm +567 -0
  46. data/src/view.cpp +52 -18
  47. data/src/win32/application.cpp +5 -26
  48. data/src/win32/event.cpp +8 -7
  49. data/src/win32/event.h +5 -0
  50. data/src/win32/gamepad.cpp +110 -0
  51. data/src/win32/gamepad.h +20 -0
  52. data/src/win32/window.cpp +9 -1
  53. data/src/window.cpp +15 -0
  54. data/src/window.h +9 -0
  55. metadata +30 -14
@@ -4,6 +4,7 @@
4
4
  void Init_reflex ();
5
5
  void Init_reflex_exception ();
6
6
 
7
+ void Init_reflex_pointer ();
7
8
  void Init_reflex_selector ();
8
9
  void Init_reflex_style ();
9
10
  void Init_reflex_style_length ();
@@ -11,19 +12,19 @@ void Init_reflex_timer ();
11
12
  void Init_reflex_filter ();
12
13
 
13
14
  void Init_reflex_event ();
14
- void Init_reflex_motion_event ();
15
+ void Init_reflex_device_event ();
15
16
  void Init_reflex_update_event ();
16
17
  void Init_reflex_draw_event ();
17
18
  void Init_reflex_frame_event ();
18
19
  void Init_reflex_scroll_event ();
19
20
  void Init_reflex_focus_event ();
20
21
  void Init_reflex_key_event ();
21
- void Init_reflex_pointer ();
22
22
  void Init_reflex_pointer_event ();
23
23
  void Init_reflex_wheel_event ();
24
24
  void Init_reflex_capture_event ();
25
25
  void Init_reflex_timer_event ();
26
26
  void Init_reflex_contact_event ();
27
+ void Init_reflex_motion_event ();
27
28
 
28
29
  void Init_reflex_shape ();
29
30
  void Init_reflex_polygon_shape ();
@@ -55,6 +56,7 @@ extern "C" void
55
56
  Init_reflex();
56
57
  Init_reflex_exception();
57
58
 
59
+ Init_reflex_pointer();
58
60
  Init_reflex_selector();
59
61
  Init_reflex_style();
60
62
  Init_reflex_style_length();
@@ -62,19 +64,19 @@ extern "C" void
62
64
  Init_reflex_filter();
63
65
 
64
66
  Init_reflex_event();
65
- Init_reflex_motion_event();
67
+ Init_reflex_device_event();
66
68
  Init_reflex_update_event();
67
69
  Init_reflex_draw_event();
68
70
  Init_reflex_frame_event();
69
71
  Init_reflex_scroll_event();
70
72
  Init_reflex_focus_event();
71
73
  Init_reflex_key_event();
72
- Init_reflex_pointer();
73
74
  Init_reflex_pointer_event();
74
75
  Init_reflex_wheel_event();
75
76
  Init_reflex_capture_event();
76
77
  Init_reflex_timer_event();
77
78
  Init_reflex_contact_event();
79
+ Init_reflex_motion_event();
78
80
 
79
81
  Init_reflex_shape();
80
82
  Init_reflex_polygon_shape();
@@ -251,6 +251,30 @@ Init_reflex ()
251
251
  DEFINE_CONST(KEY_LAUNCH_APP1);
252
252
  DEFINE_CONST(KEY_LAUNCH_APP2);
253
253
 
254
+ DEFINE_CONST(KEY_GAMEPAD_LEFT);
255
+ DEFINE_CONST(KEY_GAMEPAD_RIGHT);
256
+ DEFINE_CONST(KEY_GAMEPAD_UP);
257
+ DEFINE_CONST(KEY_GAMEPAD_DOWN);
258
+
259
+ DEFINE_CONST(KEY_GAMEPAD_A);
260
+ DEFINE_CONST(KEY_GAMEPAD_B);
261
+ DEFINE_CONST(KEY_GAMEPAD_X);
262
+ DEFINE_CONST(KEY_GAMEPAD_Y);
263
+
264
+ DEFINE_CONST(KEY_GAMEPAD_LSHOULDER);
265
+ DEFINE_CONST(KEY_GAMEPAD_RSHOULDER);
266
+ DEFINE_CONST(KEY_GAMEPAD_LTRIGGER);
267
+ DEFINE_CONST(KEY_GAMEPAD_RTRIGGER);
268
+ DEFINE_CONST(KEY_GAMEPAD_LTHUMB);
269
+ DEFINE_CONST(KEY_GAMEPAD_RTHUMB);
270
+
271
+ DEFINE_CONST(KEY_GAMEPAD_HOME);
272
+ DEFINE_CONST(KEY_GAMEPAD_MENU);
273
+ DEFINE_CONST(KEY_GAMEPAD_OPTION);
274
+ DEFINE_CONST(KEY_GAMEPAD_SHARE);
275
+ DEFINE_CONST(KEY_GAMEPAD_START);
276
+ DEFINE_CONST(KEY_GAMEPAD_SELECT);
277
+
254
278
  DEFINE_CONST(MOD_SHIFT);
255
279
  DEFINE_CONST(MOD_CONTROL);
256
280
  DEFINE_CONST(MOD_ALT);
@@ -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);
@@ -277,6 +277,66 @@ namespace Reflex
277
277
 
278
278
  #undef NATIVE_VK
279
279
 
280
+ KEY_GAMEPAD_LEFT = 0x100,
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
339
+
280
340
  };// KeyCode
281
341
 
282
342
 
@@ -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
 
@@ -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
 
@@ -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
 
@@ -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<Gamepad::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
@@ -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);
@@ -0,0 +1,40 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __REFLEX_RUBY_DEVICE_H__
4
+ #define __REFLEX_RUBY_DEVICE_H__
5
+
6
+
7
+ #include <rucy/class.h>
8
+ #include <rucy/extension.h>
9
+ #include <reflex/device.h>
10
+
11
+
12
+ RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::Device)
13
+
14
+
15
+ namespace Reflex
16
+ {
17
+
18
+
19
+ REFLEX_EXPORT Rucy::Class device_class ();
20
+ // class Reflex::Device
21
+
22
+
23
+ }// Reflex
24
+
25
+
26
+ namespace Rucy
27
+ {
28
+
29
+
30
+ template <> inline Class
31
+ get_ruby_class<Reflex::Device> ()
32
+ {
33
+ return Reflex::device_class();
34
+ }
35
+
36
+
37
+ }// Rucy
38
+
39
+
40
+ #endif//EOH
@@ -11,6 +11,8 @@
11
11
 
12
12
  RUCY_DECLARE_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::Event)
13
13
 
14
+ RUCY_DECLARE_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::DeviceEvent)
15
+
14
16
  RUCY_DECLARE_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::UpdateEvent)
15
17
 
16
18
  RUCY_DECLARE_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::DrawEvent)
@@ -43,6 +45,9 @@ namespace Reflex
43
45
  REFLEX_EXPORT Rucy::Class event_class ();
44
46
  // class Reflex::Event
45
47
 
48
+ REFLEX_EXPORT Rucy::Class device_event_class ();
49
+ // class Reflex::DeviceEvent
50
+
46
51
  REFLEX_EXPORT Rucy::Class update_event_class ();
47
52
  // class Reflex::UpdateEvent
48
53
 
@@ -93,6 +98,12 @@ namespace Rucy
93
98
  return Reflex::event_class();
94
99
  }
95
100
 
101
+ template <> inline Class
102
+ get_ruby_class<Reflex::DeviceEvent> ()
103
+ {
104
+ return Reflex::device_event_class();
105
+ }
106
+
96
107
  template <> inline Class
97
108
  get_ruby_class<Reflex::UpdateEvent> ()
98
109
  {
data/reflex.gemspec CHANGED
@@ -25,9 +25,9 @@ Gem::Specification.new do |s|
25
25
  s.platform = Gem::Platform::RUBY
26
26
  s.required_ruby_version = '>= 3.0.0'
27
27
 
28
- s.add_dependency 'xot', '~> 0.3.4', '>= 0.3.4'
29
- s.add_dependency 'rucy', '~> 0.3.4', '>= 0.3.4'
30
- s.add_dependency 'rays', '~> 0.3.4', '>= 0.3.4'
28
+ s.add_dependency 'xot', '~> 0.3.6', '>= 0.3.6'
29
+ s.add_dependency 'rucy', '~> 0.3.6', '>= 0.3.6'
30
+ s.add_dependency 'rays', '~> 0.3.6', '>= 0.3.6'
31
31
 
32
32
  s.files = `git ls-files`.split $/
33
33
  s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
data/src/application.cpp CHANGED
@@ -4,6 +4,7 @@
4
4
  #include "reflex/exception.h"
5
5
  #include "reflex/debug.h"
6
6
  #include "window.h"
7
+ #include "gamepad.h"
7
8
 
8
9
 
9
10
  namespace Reflex
@@ -18,6 +19,37 @@ namespace Reflex
18
19
  }// global
19
20
 
20
21
 
22
+ void
23
+ Application_call_start (Application* app, Event* e)
24
+ {
25
+ Gamepad_init(app);
26
+
27
+ app->on_start(e);
28
+ }
29
+
30
+ void
31
+ Application_call_quit (Application* app, Event* e)
32
+ {
33
+ app->on_quit(e);
34
+ if (e->is_blocked()) return;
35
+
36
+ Gamepad_fin(app);
37
+ }
38
+
39
+ void
40
+ Application_call_device_connect (Application* app, Device* device)
41
+ {
42
+ DeviceEvent e(device);
43
+ app->on_device_connect(&e);
44
+ }
45
+
46
+ void
47
+ Application_call_device_disconnect (Application* app, Device* device)
48
+ {
49
+ DeviceEvent e(device);
50
+ app->on_device_disconnect(&e);
51
+ }
52
+
21
53
  Application*
22
54
  app ()
23
55
  {
@@ -78,6 +110,41 @@ namespace Reflex
78
110
  return Window_all().end();
79
111
  }
80
112
 
113
+ void
114
+ Application::on_start (Event* e)
115
+ {
116
+ }
117
+
118
+ void
119
+ Application::on_quit (Event* e)
120
+ {
121
+ }
122
+
123
+ void
124
+ Application::on_device_connect (DeviceEvent* e)
125
+ {
126
+ }
127
+
128
+ void
129
+ Application::on_device_disconnect (DeviceEvent* e)
130
+ {
131
+ }
132
+
133
+ void
134
+ Application::on_motion (MotionEvent* e)
135
+ {
136
+ }
137
+
138
+ void
139
+ Application::on_preference (Event* e)
140
+ {
141
+ }
142
+
143
+ Application::operator bool () const
144
+ {
145
+ return true;
146
+ }
147
+
81
148
  bool
82
149
  Application::operator ! () const
83
150
  {
data/src/application.h CHANGED
@@ -22,6 +22,15 @@ namespace Reflex
22
22
  Application::Data* Application_create_data ();
23
23
 
24
24
 
25
+ void Application_call_start (Application* app, Event* e);
26
+
27
+ void Application_call_quit (Application* app, Event* e);
28
+
29
+ void Application_call_device_connect (Application* app, Device* device);
30
+
31
+ void Application_call_device_disconnect (Application* app, Device* device);
32
+
33
+
25
34
  }// Reflex
26
35
 
27
36
 
data/src/device.cpp ADDED
@@ -0,0 +1,24 @@
1
+ #include "reflex/device.h"
2
+
3
+
4
+ namespace Reflex
5
+ {
6
+
7
+
8
+ Device::~Device ()
9
+ {
10
+ }
11
+
12
+ Device::operator bool () const
13
+ {
14
+ return true;
15
+ }
16
+
17
+ bool
18
+ Device::operator ! () const
19
+ {
20
+ return !operator bool();
21
+ }
22
+
23
+
24
+ }// Reflex
data/src/event.cpp CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
 
4
4
  #include <algorithm>
5
+ #include "reflex/device.h"
5
6
  #include "reflex/timer.h"
6
7
  #include "reflex/shape.h"
7
8
  #include "reflex/exception.h"
@@ -69,6 +70,43 @@ namespace Reflex
69
70
  }
70
71
 
71
72
 
73
+ struct DeviceEvent::Data
74
+ {
75
+
76
+ Device::Ref device;
77
+
78
+ };// DeviceEvent::Data
79
+
80
+
81
+ DeviceEvent::DeviceEvent (Device* device)
82
+ {
83
+ if (device) self->device = device;
84
+ }
85
+
86
+ DeviceEvent::DeviceEvent (const DeviceEvent* src)
87
+ : Event(src), self(new Data(*src->self))
88
+ {
89
+ }
90
+
91
+ DeviceEvent
92
+ DeviceEvent::dup () const
93
+ {
94
+ return DeviceEvent(this);
95
+ }
96
+
97
+ Device*
98
+ DeviceEvent::device ()
99
+ {
100
+ return self->device;
101
+ }
102
+
103
+ const Device*
104
+ DeviceEvent::device () const
105
+ {
106
+ return self->device;
107
+ }
108
+
109
+
72
110
  struct UpdateEvent::Data
73
111
  {
74
112