mirror of
https://github.com/radio95-rnt/rds95.git
synced 2026-02-27 04:43:52 +01:00
command parsing is moving to lua
This commit is contained in:
@@ -17,3 +17,10 @@ target_include_directories(rds95 PRIVATE ${LUA_INCLUDE_DIR})
|
|||||||
target_link_libraries(rds95 PRIVATE m pthread pulse pulse-simple inih ${LUA_LIBRARIES})
|
target_link_libraries(rds95 PRIVATE m pthread pulse pulse-simple inih ${LUA_LIBRARIES})
|
||||||
|
|
||||||
install(TARGETS rds95 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
install(TARGETS rds95 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||||
|
|
||||||
|
install(CODE
|
||||||
|
"
|
||||||
|
execute_process(COMMAND ${CMAKE_COMMAND} -E copy
|
||||||
|
\"${CMAKE_CURRENT_SOURCE_DIR}/src/command.lua\"
|
||||||
|
\"$ENV{HOME}/.rds95.command.lua\")
|
||||||
|
")
|
||||||
|
|||||||
15
src/command.lua
Normal file
15
src/command.lua
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
cmd_output = ""
|
||||||
|
|
||||||
|
if type(cmd) == "string" then
|
||||||
|
if cmd:sub(1, 3) == "PI=" then
|
||||||
|
local hex = cmd:sub(7)
|
||||||
|
local pi = tonumber(hex, 16)
|
||||||
|
|
||||||
|
if pi then
|
||||||
|
set_rds_pi(pi)
|
||||||
|
cmd_output = string.format("+", pi)
|
||||||
|
else
|
||||||
|
cmd_output = "Invalid hex PI"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -23,7 +23,7 @@ void run_lua(char *str, char *cmd_output) {
|
|||||||
int top = lua_gettop(L);
|
int top = lua_gettop(L);
|
||||||
|
|
||||||
char path[128];
|
char path[128];
|
||||||
snprintf(path, sizeof(path), "%s/.command95.lua", getenv("HOME"));
|
snprintf(path, sizeof(path), "%s/.rds95.command.lua", getenv("HOME"));
|
||||||
if (luaL_dofile(L, path) != LUA_OK) {
|
if (luaL_dofile(L, path) != LUA_OK) {
|
||||||
const char *err = lua_tostring(L, -1);
|
const char *err = lua_tostring(L, -1);
|
||||||
fprintf(stderr, "Lua error: %s\n", err);
|
fprintf(stderr, "Lua error: %s\n", err);
|
||||||
|
|||||||
Reference in New Issue
Block a user