reflexion 0.3.3 → 0.3.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fecd1db4ed537d71ce28cfcfd6d6556e2a7d39c108db0bfff677155bdb399fb6
4
- data.tar.gz: 22ea1366244b563a0ea67db01b8b18c89a25e273f781c78f11bab186761f3b90
3
+ metadata.gz: 0d6d1b028ab65bd561deb01b032b0fc7ddb1d633f493fecf9c9407bc8321f568
4
+ data.tar.gz: 32f3da5338572a0ce044d64e7c8474f73dbb3d99d0813f86aa1ca0194a18e4c3
5
5
  SHA512:
6
- metadata.gz: 8d01aa555b6a680c53b4c88ac0a8eabca0beec42fe0db6a173e45d4d405f4baa4fa4c43e44ce57fdc24a86bb85dfedd7f103c5a5a250377e5a71992817b49060
7
- data.tar.gz: 706935d574fd567b9a597643f4797e93718baf1e8f8ef1fca2ae183982e6b6e50c9936dbe2ef5d7ca274f9221fc83e4814a9fa071f00413b1cc26b545c0bd971
6
+ metadata.gz: 6f44899a6ae5eaadd962a62c18c1d1dc1d70c5bdf5f09a71fa68ac829c318853a492e390188e7100391255a53b9f84276028d7038b31a5cd5b4b7b57a38bb715
7
+ data.tar.gz: 3dec2aa1ec50884e538b19b46066737cf6cdd3943fba0c4918e388d7be64d75dd4bab0dbd4c7a27989c197428ebcc0e6c093f76697dc1d83ef8ff4385c9b9d9d
@@ -256,6 +256,26 @@ VALUE get_key(VALUE self)
256
256
  CASE(LAUNCH_APP1): SYMBOL1(launch_app1);
257
257
  CASE(LAUNCH_APP2): SYMBOL1(launch_app2);
258
258
 
259
+ CASE(GAMEPAD_LEFT): SYMBOL1(gamepad_left);
260
+ CASE(GAMEPAD_RIGHT): SYMBOL1(gamepad_right);
261
+ CASE(GAMEPAD_UP): SYMBOL1(gamepad_up);
262
+ CASE(GAMEPAD_DOWN): SYMBOL1(gamepad_down);
263
+ CASE(GAMEPAD_A): SYMBOL1(gamepad_a);
264
+ CASE(GAMEPAD_B): SYMBOL1(gamepad_b);
265
+ CASE(GAMEPAD_X): SYMBOL1(gamepad_x);
266
+ CASE(GAMEPAD_Y): SYMBOL1(gamepad_y);
267
+ CASE(GAMEPAD_TRIGGER_LEFT): SYMBOL1(gamepad_trigger_left);
268
+ CASE(GAMEPAD_TRIGGER_RIGHT): SYMBOL1(gamepad_trigger_right);
269
+ CASE(GAMEPAD_SHOULDER_LEFT): SYMBOL1(gamepad_shoulder_left);
270
+ CASE(GAMEPAD_SHOULDER_RIGHT): SYMBOL1(gamepad_shoulder_right);
271
+ CASE(GAMEPAD_THUMB_LEFT): SYMBOL1(gamepad_thumb_left);
272
+ CASE(GAMEPAD_THUMB_RIGHT): SYMBOL1(gamepad_thumb_right);
273
+ CASE(GAMEPAD_HOME): SYMBOL1(gamepad_home);
274
+ CASE(GAMEPAD_MENU): SYMBOL1(gamepad_menu);
275
+ CASE(GAMEPAD_OPTION): SYMBOL1(gamepad_option);
276
+ CASE(GAMEPAD_START): SYMBOL1(gamepad_start);
277
+ CASE(GAMEPAD_SELECT): SYMBOL1(gamepad_select);
278
+
259
279
  #undef CASE
260
280
  #undef SYMBOL1
261
281
  #undef SYMBOL2
@@ -249,6 +249,29 @@ Init_reflex ()
249
249
  DEFINE_CONST(KEY_LAUNCH_APP1);
250
250
  DEFINE_CONST(KEY_LAUNCH_APP2);
251
251
 
