fix: chatmix direction display, mock battery walkdown, mock chatmix, sendCommand guard
This commit is contained in:
1 parent
90a3008e7d
commit
caa9364501
1 file changed
+18
-6
@@ -92,12 +92,18 @@ end
|
||||
|
||||
-- Mock battery walks down 88 -> 10 then resets, exercising all color bands + warning.
|
||||
local mockBattery = 88
|
||||
local function mockChatmix()
|
||||
if mockBattery > 60 then return 40 end
|
||||
if mockBattery > 30 then return -40 end
|
||||
return 0
|
||||
end
|
||||
local function nextMockStatus()
|
||||
mockBattery = mockBattery - 1
|
||||
if mockBattery < 10 then mockBattery = 88 end
|
||||
local level = mockBattery
|
||||
mockBattery = mockBattery - 1
|
||||
return {
|
||||
battery = { status = "BATTERY_NORMAL", level = mockBattery },
|
||||
chatmix = 0,
|
||||
battery = { status = "BATTERY_NORMAL", level = level },
|
||||
chatmix = mockChatmix(),
|
||||
}
|
||||
end
|
||||
|
||||
@@ -136,6 +142,7 @@ function M.fetchStatus(cb)
|
||||
end
|
||||
|
||||
-- Runs a command as an argv array: sendCommand({"-s", "64"}, cb).
|
||||
-- cb(result) receives { exitCode, stdout, stderr, ... }; callers must check result.exitCode.
|
||||
function M.sendCommand(args, cb)
|
||||
if config.mock then
|
||||
if cb then cb({ exitCode = 0, stdout = "", stderr = "" }) end
|
||||
@@ -143,14 +150,19 @@ function M.sendCommand(args, cb)
|
||||
end
|
||||
local argv = { "headsetcontrol" }
|
||||
for _, a in ipairs(deviceArgs()) do table.insert(argv, a) end
|
||||
for _, a in ipairs(args) do table.insert(argv, a) end
|
||||
if args ~= nil then
|
||||
for _, a in ipairs(args) do table.insert(argv, a) end
|
||||
end
|
||||
noctalia.runAsync(argv, cb or function() end)
|
||||
end
|
||||
|
||||
-- chatmix direction is device-ambiguous. Negative = game side on signed-convention
|
||||
-- devices; positive is shown raw because center/direction conventions vary by device
|
||||
-- (e.g. Maxwell uses unsigned 0-128 centered at 64).
|
||||
function M.chatmixText(value)
|
||||
if value == 0 then return "0" end
|
||||
if value < 0 then return tostring(value) .. " \194\183 " .. noctalia.tr("chatmix.game") end
|
||||
return tostring(value) .. " \194\183 " .. noctalia.tr("chatmix.chat")
|
||||
if value == 0 then return "0" end
|
||||
return tostring(value)
|
||||
end
|
||||
|
||||
return M
|
||||
Reference in new issue
Block a user