From 71b46730394979ea528d152dbe884cc35c368759 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Wed, 17 Jan 2024 11:48:40 +1100 Subject: all screens basically working, but bluetooth is rough --- src/lua/lua_controls.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/lua/lua_controls.cpp (limited to 'src/lua/lua_controls.cpp') diff --git a/src/lua/lua_controls.cpp b/src/lua/lua_controls.cpp new file mode 100644 index 00000000..2da0ed11 --- /dev/null +++ b/src/lua/lua_controls.cpp @@ -0,0 +1,58 @@ +/* + * Copyright 2023 jacqueline + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#include "lua_controls.hpp" + +#include +#include + +#include "lua.hpp" + +#include "esp_log.h" +#include "lauxlib.h" +#include "lua.h" +#include "lvgl.h" + +#include "nvs.hpp" +#include "ui_events.hpp" + +namespace lua { + +[[maybe_unused]] static constexpr char kTag[] = "lua_controls"; + +static auto controls_schemes(lua_State* L) -> int { + lua_newtable(L); + + lua_pushliteral(L, "Buttons Only"); + lua_rawseti(L, -2, + static_cast(drivers::NvsStorage::InputModes::kButtonsOnly)); + + lua_pushliteral(L, "D-Pad"); + lua_rawseti( + L, -2, + static_cast(drivers::NvsStorage::InputModes::kDirectionalWheel)); + + lua_pushliteral(L, "Touchwheel"); + lua_rawseti( + L, -2, static_cast(drivers::NvsStorage::InputModes::kRotatingWheel)); + + return 1; +} + +static const struct luaL_Reg kControlsFuncs[] = {{"schemes", controls_schemes}, + {NULL, NULL}}; + +static auto lua_controls(lua_State* state) -> int { + luaL_newlib(state, kControlsFuncs); + return 1; +} + +auto RegisterControlsModule(lua_State* s) -> void { + luaL_requiref(s, "controls", lua_controls, true); + lua_pop(s, 1); +} + +} // namespace lua -- cgit v1.2.3