252
+ DEFINE_CONST(KEY_GAMEPAD_LEFT);
253
+ DEFINE_CONST(KEY_GAMEPAD_RIGHT);
254
+ DEFINE_CONST(KEY_GAMEPAD_UP);
255
+ DEFINE_CONST(KEY_GAMEPAD_DOWN);
256
+
257
+ DEFINE_CONST(KEY_GAMEPAD_A);
258
+ DEFINE_CONST(KEY_GAMEPAD_B);
259
+ DEFINE_CONST(KEY_GAMEPAD_X);
260
+ DEFINE_CONST(KEY_GAMEPAD_Y);
261
+
262
+ DEFINE_CONST(KEY_GAMEPAD_SHOULDER_LEFT);
263
+ DEFINE_CONST(KEY_GAMEPAD_SHOULDER_RIGHT);
264
+ DEFINE_CONST(KEY_GAMEPAD_TRIGGER_LEFT);
265
+ DEFINE_CONST(KEY_GAMEPAD_TRIGGER_RIGHT);
266
+ DEFINE_CONST(KEY_GAMEPAD_THUMB_LEFT);
267
+ DEFINE_CONST(KEY_GAMEPAD_THUMB_RIGHT);
268
+
269
+ DEFINE_CONST(KEY_GAMEPAD_HOME);
270
+ DEFINE_CONST(KEY_GAMEPAD_MENU);
271
+ DEFINE_CONST(KEY_GAMEPAD_OPTION);
272
+ DEFINE_CONST(KEY_GAMEPAD_START);
273
+ DEFINE_CONST(KEY_GAMEPAD_SELECT);
274
+
252
275
  DEFINE_CONST(MOD_SHIFT);
253
276
  DEFINE_CONST(MOD_CONTROL);
254
277
  DEFINE_CONST(MOD_ALT);
