bluetooth: fix BLE/HID keyboard & mouse pairing, auto-bypass T9 on external keyboard, and show mouse cursor

This commit is contained in:
Luxferre committed 2026-11-03 20:24:54 +02:00
1 parent b9e7c6847b
commit 02ce3ab1f4
67 files changed
+1227 -293

No files matched your search

+52 -28
View File
@@ -50,7 +50,7 @@ std::vector<BtSendTarget> queryBtSendTargets(bool scanFirst = false) {
runCaptureCmd("SXMO_OS=alpine doas -n sxmo_bluetoothtoggle.sh on >/dev/null 2>&1");
}
if (scanFirst) {
runCaptureCmd("timeout 5 bluetoothctl --timeout 4 scan on >/dev/null 2>&1");
runCaptureCmd("timeout 16 bluetoothctl --timeout 15 scan on >/dev/null 2>&1");
}
std::unordered_set<std::string> pairedMacs;
std::unordered_set<std::string> connectedMacs;
@@ -1450,7 +1450,8 @@ int runFilesApp(int argc, char** argv) {
drawPango(layoutMain, &colWhite, 28, 0, 36, inputTitle, 145);
const char* mBadge = "[abc]";
if (caseMode == TextCaseMode::Title) mBadge = "[Abc]";
if (isExternalKeyboardActive()) mBadge = "[KBD]";
else if (caseMode == TextCaseMode::Title) mBadge = "[Abc]";
else if (caseMode == TextCaseMode::Upper) mBadge = "[ABC]";
else if (caseMode == TextCaseMode::Num) mBadge = "[123]";
drawPango(layoutSmall, &colYellow, kWinWidth - 46, 0, 36, mBadge);
@@ -1516,7 +1517,8 @@ int runFilesApp(int argc, char** argv) {
drawPango(layoutMain, &colWhite, 25, 0, 32, titleDisp, 114);
const char* mBadge = "[abc]";
if (editCaseMode == TextCaseMode::Title) mBadge = "[Abc]";
if (isExternalKeyboardActive()) mBadge = "[KBD]";
else if (editCaseMode == TextCaseMode::Title) mBadge = "[Abc]";
else if (editCaseMode == TextCaseMode::Upper) mBadge = "[ABC]";
else if (editCaseMode == TextCaseMode::Num) mBadge = "[123]";
else if (editCaseMode == TextCaseMode::Sym) mBadge = "[Sym]";
@@ -2405,8 +2407,8 @@ int runFilesApp(int argc, char** argv) {
} else if (mode == ViewMode::BtSendModal) {
if (isLeft) {
if (btTargets.empty()) {
statusBanner = "Scanning Bluetooth...";
statusBannerUntilMs = nowMs() + 2500;
statusBanner = "Scanning Bluetooth (15s)...";
statusBannerUntilMs = nowMs() + 16000;
drawUI();
btTargets = queryBtSendTargets(true);
btTargetSel = 0;
@@ -2475,7 +2477,7 @@ int runFilesApp(int argc, char** argv) {
} else if (ev.type == KeyPress) {
int64_t tNow = nowMs();
unsigned int kc = ev.xkey.keycode;
KeySym sym = XLookupKeysym(&ev.xkey, 0);
KeySym sym = XLookupKeysym(&ev.xkey, (ev.xkey.state & ShiftMask) ? 1 : 0);
bool isLeftSk =
(kc == 135 || sym == XK_Menu || sym == XF86XK_KbdLcdMenu1 ||
@@ -2686,17 +2688,28 @@ int runFilesApp(int argc, char** argv) {
insertEditorNewline();
drawUI();
} else {
char d = mapDialKey(sym, kc, ev.xkey.state);
if (d == '#') {
if (!isExternalKeyboardActive()) {
char d = mapDialKey(sym, kc, ev.xkey.state);
if (d == '#') {
editLastTapDigit = -1;
editCaseMode = static_cast<TextCaseMode>(
(static_cast<int>(editCaseMode) + 1) % 5);
drawUI();
continue;
} else if (d == '*') {
commitEditorTap(10);
drawUI();
continue;
} else if (d >= '0' && d <= '9') {
commitEditorTap(d - '0');
drawUI();
continue;
}
}
if (sym >= 0x20 && sym <= 0x7e &&
!(ev.xkey.state & (ControlMask | Mod1Mask))) {
editLastTapDigit = -1;
editCaseMode = static_cast<TextCaseMode>(
(static_cast<int>(editCaseMode) + 1) % 5);
drawUI();
} else if (d == '*') {
commitEditorTap(10);
drawUI();
} else if (d >= '0' && d <= '9') {
commitEditorTap(d - '0');
insertEditorStr(std::string(1, static_cast<char>(sym)));
drawUI();
}
}
@@ -2757,17 +2770,28 @@ int runFilesApp(int argc, char** argv) {
lastTapDigit = -1;
drawUI();
} else {
char d = mapDialKey(sym, kc, ev.xkey.state);
if (d == '#') {
if (!isExternalKeyboardActive()) {
char d = mapDialKey(sym, kc, ev.xkey.state);
if (d == '#') {
lastTapDigit = -1;
caseMode = static_cast<TextCaseMode>(
(static_cast<int>(caseMode) + 1) % 4);
drawUI();
continue;
} else if (d == '*') {
commitModalTap(1);
drawUI();
continue;
} else if (d >= '0' && d <= '9') {
commitModalTap(d - '0');
drawUI();
continue;
}
}
if (sym >= 0x20 && sym <= 0x7e &&
!(ev.xkey.state & (ControlMask | Mod1Mask))) {
lastTapDigit = -1;
caseMode = static_cast<TextCaseMode>(
(static_cast<int>(caseMode) + 1) % 4);
drawUI();
} else if (d == '*') {
commitModalTap(1);
drawUI();
} else if (d >= '0' && d <= '9') {
commitModalTap(d - '0');
inputValue.push_back(static_cast<char>(sym));
drawUI();
}
}
@@ -2795,8 +2819,8 @@ int runFilesApp(int argc, char** argv) {
drawUI();
}
} else if (d == '*') {
statusBanner = "Scanning Bluetooth...";
statusBannerUntilMs = nowMs() + 2500;
statusBanner = "Scanning Bluetooth (15s)...";
statusBannerUntilMs = nowMs() + 16000;
drawUI();
btTargets = queryBtSendTargets(true);
btTargetSel = 0;