fix(sdk/input): 框架App侧插孔消抖 — 插孔变化后800ms内忽略音量键边沿(与launcher/watchdog 255同款,补齐SDK侧缺口); meow_ui.a 12cdd5d7; hello 34b01e76/files 2f44e27e/ncm 52412137 重链热更到卡。test_sdk_input_keys PASS

This commit is contained in:
MeowOS committed 2026-09-01 09:28:09 +08:00
1 parent 6200a41b71
commit 56c569f3a9
5 files changed
+28 -1

No files matched your search

Binary file not shown.
Binary file not shown.
Binary file not shown.
+28 -1
View File
@@ -109,6 +109,33 @@ static const char *meow_settings_path(void)
return (e && e[0]) ? e : "/usr/data/meow/settings.conf";
}
/* ---- 插孔消抖(M2.92,与 launcher/watchdog 255 同款)----
* 插拔 3.5/4.4 耳机的电气瞬态会在音量键 ADC(event2)上产生幽灵 VOL_UP/DOWN 按下
* (真机实证:插 4.4 同帧 ramp 爬满上限)。插孔状态变化后 800ms 内忽略音量键边沿。
* 节流:500ms 才真读 /sys 一次(不在热路径每圈读文件)。 */
static int g_jack_combo = -1; /* hs*2+bal 缓存,-1=未读 */
static unsigned long long g_jack_changed_at = 0, g_jack_polled_at = 0;
static int meow_input_jack_debounce(void)
{
unsigned long long now = meow_ui_time_ms();
if (now - g_jack_polled_at >= 500) {
g_jack_polled_at = now;
int hs = -1, bal = -1;
char b[8];
int fd = open("/sys/class/switch/headset/state", O_RDONLY);
if (fd >= 0) { ssize_t n = read(fd, b, sizeof b - 1); close(fd); if (n > 0) { b[n] = 0; hs = atoi(b); } }
fd = open("/sys/class/switch/balance/state", O_RDONLY);
if (fd >= 0) { ssize_t n = read(fd, b, sizeof b - 1); close(fd); if (n > 0) { b[n] = 0; bal = atoi(b); } }
if (hs >= 0 && bal >= 0) {
int combo = hs * 2 + bal;
if (g_jack_combo >= 0 && combo != g_jack_combo) g_jack_changed_at = now;
g_jack_combo = combo;
}
}
return g_jack_changed_at && (now - g_jack_changed_at) < 800;
}
/* ---- 系统按键语义(M2.55:SDK 输入层消化,App 前台也生效)----
* 物理键是系统资源(APPS.md §3.4.1),语义全局统一。本函数在输入线程执行系统动作:
* 电源 116 → 息屏/亮屏/长按菜单(内核/sys_server/watchdog),SDK 不动(维持现状);
@@ -124,7 +151,7 @@ static void meow_input_handle_sys_key(int code, int val)
break;
case MEOW_KEY_VOLUMEDOWN:
case MEOW_KEY_VOLUMEUP:
if (val == 1) {
if (val == 1 && !meow_input_jack_debounce()) { /* 插孔瞬态期忽略幽灵音量边沿 */
int dir = (code == MEOW_KEY_VOLUMEUP) ? +1 : -1;
int nv = meow_ui_vol_step(meow_settings_path(), dir); /* settings 语义+持久化 */
meow_ui_vol_dac_write(nv); /* 写真实 CS43198 DAC */
Binary file not shown.