@@ -0,0 +1,12 @@
1
+ ## Pull Requests Not Accepted 🚫
2
+
3
+ Thank you for your interest in contributing!
4
+ However, this repository does not accept pull requests directly.
5
+
6
+ ### Where to Contribute?
7
+
8
+ Please submit your changes to the [xord/all](https://github.com/xord/all) monorepo, which serves as the primary repository for all our main libraries.
9
+
10
+ For more details, please refer to our [contribution guidelines](../CONTRIBUTING.md).
11
+
12
+ Thanks for your understanding! 🙌
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,7 @@
1
+ # Contribution Guide
2
+
3
+ Thank you for your interest in contributing!
4
+ However, this repository does not accept pull requests.
5
+ Instead, please submit your changes to the [xord/all](https://github.com/xord/all) monorepo, which serves as the primary repository for all our main libraries.
6
+
7
+ For any questions, feel free to open an issue.
data/ChangeLog.md CHANGED
@@ -1,6 +1,27 @@
1
1
  # reflex ChangeLog
2
2
 
3
3
 
4
+ ## [v0.3.5] - 2025-03-24
5
+
6
+ - Add PULL_REQUEST_TEMPLATE.md
7
+ - Add CONTRIBUTING.md
8
+ - Handle gamepad events on macOS, iOS, and Win32
9
+ - Call activate/deactivate event for window on Win32
10
+ - Define constants for gamepad keys
11
+ - Delay removing child to avoid breaking child list looped on View_update_tree()
12
+
13
+ - Fix a crash caused by add/remove_child()
14
+
15
+
16
+ ## [v0.3.4] - 2025-03-07
17
+
18
+ - Captured key and pointer events can be blocked before being sent to the window and views
19
+ - Apply pixel<->meter scale to linear velocity and linear damping
20
+ - Call awake() after moving the view
21
+
22
+ - Fix an issue where capturing keys do not work
23
+
24
+
4
25
  ## [v0.3.3] - 2025-01-23
5
26
 
6
27
  - Remove dependence on the beeps library
data/README.md CHANGED
@@ -1,4 +1,48 @@
1
-
2
1
  # Reflex - A Graphical User Interface Tool Kit for Ruby.
3
2
 
4
- by xordog@gmail.com
3
+ ![License](https://img.shields.io/github/license/xord/reflex)
4
+ ![Build Status](https://github.com/xord/reflex/actions/workflows/test.yml/badge.svg)
5
+ ![Gem Version](https://badge.fury.io/rb/reflexion.svg)
6
+
7
+ ## ⚠️ Notice
8
+
9
+ This repository is a read-only mirror of our monorepo.
10
+ We do not accept pull requests or direct contributions here.
11
+
12
+ ### 🔄 Where to Contribute?
13
+
14
+ All development happens in our [xord/all](https://github.com/xord/all) monorepo, which contains all our main libraries.
15
+ If you'd like to contribute, please submit your changes there.
16
+
17
+ For more details, check out our [Contribution Guidelines](./CONTRIBUTING.md).
18
+
19
+ Thanks for your support! 🙌
20
+
21
+ ## 🚀 About
22
+
23
+ **Reflex** is a graphical user interface (GUI) toolkit for Ruby.
24
+
25
+ It is designed to help developers create intuitive and responsive user interfaces for their Ruby applications.
26
+ **Reflex** provides core components such as Window and View, making it easier to build the foundation of your GUI applications.
27
+
28
+ ## 📦 Installation
29
+
30
+ Add this line to your Gemfile:
31
+ ```ruby
32
+ $ gem 'reflexion'
33
+ ```
34
+
35
+ Then, install gem:
36
+ ```bash
37
+ $ bundle install
38
+ ```
39
+
40
+ Or install it directly:
41
+ ```bash
42
+ $ gem install reflexion
43
+ ```
44
+
45
+ ## 📜 License
46
+
47
+ **Reflex** is licensed under the MIT License.
48
+ See the [LICENSE](./LICENSE) file for details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.3.5
@@ -13,9 +13,9 @@ require 'reflex/extension'
13
13
  Xot::ExtConf.new Xot, Rucy, Rays, Reflex do
14
14
  setup do
15
15
  headers << 'ruby.h'
16
- libs.unshift 'gdi32', 'winmm', 'opengl32', 'glew32' if win32?
17
- frameworks << 'Cocoa' if osx?
18
- $LDFLAGS << ' -Wl,--out-implib=native.dll.a' if mingw? || cygwin?
16
+ libs.unshift 'gdi32', 'winmm', 'opengl32', 'glew32', 'xinput' if win32?
17
+ frameworks << 'Cocoa' << 'GameController' if osx?
18
+ $LDFLAGS << ' -Wl,--out-implib=native.dll.a' if mingw? || cygwin?
19
19
 
20
20
  unless osx?
21
21
  lib_dirs << Rays::Extension.ext_dir
@@ -260,6 +260,26 @@ RUCY_DEF0(get_key)
260
260
  CASE(LAUNCH_APP1): SYMBOL1(launch_app1);
261
261
  CASE(LAUNCH_APP2): SYMBOL1(launch_app2);
262
262
 
263
+ CASE(GAMEPAD_LEFT): SYMBOL1(gamepad_left);
264
+ CASE(GAMEPAD_RIGHT): SYMBOL1(gamepad_right);
265
+ CASE(GAMEPAD_UP): SYMBOL1(gamepad_up);
266
+ CASE(GAMEPAD_DOWN): SYMBOL1(gamepad_down);
267
+ CASE(GAMEPAD_A): SYMBOL1(gamepad_a);
268
+ CASE(GAMEPAD_B): SYMBOL1(gamepad_b);
269
+ CASE(GAMEPAD_X): SYMBOL1(gamepad_x);
270
+ CASE(GAMEPAD_Y): SYMBOL1(gamepad_y);
271
+ CASE(GAMEPAD_TRIGGER_LEFT): SYMBOL1(gamepad_trigger_left);
272
+ CASE(GAMEPAD_TRIGGER_RIGHT): SYMBOL1(gamepad_trigger_right);
273
+ CASE(GAMEPAD_SHOULDER_LEFT): SYMBOL1(gamepad_shoulder_left);
274
+ CASE(GAMEPAD_SHOULDER_RIGHT): SYMBOL1(gamepad_shoulder_right);
275
+ CASE(GAMEPAD_THUMB_LEFT): SYMBOL1(gamepad_thumb_left);
276
+ CASE(GAMEPAD_THUMB_RIGHT): SYMBOL1(gamepad_thumb_right);
277
+ CASE(GAMEPAD_HOME): SYMBOL1(gamepad_home);
278
+ CASE(GAMEPAD_MENU): SYMBOL1(gamepad_menu);
279
+ CASE(GAMEPAD_OPTION): SYMBOL1(gamepad_option);
280
+ CASE(GAMEPAD_START): SYMBOL1(gamepad_start);
281
+ CASE(GAMEPAD_SELECT): SYMBOL1(gamepad_select);
282
+
263
283
  #undef CASE
264
284
  #undef SYMBOL1
265
285
  #undef SYMBOL2
@@ -251,6 +251,29 @@ 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_SHOULDER_LEFT);
265
+ DEFINE_CONST(KEY_GAMEPAD_SHOULDER_RIGHT);
266
+ DEFINE_CONST(KEY_GAMEPAD_TRIGGER_LEFT);
267
+ DEFINE_CONST(KEY_GAMEPAD_TRIGGER_RIGHT);
268
+ DEFINE_CONST(KEY_GAMEPAD_THUMB_LEFT);
269
+ DEFINE_CONST(KEY_GAMEPAD_THUMB_RIGHT);
270
+
271
+ DEFINE_CONST(KEY_GAMEPAD_HOME);
272
+ DEFINE_CONST(KEY_GAMEPAD_MENU);
273
+ DEFINE_CONST(KEY_GAMEPAD_OPTION);
274
+ DEFINE_CONST(KEY_GAMEPAD_START);
275
+ DEFINE_CONST(KEY_GAMEPAD_SELECT);
276
+
254
277
  DEFINE_CONST(MOD_SHIFT);
255
278
  DEFINE_CONST(MOD_CONTROL);
256
279
  DEFINE_CONST(MOD_ALT);
@@ -277,6 +277,29 @@ namespace Reflex
277
277
 
278
278
  #undef NATIVE_VK
279
279
 
280
+ KEY_GAMEPAD_LEFT = 0x100,
281
+ KEY_GAMEPAD_RIGHT = 0x101,
282
+ KEY_GAMEPAD_UP = 0x102,
283
+ KEY_GAMEPAD_DOWN = 0x103,
284
+
285
+ KEY_GAMEPAD_A = 0x104,
286
+ KEY_GAMEPAD_B = 0x105,
287
+ KEY_GAMEPAD_X = 0x106,
288
+ KEY_GAMEPAD_Y = 0x107,
289
+
290
+ KEY_GAMEPAD_SHOULDER_LEFT = 0x108,
291
+ KEY_GAMEPAD_SHOULDER_RIGHT = 0x109,
292
+ KEY_GAMEPAD_TRIGGER_LEFT = 0x10A,
293
+ KEY_GAMEPAD_TRIGGER_RIGHT = 0x10B,
294
+ KEY_GAMEPAD_THUMB_LEFT = 0x10C,
295
+ KEY_GAMEPAD_THUMB_RIGHT = 0x10D,
296
+
297
+ KEY_GAMEPAD_HOME = 0x10E,
298
+ KEY_GAMEPAD_MENU = 0x10F,
299
+ KEY_GAMEPAD_OPTION = 0x110,
300
+ KEY_GAMEPAD_START = 0x111,
301
+ KEY_GAMEPAD_SELECT = 0x112,
302
+
280
303
  };// KeyCode
281
304
 
282
305
 
@@ -59,30 +59,30 @@ namespace Reflex
59
59
  enum Flag
60
60
  {
61
61
 
62
- FLAG_CLIP = Xot::bit(0),
62
+ FLAG_CLIP = Xot::bit(0),
63
63
 
64
- FLAG_CACHE = Xot::bit(1),
64
+ FLAG_CACHE = Xot::bit(1),
65
65
 
66
- FLAG_RESIZE_TO_FIT = Xot::bit(2),
66
+ FLAG_RESIZE_TO_FIT = Xot::bit(2),
67
67
 
68
- FLAG_SCROLL_TO_FIT = Xot::bit(3),
68
+ FLAG_SCROLL_TO_FIT = Xot::bit(3),
69
69
 
70
- FLAG_FIX_ANGLE = Xot::bit(4),
70
+ FLAG_FIX_ANGLE = Xot::bit(4),
71
71
 
72
- FLAG_LAST = FLAG_FIX_ANGLE
72
+ FLAG_LAST = FLAG_FIX_ANGLE
73
73
 
74
74
  };// Flag
75
75
 
76
76
  enum Capture
77
77
  {
78
78
 
79
- CAPTURE_NONE = 0,
79
+ CAPTURE_NONE = 0,
80
80
 
81
- CAPTURE_KEY = Xot::bit(0),
81
+ CAPTURE_KEY = Xot::bit(0),
82
82
 
83
- CAPTURE_POINTER = Xot::bit(1),
83
+ CAPTURE_POINTER = Xot::bit(1),
84
84
 
85
- CAPTURE_ALL = CAPTURE_KEY | CAPTURE_POINTER,
85
+ CAPTURE_ALL = CAPTURE_KEY | CAPTURE_POINTER,
86
86
 
87
87
  };// Capture
88
88
 
@@ -1,9 +1,9 @@
1
1
  require 'xot/setter'
2
2
  require 'xot/universal_accessor'
3
+ require 'xot/hookable'
3
4
  require 'xot/block_util'
4
5
  require 'xot/inspectable'
5
6
  require 'reflex/ext'
6
- require 'reflex/helper'
7
7
 
8
8
 
9
9
  module Reflex
@@ -12,8 +12,8 @@ module Reflex
12
12
  class Application
13
13
 
14
14
  include Xot::Setter
15
+ include Xot::Hookable
15
16
  include Xot::Inspectable
16
- include Hookable
17
17
 
18
18
  universal_accessor :name
19
19
 
data/lib/reflex/helper.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'xot/hookable'
2
1
  require 'xot/universal_accessor'
3
2
  require 'reflex/point'
4
3
  require 'reflex/bounds'
@@ -7,17 +6,6 @@ require 'reflex/bounds'
7
6
  module Reflex
8
7
 
9
8
 
10
- module Hookable
11
-
12
- include Xot::Hookable
13
-
14
- def hook(name, &block)
15
- super "on_#{name}".intern, &block
16
- end
17
-
18
- end# Hookable
19
-
20
-
21
9
  module HasFrame
22
10
 
23
11
  def move_to(*args)
data/lib/reflex/shape.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'xot/setter'
2
2
  require 'xot/universal_accessor'
3
+ require 'xot/hookable'
3
4
  require 'xot/block_util'
4
5
  require 'reflex/ext'
5
6
  require 'reflex/helper'
@@ -11,7 +12,7 @@ module Reflex
11
12
  class Shape
12
13
 
13
14
  include Xot::Setter
14
- include Hookable
15
+ include Xot::Hookable
15
16
  include HasFrame
16
17
  include HasTags
17
18
 
data/lib/reflex/view.rb CHANGED
@@ -2,6 +2,7 @@ require 'forwardable'
2
2
  require 'xot/setter'
3
3
  require 'xot/bit_flag_accessor'
4
4
  require 'xot/universal_accessor'
5
+ require 'xot/hookable'
5
6
  require 'xot/block_util'
6
7
  require 'reflex/ext'
7
8
  require 'reflex/selector'
@@ -16,7 +17,7 @@ module Reflex
16
17
  class View
17
18
 
18
19
  include Xot::Setter
19
- include Hookable
20
+ include Xot::Hookable
20
21
  include HasFrame
21
22
  include HasTags
22
23
 
@@ -98,8 +99,14 @@ module Reflex
98
99
  end
99
100
 
100
101
  def capturing?(*args)
101
- cap = capture
102
- args.all? {|type| cap.include? type}
102
+ args, cap = args.flatten, capture
103
+ if args.empty?
104
+ not cap.empty?
105
+ elsif args.include?(:all)
106
+ cap == [:key, :pointer]
107
+ else
108
+ args.all? {|type| cap.include? type}
109
+ end
103
110
  end
104
111
 
105
112
  def on_contact(e)
data/lib/reflex/window.rb CHANGED
@@ -2,6 +2,7 @@ require 'forwardable'
2
2
  require 'xot/setter'
3
3
  require 'xot/bit_flag_accessor'
4
4
  require 'xot/universal_accessor'
5
+ require 'xot/hookable'
5
6
  require 'xot/block_util'
6
7
  require 'xot/inspectable'
7
8
  require 'reflex/ext'
@@ -14,8 +15,8 @@ module Reflex
14
15
  class Window
15
16
 
16
17
  include Xot::Setter
18
+ include Xot::Hookable
17
19
  include Xot::Inspectable
18
- include Hookable
19
20
  include HasFrame
20
21
 
21
22
  extend Forwardable
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.3', '>= 0.3.3'
29
- s.add_dependency 'rucy', '~> 0.3.3', '>= 0.3.3'
30
- s.add_dependency 'rays', '~> 0.3.3', '>= 0.3.3'
28
+ s.add_dependency 'xot', '~> 0.3.5', '>= 0.3.5'
29
+ s.add_dependency 'rucy', '~> 0.3.5', '>= 0.3.5'
30
+ s.add_dependency 'rays', '~> 0.3.5', '>= 0.3.5'
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/body.cpp CHANGED
@@ -291,9 +291,7 @@ namespace Reflex
291
291
  assert(b2to && b2from);
292
292
 
293
293
  b2to->SetType( b2from->GetType());
294
- b2to->SetLinearVelocity( b2from->GetLinearVelocity());
295
294
  b2to->SetAngularVelocity(b2from->GetAngularVelocity());
296
- b2to->SetLinearDamping( b2from->GetLinearDamping());
297
295
  b2to->SetAngularDamping( b2from->GetAngularDamping());
298
296
  b2to->SetGravityScale( b2from->GetGravityScale());
299
297
  b2to->SetBullet( b2from->IsBullet());
@@ -301,12 +299,24 @@ namespace Reflex
301
299
  float ppm_to = to->self->ppm;
302
300
  float ppm_from = from.self->ppm;
303
301
  if (ppm_to == ppm_from)
304
- b2to->SetTransform(b2from->GetPosition(), b2from->GetAngle());
302
+ {
303
+ b2to->SetTransform( b2from->GetPosition(),
304
+ b2from->GetAngle());
305
+ b2to->SetLinearVelocity(b2from->GetLinearVelocity());
306
+ b2to->SetLinearDamping( b2from->GetLinearDamping());
307
+ }
305
308
  else
306
309
  {
307
- auto pos = b2from->GetPosition();
308
- pos *= ppm_from / ppm_to;
310
+ float scale = ppm_from / ppm_to;
311
+ auto pos = b2from->GetPosition();
312
+ auto vel = b2from->GetLinearVelocity();
313
+ auto damp = b2from->GetLinearDamping();
314
+ pos *= scale;
315
+ vel *= scale;
316
+ damp *= scale;
309
317
  b2to->SetTransform(pos, b2from->GetAngle());
318
+ b2to->SetLinearVelocity(vel);
319
+ b2to->SetLinearDamping(damp);
310
320
  }
311
321
  }
312
322
 
data/src/ios/event.h CHANGED
@@ -22,6 +22,11 @@ namespace Reflex
22
22
  };// NativePointerEvent
23
23
 
24
24
 
25
+ void init_game_controllers ();
26
+
27
+ void fin_game_controllers ();
28
+
29
+
25
30
  }// Reflex
26
31
 
27
32
 
data/src/ios/event.mm CHANGED
@@ -4,7 +4,8 @@
4
4
 
5
5
  #include <assert.h>
6
6
  #include <algorithm>
7
- #include "../pointer.h"
7
+ #import <GameController/GameController.h>
8
+ #include "window.h"
8
9
 
9
10
 
10
11
  namespace Reflex
@@ -98,4 +99,86 @@ namespace Reflex
98
99
  }
