feat: Implement gamepad support and audio control enhancements in input and audio services

This commit is contained in:
2026-01-05 06:32:34 +00:00
parent e7737c60f9
commit 5548d3b3ce
10 changed files with 406 additions and 185 deletions

View File

@@ -159,6 +159,7 @@ void ScriptEngineService::RegisterBindings(lua_State* L) {
bind("glm_matrix_from_transform", &ScriptEngineService::GlmMatrixFromTransform);
bind("audio_play_background", &ScriptEngineService::AudioPlayBackground);
bind("audio_play_sound", &ScriptEngineService::AudioPlaySound);
bind("audio_stop_background", &ScriptEngineService::AudioStopBackground);
}
int ScriptEngineService::LoadMeshFromFile(lua_State* L) {
@@ -360,6 +361,29 @@ int ScriptEngineService::AudioPlaySound(lua_State* L) {
return 1;
}
int ScriptEngineService::AudioStopBackground(lua_State* L) {
auto* context = static_cast<LuaBindingContext*>(lua_touserdata(L, lua_upvalueindex(1)));
auto logger = context ? context->logger : nullptr;
if (!context || !context->audioCommandService) {
lua_pushnil(L);
lua_pushstring(L, "Audio service not available");
return 2;
}
if (logger) {
logger->Trace("ScriptEngineService", "AudioStopBackground");
}
std::string error;
if (!context->audioCommandService->StopBackground(error)) {
lua_pushnil(L);
lua_pushstring(L, error.c_str());
return 2;
}
lua_pushboolean(L, 1);
return 1;
}
int ScriptEngineService::GlmMatrixFromTransform(lua_State* L) {
auto* context = static_cast<LuaBindingContext*>(lua_touserdata(L, lua_upvalueindex(1)));
auto logger = context ? context->logger : nullptr;