@@ -59,19 +59,19 @@ static void ExecOp(const QueueOp& opt, bool additive = false)
5959
6060 switch (op)
6161 {
62- case INPUT_OP::MOUSE_POS:
62+ /* case INPUT_OP::MOUSE_POS:
6363 {
6464 auto& mousePos = std::get<InputMousePos>(payload);
6565
6666 if (additive)
6767 {
68- rgd->mouseX += mousePos.x ;
69- rgd->mouseY += mousePos.y ;
68+ rgd->mouseDeltaX += mousePos.x;
69+ rgd->mouseDeltaY += mousePos.y;
7070 }
7171 else
7272 {
73- rgd->mouseX = mousePos.x ;
74- rgd->mouseY = mousePos.y ;
73+ rgd->mouseDeltaX = mousePos.x;
74+ rgd->mouseDeltaY = mousePos.y;
7575 }
7676 break;
7777 }
@@ -100,7 +100,7 @@ static void ExecOp(const QueueOp& opt, bool additive = false)
100100 rgd->mouseButtons &= ~(1 << mouseButtonState.index);
101101 }
102102 break;
103- }
103+ }*/
104104 case INPUT_OP::KEY_STATE:
105105 {
106106 auto & keyState = std::get<InputKeyState>(payload);
@@ -193,25 +193,40 @@ static InitFunction initFunction([]()
193193 return CefV8Value::CreateBool (true );
194194 });
195195
196- nuiApp->AddV8Handler (" sendMousePos " , [](const CefV8ValueList& arguments, CefString& exception )
196+ nuiApp->AddV8Handler (" setRawMouseCapture " , [](const CefV8ValueList& arguments, CefString& exception )
197197 {
198- if (arguments.size () != 2 )
198+ if (arguments.size () != 1 )
199199 {
200- exception .FromString (fmt::sprintf (" Expected 2 arguments , got %d" , arguments.size ()));
200+ exception .FromString (fmt::sprintf (" Expected 1 argument , got %d" , arguments.size ()));
201201 return CefV8Value::CreateBool (false );
202202 }
203203
204- int x = arguments[0 ]->GetIntValue ();
205- int y = arguments[1 ]->GetIntValue ();
206-
207- rgd->mouseX = x;
208- rgd->mouseY = y;
209-
210- // ExecOrQueueOp({ INPUT_OP::MOUSE_POS, InputMousePos{ x, y } });
204+ rgd->useRawMouseCapture = arguments[0 ]->GetBoolValue ();
211205
212206 return CefV8Value::CreateBool (true );
213207 });
214208
209+ // nuiApp->AddV8Handler("sendMousePos", [](const CefV8ValueList& arguments, CefString& exception)
210+ // {
211+ // return CefV8Value::CreateBool(true);
212+
213+ // if (arguments.size() != 2)
214+ // {
215+ // exception.FromString(fmt::sprintf("Expected 2 arguments, got %d", arguments.size()));
216+ // return CefV8Value::CreateBool(false);
217+ // }
218+
219+ // int x = arguments[0]->GetIntValue();
220+ // int y = arguments[1]->GetIntValue();
221+
222+ // rgd->mouseDeltaX = x;
223+ // rgd->mouseDeltaY = y;
224+
225+ // //ExecOrQueueOp({ INPUT_OP::MOUSE_POS, InputMousePos{ x, y } });
226+
227+ // return CefV8Value::CreateBool(true);
228+ // });
229+
215230 nuiApp->AddV8Handler (" setMouseButtonState" , [](const CefV8ValueList& arguments, CefString& exception )
216231 {
217232 if (arguments.size () != 2 )
@@ -269,6 +284,27 @@ static InitFunction initFunction([]()
269284
270285 return CefV8Value::CreateBool (true );
271286 });
287+
288+ nuiApp->AddV8Handler (" setInputChar" , [](const CefV8ValueList& arguments, CefString& exception )
289+ {
290+ if (arguments.size () == 1 )
291+ {
292+ // "x", "X", "y", "Y"
293+ if (arguments[0 ]->IsString ())
294+ {
295+ auto charString = arguments[0 ]->GetStringValue ();
296+ rgd->inputChar = charString.c_str ()[0 ];
297+ }
298+ // big keys in JS are processed as "BackSpace", "Shift", "Alt", ... The charcode is sent instead in this case.
299+ else
300+ {
301+ auto charCode = arguments[0 ]->GetIntValue ();
302+ rgd->inputChar = (wchar_t )charCode;
303+ }
304+ }
305+
306+ return CefV8Value::CreateUndefined ();
307+ });
272308
273309 nuiApp->AddContextReleaseHandler ([](CefRefPtr<CefV8Context>)
274310 {
0 commit comments