diff options
| author | cooljqln <cooljqln@noreply.codeberg.org> | 2024-05-03 04:48:17 +0000 |
|---|---|---|
| committer | cooljqln <cooljqln@noreply.codeberg.org> | 2024-05-03 04:48:17 +0000 |
| commit | 3ceb8025ee4330c177101ed30ec17dfb0002f41e (patch) | |
| tree | 58350210f15df7d00d967cac6f30eeceeb031a3c /src/tangara/lua/lua_controls.cpp | |
| parent | 964da15a0b84f8e5f00e8abac2f7dfda0bf60488 (diff) | |
| parent | 9fafd797a5504f458b5fcae4a1d28a68da936315 (diff) | |
| download | tangara-fw-3ceb8025ee4330c177101ed30ec17dfb0002f41e.tar.gz | |
Merge pull request 'Break dependency cycles with our components by merging co-dependent components together' (#68) from jqln/component-merge into main
Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/68
Diffstat (limited to 'src/tangara/lua/lua_controls.cpp')
| -rw-r--r-- | src/tangara/lua/lua_controls.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/tangara/lua/lua_controls.cpp b/src/tangara/lua/lua_controls.cpp new file mode 100644 index 00000000..baf40891 --- /dev/null +++ b/src/tangara/lua/lua_controls.cpp @@ -0,0 +1,58 @@ +/* + * Copyright 2023 jacqueline <me@jacqueline.id.au> + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#include "lua/lua_controls.hpp" + +#include <memory> +#include <string> + +#include "lua.hpp" + +#include "esp_log.h" +#include "lauxlib.h" +#include "lua.h" +#include "lvgl.h" + +#include "drivers/nvs.hpp" +#include "ui/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<int>(drivers::NvsStorage::InputModes::kButtonsOnly)); + + lua_pushliteral(L, "D-Pad"); + lua_rawseti( + L, -2, + static_cast<int>(drivers::NvsStorage::InputModes::kDirectionalWheel)); + + lua_pushliteral(L, "Touchwheel"); + lua_rawseti( + L, -2, static_cast<int>(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 |
