From 1438a628adc9ddbd6675204cadb85912bb1a1bd1 Mon Sep 17 00:00:00 2001 From: Kai Tao <69313318+vanzue@users.noreply.github.com> Date: Mon, 5 Jan 2026 11:12:25 +0800 Subject: [PATCH] Find My Mouse: Add telemetry for trigger source (#44446) ## Summary of the Pull Request ## PR Checklist - [ ] Closes: #xxx - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx ## Detailed Description of the Pull Request / Additional comments ## Validation Steps Performed Verified trace successfully locally --- src/modules/MouseUtils/FindMyMouse/FindMyMouse.cpp | 12 ++++++------ src/modules/MouseUtils/FindMyMouse/trace.cpp | 5 +++-- src/modules/MouseUtils/FindMyMouse/trace.h | 3 ++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/modules/MouseUtils/FindMyMouse/FindMyMouse.cpp b/src/modules/MouseUtils/FindMyMouse/FindMyMouse.cpp index f953af0fdd..5221e12a63 100644 --- a/src/modules/MouseUtils/FindMyMouse/FindMyMouse.cpp +++ b/src/modules/MouseUtils/FindMyMouse/FindMyMouse.cpp @@ -155,7 +155,7 @@ private: void DetectShake(); bool KeyboardInputCanActivate(); - void StartSonar(); + void StartSonar(FindMyMouseActivationMethod activationMethod); void StopSonar(); }; @@ -275,7 +275,7 @@ LRESULT SuperSonar::BaseWndProc(UINT message, WPARAM wParam, LPARAM lParam) n { if (m_sonarStart == NoSonar) { - StartSonar(); + StartSonar(FindMyMouseActivationMethod::Shortcut); } else { @@ -384,7 +384,7 @@ void SuperSonar::OnSonarKeyboardInput(RAWINPUT const& input) IsEqual(m_lastKeyPos, ptCursor)) { m_sonarState = SonarState::ControlDown2; - StartSonar(); + StartSonar(m_activationMethod); } else { @@ -451,7 +451,7 @@ void SuperSonar::DetectShake() if (diagonal > 0 && distanceTravelled / diagonal > (m_shakeFactor / 100.f)) { m_movementHistory.clear(); - StartSonar(); + StartSonar(m_activationMethod); } } @@ -519,7 +519,7 @@ void SuperSonar::OnSonarMouseInput(RAWINPUT const& input) } template -void SuperSonar::StartSonar() +void SuperSonar::StartSonar(FindMyMouseActivationMethod activationMethod) { // Don't activate if game mode is on. if (m_doNotActivateOnGameMode && detect_game_mode()) @@ -532,7 +532,7 @@ void SuperSonar::StartSonar() return; } - Trace::MousePointerFocused(); + Trace::MousePointerFocused(static_cast(activationMethod)); // Cover the entire virtual screen. // HACK: Draw with 1 pixel off. Otherwise, Windows glitches the task bar transparency when a transparent window fill the whole screen. SetWindowPos(m_hwnd, HWND_TOPMOST, GetSystemMetrics(SM_XVIRTUALSCREEN) + 1, GetSystemMetrics(SM_YVIRTUALSCREEN) + 1, GetSystemMetrics(SM_CXVIRTUALSCREEN) - 2, GetSystemMetrics(SM_CYVIRTUALSCREEN) - 2, 0); diff --git a/src/modules/MouseUtils/FindMyMouse/trace.cpp b/src/modules/MouseUtils/FindMyMouse/trace.cpp index bf79461e9a..6309596cf8 100644 --- a/src/modules/MouseUtils/FindMyMouse/trace.cpp +++ b/src/modules/MouseUtils/FindMyMouse/trace.cpp @@ -22,11 +22,12 @@ void Trace::EnableFindMyMouse(const bool enabled) noexcept } // Log that the user activated the module by focusing the mouse pointer -void Trace::MousePointerFocused() noexcept +void Trace::MousePointerFocused(const int activationMethod) noexcept { TraceLoggingWriteWrapper( g_hProvider, "FindMyMouse_MousePointerFocused", ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance), - TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE)); + TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE), + TraceLoggingInt32(activationMethod, "ActivationMethod")); } diff --git a/src/modules/MouseUtils/FindMyMouse/trace.h b/src/modules/MouseUtils/FindMyMouse/trace.h index 59d3183b5b..90933e9403 100644 --- a/src/modules/MouseUtils/FindMyMouse/trace.h +++ b/src/modules/MouseUtils/FindMyMouse/trace.h @@ -9,5 +9,6 @@ public: static void EnableFindMyMouse(const bool enabled) noexcept; // Log that the user activated the module by focusing the mouse pointer - static void MousePointerFocused() noexcept; + // activationMethod: 0 = DoubleLeftControlKey, 1 = DoubleRightControlKey, 2 = ShakeMouse, 3 = Shortcut + static void MousePointerFocused(const int activationMethod) noexcept; };