Find My Mouse: Add telemetry for trigger source (#44446)

<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [ ] Closes: #xxx
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
Verified trace successfully locally
This commit is contained in:
Kai Tao
2026-01-05 11:12:25 +08:00
committed by GitHub
parent 1b6b446915
commit 1438a628ad
3 changed files with 11 additions and 9 deletions

View File

@@ -155,7 +155,7 @@ private:
void DetectShake(); void DetectShake();
bool KeyboardInputCanActivate(); bool KeyboardInputCanActivate();
void StartSonar(); void StartSonar(FindMyMouseActivationMethod activationMethod);
void StopSonar(); void StopSonar();
}; };
@@ -275,7 +275,7 @@ LRESULT SuperSonar<D>::BaseWndProc(UINT message, WPARAM wParam, LPARAM lParam) n
{ {
if (m_sonarStart == NoSonar) if (m_sonarStart == NoSonar)
{ {
StartSonar(); StartSonar(FindMyMouseActivationMethod::Shortcut);
} }
else else
{ {
@@ -384,7 +384,7 @@ void SuperSonar<D>::OnSonarKeyboardInput(RAWINPUT const& input)
IsEqual(m_lastKeyPos, ptCursor)) IsEqual(m_lastKeyPos, ptCursor))
{ {
m_sonarState = SonarState::ControlDown2; m_sonarState = SonarState::ControlDown2;
StartSonar(); StartSonar(m_activationMethod);
} }
else else
{ {
@@ -451,7 +451,7 @@ void SuperSonar<D>::DetectShake()
if (diagonal > 0 && distanceTravelled / diagonal > (m_shakeFactor / 100.f)) if (diagonal > 0 && distanceTravelled / diagonal > (m_shakeFactor / 100.f))
{ {
m_movementHistory.clear(); m_movementHistory.clear();
StartSonar(); StartSonar(m_activationMethod);
} }
} }
@@ -519,7 +519,7 @@ void SuperSonar<D>::OnSonarMouseInput(RAWINPUT const& input)
} }
template<typename D> template<typename D>
void SuperSonar<D>::StartSonar() void SuperSonar<D>::StartSonar(FindMyMouseActivationMethod activationMethod)
{ {
// Don't activate if game mode is on. // Don't activate if game mode is on.
if (m_doNotActivateOnGameMode && detect_game_mode()) if (m_doNotActivateOnGameMode && detect_game_mode())
@@ -532,7 +532,7 @@ void SuperSonar<D>::StartSonar()
return; return;
} }
Trace::MousePointerFocused(); Trace::MousePointerFocused(static_cast<int>(activationMethod));
// Cover the entire virtual screen. // 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. // 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); SetWindowPos(m_hwnd, HWND_TOPMOST, GetSystemMetrics(SM_XVIRTUALSCREEN) + 1, GetSystemMetrics(SM_YVIRTUALSCREEN) + 1, GetSystemMetrics(SM_CXVIRTUALSCREEN) - 2, GetSystemMetrics(SM_CYVIRTUALSCREEN) - 2, 0);

View File

@@ -22,11 +22,12 @@ void Trace::EnableFindMyMouse(const bool enabled) noexcept
} }
// Log that the user activated the module by focusing the mouse pointer // Log that the user activated the module by focusing the mouse pointer
void Trace::MousePointerFocused() noexcept void Trace::MousePointerFocused(const int activationMethod) noexcept
{ {
TraceLoggingWriteWrapper( TraceLoggingWriteWrapper(
g_hProvider, g_hProvider,
"FindMyMouse_MousePointerFocused", "FindMyMouse_MousePointerFocused",
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance), ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE)); TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
TraceLoggingInt32(activationMethod, "ActivationMethod"));
} }

View File

@@ -9,5 +9,6 @@ public:
static void EnableFindMyMouse(const bool enabled) noexcept; static void EnableFindMyMouse(const bool enabled) noexcept;
// Log that the user activated the module by focusing the mouse pointer // 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;
}; };