99
100
 
100
101
 
102
+ static void
103
+ call_gamepad_event (int code, bool pressed)
104
+ {
105
+ Window* win = Window_get_active();
106
+ if (!win) return;
107
+
108
+ auto action = pressed ? KeyEvent::DOWN : KeyEvent::UP;
109
+ KeyEvent e(action, NULL, code, 0, 0);
110
+ Window_call_key_event(win, &e);
111
+ }
112
+
113
+ static void
114
+ handle_gamepad_event (GCControllerButtonInput* input, int code)
115
+ {
116
+ [input setPressedChangedHandler:
117
+ ^(GCControllerButtonInput* button, float value, BOOL pressed) {
118
+ call_gamepad_event(code, pressed);
119
+ }];
120
+ }
121
+
122
+ static void
123
+ handle_gamepad_events (GCController* controller)
124
+ {
125
+ GCExtendedGamepad* gamepad = controller.extendedGamepad;
126
+ if (!gamepad) return;
127
+
128
+ handle_gamepad_event(gamepad.dpad.left, KEY_GAMEPAD_LEFT);
129
+ handle_gamepad_event(gamepad.dpad.right, KEY_GAMEPAD_RIGHT);
130
+ handle_gamepad_event(gamepad.dpad.up, KEY_GAMEPAD_UP);
131
+ handle_gamepad_event(gamepad.dpad.down, KEY_GAMEPAD_DOWN);
132
+
133
+ handle_gamepad_event(gamepad.buttonA, KEY_GAMEPAD_A);
134
+ handle_gamepad_event(gamepad.buttonB, KEY_GAMEPAD_B);
135
+ handle_gamepad_event(gamepad.buttonX, KEY_GAMEPAD_X);
136
+ handle_gamepad_event(gamepad.buttonY, KEY_GAMEPAD_Y);
137
+
138
+ handle_gamepad_event(gamepad. leftShoulder, KEY_GAMEPAD_SHOULDER_LEFT);
139
+ handle_gamepad_event(gamepad.rightShoulder, KEY_GAMEPAD_SHOULDER_RIGHT);
140
+ handle_gamepad_event(gamepad. leftTrigger, KEY_GAMEPAD_TRIGGER_LEFT);
141
+ handle_gamepad_event(gamepad.rightTrigger, KEY_GAMEPAD_TRIGGER_RIGHT);
142
+
143
+ if (@available(iOS 12.1, *))
144
+ {
145
+ handle_gamepad_event(gamepad. leftThumbstickButton, KEY_GAMEPAD_THUMB_LEFT);
146
+ handle_gamepad_event(gamepad.rightThumbstickButton, KEY_GAMEPAD_THUMB_RIGHT);
147
+ }
148
+
149
+ if (@available(iOS 13.0, *))
150
+ {
151
+ handle_gamepad_event(gamepad.buttonMenu, KEY_GAMEPAD_MENU);
152
+ handle_gamepad_event(gamepad.buttonOptions, KEY_GAMEPAD_OPTION);
153
+ }
154
+
155
+ if (@available(iOS 14.0, *))
156
+ handle_gamepad_event(gamepad.buttonHome, KEY_GAMEPAD_HOME);
157
+ }
158
+
159
+ static id game_controllers_observer = nil;
160
+
161
+ void
162
+ init_game_controllers ()
163
+ {
164
+ for (GCController* c in GCController.controllers)
165
+ handle_gamepad_events(c);
166
+
167
+ game_controllers_observer = [NSNotificationCenter.defaultCenter
168
+ addObserverForName: GCControllerDidConnectNotification
169
+ object: nil
170
+ queue: NSOperationQueue.mainQueue
171
+ usingBlock: ^(NSNotification* n) {handle_gamepad_events(n.object);}];
172
+ }
173
+
174
+ void
175
+ fin_game_controllers ()
176
+ {
177
+ if (!game_controllers_observer) return;
178
+
179
+ [NSNotificationCenter.defaultCenter
180
+ removeObserver: game_controllers_observer];
181
+ }
182
+
183
+
101
184
  };// Reflex
