diff --git a/doc/img/ModCWControls2.png b/doc/img/ModCWControls2.png index bfb478a30..38cf41a79 100644 Binary files a/doc/img/ModCWControls2.png and b/doc/img/ModCWControls2.png differ diff --git a/doc/img/ModCWControls2.xcf b/doc/img/ModCWControls2.xcf index e4254eb76..6427d725e 100644 Binary files a/doc/img/ModCWControls2.xcf and b/doc/img/ModCWControls2.xcf differ diff --git a/plugins/channeltx/modam/readme.md b/plugins/channeltx/modam/readme.md index 059f94edc..930792f2c 100644 --- a/plugins/channeltx/modam/readme.md +++ b/plugins/channeltx/modam/readme.md @@ -72,11 +72,11 @@ Enter the text to be keyed when Morse input is active and in text mode Clears the CW (Morse) text -

12: Morse keyer controls

+

12a: Morse keyer controls (line 1)

![Morse keyer control GUI1](../../../doc/img/ModCWControls1.png) -

12.1: CW keying speed

+

12a.1: CW keying speed

Sets the CW speed in Words Per Minute (WPM). This is based on the word "PARIS" sent 5 times. For 5 WPM the dot length is 240 ms. In other terms the dot length is calculated as 1.2 / WPM seconds. The dot length is used as the base to compute other timings: @@ -85,43 +85,49 @@ Sets the CW speed in Words Per Minute (WPM). This is based on the word "PARIS" s - Character silence separator: 3 dot lengths - Word silence separator: 7 dot lengths -

12.2: Dots keying

+

12a.2: Dots keying

Switch this button to send dots continuously -

12.3: Dashes keying

+

12a.3: Dashes keying

Switch this button to send dashes continuously -

12.4: Text keying

+

12a.4: Text keying

Switch this button to send the text typed into the text box (10) -

12.5: Text auto repeat

+

12a.5: Text auto repeat

Switch this button to auto repeat the text keying -

12.6: Text play/stop

+

12a.6: Text play/stop

Use this button to stop sending text. When resuming keying restarts at the start of text +

12a: Morse keyer controls (line 2)

+ ![Morse keyer control GUI2](../../../doc/img/ModCWControls2.png) ⚠ WARNING: what follows is not really useful if you do not use a proper Morse keyer with direct audio feedback. There is a significant audio delay either with the direct monitoring or by monitoring the transmitted signal so keying with this audio as feedback is not practical -12.7: Activate morse keys keyboard control +12b.1: Activate morse keys keyboard and mouse control -This disables text or continuous dots or dashes. Toggle input from keyboard. Occasionally the focus may get lost and you will have to deactivate and reactivate it to recover the key bindings. +This disables text or continuous dots or dashes. Toggle input from keyboard or mouse (see 16b.3). Occasionally the focus may get lost and you will have to deactivate and reactivate it to recover the key bindings. -12.8: Iambic or straight +12b.2: Iambic or straight Choose iambic or straight keying style. When straight is selected the dot or dash key may be used. -12.9: Register dot key +12b.3: Mouse control pad + +When keyboard and mouse control is activated move the pointer to this area to use the left button as the dot paddle and the right button as the dash paddle. In straight mode both buttons have the same effect (key down). + +12a.4: Register dot key Click on the button and while selected type a character or character and modifier (Shift + key for example) to select which key is used for dots. The key or key sequence appears next (here dot `.`) -12.10: Register dash key +12a.5: Register dash key Click on the button and while selected type a character or character and modifier (Shift + key for example) to select which key is used for dashes. The key or key sequence appears next (here dot `.`) diff --git a/plugins/channeltx/modfreedv/readme.md b/plugins/channeltx/modfreedv/readme.md index 3ad241d68..bb6092816 100644 --- a/plugins/channeltx/modfreedv/readme.md +++ b/plugins/channeltx/modfreedv/readme.md @@ -81,11 +81,11 @@ Enter the text to be keyed when Morse input is active and in text mode. Clears the CW (Morse) text -

10: Morse keyer controls

+

10a: Morse keyer controls (line 1)

![Morse keyer control GUI1](../../../doc/img/ModCWControls1.png) -

10.1: CW keying speed

+

10a.1: CW keying speed

Sets the CW speed in Words Per Minute (WPM). This is based on the word "PARIS" sent 5 times. For 5 WPM the dot length is 240 ms. In other terms the dot length is calculated as 1.2 / WPM seconds. The dot length is used as the base to compute other timings: @@ -94,43 +94,49 @@ Sets the CW speed in Words Per Minute (WPM). This is based on the word "PARIS" s - Character silence separator: 3 dot lengths - Word silence separator: 7 dot lengths -

10.2: Dots keying

+

10a.2: Dots keying

Switch this button to send dots continuously -

10.3: Dashes keying

+

10a.3: Dashes keying

Switch this button to send dashes continuously -

10.4: Text keying

+

10a.4: Text keying

Switch this button to send the text typed into the text box (13) -

10.5: Text auto repeat

+

10a.5: Text auto repeat

Switch this button to auto repeat the text keying -

10.6: Text play/stop

+

10a.6: Text play/stop

Use this button to stop sending text. When resuming keying restarts at the start of text +

10b.1: CW keying speed

+ ![Morse keyer control GUI2](../../../doc/img/ModCWControls2.png) ⚠ WARNING: what follows is not really useful if you do not use a proper Morse keyer with direct audio feedback. There is a significant audio delay either with the direct monitoring or by monitoring the transmitted signal so keying with this audio as feedback is not practical -10.7: Activate morse keys keyboard control +10b.1: Activate morse keys keyboard and mouse control -This disables text or continuous dots or dashes. Toggle input from keyboard. Occasionally the focus may get lost and you will have to deactivate and reactivate it to recover the key bindings. +This disables text or continuous dots or dashes. Toggle input from keyboard or mouse (see 16b.3). Occasionally the focus may get lost and you will have to deactivate and reactivate it to recover the key bindings. -10.8: Iambic or straight +10b.2: Iambic or straight Choose iambic or straight keying style. When straight is selected the dot or dash key may be used. -10.9: Register dot key +10b.3: Mouse control pad + +When keyboard and mouse control is activated move the pointer to this area to use the left button as the dot paddle and the right button as the dash paddle. In straight mode both buttons have the same effect (key down). + +10a.4: Register dot key Click on the button and while selected type a character or character and modifier (Shift + key for example) to select which key is used for dots. The key or key sequence appears next (here dot `.`) -10.10: Register dash key +10a.5: Register dash key Click on the button and while selected type a character or character and modifier (Shift + key for example) to select which key is used for dashes. The key or key sequence appears next (here dot `.`) diff --git a/plugins/channeltx/modnfm/readme.md b/plugins/channeltx/modnfm/readme.md index 0d855a50e..4da22bc42 100644 --- a/plugins/channeltx/modnfm/readme.md +++ b/plugins/channeltx/modnfm/readme.md @@ -170,11 +170,11 @@ Enter the text to be keyed when Morse input is active and in text mode Clears the CW (Morse) text -

17: Morse keyer controls

+

17a: Morse keyer controls (line 1)

![Morse keyer control GUI1](../../../doc/img/ModCWControls1.png) -

17.1: CW keying speed

+

17a.1: CW keying speed

Sets the CW speed in Words Per Minute (WPM). This is based on the word "PARIS" sent 5 times. For 5 WPM the dot length is 240 ms. In other terms the dot length is calculated as 1.2 / WPM seconds. The dot length is used as the base to compute other timings: @@ -183,45 +183,49 @@ Sets the CW speed in Words Per Minute (WPM). This is based on the word "PARIS" s - Character silence separator: 3 dot lengths - Word silence separator: 7 dot lengths -

17.2: Dots keying

+

17a.2: Dots keying

Switch this button to send dots continuously -

17.3: Dashes keying

+

17a.3: Dashes keying

Switch this button to send dashes continuously -

17.4: Text keying

+

17a.4: Text keying

Switch this button to send the text typed into the text box (14) -

17.5: Text auto repeat

+

17a.5: Text auto repeat

Switch this button to auto repeat the text keying -

17.6: Text play/stop

+

17a.6: Text play/stop

Use this button to stop sending text. When resuming keying restarts at the start of text -

18: Use keyboard for morse keying

+

17b: Morse keyer controls (line 2)

![Morse keyer control GUI2](../../../doc/img/ModCWControls2.png) ⚠ WARNING: this is not really useful if you do not use a proper Morse keyer with direct audio feedback. There is a significant audio delay either with the direct monitoring or by monitoring the transmitted signal so keying with this audio as feedback is not practical -18.7: Activate morse keys keyboard control +17b.1: Activate morse keys keyboard and mouse control -This disables text or continuous dots or dashes. Toggle input from keyboard. Occasionally the focus may get lost and you will have to deactivate and reactivate it to recover the key bindings. +This disables text or continuous dots or dashes. Toggle input from keyboard or mouse (see 16b.3). Occasionally the focus may get lost and you will have to deactivate and reactivate it to recover the key bindings. -18.8: Iambic or straight +17b.2: Iambic or straight Choose iambic or straight keying style. When straight is selected the dot or dash key may be used. -18.9: Register dot key +17b.3: Mouse control pad + +When keyboard and mouse control is activated move the pointer to this area to use the left button as the dot paddle and the right button as the dash paddle. In straight mode both buttons have the same effect (key down). + +17a.4: Register dot key Click on the button and while selected type a character or character and modifier (Shift + key for example) to select which key is used for dots. The key or key sequence appears next (here dot `.`) -18.10: Register dash key +17a.5: Register dash key Click on the button and while selected type a character or character and modifier (Shift + key for example) to select which key is used for dashes. The key or key sequence appears next (here dot `.`) diff --git a/plugins/channeltx/modssb/readme.md b/plugins/channeltx/modssb/readme.md index 26f271c54..e032187e8 100644 --- a/plugins/channeltx/modssb/readme.md +++ b/plugins/channeltx/modssb/readme.md @@ -161,11 +161,11 @@ Enter the text to be keyed when Morse input is active and in text mode Clears the CW (Morse) text -

16: Morse keyer controls

+

16a: Morse keyer controls (line1)

![Morse keyer control GUI1](../../../doc/img/ModCWControls1.png) -

16.1: CW keying speed

+

16a.1: CW keying speed

Sets the CW speed in Words Per Minute (WPM). This is based on the word "PARIS" sent 5 times. For 5 WPM the dot length is 240 ms. In other terms the dot length is calculated as 1.2 / WPM seconds. The dot length is used as the base to compute other timings: @@ -174,43 +174,49 @@ Sets the CW speed in Words Per Minute (WPM). This is based on the word "PARIS" s - Character silence separator: 3 dot lengths - Word silence separator: 7 dot lengths -

16.2: Dots keying

+

16a.2: Dots keying

Switch this button to send dots continuously -

16.3: Dashes keying

+

16a.3: Dashes keying

Switch this button to send dashes continuously -

16.4: Text keying

+

16a.4: Text keying

Switch this button to send the text typed into the text box (13) -

16.5: Text auto repeat

+

16a.5: Text auto repeat

Switch this button to auto repeat the text keying -

16.6: Text play/stop

+

16a.6: Text play/stop

Use this button to stop sending text. When resuming keying restarts at the start of text +

16b: Morse keyer controls (line2)

+ ![Morse keyer control GUI2](../../../doc/img/ModCWControls2.png) ⚠ WARNING: what follows is not really useful if you do not use a proper Morse keyer with direct audio feedback. There is a significant audio delay either with the direct monitoring or by monitoring the transmitted signal so keying with this audio as feedback is not practical -16.7: Activate morse keys keyboard control +16b.1: Activate morse keys keyboard and mouse control -This disables text or continuous dots or dashes. Toggle input from keyboard. Occasionally the focus may get lost and you will have to deactivate and reactivate it to recover the key bindings. +This disables text or continuous dots or dashes. Toggle input from keyboard or mouse (see 16b.3). Occasionally the focus may get lost and you will have to deactivate and reactivate it to recover the key bindings. -16.8: Iambic or straight +16b.2: Iambic or straight Choose iambic or straight keying style. When straight is selected the dot or dash key may be used. -16.9: Register dot key +16b.3: Mouse control pad + +When keyboard and mouse control is activated move the pointer to this area to use the left button as the dot paddle and the right button as the dash paddle. In straight mode both buttons have the same effect (key down). + +16b.4: Register dot key Click on the button and while selected type a character or character and modifier (Shift + key for example) to select which key is used for dots. The key or key sequence appears next (here dot `.`) -16.10: Register dash key +16b.5: Register dash key Click on the button and while selected type a character or character and modifier (Shift + key for example) to select which key is used for dashes. The key or key sequence appears next (here dot `.`) diff --git a/plugins/channeltx/modssb/ssbmodgui.cpp b/plugins/channeltx/modssb/ssbmodgui.cpp index 8e57b3e07..3289db300 100644 --- a/plugins/channeltx/modssb/ssbmodgui.cpp +++ b/plugins/channeltx/modssb/ssbmodgui.cpp @@ -790,7 +790,7 @@ void SSBModGUI::audioSelect(const QPoint& p) void SSBModGUI::audioFeedbackSelect(const QPoint& p) { qDebug("SSBModGUI::audioFeedbackSelect"); - AudioSelectDialog audioSelect(DSPEngine::instance()->getAudioDeviceManager(), m_settings.m_audioDeviceName, false); // false for output + AudioSelectDialog audioSelect(DSPEngine::instance()->getAudioDeviceManager(), m_settings.m_feedbackAudioDeviceName, false); // false for output audioSelect.move(p); new DialogPositioner(&audioSelect, false); audioSelect.exec(); diff --git a/plugins/channeltx/modssb/ssbmodsource.cpp b/plugins/channeltx/modssb/ssbmodsource.cpp index 8ebaa31c5..6310ca9a0 100644 --- a/plugins/channeltx/modssb/ssbmodsource.cpp +++ b/plugins/channeltx/modssb/ssbmodsource.cpp @@ -35,7 +35,7 @@ SSBModSource::SSBModSource() : m_spectrumSink(nullptr), m_audioSampleRate(48000), m_audioFifo(12000), - m_feedbackAudioFifo(48000), + m_feedbackAudioFifo(12000), m_levelCalcCount(0), m_peakLevel(0.0f), m_levelSum(0.0f), @@ -55,7 +55,7 @@ SSBModSource::SSBModSource() : m_audioReadBuffer.resize(24000); m_audioReadBufferFill = 0; - m_feedbackAudioBuffer.resize(1<<14); + m_feedbackAudioBuffer.resize(4800); m_feedbackAudioBufferFill = 0; m_demodBuffer.resize(1<<12); @@ -538,22 +538,31 @@ void SSBModSource::pushFeedback(Complex c) void SSBModSource::processOneSample(Complex& ci) { - m_feedbackAudioBuffer[m_feedbackAudioBufferFill].l = ci.real(); - m_feedbackAudioBuffer[m_feedbackAudioBufferFill].r = ci.imag(); - ++m_feedbackAudioBufferFill; - - if (m_feedbackAudioBufferFill >= m_feedbackAudioBuffer.size()) + if (m_settings.m_modAFInput == SSBModSettings::SSBModInputCWTone) // minimize latency for CW { - uint res = m_feedbackAudioFifo.write((const quint8*)&m_feedbackAudioBuffer[0], m_feedbackAudioBufferFill); + m_feedbackAudioBuffer[0].l = ci.real(); + m_feedbackAudioBuffer[0].r = ci.imag(); + m_feedbackAudioFifo.writeOne((const quint8*) &m_feedbackAudioBuffer[0]); + } + else + { + m_feedbackAudioBuffer[m_feedbackAudioBufferFill].l = ci.real(); + m_feedbackAudioBuffer[m_feedbackAudioBufferFill].r = ci.imag(); + ++m_feedbackAudioBufferFill; - if (res != m_feedbackAudioBufferFill) + if (m_feedbackAudioBufferFill >= m_feedbackAudioBuffer.size()) { - qDebug("SSBModSource::pushFeedback: %u/%u audio samples written m_feedbackInterpolatorDistance: %f", - res, m_feedbackAudioBufferFill, m_feedbackInterpolatorDistance); - m_feedbackAudioFifo.clear(); - } + uint res = m_feedbackAudioFifo.write((const quint8*)&m_feedbackAudioBuffer[0], m_feedbackAudioBufferFill); - m_feedbackAudioBufferFill = 0; + if (res != m_feedbackAudioBufferFill) + { + qDebug("SSBModSource::pushFeedback: %u/%u audio samples written m_feedbackInterpolatorDistance: %f", + res, m_feedbackAudioBufferFill, m_feedbackInterpolatorDistance); + m_feedbackAudioFifo.clear(); + } + + m_feedbackAudioBufferFill = 0; + } } } diff --git a/plugins/channeltx/modwfm/readme.md b/plugins/channeltx/modwfm/readme.md index fe1017292..92e675b7b 100644 --- a/plugins/channeltx/modwfm/readme.md +++ b/plugins/channeltx/modwfm/readme.md @@ -76,11 +76,11 @@ Enter the text to be keyed when Morse input is active and in text mode Clears the CW (Morse) text -

13: Morse keyer controls

+

13a: Morse keyer controls (line 1)

![Morse keyer control GUI1](../../../doc/img/ModCWControls1.png) -

13.1: CW keying speed

+

13a.1: CW keying speed

Sets the CW speed in Words Per Minute (WPM). This is based on the word "PARIS" sent 5 times. For 5 WPM the dot length is 240 ms. In other terms the dot length is calculated as 1.2 / WPM seconds. The dot length is used as the base to compute other timings: @@ -89,43 +89,49 @@ Sets the CW speed in Words Per Minute (WPM). This is based on the word "PARIS" s - Character silence separator: 3 dot lengths - Word silence separator: 7 dot lengths -

13.2: Dots keying

+

13a.2: Dots keying

Switch this button to send dots continuously -

13.3: Dashes keying

+

13a.3: Dashes keying

Switch this button to send dashes continuously -

13.4: Text keying

+

13a.4: Text keying

Switch this button to send the text typed into the text box (11) -

13.5: Text auto repeat

+

13a.5: Text auto repeat

Switch this button to auto repeat the text keying -

13.6: Text play/stop

+

13a.6: Text play/stop

Use this button to stop sending text. When resuming keying restarts at the start of text +

13b: Morse keyer controls (line 2)

+ ![Morse keyer control GUI2](../../../doc/img/ModCWControls2.png) ⚠ WARNING: what follows is not really useful if you do not use a proper Morse keyer with direct audio feedback. There is a significant audio delay either with the direct monitoring or by monitoring the transmitted signal so keying with this audio as feedback is not practical -13.7: Activate morse keys keyboard control +13b.1: Activate morse keys keyboard and mouse control -This disables text or continuous dots or dashes. Toggle input from keyboard. Occasionally the focus may get lost and you will have to deactivate and reactivate it to recover the key bindings. +This disables text or continuous dots or dashes. Toggle input from keyboard or mouse (see 16b.3). Occasionally the focus may get lost and you will have to deactivate and reactivate it to recover the key bindings. -13.8: Iambic or straight +13b.2: Iambic or straight Choose iambic or straight keying style. When straight is selected the dot or dash key may be used. -13.9: Register dot key +13b.3: Mouse control pad + +When keyboard and mouse control is activated move the pointer to this area to use the left button as the dot paddle and the right button as the dash paddle. In straight mode both buttons have the same effect (key down). + +13b.4: Register dot key Click on the button and while selected type a character or character and modifier (Shift + key for example) to select which key is used for dots. The key or key sequence appears next (here dot `.`) -13.10: Register dash key +13b.5: Register dash key Click on the button and while selected type a character or character and modifier (Shift + key for example) to select which key is used for dashes. The key or key sequence appears next (here dot `.`) diff --git a/sdrbase/audio/audiofifo.cpp b/sdrbase/audio/audiofifo.cpp index 14c65d0c7..d562c8a76 100644 --- a/sdrbase/audio/audiofifo.cpp +++ b/sdrbase/audio/audiofifo.cpp @@ -174,6 +174,31 @@ bool AudioFifo::readOne(quint8* data) return true; } +uint32_t AudioFifo::writeOne(const quint8* data) +{ + if (!m_fifo) { + return 0; + } + + if (isFull()) + { + emit overflow(1); + return 0; + } + + m_mutex.lock(); + + memcpy(m_fifo + (m_tail * m_sampleSize), data, m_sampleSize); + m_tail += 1; + m_tail %= m_size; + m_fill += 1; + + m_mutex.unlock(); + + emit dataReady(); + return 1; +} + uint AudioFifo::drain(uint32_t numSamples) { QMutexLocker mutexLocker(&m_mutex); diff --git a/sdrbase/audio/audiofifo.h b/sdrbase/audio/audiofifo.h index 3a09e2716..1a531f37f 100644 --- a/sdrbase/audio/audiofifo.h +++ b/sdrbase/audio/audiofifo.h @@ -41,6 +41,7 @@ public: uint32_t write(const quint8* data, uint32_t numSamples); uint32_t read(quint8* data, uint32_t numSamples); bool readOne(quint8* data); + uint32_t writeOne(const quint8* data); uint32_t drain(uint32_t numSamples); void clear(); diff --git a/sdrgui/CMakeLists.txt b/sdrgui/CMakeLists.txt index 358e4029f..39bec49ac 100644 --- a/sdrgui/CMakeLists.txt +++ b/sdrgui/CMakeLists.txt @@ -26,6 +26,7 @@ set(sdrgui_SOURCES gui/crightclickenabler.cpp gui/customtextedit.cpp gui/cwkeyergui.cpp + gui/cwmousekeyerenabler.cpp gui/datetimedelegate.cpp gui/decimaldelegate.cpp gui/devicesetselectiondialog.cpp @@ -150,6 +151,7 @@ set(sdrgui_HEADERS gui/crightclickenabler.h gui/customtextedit.h gui/cwkeyergui.h + gui/cwmousekeyerenabler.h gui/datetimedelegate.h gui/decimaldelegate.h gui/devicesetselectiondialog.h diff --git a/sdrgui/gui/cwkeyergui.cpp b/sdrgui/gui/cwkeyergui.cpp index 17ef78fdf..abeb7008b 100644 --- a/sdrgui/gui/cwkeyergui.cpp +++ b/sdrgui/gui/cwkeyergui.cpp @@ -21,6 +21,7 @@ #include "gui/cwkeyergui.h" #include "gui/dialpopup.h" +#include "gui/cwmousekeyerenabler.h" #include "ui_cwkeyergui.h" #include "dsp/cwkeyer.h" #include "util/simpleserializer.h" @@ -40,6 +41,11 @@ CWKeyerGUI::CWKeyerGUI(QWidget* parent) : m_commandKeyReceiver->setRelease(true); this->installEventFilter(m_commandKeyReceiver); DialPopup::addPopupsToChildDials(this); + CWMouseKeyerEnabler *cwMouseKeyerEnabler = new CWMouseKeyerEnabler(ui->cwMouseKeyerPad); + QObject::connect(cwMouseKeyerEnabler, &CWMouseKeyerEnabler::leftButtonPress, this, &CWKeyerGUI::cwKeyerMouseLeftPressed); + QObject::connect(cwMouseKeyerEnabler, &CWMouseKeyerEnabler::leftButtonRelease, this, &CWKeyerGUI::cwKeyerMouseLeftReleased); + QObject::connect(cwMouseKeyerEnabler, &CWMouseKeyerEnabler::rightButtonPress, this, &CWKeyerGUI::cwKeyerMouseRightPressed); + QObject::connect(cwMouseKeyerEnabler, &CWMouseKeyerEnabler::rightButtonRelease, this, &CWKeyerGUI::cwKeyerMouseRightReleased); } CWKeyerGUI::~CWKeyerGUI() @@ -359,3 +365,23 @@ void CWKeyerGUI::blockApplySettings(bool block) { m_doApplySettings = !block; } + +void CWKeyerGUI::cwKeyerMouseLeftPressed() +{ + m_cwKeyer->setKeyboardDots(); +} + +void CWKeyerGUI::cwKeyerMouseLeftReleased() +{ + m_cwKeyer->setKeyboardSilence(); +} + +void CWKeyerGUI::cwKeyerMouseRightPressed() +{ + m_cwKeyer->setKeyboardDashes(); +} + +void CWKeyerGUI::cwKeyerMouseRightReleased() +{ + m_cwKeyer->setKeyboardSilence(); +} diff --git a/sdrgui/gui/cwkeyergui.h b/sdrgui/gui/cwkeyergui.h index b71e69fa7..456ee0d56 100644 --- a/sdrgui/gui/cwkeyergui.h +++ b/sdrgui/gui/cwkeyergui.h @@ -90,6 +90,10 @@ private slots: void on_keyboardKeyer_toggled(bool checked); void commandKeyPressed(Qt::Key key, Qt::KeyboardModifiers keyModifiers, bool release); void keyboardKeyPressed(Qt::Key key, Qt::KeyboardModifiers keyModifiers, bool release); + void cwKeyerMouseLeftPressed(); + void cwKeyerMouseLeftReleased(); + void cwKeyerMouseRightPressed(); + void cwKeyerMouseRightReleased(); }; diff --git a/sdrgui/gui/cwkeyergui.ui b/sdrgui/gui/cwkeyergui.ui index fa01e02f1..f9bf4bd32 100644 --- a/sdrgui/gui/cwkeyergui.ui +++ b/sdrgui/gui/cwkeyergui.ui @@ -7,7 +7,7 @@ 0 0 375 - 91 + 92 @@ -82,6 +82,7 @@ + Liberation Sans 9 @@ -149,6 +150,7 @@ + Liberation Sans 12 75 true @@ -215,6 +217,7 @@ + Liberation Sans 12 75 true @@ -487,6 +490,28 @@ + + + + + 32 + 0 + + + + Put the mouse pointer here to activate the CW mouse keyer + + + QFrame::NoFrame + + + + + + :/mouse.png + + + @@ -546,6 +571,7 @@ + Liberation Sans 12 75 true @@ -634,6 +660,7 @@ + Liberation Sans 12 75 true diff --git a/sdrgui/gui/cwmousekeyerenabler.cpp b/sdrgui/gui/cwmousekeyerenabler.cpp new file mode 100644 index 000000000..535f3b8a6 --- /dev/null +++ b/sdrgui/gui/cwmousekeyerenabler.cpp @@ -0,0 +1,70 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2024 Edouard Griffiths, F4EXB // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#include +#include + +#include "cwmousekeyerenabler.h" + +CWMouseKeyerEnabler::CWMouseKeyerEnabler(QWidget *widget) : + QObject(widget), + m_widget(widget) +{ + m_widget->installEventFilter(this); +} + +bool CWMouseKeyerEnabler::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::MouseButtonPress) + { + auto mouseEvent = (QMouseEvent*) event; + + if (mouseEvent->button() == Qt::RightButton) + { + emit rightButtonPress(mouseEvent->globalPos()); + mouseEvent->setAccepted(true); + return true; + } + + if (mouseEvent->button() == Qt::LeftButton) + { + emit leftButtonPress(mouseEvent->globalPos()); + mouseEvent->setAccepted(true); + return true; + } + } + else if (event->type() == QEvent::MouseButtonRelease) + { + auto mouseEvent = (QMouseEvent*) event; + + if (mouseEvent->button() == Qt::RightButton) + { + emit rightButtonRelease(mouseEvent->globalPos()); + mouseEvent->setAccepted(true); + return true; + } + + if (mouseEvent->button() == Qt::LeftButton) + { + emit leftButtonRelease(mouseEvent->globalPos()); + mouseEvent->setAccepted(true); + return true; + } + } + + return QObject::eventFilter(obj, event); +} diff --git a/sdrgui/gui/cwmousekeyerenabler.h b/sdrgui/gui/cwmousekeyerenabler.h new file mode 100644 index 000000000..a39b41215 --- /dev/null +++ b/sdrgui/gui/cwmousekeyerenabler.h @@ -0,0 +1,43 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2024 Edouard Griffiths, F4EXB // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef SDRGUI_GUI_CWMOUSEKEYERENABLER_H_ +#define SDRGUI_GUI_CWMOUSEKEYERENABLER_H_ + +#include + +#include "export.h" + +class SDRGUI_API CWMouseKeyerEnabler : public QObject { + Q_OBJECT +public: + CWMouseKeyerEnabler(QWidget *widget); + +signals: + void leftButtonPress(const QPoint&); // Emitted for left mouse press + void leftButtonRelease(const QPoint&); // Emitted for left mouse release + void rightButtonPress(const QPoint&); // Emitted for right mouse press + void rightButtonRelease(const QPoint&); // Emitted for right mouse release + +protected: + bool eventFilter(QObject *watched, QEvent *event) override; + +private: + QWidget* m_widget; +}; + +#endif /* SDRGUI_GUI_CRIGHTCLICKENABLER_H_ */ diff --git a/sdrgui/resources/mouse.png b/sdrgui/resources/mouse.png new file mode 100644 index 000000000..70190a280 Binary files /dev/null and b/sdrgui/resources/mouse.png differ diff --git a/sdrgui/resources/res.qrc b/sdrgui/resources/res.qrc index 031ced019..cc76843c6 100644 --- a/sdrgui/resources/res.qrc +++ b/sdrgui/resources/res.qrc @@ -156,6 +156,7 @@ tab.png clockfile.png clockcurrent.png + mouse.png LiberationMono-Regular.ttf LiberationSans-Regular.ttf