reflexion 0.2.1 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.doc/ext/reflex/application.cpp +1 -1
- data/.doc/ext/reflex/capture_event.cpp +1 -1
- data/.doc/ext/reflex/contact_event.cpp +1 -1
- data/.doc/ext/reflex/draw_event.cpp +1 -1
- data/.doc/ext/reflex/ellipse_shape.cpp +1 -1
- data/.doc/ext/reflex/event.cpp +1 -1
- data/.doc/ext/reflex/filter.cpp +1 -1
- data/.doc/ext/reflex/focus_event.cpp +1 -1
- data/.doc/ext/reflex/frame_event.cpp +1 -1
- data/.doc/ext/reflex/image_view.cpp +1 -1
- data/.doc/ext/reflex/key_event.cpp +74 -69
- data/.doc/ext/reflex/line_shape.cpp +1 -1
- data/.doc/ext/reflex/motion_event.cpp +1 -1
- data/.doc/ext/reflex/pointer.cpp +1 -1
- data/.doc/ext/reflex/pointer_event.cpp +1 -1
- data/.doc/ext/reflex/polygon_shape.cpp +1 -1
- data/.doc/ext/reflex/rect_shape.cpp +1 -1
- data/.doc/ext/reflex/reflex.cpp +58 -50
- data/.doc/ext/reflex/screen.cpp +1 -1
- data/.doc/ext/reflex/scroll_event.cpp +1 -1
- data/.doc/ext/reflex/selector.cpp +2 -2
- data/.doc/ext/reflex/shape.cpp +1 -1
- data/.doc/ext/reflex/style.cpp +1 -1
- data/.doc/ext/reflex/style_length.cpp +2 -2
- data/.doc/ext/reflex/timer.cpp +1 -1
- data/.doc/ext/reflex/timer_event.cpp +1 -1
- data/.doc/ext/reflex/update_event.cpp +1 -1
- data/.doc/ext/reflex/view.cpp +1 -1
- data/.doc/ext/reflex/wheel_event.cpp +1 -1
- data/.doc/ext/reflex/window.cpp +1 -1
- data/.github/workflows/release-gem.yml +1 -1
- data/.github/workflows/test.yml +3 -0
- data/ChangeLog.md +5 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/ext/reflex/application.cpp +1 -1
- data/ext/reflex/capture_event.cpp +1 -1
- data/ext/reflex/contact_event.cpp +1 -1
- data/ext/reflex/defs.h +2 -0
- data/ext/reflex/draw_event.cpp +1 -1
- data/ext/reflex/ellipse_shape.cpp +1 -1
- data/ext/reflex/event.cpp +1 -1
- data/ext/reflex/extconf.rb +4 -4
- data/ext/reflex/filter.cpp +1 -1
- data/ext/reflex/focus_event.cpp +1 -1
- data/ext/reflex/frame_event.cpp +1 -1
- data/ext/reflex/image_view.cpp +1 -1
- data/ext/reflex/key_event.cpp +74 -69
- data/ext/reflex/line_shape.cpp +1 -1
- data/ext/reflex/motion_event.cpp +1 -1
- data/ext/reflex/pointer.cpp +1 -1
- data/ext/reflex/pointer_event.cpp +1 -1
- data/ext/reflex/polygon_shape.cpp +1 -1
- data/ext/reflex/rect_shape.cpp +1 -1
- data/ext/reflex/reflex.cpp +58 -50
- data/ext/reflex/screen.cpp +1 -1
- data/ext/reflex/scroll_event.cpp +1 -1
- data/ext/reflex/selector.cpp +2 -2
- data/ext/reflex/shape.cpp +1 -1
- data/ext/reflex/style.cpp +1 -1
- data/ext/reflex/style_length.cpp +2 -2
- data/ext/reflex/timer.cpp +1 -1
- data/ext/reflex/timer_event.cpp +1 -1
- data/ext/reflex/update_event.cpp +1 -1
- data/ext/reflex/view.cpp +1 -1
- data/ext/reflex/wheel_event.cpp +1 -1
- data/ext/reflex/window.cpp +1 -1
- data/include/reflex/defs.h +204 -187
- data/include/reflex/reflex.h +1 -0
- data/include/reflex/ruby/application.h +2 -2
- data/include/reflex/ruby/event.h +26 -26
- data/include/reflex/ruby/exception.h +3 -3
- data/include/reflex/ruby/filter.h +2 -2
- data/include/reflex/ruby/image_view.h +2 -2
- data/include/reflex/ruby/pointer.h +2 -2
- data/include/reflex/ruby/reflex.h +1 -1
- data/include/reflex/ruby/screen.h +2 -2
- data/include/reflex/ruby/selector.h +2 -2
- data/include/reflex/ruby/shape.h +10 -10
- data/include/reflex/ruby/style.h +4 -4
- data/include/reflex/ruby/timer.h +2 -2
- data/include/reflex/ruby/view.h +2 -2
- data/include/reflex/ruby/window.h +2 -2
- data/lib/reflex/extension.rb +4 -0
- data/reflex.gemspec +4 -4
- data/src/event.cpp +7 -3
- data/src/event.h +2 -0
- data/src/ios/event.mm +21 -27
- data/src/shape.cpp +2 -2
- data/src/view.cpp +1 -0
- data/src/win32/application.cpp +48 -35
- data/src/win32/device.cpp +18 -0
- data/src/win32/event.cpp +221 -0
- data/src/win32/event.h +50 -0
- data/src/win32/opengl.cpp +54 -27
- data/src/win32/opengl.h +15 -13
- data/src/win32/reflex.cpp +10 -16
- data/src/win32/screen.cpp +61 -0
- data/src/win32/screen.h +21 -0
- data/src/win32/window.cpp +445 -240
- data/src/window.cpp +1 -0
- data/test/test_window.rb +24 -21
- metadata +14 -11
- data/src/win32/defs.cpp +0 -303
- data/src/win32/defs.h +0 -34
@@ -9,14 +9,14 @@
|
|
9
9
|
#include <reflex/screen.h>
|
10
10
|
|
11
11
|
|
12
|
-
RUCY_DECLARE_VALUE_FROM_TO(Reflex::Screen)
|
12
|
+
RUCY_DECLARE_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::Screen)
|
13
13
|
|
14
14
|
|
15
15
|
namespace Reflex
|
16
16
|
{
|
17
17
|
|
18
18
|
|
19
|
-
Rucy::Class screen_class ();
|
19
|
+
REFLEX_EXPORT Rucy::Class screen_class ();
|
20
20
|
// class Reflex::Screen
|
21
21
|
|
22
22
|
|
@@ -9,14 +9,14 @@
|
|
9
9
|
#include <reflex/selector.h>
|
10
10
|
|
11
11
|
|
12
|
-
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Reflex::Selector)
|
12
|
+
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(REFLEX_EXPORT, Reflex::Selector)
|
13
13
|
|
14
14
|
|
15
15
|
namespace Reflex
|
16
16
|
{
|
17
17
|
|
18
18
|
|
19
|
-
Rucy::Class selector_class ();
|
19
|
+
REFLEX_EXPORT Rucy::Class selector_class ();
|
20
20
|
// class Reflex::Selector
|
21
21
|
|
22
22
|
|
data/include/reflex/ruby/shape.h
CHANGED
@@ -10,34 +10,34 @@
|
|
10
10
|
#include <reflex/ruby/event.h>
|
11
11
|
|
12
12
|
|
13
|
-
RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Reflex::Shape)
|
13
|
+
RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::Shape)
|
14
14
|
|
15
|
-
RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Reflex::PolygonShape)
|
15
|
+
RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::PolygonShape)
|
16
16
|
|
17
|
-
RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Reflex::LineShape)
|
17
|
+
RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::LineShape)
|
18
18
|
|
19
|
-
RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Reflex::RectShape)
|
19
|
+
RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::RectShape)
|
20
20
|
|
21
|
-
RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Reflex::EllipseShape)
|
21
|
+
RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::EllipseShape)
|
22
22
|
|
23
23
|
|
24
24
|
namespace Reflex
|
25
25
|
{
|
26
26
|
|
27
27
|
|
28
|
-
Rucy::Class shape_class ();
|
28
|
+
REFLEX_EXPORT Rucy::Class shape_class ();
|
29
29
|
// class Reflex::Shape
|
30
30
|
|
31
|
-
Rucy::Class polygon_shape_class ();
|
31
|
+
REFLEX_EXPORT Rucy::Class polygon_shape_class ();
|
32
32
|
// class Reflex::PolygonShape
|
33
33
|
|
34
|
-
Rucy::Class line_shape_class ();
|
34
|
+
REFLEX_EXPORT Rucy::Class line_shape_class ();
|
35
35
|
// class Reflex::LineShape
|
36
36
|
|
37
|
-
Rucy::Class rect_shape_class ();
|
37
|
+
REFLEX_EXPORT Rucy::Class rect_shape_class ();
|
38
38
|
// class Reflex::RectShape
|
39
39
|
|
40
|
-
Rucy::Class ellipse_shape_class ();
|
40
|
+
REFLEX_EXPORT Rucy::Class ellipse_shape_class ();
|
41
41
|
// class Reflex::EllipseShape
|
42
42
|
|
43
43
|
|
data/include/reflex/ruby/style.h
CHANGED
@@ -9,19 +9,19 @@
|
|
9
9
|
#include <reflex/style.h>
|
10
10
|
|
11
11
|
|
12
|
-
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Reflex::StyleLength)
|
12
|
+
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(REFLEX_EXPORT, Reflex::StyleLength)
|
13
13
|
|
14
|
-
RUCY_DECLARE_VALUE_FROM_TO(Reflex::Style)
|
14
|
+
RUCY_DECLARE_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::Style)
|
15
15
|
|
16
16
|
|
17
17
|
namespace Reflex
|
18
18
|
{
|
19
19
|
|
20
20
|
|
21
|
-
Rucy::Class style_length_class ();
|
21
|
+
REFLEX_EXPORT Rucy::Class style_length_class ();
|
22
22
|
// class Reflex::StyleLength
|
23
23
|
|
24
|
-
Rucy::Class style_class ();
|
24
|
+
REFLEX_EXPORT Rucy::Class style_class ();
|
25
25
|
// class Reflex::Style
|
26
26
|
|
27
27
|
|
data/include/reflex/ruby/timer.h
CHANGED
@@ -9,14 +9,14 @@
|
|
9
9
|
#include <reflex/timer.h>
|
10
10
|
|
11
11
|
|
12
|
-
RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Reflex::Timer)
|
12
|
+
RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::Timer)
|
13
13
|
|
14
14
|
|
15
15
|
namespace Reflex
|
16
16
|
{
|
17
17
|
|
18
18
|
|
19
|
-
Rucy::Class timer_class ();
|
19
|
+
REFLEX_EXPORT Rucy::Class timer_class ();
|
20
20
|
// class Reflex::Timer
|
21
21
|
|
22
22
|
|
data/include/reflex/ruby/view.h
CHANGED
@@ -10,14 +10,14 @@
|
|
10
10
|
#include <reflex/ruby/event.h>
|
11
11
|
|
12
12
|
|
13
|
-
RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Reflex::View)
|
13
|
+
RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::View)
|
14
14
|
|
15
15
|
|
16
16
|
namespace Reflex
|
17
17
|
{
|
18
18
|
|
19
19
|
|
20
|
-
Rucy::Class view_class ();
|
20
|
+
REFLEX_EXPORT Rucy::Class view_class ();
|
21
21
|
// class Reflex::View
|
22
22
|
|
23
23
|
|
@@ -10,14 +10,14 @@
|
|
10
10
|
#include <reflex/ruby/event.h>
|
11
11
|
|
12
12
|
|
13
|
-
RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Reflex::Window)
|
13
|
+
RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::Window)
|
14
14
|
|
15
15
|
|
16
16
|
namespace Reflex
|
17
17
|
{
|
18
18
|
|
19
19
|
|
20
|
-
Rucy::Class window_class ();
|
20
|
+
REFLEX_EXPORT Rucy::Class window_class ();
|
21
21
|
// class Reflex::Window
|
22
22
|
|
23
23
|
|
data/lib/reflex/extension.rb
CHANGED
data/reflex.gemspec
CHANGED
@@ -25,10 +25,10 @@ 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_runtime_dependency 'xot', '~> 0.
|
29
|
-
s.add_runtime_dependency 'rucy', '~> 0.
|
30
|
-
s.add_runtime_dependency 'beeps', '~> 0.
|
31
|
-
s.add_runtime_dependency 'rays', '~> 0.
|
28
|
+
s.add_runtime_dependency 'xot', '~> 0.3'
|
29
|
+
s.add_runtime_dependency 'rucy', '~> 0.3'
|
30
|
+
s.add_runtime_dependency 'beeps', '~> 0.3'
|
31
|
+
s.add_runtime_dependency 'rays', '~> 0.3'
|
32
32
|
|
33
33
|
s.files = `git ls-files`.split $/
|
34
34
|
s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
|
data/src/event.cpp
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#include "event.h"
|
2
2
|
|
3
3
|
|
4
|
+
#include <algorithm>
|
4
5
|
#include "reflex/timer.h"
|
5
6
|
#include "reflex/shape.h"
|
6
7
|
#include "reflex/exception.h"
|
@@ -506,11 +507,14 @@ namespace Reflex
|
|
506
507
|
|
507
508
|
|
508
509
|
void
|
509
|
-
|
510
|
+
KeyEvent_set_chars (KeyEvent* pthis, const char* chars)
|
510
511
|
{
|
511
|
-
|
512
|
-
|
512
|
+
pthis->self->chars = chars ? chars : "";
|
513
|
+
}
|
513
514
|
|
515
|
+
void
|
516
|
+
KeyEvent_set_captured (KeyEvent* pthis, bool captured)
|
517
|
+
{
|
514
518
|
pthis->self->captured = captured;
|
515
519
|
}
|
516
520
|
|
data/src/event.h
CHANGED
data/src/ios/event.mm
CHANGED
@@ -69,38 +69,32 @@ namespace Reflex
|
|
69
69
|
(flags & UIKeyModifierNumericPad) ? MOD_NUMPAD : 0;
|
70
70
|
}
|
71
71
|
|
72
|
-
static Pointer
|
73
|
-
create_pointer (UITouch* touch, UIEvent* event, UIView* view)
|
74
|
-
{
|
75
|
-
Pointer::Action action = get_action(touch);
|
76
|
-
|
77
|
-
Pointer pointer(
|
78
|
-
0,
|
79
|
-
get_type(touch),
|
80
|
-
action,
|
81
|
-
to_point([touch locationInView: view]),
|
82
|
-
get_modifiers(event),
|
83
|
-
action == Pointer::MOVE,
|
84
|
-
(uint) touch.tapCount,
|
85
|
-
0,
|
86
|
-
touch.timestamp);
|
87
|
-
|
88
|
-
if (touch.phase != UITouchPhaseBegan)
|
89
|
-
{
|
90
|
-
Pointer_set_prev_position(
|
91
|
-
&pointer, to_point([touch previousLocationInView: view]));
|
92
|
-
}
|
93
|
-
|
94
|
-
return pointer;
|
95
|
-
}
|
96
|
-
|
97
72
|
NativePointerEvent::NativePointerEvent (
|
98
73
|
NSSet* touches, UIEvent* event, UIView* view)
|
99
74
|
{
|
100
75
|
for (UITouch* touch in touches)
|
101
76
|
{
|
102
|
-
Pointer
|
103
|
-
|
77
|
+
Pointer::Action action = get_action(touch);
|
78
|
+
|
79
|
+
Pointer pointer(
|
80
|
+
0,
|
81
|
+
get_type(touch),
|
82
|
+
action,
|
83
|
+
to_point([touch locationInView: view]),
|
84
|
+
get_modifiers(event),
|
85
|
+
action == Pointer::MOVE,
|
86
|
+
(uint) touch.tapCount,
|
87
|
+
0,
|
88
|
+
touch.timestamp);
|
89
|
+
|
90
|
+
if (pointer.action() != Pointer::DOWN)
|
91
|
+
{
|
92
|
+
Pointer_set_prev_position(
|
93
|
+
&pointer, to_point([touch previousLocationInView: view]));
|
94
|
+
}
|
95
|
+
|
96
|
+
if (pointer)
|
97
|
+
PointerEvent_add_pointer(this, pointer);
|
104
98
|
}
|
105
99
|
}
|
106
100
|
|
data/src/shape.cpp
CHANGED
@@ -1024,8 +1024,8 @@ namespace Reflex
|
|
1024
1024
|
bool has_angle () const
|
1025
1025
|
{
|
1026
1026
|
return
|
1027
|
-
angle_from != DEFAULT_ANGLE_FROM ||
|
1028
|
-
angle_to != DEFAULT_ANGLE_TO;
|
1027
|
+
angle_from != (float) DEFAULT_ANGLE_FROM ||
|
1028
|
+
angle_to != (float) DEFAULT_ANGLE_TO;
|
1029
1029
|
}
|
1030
1030
|
|
1031
1031
|
Fixture* create_fixtures (Shape* shape) override
|
data/src/view.cpp
CHANGED
data/src/win32/application.cpp
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#include "reflex/application.h"
|
2
2
|
|
3
3
|
|
4
|
-
#include <windows.h>
|
4
|
+
#include <xot/windows.h>
|
5
5
|
#include "reflex/exception.h"
|
6
6
|
|
7
7
|
|
@@ -9,13 +9,18 @@ namespace Reflex
|
|
9
9
|
{
|
10
10
|
|
11
11
|
|
12
|
-
|
12
|
+
namespace global
|
13
|
+
{
|
14
|
+
|
15
|
+
static Application* instance = NULL;
|
16
|
+
|
17
|
+
}// global
|
13
18
|
|
14
19
|
|
15
20
|
Application*
|
16
21
|
app ()
|
17
22
|
{
|
18
|
-
return instance;
|
23
|
+
return global::instance;
|
19
24
|
}
|
20
25
|
|
21
26
|
|
@@ -24,30 +29,27 @@ namespace Reflex
|
|
24
29
|
|
25
30
|
String name;
|
26
31
|
|
27
|
-
operator bool () const
|
28
|
-
{
|
29
|
-
return true;
|
30
|
-
}
|
31
|
-
|
32
32
|
};// Application::Data
|
33
33
|
|
34
34
|
|
35
35
|
Application::Application ()
|
36
36
|
{
|
37
|
-
if (instance)
|
37
|
+
if (global::instance)
|
38
|
+
reflex_error(__FILE__, __LINE__, "multiple application instances.");
|
38
39
|
|
39
|
-
instance = this;
|
40
|
+
global::instance = this;
|
40
41
|
}
|
41
42
|
|
42
43
|
Application::~Application ()
|
43
44
|
{
|
44
|
-
instance = NULL;
|
45
|
+
global::instance = NULL;
|
45
46
|
}
|
46
47
|
|
47
|
-
|
48
|
-
Application::
|
48
|
+
void
|
49
|
+
Application::start ()
|
49
50
|
{
|
50
|
-
|
51
|
+
Event e;
|
52
|
+
on_start(&e);
|
51
53
|
|
52
54
|
MSG msg;
|
53
55
|
while (GetMessage(&msg, NULL, 0, 0))
|
@@ -56,48 +58,59 @@ namespace Reflex
|
|
56
58
|
DispatchMessage(&msg);
|
57
59
|
}
|
58
60
|
|
59
|
-
|
61
|
+
if (msg.wParam != 0)
|
62
|
+
reflex_error(__FILE__, __LINE__, "WM_QUIT with wParam %d.", msg.wParam);
|
60
63
|
}
|
61
64
|
|
62
|
-
|
65
|
+
void
|
63
66
|
Application::quit ()
|
64
67
|
{
|
65
|
-
if (!*this) return false;
|
66
|
-
|
67
68
|
PostQuitMessage(0);
|
68
|
-
return true;
|
69
69
|
}
|
70
70
|
|
71
|
-
|
72
|
-
Application::
|
71
|
+
void
|
72
|
+
Application::set_name (const char* name)
|
73
73
|
{
|
74
|
-
|
74
|
+
if (!name)
|
75
|
+
argument_error(__FILE__, __LINE__);
|
76
|
+
|
77
|
+
self->name = name;
|
75
78
|
}
|
76
79
|
|
77
|
-
|
78
|
-
Application::
|
80
|
+
const char*
|
81
|
+
Application::name () const
|
79
82
|
{
|
80
|
-
return
|
83
|
+
return self->name.c_str();
|
81
84
|
}
|
82
85
|
|
83
|
-
|
84
|
-
Application::
|
86
|
+
void
|
87
|
+
Application::on_start (Event* e)
|
85
88
|
{
|
86
|
-
if (!*this || !name) return false;
|
87
|
-
self->name = name;
|
88
|
-
return true;
|
89
89
|
}
|
90
90
|
|
91
|
-
|
92
|
-
Application::
|
91
|
+
void
|
92
|
+
Application::on_quit (Event* e)
|
93
|
+
{
|
94
|
+
}
|
95
|
+
|
96
|
+
void
|
97
|
+
Application::on_motion (MotionEvent* e)
|
98
|
+
{
|
99
|
+
}
|
100
|
+
|
101
|
+
void
|
102
|
+
Application::on_preference (Event* e)
|
103
|
+
{
|
104
|
+
}
|
105
|
+
|
106
|
+
void
|
107
|
+
Application::on_about (Event* e)
|
93
108
|
{
|
94
|
-
if (!*this) return "";
|
95
|
-
return self->name.c_str();
|
96
109
|
}
|
97
110
|
|
98
111
|
Application::operator bool () const
|
99
112
|
{
|
100
|
-
return
|
113
|
+
return true;
|
101
114
|
}
|
102
115
|
|
103
116
|
bool
|
data/src/win32/event.cpp
ADDED
@@ -0,0 +1,221 @@
|
|
1
|
+
#include "event.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include <xot/time.h>
|
5
|
+
#include "reflex/exception.h"
|
6
|
+
#include "../pointer.h"
|
7
|
+
|
8
|
+
|
9
|
+
namespace Reflex
|
10
|
+
{
|
11
|
+
|
12
|
+
|
13
|
+
static uint
|
14
|
+
get_modifiers ()
|
15
|
+
{
|
16
|
+
return
|
17
|
+
(GetKeyState(VK_SHIFT) & 0x8000 ? MOD_SHIFT : 0) |
|
18
|
+
(GetKeyState(VK_CONTROL) & 0x8000 ? MOD_CONTROL : 0) |
|
19
|
+
(GetKeyState(VK_MENU) & 0x8000 ? MOD_ALT : 0) |
|
20
|
+
(GetKeyState(VK_LWIN) & 0x8000 ? MOD_WIN : 0) |
|
21
|
+
(GetKeyState(VK_RWIN) & 0x8000 ? MOD_WIN : 0);
|
22
|
+
}
|
23
|
+
|
24
|
+
|
25
|
+
static KeyEvent::Action
|
26
|
+
get_key_action (UINT msg)
|
27
|
+
{
|
28
|
+
switch (msg)
|
29
|
+
{
|
30
|
+
case WM_KEYDOWN:
|
31
|
+
case WM_SYSKEYDOWN: return KeyEvent::DOWN;
|
32
|
+
case WM_KEYUP:
|
33
|
+
case WM_SYSKEYUP: return KeyEvent::UP;
|
34
|
+
default: argument_error(__FILE__, __LINE__);
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
NativeKeyEvent::NativeKeyEvent (UINT msg, WPARAM wp, LPARAM lp, const char* chars)
|
39
|
+
: KeyEvent(get_key_action(msg), chars, (int) wp, get_modifiers(), lp & 0xFF)
|
40
|
+
{
|
41
|
+
}
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
static uint
|
46
|
+
get_mouse_type (UINT msg, WPARAM wp)
|
47
|
+
{
|
48
|
+
uint type = Reflex::Pointer::TYPE_NONE;
|
49
|
+
|
50
|
+
switch (msg)
|
51
|
+
{
|
52
|
+
case WM_LBUTTONDOWN:
|
53
|
+
case WM_LBUTTONDBLCLK:
|
54
|
+
case WM_LBUTTONUP:
|
55
|
+
type |= Reflex::Pointer::MOUSE | Reflex::Pointer::MOUSE_LEFT;
|
56
|
+
break;
|
57
|
+
|
58
|
+
case WM_RBUTTONDOWN:
|
59
|
+
case WM_RBUTTONDBLCLK:
|
60
|
+
case WM_RBUTTONUP:
|
61
|
+
type |= Reflex::Pointer::MOUSE | Reflex::Pointer::MOUSE_RIGHT;
|
62
|
+
break;
|
63
|
+
|
64
|
+
case WM_MBUTTONDOWN:
|
65
|
+
case WM_MBUTTONDBLCLK:
|
66
|
+
case WM_MBUTTONUP:
|
67
|
+
type |= Reflex::Pointer::MOUSE | Reflex::Pointer::MOUSE_MIDDLE;
|
68
|
+
break;
|
69
|
+
|
70
|
+
case WM_MOUSEMOVE:
|
71
|
+
type |= Reflex::Pointer::MOUSE;
|
72
|
+
break;
|
73
|
+
}
|
74
|
+
|
75
|
+
return type;
|
76
|
+
}
|
77
|
+
|
78
|
+
static Reflex::Pointer::Action
|
79
|
+
get_mouse_action (UINT msg)
|
80
|
+
{
|
81
|
+
switch (msg)
|
82
|
+
{
|
83
|
+
case WM_LBUTTONDOWN:
|
84
|
+
case WM_RBUTTONDOWN:
|
85
|
+
case WM_MBUTTONDOWN:
|
86
|
+
case WM_LBUTTONDBLCLK:
|
87
|
+
case WM_RBUTTONDBLCLK:
|
88
|
+
case WM_MBUTTONDBLCLK:
|
89
|
+
return Reflex::Pointer::DOWN;
|
90
|
+
|
91
|
+
case WM_LBUTTONUP:
|
92
|
+
case WM_RBUTTONUP:
|
93
|
+
case WM_MBUTTONUP:
|
94
|
+
return Reflex::Pointer::UP;
|
95
|
+
|
96
|
+
case WM_MOUSEMOVE:
|
97
|
+
return Reflex::Pointer::MOVE;
|
98
|
+
|
99
|
+
default:
|
100
|
+
return Reflex::Pointer::ACTION_NONE;
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
static bool
|
105
|
+
is_mouse_dragging (UINT msg, WPARAM wp)
|
106
|
+
{
|
107
|
+
return msg == WM_MOUSEMOVE && wp & (MK_LBUTTON | MK_RBUTTON | MK_MBUTTON);
|
108
|
+
}
|
109
|
+
|
110
|
+
static int
|
111
|
+
get_mouse_click_count (UINT msg)
|
112
|
+
{
|
113
|
+
switch (msg)
|
114
|
+
{
|
115
|
+
case WM_LBUTTONDOWN:
|
116
|
+
case WM_RBUTTONDOWN:
|
117
|
+
case WM_MBUTTONDOWN:
|
118
|
+
return 1;
|
119
|
+
|
120
|
+
case WM_LBUTTONDBLCLK:
|
121
|
+
case WM_RBUTTONDBLCLK:
|
122
|
+
case WM_MBUTTONDBLCLK:
|
123
|
+
return 2;
|
124
|
+
|
125
|
+
default:
|
126
|
+
return 0;
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
130
|
+
NativePointerEvent::NativePointerEvent (UINT msg, WPARAM wp, LPARAM lp)
|
131
|
+
{
|
132
|
+
PointerEvent_add_pointer(this, Pointer(
|
133
|
+
0,
|
134
|
+
get_mouse_type(msg, wp),
|
135
|
+
get_mouse_action(msg),
|
136
|
+
Point(GET_X_LPARAM(lp), GET_Y_LPARAM(lp)),
|
137
|
+
get_modifiers(),
|
138
|
+
is_mouse_dragging(msg, wp),
|
139
|
+
get_mouse_click_count(msg),
|
140
|
+
0,
|
141
|
+
Xot::time()));
|
142
|
+
}
|
143
|
+
|
144
|
+
static uint
|
145
|
+
get_touch_type (const TOUCHINPUT& touch)
|
146
|
+
{
|
147
|
+
if (touch.dwFlags & TOUCHEVENTF_PEN) return Pointer::PEN;
|
148
|
+
if (touch.dwFlags & TOUCHEVENTF_PALM) return Pointer::TYPE_NONE;
|
149
|
+
else return Pointer::TOUCH;
|
150
|
+
}
|
151
|
+
|
152
|
+
static Pointer::Action
|
153
|
+
get_touch_action (const TOUCHINPUT& touch)
|
154
|
+
{
|
155
|
+
if (touch.dwFlags & TOUCHEVENTF_DOWN) return Pointer::DOWN;
|
156
|
+
if (touch.dwFlags & TOUCHEVENTF_UP) return Pointer::UP;
|
157
|
+
if (touch.dwFlags & TOUCHEVENTF_MOVE) return Pointer::MOVE;
|
158
|
+
else return Pointer::ACTION_NONE;
|
159
|
+
}
|
160
|
+
|
161
|
+
static Point
|
162
|
+
get_touch_position (HWND hwnd, const TOUCHINPUT& touch)
|
163
|
+
{
|
164
|
+
coord x = (coord) touch.x / 100;
|
165
|
+
coord y = (coord) touch.y / 100;
|
166
|
+
|
167
|
+
POINT point = {0, 0};
|
168
|
+
if (ClientToScreen(hwnd, &point))
|
169
|
+
{
|
170
|
+
x -= point.x;
|
171
|
+
y -= point.y;
|
172
|
+
}
|
173
|
+
|
174
|
+
return Point(x, y);
|
175
|
+
}
|
176
|
+
|
177
|
+
static double
|
178
|
+
get_touch_time (const TOUCHINPUT& touch)
|
179
|
+
{
|
180
|
+
//if (touch.dwFlags & TOUCHINPUTMASKF_TIMEFROMSYSTEM)
|
181
|
+
// return (double) touch.dwTime / 1000.0;
|
182
|
+
|
183
|
+
return Xot::time();
|
184
|
+
}
|
185
|
+
|
186
|
+
NativePointerEvent::NativePointerEvent (
|
187
|
+
HWND hwnd, const TOUCHINPUT* touches, size_t size)
|
188
|
+
{
|
189
|
+
for (size_t i = 0; i < size; ++i)
|
190
|
+
{
|
191
|
+
const TOUCHINPUT& touch = touches[i];
|
192
|
+
Pointer::Action action = get_touch_action(touch);
|
193
|
+
|
194
|
+
Pointer pointer(
|
195
|
+
0,
|
196
|
+
get_touch_type(touch),
|
197
|
+
action,
|
198
|
+
get_touch_position(hwnd, touch),
|
199
|
+
get_modifiers(),
|
200
|
+
action == Pointer::MOVE,
|
201
|
+
action == Pointer::DOWN ? 1 : 0,
|
202
|
+
0,
|
203
|
+
get_touch_time(touch));
|
204
|
+
Pointer_set_system_id(&pointer, touch.dwID);
|
205
|
+
|
206
|
+
if (pointer)
|
207
|
+
PointerEvent_add_pointer(this, pointer);
|
208
|
+
}
|
209
|
+
}
|
210
|
+
|
211
|
+
|
212
|
+
NativeWheelEvent::NativeWheelEvent (WPARAM wp_x, WPARAM wp_y, LPARAM lp)
|
213
|
+
: WheelEvent(
|
214
|
+
GET_X_LPARAM(lp), GET_Y_LPARAM(lp), 0,
|
215
|
+
GET_WHEEL_DELTA_WPARAM(wp_x), -GET_WHEEL_DELTA_WPARAM(wp_y), 0,
|
216
|
+
get_modifiers())
|
217
|
+
{
|
218
|
+
}
|
219
|
+
|
220
|
+
|
221
|
+
}// Reflex
|