data/src/ios/reflex.mm CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
 
5
5
  #include "reflex/exception.h"
6
+ #include "event.h"
6
7
 
7
8
 
8
9
  namespace Reflex
@@ -24,6 +25,8 @@ namespace Reflex
24
25
  reflex_error(__FILE__, __LINE__, "already initialized.");
25
26
 
26
27
  global::pool = [[NSAutoreleasePool alloc] init];
28
+
29
+ init_game_controllers();
27
30
  }
28
31
 
29
32
  void
@@ -32,6 +35,8 @@ namespace Reflex
32
35
  if (!global::pool)
33
36
  reflex_error(__FILE__, __LINE__, "not initialized.");
34
37
 
38
+ fin_game_controllers();
39
+
35
40
  [global::pool release];
36
41
  global::pool = nil;
37
42
  }
@@ -369,13 +369,7 @@ ReflexViewController_get_show_fun ()
369
369
 
370
370
  ++update_count;
371
371
 
372
- double now = Xot::time();
373
- Reflex::UpdateEvent e(now, now - win->self->prev_time_update);
374
- win->self->prev_time_update = now;
375
-
376
- win->on_update(&e);
377
- if (!e.is_blocked())
378
- Reflex::View_update_tree(win->root(), e);
372
+ Window_call_update_event(win);
379
373
 
380
374
  if (win->self->redraw)
381
375
  {
data/src/osx/event.h CHANGED
@@ -53,6 +53,11 @@ namespace Reflex
53
53
  };// NativeWheelEvent
54
54
 
55
55
 
56
+ void init_game_controllers ();
57
+
58
+ void fin_game_controllers ();
59
+
60
+
56
61
  }// Reflex
57
62
 
58
63