Browse Source

Add diagnostics for stalled PTT shortcut recording

master
evgeny 4 days ago
parent
commit
2845270016
  1. 19
      tools/chatgui/src/ptt_hotkey_manager.cpp
  2. 32
      tools/chatgui/src/radiosettingspage.cpp

19
tools/chatgui/src/ptt_hotkey_manager.cpp

@ -129,9 +129,16 @@ void PttHotkeyManager::pollKeys() {
m_talking = false;
return;
}
if (m_capturing && !m_captureArmed && held.isEmpty()) m_captureArmed = true;
if (m_capturing && !m_captureArmed && held.isEmpty()) {
m_captureArmed = true;
DEBUG_INFO(DEBUG_CATEGORY_RADIO, "PTT: capture armed after all keys released");
}
bool changed = held != m_held;
m_held = held;
if (m_capturing && changed) {
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "PTT: capture poll armed=%d held=[%s] codes=[%s] application_state=%d",
m_captureArmed, qPrintable(describe(held)), qPrintable(pttEncodeChord(held)), int(QGuiApplication::applicationState()));
}
bool talking = false;
if (!m_capturing && RadioAudioEngine::instance()->isActive()) {
for (const auto& chord : m_chords) if (pttChordHeld(chord, held)) { talking = true; break; }
@ -160,14 +167,20 @@ bool PttHotkeyManager::beginCapture() {
m_captureArmed = held.isEmpty(); // ждём отпускания клавиши, которой нажали кнопку
m_talking = false;
RadioAudioEngine::instance()->setHotkeyTalking(false);
DEBUG_DEBUG(DEBUG_CATEGORY_RADIO, "PTT: key capture started");
DEBUG_INFO(DEBUG_CATEGORY_RADIO, "PTT: capture started armed=%d held=[%s] codes=[%s] platform=%s interval=%dms",
m_captureArmed, qPrintable(describe(held)), qPrintable(pttEncodeChord(held)),
qPrintable(QGuiApplication::platformName()), m_timer.interval());
if (!m_captureArmed) {
DEBUG_INFO(DEBUG_CATEGORY_RADIO, "PTT: capture waiting for ALL keys to be released; keys pressed meanwhile are ignored");
}
return true;
}
void PttHotkeyManager::endCapture() {
if (!m_capturing) return;
m_capturing = false;
DEBUG_DEBUG(DEBUG_CATEGORY_RADIO, "PTT: key capture finished");
DEBUG_INFO(DEBUG_CATEGORY_RADIO, "PTT: capture finished armed=%d polling=%d last_held=[%s] codes=[%s]",
m_captureArmed, m_timer.isActive(), qPrintable(describe(m_held)), qPrintable(pttEncodeChord(m_held)));
}
QString PttHotkeyManager::keyName(int key) const {

32
tools/chatgui/src/radiosettingspage.cpp

@ -15,6 +15,10 @@
#include <QFormLayout>
#include <QSpinBox>
#include <QCheckBox>
#include <QKeyEvent>
#ifdef Q_OS_WIN
#include <qt_windows.h>
#endif
RadioSettingsPage::RadioSettingsPage(DbManager* db, QWidget* parent) : QWidget(parent), m_db(db) {
auto* layout = new QVBoxLayout(this);
@ -136,6 +140,7 @@ RadioSettingsPage::~RadioSettingsPage() {
void RadioSettingsPage::startCapture(int index) {
finishCapture(false);
DEBUG_INFO(DEBUG_CATEGORY_RADIO, "PTT: recording requested slot=%d", index + 1);
if (!PttHotkeyManager::instance()->beginCapture()) {
m_labels[index]->setText(QCoreApplication::translate("ChatGui", "Failed to start key recording. See the radio log for details."));
return;
@ -152,7 +157,11 @@ void RadioSettingsPage::finishCapture(bool save) {
int index = m_captureIndex;
if (save) {
m_chords[index] = m_capture.candidate;
DEBUG_INFO(DEBUG_CATEGORY_RADIO, "PTT: captured chord=%s", qPrintable(PttHotkeyManager::instance()->describe(m_capture.candidate)));
DEBUG_INFO(DEBUG_CATEGORY_RADIO, "PTT: captured slot=%d chord=[%s] codes=[%s]", index + 1,
qPrintable(PttHotkeyManager::instance()->describe(m_capture.candidate)), qPrintable(pttEncodeChord(m_capture.candidate)));
} else {
DEBUG_INFO(DEBUG_CATEGORY_RADIO, "PTT: recording cancelled slot=%d candidate=[%s]", index + 1,
qPrintable(pttEncodeChord(m_capture.candidate)));
}
m_captureIndex = -1;
qApp->removeEventFilter(this);
@ -164,7 +173,26 @@ void RadioSettingsPage::finishCapture(bool save) {
bool RadioSettingsPage::eventFilter(QObject* object, QEvent* event) {
if (m_captureIndex >= 0) {
if (event->type() == QEvent::ShortcutOverride) { event->accept(); return true; }
if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) return true;
if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) {
auto* key = static_cast<QKeyEvent*>(event);
// Только ручная запись: сравниваем доставку событий окну с независимым опросом ОС.
if (!key->isAutoRepeat()) {
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "PTT: capture window event=%s slot=%d qt=0x%x native_vk=%u scan=%u modifiers=0x%x",
event->type() == QEvent::KeyPress ? "press" : "release", m_captureIndex + 1,
unsigned(key->key()), unsigned(key->nativeVirtualKey()), unsigned(key->nativeScanCode()),
unsigned(key->nativeModifiers()));
#ifdef Q_OS_WIN
int vk = int(key->nativeVirtualKey());
if (vk > 0 && vk < 256) {
unsigned asyncState = static_cast<unsigned short>(GetAsyncKeyState(vk));
unsigned queueState = static_cast<unsigned short>(GetKeyState(vk));
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "PTT: capture Windows vk=%d async=0x%04x queue=0x%04x remote_session=%d",
vk, asyncState, queueState, GetSystemMetrics(SM_REMOTESESSION));
}
#endif
}
return true;
}
}
return QWidget::eventFilter(object, event);
}

Loading…
Cancel
Save