@@ -36,7 +36,7 @@ namespace Babylon::Plugins
3636 }
3737
3838 NativeInput::NativeInput (Napi::Env env)
39- : m_impl{ std::make_unique<Impl>(env) }
39+ : m_impl{std::make_unique<Impl>(env)}
4040 {
4141 Napi::Value nativeInput = Napi::External<NativeInput>::New (env, this , [](Napi::Env, NativeInput* nativeInput) { delete nativeInput; });
4242 env.Global ().Set (JS_NATIVE_INPUT_NAME, nativeInput);
@@ -110,7 +110,7 @@ namespace Babylon::Plugins
110110 POINTER_MOUSEWHEEL_Z_INDEX,
111111 POINTER_DELTA_HORIZONTAL_INDEX,
112112 POINTER_DELTA_VERTICAL_INDEX,
113- POINTER_MOVE_INDEX
113+ POINTER_MOVE_INDEX,
114114 });
115115 }
116116 }
@@ -153,14 +153,16 @@ namespace Babylon::Plugins
153153 void NativeInput::Impl::PointerDown (uint32_t pointerId, uint32_t buttonIndex, int32_t x, int32_t y, DeviceType deviceType)
154154 {
155155 m_runtimeScheduler ([pointerId, buttonIndex, x, y, deviceType, this ]() {
156- const uint32_t inputIndex{ GetPointerButtonInputIndex (buttonIndex) };
157- std::vector<int32_t >& deviceInputs{ GetOrCreateInputMap (deviceType, pointerId, {
158- inputIndex,
159- POINTER_X_INPUT_INDEX,
160- POINTER_Y_INPUT_INDEX,
161- POINTER_DELTA_HORIZONTAL_INDEX,
162- POINTER_DELTA_VERTICAL_INDEX
163- })};
156+ const uint32_t inputIndex{GetPointerButtonInputIndex (buttonIndex)};
157+ std::vector<int32_t >& deviceInputs{
158+ GetOrCreateInputMap (deviceType, pointerId,
159+ {
160+ inputIndex,
161+ POINTER_X_INPUT_INDEX,
162+ POINTER_Y_INPUT_INDEX,
163+ POINTER_DELTA_HORIZONTAL_INDEX,
164+ POINTER_DELTA_VERTICAL_INDEX,
165+ })};
164166
165167 // Record the x/y, but don't raise associated events (this matches the behavior in the browser).
166168 SetInputState (deviceType, pointerId, POINTER_DELTA_HORIZONTAL_INDEX, 0 , deviceInputs, false );
@@ -176,14 +178,16 @@ namespace Babylon::Plugins
176178 void NativeInput::Impl::PointerUp (uint32_t pointerId, uint32_t buttonIndex, int32_t x, int32_t y, DeviceType deviceType)
177179 {
178180 m_runtimeScheduler ([pointerId, buttonIndex, x, y, deviceType, this ]() {
179- const uint32_t inputIndex{ GetPointerButtonInputIndex (buttonIndex) };
180- std::vector<int32_t >& deviceInputs{ GetOrCreateInputMap (deviceType, pointerId, {
181- inputIndex,
182- POINTER_X_INPUT_INDEX,
183- POINTER_Y_INPUT_INDEX,
184- POINTER_DELTA_HORIZONTAL_INDEX,
185- POINTER_DELTA_VERTICAL_INDEX
186- })};
181+ const uint32_t inputIndex{GetPointerButtonInputIndex (buttonIndex)};
182+ std::vector<int32_t >& deviceInputs{
183+ GetOrCreateInputMap (deviceType, pointerId,
184+ {
185+ inputIndex,
186+ POINTER_X_INPUT_INDEX,
187+ POINTER_Y_INPUT_INDEX,
188+ POINTER_DELTA_HORIZONTAL_INDEX,
189+ POINTER_DELTA_VERTICAL_INDEX,
190+ })};
187191
188192 // Record the x/y, but don't raise associated events (this matches the behavior in the browser).
189193 SetInputState (deviceType, pointerId, POINTER_DELTA_HORIZONTAL_INDEX, 0 , deviceInputs, false );
@@ -208,13 +212,15 @@ namespace Babylon::Plugins
208212 void NativeInput::Impl::PointerMove (uint32_t pointerId, int32_t x, int32_t y, DeviceType deviceType)
209213 {
210214 m_runtimeScheduler ([pointerId, x, y, deviceType, this ]() {
211- std::vector<int32_t >& deviceInputs{GetOrCreateInputMap (deviceType, pointerId, {
212- POINTER_X_INPUT_INDEX,
213- POINTER_Y_INPUT_INDEX,
214- POINTER_DELTA_HORIZONTAL_INDEX,
215- POINTER_DELTA_VERTICAL_INDEX,
216- POINTER_MOVE_INDEX
217- })};
215+ std::vector<int32_t >& deviceInputs{
216+ GetOrCreateInputMap (deviceType, pointerId,
217+ {
218+ POINTER_X_INPUT_INDEX,
219+ POINTER_Y_INPUT_INDEX,
220+ POINTER_DELTA_HORIZONTAL_INDEX,
221+ POINTER_DELTA_VERTICAL_INDEX,
222+ POINTER_MOVE_INDEX,
223+ })};
218224 int32_t deltaX = 0 ;
219225 int32_t deltaY = 0 ;
220226
@@ -240,21 +246,19 @@ namespace Babylon::Plugins
240246 SetInputState (deviceType, pointerId, POINTER_DELTA_HORIZONTAL_INDEX, 0 , deviceInputs, false );
241247 SetInputState (deviceType, pointerId, POINTER_DELTA_VERTICAL_INDEX, 0 , deviceInputs, false );
242248 m_eventDispatcher.tick (arcana::cancellation::none ());
243-
244249 });
245250 }
246251
247252 void NativeInput::Impl::PointerScroll (uint32_t pointerId, uint32_t scrollAxis, int32_t scrollValue, DeviceType deviceType)
248253 {
249- m_runtimeScheduler ([pointerId, scrollAxis, scrollValue, deviceType, this ]()
250- {
251- std::vector<int32_t >& deviceInputs{GetOrCreateInputMap (deviceType, pointerId, {scrollAxis})};
252- SetInputState (deviceType, pointerId, scrollAxis, scrollValue, deviceInputs, true );
254+ m_runtimeScheduler ([pointerId, scrollAxis, scrollValue, deviceType, this ]() {
255+ std::vector<int32_t >& deviceInputs{GetOrCreateInputMap (deviceType, pointerId, {scrollAxis})};
256+ SetInputState (deviceType, pointerId, scrollAxis, scrollValue, deviceInputs, true );
253257
254- m_eventDispatcher.tick (arcana::cancellation::none ());
255- SetInputState (deviceType, pointerId, scrollAxis, 0 , deviceInputs, true );
256- m_eventDispatcher.tick (arcana::cancellation::none ());
257- });
258+ m_eventDispatcher.tick (arcana::cancellation::none ());
259+ SetInputState (deviceType, pointerId, scrollAxis, 0 , deviceInputs, true );
260+ m_eventDispatcher.tick (arcana::cancellation::none ());
261+ });
258262 }
259263
260264 NativeInput::Impl::DeviceStatusChangedCallbackTicket NativeInput::Impl::AddDeviceConnectedCallback (NativeInput::Impl::DeviceStatusChangedCallback&& callback)
@@ -265,15 +269,15 @@ namespace Babylon::Plugins
265269 callback (key.first , key.second );
266270 }
267271
268- return m_deviceConnectedCallbacks.insert (std::move (callback));
272+ return m_deviceConnectedCallbacks.insert (std::move (callback));
269273 }
270274
271275 NativeInput::Impl::DeviceStatusChangedCallbackTicket NativeInput::Impl::AddDeviceDisconnectedCallback (NativeInput::Impl::DeviceStatusChangedCallback&& callback)
272276 {
273277 return m_deviceDisconnectedCallbacks.insert (std::move (callback));
274278 }
275279
276- NativeInput::Impl::InputStateChangedCallbackTicket NativeInput::Impl::AddInputChangedCallback (NativeInput::Impl::InputStateChangedCallback && callback)
280+ NativeInput::Impl::InputStateChangedCallbackTicket NativeInput::Impl::AddInputChangedCallback (NativeInput::Impl::InputStateChangedCallback&& callback)
277281 {
278282 return m_inputChangedCallbacks.insert (std::move (callback));
279283 }
@@ -285,15 +289,15 @@ namespace Babylon::Plugins
285289 {
286290 std::ostringstream message;
287291 message << " Unable to find device of type " << static_cast <uint32_t >(deviceType) << " with slot " << deviceSlot;
288- throw std::runtime_error{ message.str () };
292+ throw std::runtime_error{message.str ()};
289293 }
290294
291295 const auto & device = it->second ;
292296 if (inputIndex >= device.size ())
293297 {
294298 std::ostringstream message;
295299 message << " Unable to find " << inputIndex << " on device of type " << static_cast <uint32_t >(deviceType) << " with slot " << deviceSlot;
296- throw std::runtime_error{ message.str () };
300+ throw std::runtime_error{message.str ()};
297301 }
298302
299303 return device.at (inputIndex);
@@ -331,7 +335,7 @@ namespace Babylon::Plugins
331335 if (m_inputs.erase ({deviceType, deviceSlot}))
332336 {
333337 m_eventDispatcher.queue ([this , deviceType, deviceSlot]() {
334- m_deviceDisconnectedCallbacks.apply_to_all ([deviceType, deviceSlot](auto & callback){
338+ m_deviceDisconnectedCallbacks.apply_to_all ([deviceType, deviceSlot](auto & callback) {
335339 callback (deviceType, deviceSlot);
336340 });
337341 });
0 commit comments