MCPcopy Create free account
hub / github.com/BabylonJS/BabylonNative / InputManager

Class InputManager

Apps/Playground/Shared/InputManager.h:8–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#include <functional>
7
8class InputManager final : public Napi::ObjectWrap<InputManager>
9{
10public:
11 class InputBuffer
12 {
13 public:
14 InputBuffer(Babylon::JsRuntime& runtime)
15 : m_runtime{ runtime }
16 {}
17 InputBuffer(const InputBuffer&) = delete;
18 InputBuffer& operator=(const InputBuffer&) = delete;
19
20 void SetPointerPosition(int x, int y)
21 {
22 m_runtime.Dispatch([x, y, this](Napi::Env)
23 {
24 m_pointerX = x;
25 m_pointerY = y;
26 });
27 }
28
29 void SetPointerDown(bool isPointerDown)
30 {
31 m_runtime.Dispatch([isPointerDown, this](Napi::Env)
32 {
33 m_isPointerDown = isPointerDown;
34 });
35 }
36
37 int GetPointerX() const
38 {
39 return m_pointerX;
40 }
41
42 int GetPointerY() const
43 {
44 return m_pointerY;
45 }
46
47 bool IsPointerDown() const
48 {
49 return m_isPointerDown;
50 }
51
52 private:
53 Babylon::JsRuntime& m_runtime;
54
55 int m_pointerX{};
56 int m_pointerY{};
57 bool m_isPointerDown{};
58 };
59
60 static void Initialize(Babylon::JsRuntime& runtime, InputBuffer& inputBuffer)
61 {
62 runtime.Dispatch([data = &inputBuffer](Napi::Env env)
63 {
64 Napi::HandleScope scope{ env };
65

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected