mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 10:16:24 +02:00
[Video Conference Mute] Push to Reverse (#24892)
* Add push to talk
* Fix multiple callback WM_KEYDOWN while holding shortcut
* Code review suggestions
* Rename feature
* Revert "Rename feature"
This reverts commit 82d64bf57c.
* Add switch and settings
* Change type of bool property. Handle settings.
* Description
* Update src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.cpp
Always consume hotkey press
Co-authored-by: Andrey Nekrasov <yuyoyuppe@users.noreply.github.com>
---------
Co-authored-by: Andrey Nekrasov <yuyoyuppe@users.noreply.github.com>
This commit is contained in:
@@ -26,6 +26,7 @@ VideoConferenceModule* instance = nullptr;
|
||||
|
||||
VideoConferenceSettings VideoConferenceModule::settings;
|
||||
Toolbar VideoConferenceModule::toolbar;
|
||||
bool VideoConferenceModule::pushToTalkPressed = false;
|
||||
|
||||
HHOOK VideoConferenceModule::hook_handle;
|
||||
|
||||
@@ -123,10 +124,10 @@ LRESULT CALLBACK VideoConferenceModule::LowLevelKeyboardProc(int nCode, WPARAM w
|
||||
{
|
||||
if (nCode == HC_ACTION)
|
||||
{
|
||||
KBDLLHOOKSTRUCT* kbd = reinterpret_cast<KBDLLHOOKSTRUCT*>(lParam);
|
||||
switch (wParam)
|
||||
{
|
||||
case WM_KEYDOWN:
|
||||
KBDLLHOOKSTRUCT* kbd = reinterpret_cast<KBDLLHOOKSTRUCT*>(lParam);
|
||||
|
||||
if (isHotkeyPressed(kbd->vkCode, settings.cameraAndMicrophoneMuteHotkey))
|
||||
{
|
||||
@@ -163,11 +164,31 @@ LRESULT CALLBACK VideoConferenceModule::LowLevelKeyboardProc(int nCode, WPARAM w
|
||||
reverseMicrophoneMute();
|
||||
return 1;
|
||||
}
|
||||
else if (isHotkeyPressed(kbd->vkCode, settings.microphonePushToTalkHotkey))
|
||||
{
|
||||
if (!pushToTalkPressed)
|
||||
{
|
||||
if (settings.pushToReverseEnabled || getMicrophoneMuteState())
|
||||
{
|
||||
reverseMicrophoneMute();
|
||||
}
|
||||
pushToTalkPressed = true;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else if (isHotkeyPressed(kbd->vkCode, settings.cameraMuteHotkey))
|
||||
{
|
||||
reverseVirtualCameraMuteState();
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case WM_KEYUP:
|
||||
if (pushToTalkPressed && (kbd->vkCode == settings.microphonePushToTalkHotkey.get_code()))
|
||||
{
|
||||
reverseMicrophoneMute();
|
||||
pushToTalkPressed = false;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,6 +249,14 @@ void VideoConferenceModule::onModuleSettingsChanged()
|
||||
{
|
||||
settings.microphoneMuteHotkey = PowerToysSettings::HotkeyObject::from_json(*val);
|
||||
}
|
||||
if (const auto val = values.get_json(L"push_to_talk_microphone_hotkey"))
|
||||
{
|
||||
settings.microphonePushToTalkHotkey = PowerToysSettings::HotkeyObject::from_json(*val);
|
||||
}
|
||||
if (const auto val = values.get_bool_value(L"push_to_reverse_enabled"))
|
||||
{
|
||||
settings.pushToReverseEnabled = *val;
|
||||
}
|
||||
if (const auto val = values.get_json(L"mute_camera_hotkey"))
|
||||
{
|
||||
settings.cameraMuteHotkey = PowerToysSettings::HotkeyObject::from_json(*val);
|
||||
@@ -386,6 +415,14 @@ void VideoConferenceModule::init_settings()
|
||||
{
|
||||
settings.microphoneMuteHotkey = PowerToysSettings::HotkeyObject::from_json(*val);
|
||||
}
|
||||
if (const auto val = powerToysSettings.get_json(L"push_to_talk_microphone_hotkey"))
|
||||
{
|
||||
settings.microphonePushToTalkHotkey = PowerToysSettings::HotkeyObject::from_json(*val);
|
||||
}
|
||||
if (const auto val = powerToysSettings.get_bool_value(L"push_to_reverse_enabled"))
|
||||
{
|
||||
settings.pushToReverseEnabled = *val;
|
||||
}
|
||||
if (const auto val = powerToysSettings.get_json(L"mute_camera_hotkey"))
|
||||
{
|
||||
settings.cameraMuteHotkey = PowerToysSettings::HotkeyObject::from_json(*val);
|
||||
|
||||
@@ -20,6 +20,7 @@ struct VideoConferenceSettings
|
||||
{
|
||||
PowerToysSettings::HotkeyObject cameraAndMicrophoneMuteHotkey = PowerToysSettings::HotkeyObject::from_settings(true, false, false, true, 81);
|
||||
PowerToysSettings::HotkeyObject microphoneMuteHotkey = PowerToysSettings::HotkeyObject::from_settings(true, false, false, true, 65);
|
||||
PowerToysSettings::HotkeyObject microphonePushToTalkHotkey = PowerToysSettings::HotkeyObject::from_settings(true, false, false, true, 73);
|
||||
PowerToysSettings::HotkeyObject cameraMuteHotkey = PowerToysSettings::HotkeyObject::from_settings(true, false, false, true, 79);
|
||||
|
||||
std::wstring toolbarPositionString;
|
||||
@@ -28,6 +29,8 @@ struct VideoConferenceSettings
|
||||
std::wstring selectedCamera;
|
||||
std::wstring imageOverlayPath;
|
||||
std::wstring selectedMicrophone;
|
||||
|
||||
bool pushToReverseEnabled = false;
|
||||
};
|
||||
|
||||
class VideoConferenceModule : public PowertoyModuleIface
|
||||
@@ -93,4 +96,5 @@ private:
|
||||
|
||||
static VideoConferenceSettings settings;
|
||||
static Toolbar toolbar;
|
||||
static bool pushToTalkPressed;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user