MCPcopy Create free account
hub / github.com/The-Powder-Toy/The-Powder-Toy / pushGameControllerEvent

Function pushGameControllerEvent

src/lua/LuaScriptInterface.cpp:353–416  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351}
352
353static int pushGameControllerEvent(lua_State *L, const GameControllerEvent &event)
354{
355 if (auto *textInputEvent = std::get_if<TextInputEvent>(&event))
356 {
357 tpt_lua_pushString(L, textInputEvent->text);
358 return 1;
359 }
360 else if (auto *textEditingEvent = std::get_if<TextEditingEvent>(&event))
361 {
362 tpt_lua_pushString(L, textEditingEvent->text);
363 return 1;
364 }
365 else if (auto *keyPressEvent = std::get_if<KeyPressEvent>(&event))
366 {
367 lua_pushinteger(L, keyPressEvent->key);
368 lua_pushinteger(L, keyPressEvent->scan);
369 lua_pushboolean(L, keyPressEvent->repeat);
370 lua_pushboolean(L, keyPressEvent->shift);
371 lua_pushboolean(L, keyPressEvent->ctrl);
372 lua_pushboolean(L, keyPressEvent->alt);
373 return 6;
374 }
375 else if (auto *keyReleaseEvent = std::get_if<KeyReleaseEvent>(&event))
376 {
377 lua_pushinteger(L, keyReleaseEvent->key);
378 lua_pushinteger(L, keyReleaseEvent->scan);
379 lua_pushboolean(L, keyReleaseEvent->repeat);
380 lua_pushboolean(L, keyReleaseEvent->shift);
381 lua_pushboolean(L, keyReleaseEvent->ctrl);
382 lua_pushboolean(L, keyReleaseEvent->alt);
383 return 6;
384 }
385 else if (auto *mouseDownEvent = std::get_if<MouseDownEvent>(&event))
386 {
387 lua_pushinteger(L, mouseDownEvent->x);
388 lua_pushinteger(L, mouseDownEvent->y);
389 lua_pushinteger(L, mouseDownEvent->button);
390 return 3;
391 }
392 else if (auto *mouseUpEvent = std::get_if<MouseUpEvent>(&event))
393 {
394 lua_pushinteger(L, mouseUpEvent->x);
395 lua_pushinteger(L, mouseUpEvent->y);
396 lua_pushinteger(L, mouseUpEvent->button);
397 lua_pushinteger(L, mouseUpEvent->reason);
398 return 4;
399 }
400 else if (auto *mouseMoveEvent = std::get_if<MouseMoveEvent>(&event))
401 {
402 lua_pushinteger(L, mouseMoveEvent->x);
403 lua_pushinteger(L, mouseMoveEvent->y);
404 lua_pushinteger(L, mouseMoveEvent->dx);
405 lua_pushinteger(L, mouseMoveEvent->dy);
406 return 4;
407 }
408 else if (auto *mouseWheelEvent = std::get_if<MouseWheelEvent>(&event))
409 {
410 lua_pushinteger(L, mouseWheelEvent->x);

Callers 1

HandleEventMethod · 0.85

Calls 1

tpt_lua_pushStringFunction · 0.85

Tested by

no test coverage detected