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
@@ -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
|
data/include/reflex/ruby/event.h
CHANGED
@@ -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)
|
@@ -27,6 +29,8 @@ RUCY_DECLARE_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::PointerEvent)
|
|
27
29
|
|
28
30
|
RUCY_DECLARE_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::WheelEvent)
|
29
31
|
|
32
|
+
RUCY_DECLARE_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::NoteEvent)
|
33
|
+
|
30
34
|
RUCY_DECLARE_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::CaptureEvent)
|
31
35
|
|
32
36
|
RUCY_DECLARE_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::TimerEvent)
|
@@ -43,6 +47,9 @@ namespace Reflex
|
|
43
47
|
REFLEX_EXPORT Rucy::Class event_class ();
|
44
48
|
// class Reflex::Event
|
45
49
|
|
50
|
+
REFLEX_EXPORT Rucy::Class device_event_class ();
|
51
|
+
// class Reflex::DeviceEvent
|
52
|
+
|
46
53
|
REFLEX_EXPORT Rucy::Class update_event_class ();
|
47
54
|
// class Reflex::UpdateEvent
|
48
55
|
|
@@ -67,6 +74,9 @@ namespace Reflex
|
|
67
74
|
REFLEX_EXPORT Rucy::Class wheel_event_class ();
|
68
75
|
// class Reflex::WheelEvent
|
69
76
|
|
77
|
+
REFLEX_EXPORT Rucy::Class note_event_class ();
|
78
|
+
// class Reflex::NoteEvent
|
79
|
+
|
70
80
|
REFLEX_EXPORT Rucy::Class capture_event_class ();
|
71
81
|
// class Reflex::CaptureEvent
|
72
82
|
|
@@ -93,6 +103,12 @@ namespace Rucy
|
|
93
103
|
return Reflex::event_class();
|
94
104
|
}
|
95
105
|
|
106
|
+
template <> inline Class
|
107
|
+
get_ruby_class<Reflex::DeviceEvent> ()
|
108
|
+
{
|
109
|
+
return Reflex::device_event_class();
|
110
|
+
}
|
111
|
+
|
96
112
|
template <> inline Class
|
97
113
|
get_ruby_class<Reflex::UpdateEvent> ()
|
98
114
|
{
|
@@ -141,6 +157,12 @@ namespace Rucy
|
|
141
157
|
return Reflex::wheel_event_class();
|
142
158
|
}
|
143
159
|
|
160
|
+
template <> inline Class
|
161
|
+
get_ruby_class<Reflex::NoteEvent> ()
|
162
|
+
{
|
163
|
+
return Reflex::note_event_class();
|
164
|
+
}
|
165
|
+
|
144
166
|
template <> inline Class
|
145
167
|
get_ruby_class<Reflex::CaptureEvent> ()
|
146
168
|
{
|
@@ -0,0 +1,84 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __REFLEX_RUBY_MIDI_H__
|
4
|
+
#define __REFLEX_RUBY_MIDI_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <rucy/class.h>
|
8
|
+
#include <rucy/extension.h>
|
9
|
+
#include <reflex/midi.h>
|
10
|
+
|
11
|
+
|
12
|
+
RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::MIDI)
|
13
|
+
|
14
|
+
|
15
|
+
namespace Reflex
|
16
|
+
{
|
17
|
+
|
18
|
+
|
19
|
+
REFLEX_EXPORT Rucy::Class midi_class ();
|
20
|
+
// class Reflex::MIDI
|
21
|
+
|
22
|
+
|
23
|
+
template <typename T>
|
24
|
+
class RubyMIDI : public Rucy::ClassWrapper<T>
|
25
|
+
{
|
26
|
+
|
27
|
+
typedef Rucy::ClassWrapper<T> Super;
|
28
|
+
|
29
|
+
public:
|
30
|
+
|
31
|
+
virtual void on_note (NoteEvent* e)
|
32
|
+
{
|
33
|
+
RUCY_SYM(on_note);
|
34
|
+
if (this->is_overridable())
|
35
|
+
this->value.call(on_note, Rucy::value(e));
|
36
|
+
else
|
37
|
+
Super::on_note(e);
|
38
|
+
}
|
39
|
+
|
40
|
+
virtual void on_note_on (NoteEvent* e)
|
41
|
+
{
|
42
|
+
RUCY_SYM(on_note_on);
|
43
|
+
if (this->is_overridable())
|
44
|
+
this->value.call(on_note_on, Rucy::value(e));
|
45
|
+
else
|
46
|
+
Super::on_note_on(e);
|
47
|
+
}
|
48
|
+
|
49
|
+
virtual void on_note_off (NoteEvent* e)
|
50
|
+
{
|
51
|
+
RUCY_SYM(on_note_off);
|
52
|
+
if (this->is_overridable())
|
53
|
+
this->value.call(on_note_off, Rucy::value(e));
|
54
|
+
else
|
55
|
+
Super::on_note_off(e);
|
56
|
+
}
|
57
|
+
|
58
|
+
};// RubyMIDI
|
59
|
+
|
60
|
+
|
61
|
+
}// Reflex
|
62
|
+
|
63
|
+
|
64
|
+
namespace Rucy
|
65
|
+
{
|
66
|
+
|
67
|
+
|
68
|
+
template <> inline Class
|
69
|
+
get_ruby_class<Reflex::MIDI> ()
|
70
|
+
{
|
71
|
+
return Reflex::midi_class();
|
72
|
+
}
|
73
|
+
|
74
|
+
inline Value
|
75
|
+
value (Reflex::MIDI::Ref& ref, Value klass = Reflex::midi_class())
|
76
|
+
{
|
77
|
+
return value(ref.get(), klass);
|
78
|
+
}
|
79
|
+
|
80
|
+
|
81
|
+
}// Rucy
|
82
|
+
|
83
|
+
|
84
|
+
#endif//EOH
|
@@ -191,6 +191,33 @@ namespace Reflex
|
|
191
191
|
Super::on_wheel(e);
|
192
192
|
}
|
193
193
|
|
194
|
+
virtual void on_note (NoteEvent* e)
|
195
|
+
{
|
196
|
+
RUCY_SYM(on_note);
|
197
|
+
if (this->is_overridable())
|
198
|
+
this->value.call(on_note, Rucy::value(e));
|
199
|
+
else
|
200
|
+
Super::on_note(e);
|
201
|
+
}
|
202
|
+
|
203
|
+
virtual void on_note_on (NoteEvent* e)
|
204
|
+
{
|
205
|
+
RUCY_SYM(on_note_on);
|
206
|
+
if (this->is_overridable())
|
207
|
+
this->value.call(on_note_on, Rucy::value(e));
|
208
|
+
else
|
209
|
+
Super::on_note_on(e);
|
210
|
+
}
|
211
|
+
|
212
|
+
virtual void on_note_off (NoteEvent* e)
|
213
|
+
{
|
214
|
+
RUCY_SYM(on_note_off);
|
215
|
+
if (this->is_overridable())
|
216
|
+
this->value.call(on_note_off, Rucy::value(e));
|
217
|
+
else
|
218
|
+
Super::on_note_off(e);
|
219
|
+
}
|
220
|
+
|
194
221
|
};// RubyWindow
|
195
222
|
|
196
223
|
|
data/include/reflex/view.h
CHANGED
@@ -82,7 +82,9 @@ namespace Reflex
|
|
82
82
|
|
83
83
|
CAPTURE_POINTER = Xot::bit(1),
|
84
84
|
|
85
|
-
|
85
|
+
CAPTURE_NOTE = Xot::bit(2),
|
86
|
+
|
87
|
+
CAPTURE_ALL = CAPTURE_KEY | CAPTURE_POINTER | CAPTURE_NOTE,
|
86
88
|
|
87
89
|
};// Capture
|
88
90
|
|
@@ -380,6 +382,12 @@ namespace Reflex
|
|
380
382
|
|
381
383
|
virtual void on_wheel (WheelEvent* e);
|
382
384
|
|
385
|
+
virtual void on_note (NoteEvent* e);
|
386
|
+
|
387
|
+
virtual void on_note_on (NoteEvent* e);
|
388
|
+
|
389
|
+
virtual void on_note_off (NoteEvent* e);
|
390
|
+
|
383
391
|
virtual void on_capture (CaptureEvent* e);
|
384
392
|
|
385
393
|
virtual void on_timer (TimerEvent* e);
|
data/include/reflex/window.h
CHANGED
@@ -135,6 +135,12 @@ namespace Reflex
|
|
135
135
|
|
136
136
|
virtual void on_wheel (WheelEvent* e);
|
137
137
|
|
138
|
+
virtual void on_note (NoteEvent* e);
|
139
|
+
|
140
|
+
virtual void on_note_on (NoteEvent* e);
|
141
|
+
|
142
|
+
virtual void on_note_off (NoteEvent* e);
|
143
|
+
|
138
144
|
operator bool () const;
|
139
145
|
|
140
146
|
bool operator ! () const;
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'xot/const_symbol_accessor'
|
2
|
+
require 'reflex/ext'
|
3
|
+
|
4
|
+
|
5
|
+
module Reflex
|
6
|
+
|
7
|
+
|
8
|
+
class NoteEvent < Event
|
9
|
+
|
10
|
+
alias get_action action
|
11
|
+
|
12
|
+
const_symbol_reader :action, **{
|
13
|
+
none: ACTION_NONE,
|
14
|
+
on: ON,
|
15
|
+
off: OFF
|
16
|
+
}
|
17
|
+
|
18
|
+
def on?()
|
19
|
+
get_action == ON
|
20
|
+
end
|
21
|
+
|
22
|
+
def off?()
|
23
|
+
get_action == OFF
|
24
|
+
end
|
25
|
+
|
26
|
+
def inspect()
|
27
|
+
"#<Reflex::NoteEvent action:%s channel:%d note:%d vel:0f time:%f captured?:%s>" %
|
28
|
+
[action, channel, note, velocity, time, captured?]
|
29
|
+
end
|
30
|
+
|
31
|
+
end# NoteEvent
|
32
|
+
|
33
|
+
|
34
|
+
end# Reflex
|
data/lib/reflex/view.rb
CHANGED
@@ -49,6 +49,7 @@ module Reflex
|
|
49
49
|
bit_flag_accessor :capture do
|
50
50
|
flag :key, CAPTURE_KEY
|
51
51
|
flag :pointer, CAPTURE_POINTER
|
52
|
+
flag :note, CAPTURE_NOTE
|
52
53
|
flag :all, CAPTURE_ALL
|
53
54
|
end
|
54
55
|
|
@@ -103,7 +104,7 @@ module Reflex
|
|
103
104
|
if args.empty?
|
104
105
|
not cap.empty?
|
105
106
|
elsif args.include?(:all)
|
106
|
-
cap == [:key, :pointer]
|
107
|
+
cap == [:key, :pointer, :note]
|
107
108
|
else
|
108
109
|
args.all? {|type| cap.include? type}
|
109
110
|
end
|
data/lib/reflex.rb
CHANGED
@@ -19,37 +19,38 @@ require 'reflex/reflex'
|
|
19
19
|
require 'reflex/helper'
|
20
20
|
|
21
21
|
require 'reflex/selector'
|
22
|
+
require 'reflex/pointer'
|
22
23
|
require 'reflex/style'
|
23
24
|
require 'reflex/style_length'
|
24
25
|
require 'reflex/timer'
|
25
26
|
require 'reflex/filter'
|
26
27
|
|
28
|
+
require 'reflex/shape'
|
29
|
+
require 'reflex/polygon_shape'
|
30
|
+
require 'reflex/line_shape'
|
31
|
+
require 'reflex/rect_shape'
|
32
|
+
require 'reflex/ellipse_shape'
|
33
|
+
|
27
34
|
require 'reflex/update_event'
|
28
35
|
require 'reflex/draw_event'
|
29
36
|
require 'reflex/frame_event'
|
30
37
|
require 'reflex/scroll_event'
|
31
38
|
require 'reflex/focus_event'
|
32
39
|
require 'reflex/key_event'
|
33
|
-
require 'reflex/pointer'
|
34
40
|
require 'reflex/pointer_event'
|
35
41
|
require 'reflex/wheel_event'
|
42
|
+
require 'reflex/note_event'
|
36
43
|
require 'reflex/capture_event'
|
37
44
|
require 'reflex/timer_event'
|
38
45
|
require 'reflex/contact_event'
|
39
46
|
|
40
|
-
require 'reflex/shape'
|
41
|
-
require 'reflex/polygon_shape'
|
42
|
-
require 'reflex/line_shape'
|
43
|
-
require 'reflex/rect_shape'
|
44
|
-
require 'reflex/ellipse_shape'
|
45
|
-
|
46
47
|
require 'reflex/model'
|
47
48
|
require 'reflex/model_owner'
|
48
49
|
|
49
50
|
require 'reflex/application'
|
50
|
-
require 'reflex/screen'
|
51
51
|
require 'reflex/window'
|
52
52
|
require 'reflex/view'
|
53
|
+
require 'reflex/screen'
|
53
54
|
|
54
55
|
require 'reflex/button'
|
55
56
|
require 'reflex/text_view'
|
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.
|
29
|
-
s.add_dependency 'rucy', '~> 0.3.
|
30
|
-
s.add_dependency 'rays', '~> 0.3.
|
28
|
+
s.add_dependency 'xot', '~> 0.3.7', '>= 0.3.7'
|
29
|
+
s.add_dependency 'rucy', '~> 0.3.7', '>= 0.3.7'
|
30
|
+
s.add_dependency 'rays', '~> 0.3.7', '>= 0.3.7'
|
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,8 @@
|
|
4
4
|
#include "reflex/exception.h"
|
5
5
|
#include "reflex/debug.h"
|
6
6
|
#include "window.h"
|
7
|
+
#include "gamepad.h"
|
8
|
+
#include "midi.h"
|
7
9
|
|
8
10
|
|
9
11
|
namespace Reflex
|
@@ -18,6 +20,39 @@ namespace Reflex
|
|
18
20
|
}// global
|
19
21
|
|
20
22
|
|
23
|
+
void
|
24
|
+
Application_call_start (Application* app, Event* e)
|
25
|
+
{
|
26
|
+
Gamepad_init(app);
|
27
|
+
MIDI_init(app);
|
28
|
+
|
29
|
+
app->on_start(e);
|
30
|
+
}
|
31
|
+
|
32
|
+
void
|
33
|
+
Application_call_quit (Application* app, Event* e)
|
34
|
+
{
|
35
|
+
app->on_quit(e);
|
36
|
+
if (e->is_blocked()) return;
|
37
|
+
|
38
|
+
MIDI_fin(app);
|
39
|
+
Gamepad_fin(app);
|
40
|
+
}
|
41
|
+
|
42
|
+
void
|
43
|
+
Application_call_device_connect (Application* app, Device* device)
|
44
|
+
{
|
45
|
+
DeviceEvent e(device);
|
46
|
+
app->on_device_connect(&e);
|
47
|
+
}
|
48
|
+
|
49
|
+
void
|
50
|
+
Application_call_device_disconnect (Application* app, Device* device)
|
51
|
+
{
|
52
|
+
DeviceEvent e(device);
|
53
|
+
app->on_device_disconnect(&e);
|
54
|
+
}
|
55
|
+
|
21
56
|
Application*
|
22
57
|
app ()
|
23
58
|
{
|
@@ -78,6 +113,41 @@ namespace Reflex
|
|
78
113
|
return Window_all().end();
|
79
114
|
}
|
80
115
|
|
116
|
+
void
|
117
|
+
Application::on_start (Event* e)
|
118
|
+
{
|
119
|
+
}
|
120
|
+
|
121
|
+
void
|
122
|
+
Application::on_quit (Event* e)
|
123
|
+
{
|
124
|
+
}
|
125
|
+
|
126
|
+
void
|
127
|
+
Application::on_device_connect (DeviceEvent* e)
|
128
|
+
{
|
129
|
+
}
|
130
|
+
|
131
|
+
void
|
132
|
+
Application::on_device_disconnect (DeviceEvent* e)
|
133
|
+
{
|
134
|
+
}
|
135
|
+
|
136
|
+
void
|
137
|
+
Application::on_motion (MotionEvent* e)
|
138
|
+
{
|
139
|
+
}
|
140
|
+
|
141
|
+
void
|
142
|
+
Application::on_preference (Event* e)
|
143
|
+
{
|
144
|
+
}
|
145
|
+
|
146
|
+
Application::operator bool () const
|
147
|
+
{
|
148
|
+
return true;
|
149
|
+
}
|
150
|
+
|
81
151
|
bool
|
82
152
|
Application::operator ! () const
|
83
153
|
{
|
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"
|
@@ -16,14 +17,14 @@ namespace Reflex
|
|
16
17
|
struct Event::Data
|
17
18
|
{
|
18
19
|
|
19
|
-
bool blocked;
|
20
|
-
|
21
20
|
double time;
|
22
21
|
|
22
|
+
bool blocked;
|
23
|
+
|
23
24
|
Data* parent = NULL;
|
24
25
|
|
25
|
-
Data (
|
26
|
-
:
|
26
|
+
Data (double time = -1, bool blocked = false)
|
27
|
+
: time(time >= 0 ? time : Xot::time()), blocked(blocked)
|
27
28
|
{
|
28
29
|
}
|
29
30
|
|
@@ -36,7 +37,8 @@ namespace Reflex
|
|
36
37
|
};// Event::Data
|
37
38
|
|
38
39
|
|
39
|
-
Event::Event ()
|
40
|
+
Event::Event (double time)
|
41
|
+
: self(new Data(time))
|
40
42
|
{
|
41
43
|
}
|
42
44
|
|
@@ -69,6 +71,43 @@ namespace Reflex
|
|
69
71
|
}
|
70
72
|
|
71
73
|
|
74
|
+
struct DeviceEvent::Data
|
75
|
+
{
|
76
|
+
|
77
|
+
Device::Ref device;
|
78
|
+
|
79
|
+
};// DeviceEvent::Data
|
80
|
+
|
81
|
+
|
82
|
+
DeviceEvent::DeviceEvent (Device* device)
|
83
|
+
{
|
84
|
+
if (device) self->device = device;
|
85
|
+
}
|
86
|
+
|
87
|
+
DeviceEvent::DeviceEvent (const DeviceEvent* src)
|
88
|
+
: Event(src), self(new Data(*src->self))
|
89
|
+
{
|
90
|
+
}
|
91
|
+
|
92
|
+
DeviceEvent
|
93
|
+
DeviceEvent::dup () const
|
94
|
+
{
|
95
|
+
return DeviceEvent(this);
|
96
|
+
}
|
97
|
+
|
98
|
+
Device*
|
99
|
+
DeviceEvent::device ()
|
100
|
+
{
|
101
|
+
return self->device;
|
102
|
+
}
|
103
|
+
|
104
|
+
const Device*
|
105
|
+
DeviceEvent::device () const
|
106
|
+
{
|
107
|
+
return self->device;
|
108
|
+
}
|
109
|
+
|
110
|
+
|
72
111
|
struct UpdateEvent::Data
|
73
112
|
{
|
74
113
|
|
@@ -524,8 +563,9 @@ namespace Reflex
|
|
524
563
|
}
|
525
564
|
|
526
565
|
KeyEvent::KeyEvent (
|
527
|
-
Action action, const char* chars, int code, uint modifiers, int repeat
|
528
|
-
|
566
|
+
Action action, const char* chars, int code, uint modifiers, int repeat,
|
567
|
+
double time)
|
568
|
+
: Event(time), self(new Data(action, chars, code, modifiers, repeat))
|
529
569
|
{
|
530
570
|
}
|
531
571
|
|
@@ -828,6 +868,92 @@ namespace Reflex
|
|
828
868
|
}
|
829
869
|
|
830
870
|
|
871
|
+
struct NoteEvent::Data
|
872
|
+
{
|
873
|
+
|
874
|
+
Action action = ACTION_NONE;
|
875
|
+
|
876
|
+
int channel = 0;
|
877
|
+
|
878
|
+
int note = 0;
|
879
|
+
|
880
|
+
float velocity = 0;
|
881
|
+
|
882
|
+
bool captured = false;
|
883
|
+
|
884
|
+
};// NoteEvent::Data
|
885
|
+
|
886
|
+
|
887
|
+
void
|
888
|
+
NoteEvent_set_captured (NoteEvent* pthis, bool captured)
|
889
|
+
{
|
890
|
+
pthis->self->captured = captured;
|
891
|
+
}
|
892
|
+
|
893
|
+
|
894
|
+
NoteEvent::NoteEvent ()
|
895
|
+
{
|
896
|
+
}
|
897
|
+
|
898
|
+
NoteEvent::NoteEvent (
|
899
|
+
Action action, int channel, int note, float velocity, double time)
|
900
|
+
: Event(time)
|
901
|
+
{
|
902
|
+
self->action = action;
|
903
|
+
self->channel = channel;
|
904
|
+
self->note = note;
|
905
|
+
self->velocity = velocity;
|
906
|
+
}
|
907
|
+
|
908
|
+
NoteEvent::NoteEvent (const NoteEvent* src)
|
909
|
+
: Event(src), self(new Data(*src->self))
|
910
|
+
{
|
911
|
+
}
|
912
|
+
|
913
|
+
NoteEvent
|
914
|
+
NoteEvent::dup () const
|
915
|
+
{
|
916
|
+
return NoteEvent(this);
|
917
|
+
}
|
918
|
+
|
919
|
+
NoteEvent::Action
|
920
|
+
NoteEvent::action () const
|
921
|
+
{
|
922
|
+
return self->action;
|
923
|
+
}
|
924
|
+
|
925
|
+
int
|
926
|
+
NoteEvent::channel () const
|
927
|
+
{
|
928
|
+
return self->channel;
|
929
|
+
}
|
930
|
+
|
931
|
+
int
|
932
|
+
NoteEvent::note () const
|
933
|
+
{
|
934
|
+
return self->note;
|
935
|
+
}
|
936
|
+
|
937
|
+
float
|
938
|
+
NoteEvent::frequency () const
|
939
|
+
{
|
940
|
+
static const int A4 = 69;
|
941
|
+
return 440 * std::pow(2.0, (note() - A4) / 12.0);
|
942
|
+
}
|
943
|
+
|
944
|
+
float
|
945
|
+
NoteEvent::velocity () const
|
946
|
+
{
|
947
|
+
return self->velocity;
|
948
|
+
}
|
949
|
+
|
950
|
+
bool
|
951
|
+
NoteEvent::is_captured () const
|
952
|
+
{
|
953
|
+
return self->captured;
|
954
|
+
}
|
955
|
+
|
956
|
+
|
831
957
|
struct CaptureEvent::Data
|
832
958
|
{
|
833
959
|
|
data/src/event.h
CHANGED
@@ -19,6 +19,8 @@ namespace Reflex
|
|
19
19
|
void DrawEvent_set_bounds (DrawEvent* pthis, const Bounds& bounds);
|
20
20
|
|
21
21
|
|
22
|
+
uint KeyEvent_get_modifiers ();
|
23
|
+
|
22
24
|
void KeyEvent_set_chars (KeyEvent* pthis, const char* chars);
|
23
25
|
|
24
26
|
void KeyEvent_set_captured (KeyEvent* pthis, bool captured);
|
@@ -47,6 +49,9 @@ namespace Reflex
|
|
47
49
|
void WheelEvent_set_position (WheelEvent* pthis, const Point& position);
|
48
50
|
|
49
51
|
|
52
|
+
void NoteEvent_set_captured (NoteEvent* pthis, bool captured);
|
53
|
+
|
54
|
+
|
50
55
|
}// Reflex
|
51
56
|
|
52
57
|
|