2022-01-24 13:29:16 +00:00
|
|
|
#include "pch.h"
|
|
|
|
|
#include <interface/powertoy_module_interface.h>
|
|
|
|
|
#include <common/SettingsAPI/settings_objects.h>
|
|
|
|
|
#include "trace.h"
|
2022-01-26 14:01:24 +00:00
|
|
|
#include "InclusiveCrosshairs.h"
|
2022-01-24 13:29:16 +00:00
|
|
|
#include "common/utils/color.h"
|
Implement "Gliding cursor" accessibility feature (#41221)
## Summary of the Pull Request
Added '[Gliding
Cursor](https://github.com/microsoft/PowerToys/issues/37097)'
functionality to Mouse Pointer Crosshairs, this enables a single
hotkey/Microsoft Adaptive Hub + button to control cursor movement and
clicking. This is implemented as an extension to the existing Mouse
Pointer Crosshairs module.
Testing has been manual, ensuring that the existing Mouse Pointer
Crosshairs functionality is unchanged, and that the new Gliding Cursor
functionality works alongside Mouse Pointer Crosshairs.

<img width="857" height="438" alt="image"
src="https://github.com/user-attachments/assets/b9e7ee72-dfeb-4d20-93a5-a34e8b10d703"
/>
To test this functionality:
- Open Mouse Crosshair settings and make sure the feature is enabled.
- Press the shortcut to start the gliding cursor — a vertical line
appears.
- Press the shortcut again to slow the vertical line.
- Press once more to fix the vertical line; a horizontal line begins
moving.
- Press again to slow the horizontal line.
- When the lines meet at your target, press the shortcut to perform the
click.
## PR Checklist
- [x] Closes: #37097
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **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
The PR includes these changes:
* Updated Mouse Pointer Crosshairs XAML to include a new hotkey to start
the gliding cursor experience
* Added two sliders for fast/slow cursor movement
* mapped the new hotkey/XAML sliders through to the existing
MousePointerHotkeys project, dllmain.cpp
* Added a 10ms tick for Gliding cursor for crosshairs/cursor movement
* Added state for gliding functionality - horiz fast, horiz slow, vert
fast, vert slow, click
* added gates around the existing mouse movement hook to prevent mouse
movement when gliding
## Validation Steps Performed
Manual testing has been completed on several PCs to confirm the
following:
* Existing Mouse Pointer Crosshairs functionality is unchanged
* Gliding cursor settings are persisted/used by the gliding cursor code
* Gliding cursor restores Mouse Pointer Crosshairs state after the final
click has completed.
---------
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com>
2025-08-21 06:53:20 +01:00
|
|
|
#include <atomic>
|
|
|
|
|
#include <thread>
|
|
|
|
|
#include <chrono>
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
|
|
extern void InclusiveCrosshairsRequestUpdatePosition();
|
|
|
|
|
extern void InclusiveCrosshairsEnsureOn();
|
|
|
|
|
extern void InclusiveCrosshairsEnsureOff();
|
|
|
|
|
extern void InclusiveCrosshairsSetExternalControl(bool enabled);
|
2022-01-24 13:29:16 +00:00
|
|
|
|
|
|
|
|
// Non-Localizable strings
|
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
const wchar_t JSON_KEY_PROPERTIES[] = L"properties";
|
|
|
|
|
const wchar_t JSON_KEY_VALUE[] = L"value";
|
|
|
|
|
const wchar_t JSON_KEY_ACTIVATION_SHORTCUT[] = L"activation_shortcut";
|
Implement "Gliding cursor" accessibility feature (#41221)
## Summary of the Pull Request
Added '[Gliding
Cursor](https://github.com/microsoft/PowerToys/issues/37097)'
functionality to Mouse Pointer Crosshairs, this enables a single
hotkey/Microsoft Adaptive Hub + button to control cursor movement and
clicking. This is implemented as an extension to the existing Mouse
Pointer Crosshairs module.
Testing has been manual, ensuring that the existing Mouse Pointer
Crosshairs functionality is unchanged, and that the new Gliding Cursor
functionality works alongside Mouse Pointer Crosshairs.

<img width="857" height="438" alt="image"
src="https://github.com/user-attachments/assets/b9e7ee72-dfeb-4d20-93a5-a34e8b10d703"
/>
To test this functionality:
- Open Mouse Crosshair settings and make sure the feature is enabled.
- Press the shortcut to start the gliding cursor — a vertical line
appears.
- Press the shortcut again to slow the vertical line.
- Press once more to fix the vertical line; a horizontal line begins
moving.
- Press again to slow the horizontal line.
- When the lines meet at your target, press the shortcut to perform the
click.
## PR Checklist
- [x] Closes: #37097
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **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
The PR includes these changes:
* Updated Mouse Pointer Crosshairs XAML to include a new hotkey to start
the gliding cursor experience
* Added two sliders for fast/slow cursor movement
* mapped the new hotkey/XAML sliders through to the existing
MousePointerHotkeys project, dllmain.cpp
* Added a 10ms tick for Gliding cursor for crosshairs/cursor movement
* Added state for gliding functionality - horiz fast, horiz slow, vert
fast, vert slow, click
* added gates around the existing mouse movement hook to prevent mouse
movement when gliding
## Validation Steps Performed
Manual testing has been completed on several PCs to confirm the
following:
* Existing Mouse Pointer Crosshairs functionality is unchanged
* Gliding cursor settings are persisted/used by the gliding cursor code
* Gliding cursor restores Mouse Pointer Crosshairs state after the final
click has completed.
---------
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com>
2025-08-21 06:53:20 +01:00
|
|
|
const wchar_t JSON_KEY_GLIDING_ACTIVATION_SHORTCUT[] = L"gliding_cursor_activation_shortcut";
|
2022-01-26 14:01:24 +00:00
|
|
|
const wchar_t JSON_KEY_CROSSHAIRS_COLOR[] = L"crosshairs_color";
|
|
|
|
|
const wchar_t JSON_KEY_CROSSHAIRS_OPACITY[] = L"crosshairs_opacity";
|
|
|
|
|
const wchar_t JSON_KEY_CROSSHAIRS_RADIUS[] = L"crosshairs_radius";
|
|
|
|
|
const wchar_t JSON_KEY_CROSSHAIRS_THICKNESS[] = L"crosshairs_thickness";
|
|
|
|
|
const wchar_t JSON_KEY_CROSSHAIRS_BORDER_COLOR[] = L"crosshairs_border_color";
|
|
|
|
|
const wchar_t JSON_KEY_CROSSHAIRS_BORDER_SIZE[] = L"crosshairs_border_size";
|
2023-07-18 14:33:32 +02:00
|
|
|
const wchar_t JSON_KEY_CROSSHAIRS_AUTO_HIDE[] = L"crosshairs_auto_hide";
|
2023-07-19 07:24:47 -07:00
|
|
|
const wchar_t JSON_KEY_CROSSHAIRS_IS_FIXED_LENGTH_ENABLED[] = L"crosshairs_is_fixed_length_enabled";
|
|
|
|
|
const wchar_t JSON_KEY_CROSSHAIRS_FIXED_LENGTH[] = L"crosshairs_fixed_length";
|
2023-08-08 18:01:23 +02:00
|
|
|
const wchar_t JSON_KEY_AUTO_ACTIVATE[] = L"auto_activate";
|
Implement "Gliding cursor" accessibility feature (#41221)
## Summary of the Pull Request
Added '[Gliding
Cursor](https://github.com/microsoft/PowerToys/issues/37097)'
functionality to Mouse Pointer Crosshairs, this enables a single
hotkey/Microsoft Adaptive Hub + button to control cursor movement and
clicking. This is implemented as an extension to the existing Mouse
Pointer Crosshairs module.
Testing has been manual, ensuring that the existing Mouse Pointer
Crosshairs functionality is unchanged, and that the new Gliding Cursor
functionality works alongside Mouse Pointer Crosshairs.

<img width="857" height="438" alt="image"
src="https://github.com/user-attachments/assets/b9e7ee72-dfeb-4d20-93a5-a34e8b10d703"
/>
To test this functionality:
- Open Mouse Crosshair settings and make sure the feature is enabled.
- Press the shortcut to start the gliding cursor — a vertical line
appears.
- Press the shortcut again to slow the vertical line.
- Press once more to fix the vertical line; a horizontal line begins
moving.
- Press again to slow the horizontal line.
- When the lines meet at your target, press the shortcut to perform the
click.
## PR Checklist
- [x] Closes: #37097
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **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
The PR includes these changes:
* Updated Mouse Pointer Crosshairs XAML to include a new hotkey to start
the gliding cursor experience
* Added two sliders for fast/slow cursor movement
* mapped the new hotkey/XAML sliders through to the existing
MousePointerHotkeys project, dllmain.cpp
* Added a 10ms tick for Gliding cursor for crosshairs/cursor movement
* Added state for gliding functionality - horiz fast, horiz slow, vert
fast, vert slow, click
* added gates around the existing mouse movement hook to prevent mouse
movement when gliding
## Validation Steps Performed
Manual testing has been completed on several PCs to confirm the
following:
* Existing Mouse Pointer Crosshairs functionality is unchanged
* Gliding cursor settings are persisted/used by the gliding cursor code
* Gliding cursor restores Mouse Pointer Crosshairs state after the final
click has completed.
---------
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com>
2025-08-21 06:53:20 +01:00
|
|
|
const wchar_t JSON_KEY_GLIDE_TRAVEL_SPEED[] = L"gliding_travel_speed";
|
|
|
|
|
const wchar_t JSON_KEY_GLIDE_DELAY_SPEED[] = L"gliding_delay_speed";
|
2022-01-24 13:29:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extern "C" IMAGE_DOS_HEADER __ImageBase;
|
|
|
|
|
|
|
|
|
|
HMODULE m_hModule;
|
|
|
|
|
|
Implement "Gliding cursor" accessibility feature (#41221)
## Summary of the Pull Request
Added '[Gliding
Cursor](https://github.com/microsoft/PowerToys/issues/37097)'
functionality to Mouse Pointer Crosshairs, this enables a single
hotkey/Microsoft Adaptive Hub + button to control cursor movement and
clicking. This is implemented as an extension to the existing Mouse
Pointer Crosshairs module.
Testing has been manual, ensuring that the existing Mouse Pointer
Crosshairs functionality is unchanged, and that the new Gliding Cursor
functionality works alongside Mouse Pointer Crosshairs.

<img width="857" height="438" alt="image"
src="https://github.com/user-attachments/assets/b9e7ee72-dfeb-4d20-93a5-a34e8b10d703"
/>
To test this functionality:
- Open Mouse Crosshair settings and make sure the feature is enabled.
- Press the shortcut to start the gliding cursor — a vertical line
appears.
- Press the shortcut again to slow the vertical line.
- Press once more to fix the vertical line; a horizontal line begins
moving.
- Press again to slow the horizontal line.
- When the lines meet at your target, press the shortcut to perform the
click.
## PR Checklist
- [x] Closes: #37097
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **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
The PR includes these changes:
* Updated Mouse Pointer Crosshairs XAML to include a new hotkey to start
the gliding cursor experience
* Added two sliders for fast/slow cursor movement
* mapped the new hotkey/XAML sliders through to the existing
MousePointerHotkeys project, dllmain.cpp
* Added a 10ms tick for Gliding cursor for crosshairs/cursor movement
* Added state for gliding functionality - horiz fast, horiz slow, vert
fast, vert slow, click
* added gates around the existing mouse movement hook to prevent mouse
movement when gliding
## Validation Steps Performed
Manual testing has been completed on several PCs to confirm the
following:
* Existing Mouse Pointer Crosshairs functionality is unchanged
* Gliding cursor settings are persisted/used by the gliding cursor code
* Gliding cursor restores Mouse Pointer Crosshairs state after the final
click has completed.
---------
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com>
2025-08-21 06:53:20 +01:00
|
|
|
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
|
2022-01-24 13:29:16 +00:00
|
|
|
{
|
|
|
|
|
m_hModule = hModule;
|
|
|
|
|
switch (ul_reason_for_call)
|
|
|
|
|
{
|
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
|
Trace::RegisterProvider();
|
|
|
|
|
break;
|
|
|
|
|
case DLL_THREAD_ATTACH:
|
|
|
|
|
case DLL_THREAD_DETACH:
|
|
|
|
|
break;
|
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
|
Trace::UnregisterProvider();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The PowerToy name that will be shown in the settings.
|
2022-01-26 14:01:24 +00:00
|
|
|
const static wchar_t* MODULE_NAME = L"MousePointerCrosshairs";
|
2022-01-24 13:29:16 +00:00
|
|
|
// Add a description that will we shown in the module settings page.
|
|
|
|
|
const static wchar_t* MODULE_DESC = L"<no description>";
|
|
|
|
|
|
|
|
|
|
// Implement the PowerToy Module Interface and all the required methods.
|
2022-01-26 14:01:24 +00:00
|
|
|
class MousePointerCrosshairs : public PowertoyModuleIface
|
2022-01-24 13:29:16 +00:00
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
// The PowerToy state.
|
|
|
|
|
bool m_enabled = false;
|
|
|
|
|
|
Implement "Gliding cursor" accessibility feature (#41221)
## Summary of the Pull Request
Added '[Gliding
Cursor](https://github.com/microsoft/PowerToys/issues/37097)'
functionality to Mouse Pointer Crosshairs, this enables a single
hotkey/Microsoft Adaptive Hub + button to control cursor movement and
clicking. This is implemented as an extension to the existing Mouse
Pointer Crosshairs module.
Testing has been manual, ensuring that the existing Mouse Pointer
Crosshairs functionality is unchanged, and that the new Gliding Cursor
functionality works alongside Mouse Pointer Crosshairs.

<img width="857" height="438" alt="image"
src="https://github.com/user-attachments/assets/b9e7ee72-dfeb-4d20-93a5-a34e8b10d703"
/>
To test this functionality:
- Open Mouse Crosshair settings and make sure the feature is enabled.
- Press the shortcut to start the gliding cursor — a vertical line
appears.
- Press the shortcut again to slow the vertical line.
- Press once more to fix the vertical line; a horizontal line begins
moving.
- Press again to slow the horizontal line.
- When the lines meet at your target, press the shortcut to perform the
click.
## PR Checklist
- [x] Closes: #37097
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **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
The PR includes these changes:
* Updated Mouse Pointer Crosshairs XAML to include a new hotkey to start
the gliding cursor experience
* Added two sliders for fast/slow cursor movement
* mapped the new hotkey/XAML sliders through to the existing
MousePointerHotkeys project, dllmain.cpp
* Added a 10ms tick for Gliding cursor for crosshairs/cursor movement
* Added state for gliding functionality - horiz fast, horiz slow, vert
fast, vert slow, click
* added gates around the existing mouse movement hook to prevent mouse
movement when gliding
## Validation Steps Performed
Manual testing has been completed on several PCs to confirm the
following:
* Existing Mouse Pointer Crosshairs functionality is unchanged
* Gliding cursor settings are persisted/used by the gliding cursor code
* Gliding cursor restores Mouse Pointer Crosshairs state after the final
click has completed.
---------
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com>
2025-08-21 06:53:20 +01:00
|
|
|
// Additional hotkeys (legacy API) to support multiple shortcuts
|
|
|
|
|
Hotkey m_activationHotkey{}; // Crosshairs toggle
|
|
|
|
|
Hotkey m_glidingHotkey{}; // Gliding cursor state machine
|
|
|
|
|
|
|
|
|
|
// Shared state for worker threads (decoupled from this lifetime)
|
|
|
|
|
struct State
|
|
|
|
|
{
|
|
|
|
|
std::atomic<bool> stopX{ false };
|
|
|
|
|
std::atomic<bool> stopY{ false };
|
|
|
|
|
|
|
|
|
|
// positions and speeds
|
|
|
|
|
int currentXPos{ 0 };
|
|
|
|
|
int currentYPos{ 0 };
|
|
|
|
|
int currentXSpeed{ 0 }; // pixels per base window
|
|
|
|
|
int currentYSpeed{ 0 }; // pixels per base window
|
|
|
|
|
int xPosSnapshot{ 0 }; // xPos captured at end of horizontal scan
|
|
|
|
|
|
|
|
|
|
// Fractional accumulators to spread movement across 10ms ticks
|
|
|
|
|
double xFraction{ 0.0 };
|
|
|
|
|
double yFraction{ 0.0 };
|
|
|
|
|
|
|
|
|
|
// Speeds represent pixels per 200ms (min 5, max 60 enforced by UI/settings)
|
|
|
|
|
int fastHSpeed{ 30 }; // pixels per base window
|
|
|
|
|
int slowHSpeed{ 5 }; // pixels per base window
|
|
|
|
|
int fastVSpeed{ 30 }; // pixels per base window
|
|
|
|
|
int slowVSpeed{ 5 }; // pixels per base window
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<State> m_state;
|
|
|
|
|
|
|
|
|
|
// Worker threads
|
|
|
|
|
std::thread m_xThread;
|
|
|
|
|
std::thread m_yThread;
|
|
|
|
|
|
|
|
|
|
// Gliding cursor state machine
|
|
|
|
|
std::atomic<int> m_glideState{ 0 }; // 0..4 like the AHK script
|
|
|
|
|
|
|
|
|
|
// Timer configuration: 10ms tick, speeds are defined per 200ms base window
|
|
|
|
|
static constexpr int kTimerTickMs = 10;
|
|
|
|
|
static constexpr int kBaseSpeedTickMs = 200; // mapping period for configured pixel counts
|
2022-01-24 13:29:16 +00:00
|
|
|
|
2022-01-26 14:01:24 +00:00
|
|
|
// Mouse Pointer Crosshairs specific settings
|
|
|
|
|
InclusiveCrosshairsSettings m_inclusiveCrosshairsSettings;
|
2022-01-24 13:29:16 +00:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// Constructor
|
2022-01-26 14:01:24 +00:00
|
|
|
MousePointerCrosshairs()
|
2022-01-24 13:29:16 +00:00
|
|
|
{
|
2022-01-26 14:01:24 +00:00
|
|
|
LoggerHelpers::init_logger(MODULE_NAME, L"ModuleInterface", LogSettings::mousePointerCrosshairsLoggerName);
|
Implement "Gliding cursor" accessibility feature (#41221)
## Summary of the Pull Request
Added '[Gliding
Cursor](https://github.com/microsoft/PowerToys/issues/37097)'
functionality to Mouse Pointer Crosshairs, this enables a single
hotkey/Microsoft Adaptive Hub + button to control cursor movement and
clicking. This is implemented as an extension to the existing Mouse
Pointer Crosshairs module.
Testing has been manual, ensuring that the existing Mouse Pointer
Crosshairs functionality is unchanged, and that the new Gliding Cursor
functionality works alongside Mouse Pointer Crosshairs.

<img width="857" height="438" alt="image"
src="https://github.com/user-attachments/assets/b9e7ee72-dfeb-4d20-93a5-a34e8b10d703"
/>
To test this functionality:
- Open Mouse Crosshair settings and make sure the feature is enabled.
- Press the shortcut to start the gliding cursor — a vertical line
appears.
- Press the shortcut again to slow the vertical line.
- Press once more to fix the vertical line; a horizontal line begins
moving.
- Press again to slow the horizontal line.
- When the lines meet at your target, press the shortcut to perform the
click.
## PR Checklist
- [x] Closes: #37097
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **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
The PR includes these changes:
* Updated Mouse Pointer Crosshairs XAML to include a new hotkey to start
the gliding cursor experience
* Added two sliders for fast/slow cursor movement
* mapped the new hotkey/XAML sliders through to the existing
MousePointerHotkeys project, dllmain.cpp
* Added a 10ms tick for Gliding cursor for crosshairs/cursor movement
* Added state for gliding functionality - horiz fast, horiz slow, vert
fast, vert slow, click
* added gates around the existing mouse movement hook to prevent mouse
movement when gliding
## Validation Steps Performed
Manual testing has been completed on several PCs to confirm the
following:
* Existing Mouse Pointer Crosshairs functionality is unchanged
* Gliding cursor settings are persisted/used by the gliding cursor code
* Gliding cursor restores Mouse Pointer Crosshairs state after the final
click has completed.
---------
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com>
2025-08-21 06:53:20 +01:00
|
|
|
m_state = std::make_shared<State>();
|
2022-01-24 13:29:16 +00:00
|
|
|
init_settings();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Destroy the powertoy and free memory
|
|
|
|
|
virtual void destroy() override
|
|
|
|
|
{
|
Implement "Gliding cursor" accessibility feature (#41221)
## Summary of the Pull Request
Added '[Gliding
Cursor](https://github.com/microsoft/PowerToys/issues/37097)'
functionality to Mouse Pointer Crosshairs, this enables a single
hotkey/Microsoft Adaptive Hub + button to control cursor movement and
clicking. This is implemented as an extension to the existing Mouse
Pointer Crosshairs module.
Testing has been manual, ensuring that the existing Mouse Pointer
Crosshairs functionality is unchanged, and that the new Gliding Cursor
functionality works alongside Mouse Pointer Crosshairs.

<img width="857" height="438" alt="image"
src="https://github.com/user-attachments/assets/b9e7ee72-dfeb-4d20-93a5-a34e8b10d703"
/>
To test this functionality:
- Open Mouse Crosshair settings and make sure the feature is enabled.
- Press the shortcut to start the gliding cursor — a vertical line
appears.
- Press the shortcut again to slow the vertical line.
- Press once more to fix the vertical line; a horizontal line begins
moving.
- Press again to slow the horizontal line.
- When the lines meet at your target, press the shortcut to perform the
click.
## PR Checklist
- [x] Closes: #37097
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **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
The PR includes these changes:
* Updated Mouse Pointer Crosshairs XAML to include a new hotkey to start
the gliding cursor experience
* Added two sliders for fast/slow cursor movement
* mapped the new hotkey/XAML sliders through to the existing
MousePointerHotkeys project, dllmain.cpp
* Added a 10ms tick for Gliding cursor for crosshairs/cursor movement
* Added state for gliding functionality - horiz fast, horiz slow, vert
fast, vert slow, click
* added gates around the existing mouse movement hook to prevent mouse
movement when gliding
## Validation Steps Performed
Manual testing has been completed on several PCs to confirm the
following:
* Existing Mouse Pointer Crosshairs functionality is unchanged
* Gliding cursor settings are persisted/used by the gliding cursor code
* Gliding cursor restores Mouse Pointer Crosshairs state after the final
click has completed.
---------
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com>
2025-08-21 06:53:20 +01:00
|
|
|
StopXTimer();
|
|
|
|
|
StopYTimer();
|
|
|
|
|
// Release shared state so worker threads (if any) exit when weak_ptr lock fails
|
|
|
|
|
m_state.reset();
|
2022-01-24 13:29:16 +00:00
|
|
|
delete this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Return the localized display name of the powertoy
|
|
|
|
|
virtual const wchar_t* get_name() override
|
|
|
|
|
{
|
|
|
|
|
return MODULE_NAME;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Return the non localized key of the powertoy, this will be cached by the runner
|
|
|
|
|
virtual const wchar_t* get_key() override
|
|
|
|
|
{
|
|
|
|
|
return MODULE_NAME;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-26 14:02:31 +01:00
|
|
|
// Return the configured status for the gpo policy for the module
|
|
|
|
|
virtual powertoys_gpo::gpo_rule_configured_t gpo_policy_enabled_configuration() override
|
|
|
|
|
{
|
|
|
|
|
return powertoys_gpo::getConfiguredMousePointerCrosshairsEnabledValue();
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-24 13:29:16 +00:00
|
|
|
// Return JSON with the configuration options.
|
|
|
|
|
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
|
|
|
|
{
|
|
|
|
|
HINSTANCE hinstance = reinterpret_cast<HINSTANCE>(&__ImageBase);
|
|
|
|
|
|
|
|
|
|
PowerToysSettings::Settings settings(hinstance, get_name());
|
|
|
|
|
|
|
|
|
|
return settings.serialize_to_buffer(buffer, buffer_size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Signal from the Settings editor to call a custom action.
|
|
|
|
|
// This can be used to spawn more complex editors.
|
Implement "Gliding cursor" accessibility feature (#41221)
## Summary of the Pull Request
Added '[Gliding
Cursor](https://github.com/microsoft/PowerToys/issues/37097)'
functionality to Mouse Pointer Crosshairs, this enables a single
hotkey/Microsoft Adaptive Hub + button to control cursor movement and
clicking. This is implemented as an extension to the existing Mouse
Pointer Crosshairs module.
Testing has been manual, ensuring that the existing Mouse Pointer
Crosshairs functionality is unchanged, and that the new Gliding Cursor
functionality works alongside Mouse Pointer Crosshairs.

<img width="857" height="438" alt="image"
src="https://github.com/user-attachments/assets/b9e7ee72-dfeb-4d20-93a5-a34e8b10d703"
/>
To test this functionality:
- Open Mouse Crosshair settings and make sure the feature is enabled.
- Press the shortcut to start the gliding cursor — a vertical line
appears.
- Press the shortcut again to slow the vertical line.
- Press once more to fix the vertical line; a horizontal line begins
moving.
- Press again to slow the horizontal line.
- When the lines meet at your target, press the shortcut to perform the
click.
## PR Checklist
- [x] Closes: #37097
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **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
The PR includes these changes:
* Updated Mouse Pointer Crosshairs XAML to include a new hotkey to start
the gliding cursor experience
* Added two sliders for fast/slow cursor movement
* mapped the new hotkey/XAML sliders through to the existing
MousePointerHotkeys project, dllmain.cpp
* Added a 10ms tick for Gliding cursor for crosshairs/cursor movement
* Added state for gliding functionality - horiz fast, horiz slow, vert
fast, vert slow, click
* added gates around the existing mouse movement hook to prevent mouse
movement when gliding
## Validation Steps Performed
Manual testing has been completed on several PCs to confirm the
following:
* Existing Mouse Pointer Crosshairs functionality is unchanged
* Gliding cursor settings are persisted/used by the gliding cursor code
* Gliding cursor restores Mouse Pointer Crosshairs state after the final
click has completed.
---------
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com>
2025-08-21 06:53:20 +01:00
|
|
|
virtual void call_custom_action(const wchar_t* /*action*/) override {}
|
2022-01-24 13:29:16 +00:00
|
|
|
|
|
|
|
|
// Called by the runner to pass the updated settings values as a serialized JSON.
|
|
|
|
|
virtual void set_config(const wchar_t* config) override
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Parse the input JSON string.
|
|
|
|
|
PowerToysSettings::PowerToyValues values =
|
|
|
|
|
PowerToysSettings::PowerToyValues::from_json_string(config, get_key());
|
|
|
|
|
|
|
|
|
|
parse_settings(values);
|
|
|
|
|
|
2022-01-26 14:01:24 +00:00
|
|
|
InclusiveCrosshairsApplySettings(m_inclusiveCrosshairsSettings);
|
2022-01-24 13:29:16 +00:00
|
|
|
}
|
|
|
|
|
catch (std::exception&)
|
|
|
|
|
{
|
2022-01-26 14:01:24 +00:00
|
|
|
Logger::error("Invalid json when trying to parse Mouse Pointer Crosshairs settings json.");
|
2022-01-24 13:29:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Enable the powertoy
|
|
|
|
|
virtual void enable()
|
|
|
|
|
{
|
|
|
|
|
m_enabled = true;
|
2022-01-26 14:01:24 +00:00
|
|
|
Trace::EnableMousePointerCrosshairs(true);
|
|
|
|
|
std::thread([=]() { InclusiveCrosshairsMain(m_hModule, m_inclusiveCrosshairsSettings); }).detach();
|
2022-01-24 13:29:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Disable the powertoy
|
|
|
|
|
virtual void disable()
|
|
|
|
|
{
|
|
|
|
|
m_enabled = false;
|
2022-01-26 14:01:24 +00:00
|
|
|
Trace::EnableMousePointerCrosshairs(false);
|
Implement "Gliding cursor" accessibility feature (#41221)
## Summary of the Pull Request
Added '[Gliding
Cursor](https://github.com/microsoft/PowerToys/issues/37097)'
functionality to Mouse Pointer Crosshairs, this enables a single
hotkey/Microsoft Adaptive Hub + button to control cursor movement and
clicking. This is implemented as an extension to the existing Mouse
Pointer Crosshairs module.
Testing has been manual, ensuring that the existing Mouse Pointer
Crosshairs functionality is unchanged, and that the new Gliding Cursor
functionality works alongside Mouse Pointer Crosshairs.

<img width="857" height="438" alt="image"
src="https://github.com/user-attachments/assets/b9e7ee72-dfeb-4d20-93a5-a34e8b10d703"
/>
To test this functionality:
- Open Mouse Crosshair settings and make sure the feature is enabled.
- Press the shortcut to start the gliding cursor — a vertical line
appears.
- Press the shortcut again to slow the vertical line.
- Press once more to fix the vertical line; a horizontal line begins
moving.
- Press again to slow the horizontal line.
- When the lines meet at your target, press the shortcut to perform the
click.
## PR Checklist
- [x] Closes: #37097
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **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
The PR includes these changes:
* Updated Mouse Pointer Crosshairs XAML to include a new hotkey to start
the gliding cursor experience
* Added two sliders for fast/slow cursor movement
* mapped the new hotkey/XAML sliders through to the existing
MousePointerHotkeys project, dllmain.cpp
* Added a 10ms tick for Gliding cursor for crosshairs/cursor movement
* Added state for gliding functionality - horiz fast, horiz slow, vert
fast, vert slow, click
* added gates around the existing mouse movement hook to prevent mouse
movement when gliding
## Validation Steps Performed
Manual testing has been completed on several PCs to confirm the
following:
* Existing Mouse Pointer Crosshairs functionality is unchanged
* Gliding cursor settings are persisted/used by the gliding cursor code
* Gliding cursor restores Mouse Pointer Crosshairs state after the final
click has completed.
---------
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com>
2025-08-21 06:53:20 +01:00
|
|
|
StopXTimer();
|
|
|
|
|
StopYTimer();
|
|
|
|
|
m_glideState = 0;
|
2022-01-26 14:01:24 +00:00
|
|
|
InclusiveCrosshairsDisable();
|
2022-01-24 13:29:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Returns if the powertoys is enabled
|
|
|
|
|
virtual bool is_enabled() override
|
|
|
|
|
{
|
|
|
|
|
return m_enabled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Returns whether the PowerToys should be enabled by default
|
|
|
|
|
virtual bool is_enabled_by_default() const override
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
Implement "Gliding cursor" accessibility feature (#41221)
## Summary of the Pull Request
Added '[Gliding
Cursor](https://github.com/microsoft/PowerToys/issues/37097)'
functionality to Mouse Pointer Crosshairs, this enables a single
hotkey/Microsoft Adaptive Hub + button to control cursor movement and
clicking. This is implemented as an extension to the existing Mouse
Pointer Crosshairs module.
Testing has been manual, ensuring that the existing Mouse Pointer
Crosshairs functionality is unchanged, and that the new Gliding Cursor
functionality works alongside Mouse Pointer Crosshairs.

<img width="857" height="438" alt="image"
src="https://github.com/user-attachments/assets/b9e7ee72-dfeb-4d20-93a5-a34e8b10d703"
/>
To test this functionality:
- Open Mouse Crosshair settings and make sure the feature is enabled.
- Press the shortcut to start the gliding cursor — a vertical line
appears.
- Press the shortcut again to slow the vertical line.
- Press once more to fix the vertical line; a horizontal line begins
moving.
- Press again to slow the horizontal line.
- When the lines meet at your target, press the shortcut to perform the
click.
## PR Checklist
- [x] Closes: #37097
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **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
The PR includes these changes:
* Updated Mouse Pointer Crosshairs XAML to include a new hotkey to start
the gliding cursor experience
* Added two sliders for fast/slow cursor movement
* mapped the new hotkey/XAML sliders through to the existing
MousePointerHotkeys project, dllmain.cpp
* Added a 10ms tick for Gliding cursor for crosshairs/cursor movement
* Added state for gliding functionality - horiz fast, horiz slow, vert
fast, vert slow, click
* added gates around the existing mouse movement hook to prevent mouse
movement when gliding
## Validation Steps Performed
Manual testing has been completed on several PCs to confirm the
following:
* Existing Mouse Pointer Crosshairs functionality is unchanged
* Gliding cursor settings are persisted/used by the gliding cursor code
* Gliding cursor restores Mouse Pointer Crosshairs state after the final
click has completed.
---------
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com>
2025-08-21 06:53:20 +01:00
|
|
|
// Legacy multi-hotkey support (like CropAndLock)
|
|
|
|
|
virtual size_t get_hotkeys(Hotkey* buffer, size_t buffer_size) override
|
|
|
|
|
{
|
|
|
|
|
if (buffer && buffer_size >= 2)
|
|
|
|
|
{
|
|
|
|
|
buffer[0] = m_activationHotkey; // Crosshairs toggle
|
|
|
|
|
buffer[1] = m_glidingHotkey; // Gliding cursor toggle
|
|
|
|
|
}
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual bool on_hotkey(size_t hotkeyId) override
|
|
|
|
|
{
|
|
|
|
|
if (!m_enabled)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hotkeyId == 0)
|
|
|
|
|
{
|
|
|
|
|
InclusiveCrosshairsSwitch();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if (hotkeyId == 1)
|
|
|
|
|
{
|
|
|
|
|
HandleGlidingHotkey();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
static void LeftClick()
|
|
|
|
|
{
|
|
|
|
|
INPUT inputs[2]{};
|
|
|
|
|
inputs[0].type = INPUT_MOUSE;
|
|
|
|
|
inputs[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
|
|
|
|
|
inputs[1].type = INPUT_MOUSE;
|
|
|
|
|
inputs[1].mi.dwFlags = MOUSEEVENTF_LEFTUP;
|
|
|
|
|
SendInput(2, inputs, sizeof(INPUT));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Stateless helpers operating on shared State
|
|
|
|
|
static void PositionCursorX(const std::shared_ptr<State>& s)
|
|
|
|
|
{
|
|
|
|
|
int screenW = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
|
|
|
|
int screenH = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
|
|
|
|
s->currentYPos = screenH / 2;
|
|
|
|
|
|
|
|
|
|
// Distribute movement over 10ms ticks to match pixels-per-base-window speeds
|
|
|
|
|
const double perTick = (static_cast<double>(s->currentXSpeed) * kTimerTickMs) / static_cast<double>(kBaseSpeedTickMs);
|
|
|
|
|
s->xFraction += perTick;
|
|
|
|
|
int step = static_cast<int>(s->xFraction);
|
|
|
|
|
if (step > 0)
|
|
|
|
|
{
|
|
|
|
|
s->xFraction -= step;
|
|
|
|
|
s->currentXPos += step;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
s->xPosSnapshot = s->currentXPos;
|
|
|
|
|
if (s->currentXPos >= screenW)
|
|
|
|
|
{
|
|
|
|
|
s->currentXPos = 0;
|
|
|
|
|
s->currentXSpeed = s->fastHSpeed;
|
|
|
|
|
s->xPosSnapshot = 0;
|
|
|
|
|
s->xFraction = 0.0; // reset fractional remainder on wrap
|
|
|
|
|
}
|
|
|
|
|
SetCursorPos(s->currentXPos, s->currentYPos);
|
|
|
|
|
// Ensure overlay crosshairs follow immediately
|
|
|
|
|
InclusiveCrosshairsRequestUpdatePosition();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void PositionCursorY(const std::shared_ptr<State>& s)
|
|
|
|
|
{
|
|
|
|
|
int screenH = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
|
|
|
|
// Keep X at snapshot
|
|
|
|
|
// Use s->xPosSnapshot captured during X pass
|
|
|
|
|
|
|
|
|
|
// Distribute movement over 10ms ticks to match pixels-per-base-window speeds
|
|
|
|
|
const double perTick = (static_cast<double>(s->currentYSpeed) * kTimerTickMs) / static_cast<double>(kBaseSpeedTickMs);
|
|
|
|
|
s->yFraction += perTick;
|
|
|
|
|
int step = static_cast<int>(s->yFraction);
|
|
|
|
|
if (step > 0)
|
|
|
|
|
{
|
|
|
|
|
s->yFraction -= step;
|
|
|
|
|
s->currentYPos += step;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (s->currentYPos >= screenH)
|
|
|
|
|
{
|
|
|
|
|
s->currentYPos = 0;
|
|
|
|
|
s->currentYSpeed = s->fastVSpeed;
|
|
|
|
|
s->yFraction = 0.0; // reset fractional remainder on wrap
|
|
|
|
|
}
|
|
|
|
|
SetCursorPos(s->xPosSnapshot, s->currentYPos);
|
|
|
|
|
// Ensure overlay crosshairs follow immediately
|
|
|
|
|
InclusiveCrosshairsRequestUpdatePosition();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StartXTimer()
|
|
|
|
|
{
|
|
|
|
|
auto s = m_state;
|
|
|
|
|
if (!s)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
s->stopX = false;
|
|
|
|
|
std::weak_ptr<State> wp = s;
|
|
|
|
|
m_xThread = std::thread([wp]() {
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
auto sp = wp.lock();
|
|
|
|
|
if (!sp || sp->stopX.load())
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
PositionCursorX(sp);
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(kTimerTickMs));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StopXTimer()
|
|
|
|
|
{
|
|
|
|
|
auto s = m_state;
|
|
|
|
|
if (s)
|
|
|
|
|
{
|
|
|
|
|
s->stopX = true;
|
|
|
|
|
}
|
|
|
|
|
if (m_xThread.joinable())
|
|
|
|
|
{
|
|
|
|
|
m_xThread.join();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StartYTimer()
|
|
|
|
|
{
|
|
|
|
|
auto s = m_state;
|
|
|
|
|
if (!s)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
s->stopY = false;
|
|
|
|
|
std::weak_ptr<State> wp = s;
|
|
|
|
|
m_yThread = std::thread([wp]() {
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
auto sp = wp.lock();
|
|
|
|
|
if (!sp || sp->stopY.load())
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
PositionCursorY(sp);
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(kTimerTickMs));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StopYTimer()
|
2022-01-24 13:29:16 +00:00
|
|
|
{
|
Implement "Gliding cursor" accessibility feature (#41221)
## Summary of the Pull Request
Added '[Gliding
Cursor](https://github.com/microsoft/PowerToys/issues/37097)'
functionality to Mouse Pointer Crosshairs, this enables a single
hotkey/Microsoft Adaptive Hub + button to control cursor movement and
clicking. This is implemented as an extension to the existing Mouse
Pointer Crosshairs module.
Testing has been manual, ensuring that the existing Mouse Pointer
Crosshairs functionality is unchanged, and that the new Gliding Cursor
functionality works alongside Mouse Pointer Crosshairs.

<img width="857" height="438" alt="image"
src="https://github.com/user-attachments/assets/b9e7ee72-dfeb-4d20-93a5-a34e8b10d703"
/>
To test this functionality:
- Open Mouse Crosshair settings and make sure the feature is enabled.
- Press the shortcut to start the gliding cursor — a vertical line
appears.
- Press the shortcut again to slow the vertical line.
- Press once more to fix the vertical line; a horizontal line begins
moving.
- Press again to slow the horizontal line.
- When the lines meet at your target, press the shortcut to perform the
click.
## PR Checklist
- [x] Closes: #37097
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **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
The PR includes these changes:
* Updated Mouse Pointer Crosshairs XAML to include a new hotkey to start
the gliding cursor experience
* Added two sliders for fast/slow cursor movement
* mapped the new hotkey/XAML sliders through to the existing
MousePointerHotkeys project, dllmain.cpp
* Added a 10ms tick for Gliding cursor for crosshairs/cursor movement
* Added state for gliding functionality - horiz fast, horiz slow, vert
fast, vert slow, click
* added gates around the existing mouse movement hook to prevent mouse
movement when gliding
## Validation Steps Performed
Manual testing has been completed on several PCs to confirm the
following:
* Existing Mouse Pointer Crosshairs functionality is unchanged
* Gliding cursor settings are persisted/used by the gliding cursor code
* Gliding cursor restores Mouse Pointer Crosshairs state after the final
click has completed.
---------
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com>
2025-08-21 06:53:20 +01:00
|
|
|
auto s = m_state;
|
|
|
|
|
if (s)
|
|
|
|
|
{
|
|
|
|
|
s->stopY = true;
|
|
|
|
|
}
|
|
|
|
|
if (m_yThread.joinable())
|
|
|
|
|
{
|
|
|
|
|
m_yThread.join();
|
|
|
|
|
}
|
2022-01-24 13:29:16 +00:00
|
|
|
}
|
|
|
|
|
|
Implement "Gliding cursor" accessibility feature (#41221)
## Summary of the Pull Request
Added '[Gliding
Cursor](https://github.com/microsoft/PowerToys/issues/37097)'
functionality to Mouse Pointer Crosshairs, this enables a single
hotkey/Microsoft Adaptive Hub + button to control cursor movement and
clicking. This is implemented as an extension to the existing Mouse
Pointer Crosshairs module.
Testing has been manual, ensuring that the existing Mouse Pointer
Crosshairs functionality is unchanged, and that the new Gliding Cursor
functionality works alongside Mouse Pointer Crosshairs.

<img width="857" height="438" alt="image"
src="https://github.com/user-attachments/assets/b9e7ee72-dfeb-4d20-93a5-a34e8b10d703"
/>
To test this functionality:
- Open Mouse Crosshair settings and make sure the feature is enabled.
- Press the shortcut to start the gliding cursor — a vertical line
appears.
- Press the shortcut again to slow the vertical line.
- Press once more to fix the vertical line; a horizontal line begins
moving.
- Press again to slow the horizontal line.
- When the lines meet at your target, press the shortcut to perform the
click.
## PR Checklist
- [x] Closes: #37097
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **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
The PR includes these changes:
* Updated Mouse Pointer Crosshairs XAML to include a new hotkey to start
the gliding cursor experience
* Added two sliders for fast/slow cursor movement
* mapped the new hotkey/XAML sliders through to the existing
MousePointerHotkeys project, dllmain.cpp
* Added a 10ms tick for Gliding cursor for crosshairs/cursor movement
* Added state for gliding functionality - horiz fast, horiz slow, vert
fast, vert slow, click
* added gates around the existing mouse movement hook to prevent mouse
movement when gliding
## Validation Steps Performed
Manual testing has been completed on several PCs to confirm the
following:
* Existing Mouse Pointer Crosshairs functionality is unchanged
* Gliding cursor settings are persisted/used by the gliding cursor code
* Gliding cursor restores Mouse Pointer Crosshairs state after the final
click has completed.
---------
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com>
2025-08-21 06:53:20 +01:00
|
|
|
void HandleGlidingHotkey()
|
2022-01-24 13:29:16 +00:00
|
|
|
{
|
Implement "Gliding cursor" accessibility feature (#41221)
## Summary of the Pull Request
Added '[Gliding
Cursor](https://github.com/microsoft/PowerToys/issues/37097)'
functionality to Mouse Pointer Crosshairs, this enables a single
hotkey/Microsoft Adaptive Hub + button to control cursor movement and
clicking. This is implemented as an extension to the existing Mouse
Pointer Crosshairs module.
Testing has been manual, ensuring that the existing Mouse Pointer
Crosshairs functionality is unchanged, and that the new Gliding Cursor
functionality works alongside Mouse Pointer Crosshairs.

<img width="857" height="438" alt="image"
src="https://github.com/user-attachments/assets/b9e7ee72-dfeb-4d20-93a5-a34e8b10d703"
/>
To test this functionality:
- Open Mouse Crosshair settings and make sure the feature is enabled.
- Press the shortcut to start the gliding cursor — a vertical line
appears.
- Press the shortcut again to slow the vertical line.
- Press once more to fix the vertical line; a horizontal line begins
moving.
- Press again to slow the horizontal line.
- When the lines meet at your target, press the shortcut to perform the
click.
## PR Checklist
- [x] Closes: #37097
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **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
The PR includes these changes:
* Updated Mouse Pointer Crosshairs XAML to include a new hotkey to start
the gliding cursor experience
* Added two sliders for fast/slow cursor movement
* mapped the new hotkey/XAML sliders through to the existing
MousePointerHotkeys project, dllmain.cpp
* Added a 10ms tick for Gliding cursor for crosshairs/cursor movement
* Added state for gliding functionality - horiz fast, horiz slow, vert
fast, vert slow, click
* added gates around the existing mouse movement hook to prevent mouse
movement when gliding
## Validation Steps Performed
Manual testing has been completed on several PCs to confirm the
following:
* Existing Mouse Pointer Crosshairs functionality is unchanged
* Gliding cursor settings are persisted/used by the gliding cursor code
* Gliding cursor restores Mouse Pointer Crosshairs state after the final
click has completed.
---------
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com>
2025-08-21 06:53:20 +01:00
|
|
|
auto s = m_state;
|
|
|
|
|
if (!s)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// Simulate the AHK state machine
|
|
|
|
|
int state = m_glideState.load();
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
{
|
|
|
|
|
// Ensure crosshairs on (do not toggle off if already on)
|
|
|
|
|
InclusiveCrosshairsEnsureOn();
|
|
|
|
|
// Disable internal mouse hook so we control position updates explicitly
|
|
|
|
|
InclusiveCrosshairsSetExternalControl(true);
|
|
|
|
|
|
|
|
|
|
s->currentXPos = 0;
|
|
|
|
|
s->currentXSpeed = s->fastHSpeed;
|
|
|
|
|
s->xFraction = 0.0;
|
|
|
|
|
s->yFraction = 0.0;
|
|
|
|
|
int y = GetSystemMetrics(SM_CYVIRTUALSCREEN) / 2;
|
|
|
|
|
SetCursorPos(0, y);
|
|
|
|
|
InclusiveCrosshairsRequestUpdatePosition();
|
|
|
|
|
m_glideState = 1;
|
|
|
|
|
StartXTimer();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 1:
|
|
|
|
|
{
|
|
|
|
|
// Slow horizontal
|
|
|
|
|
s->currentXSpeed = s->slowHSpeed;
|
|
|
|
|
m_glideState = 2;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 2:
|
|
|
|
|
{
|
|
|
|
|
// Stop horizontal, start vertical (fast)
|
|
|
|
|
StopXTimer();
|
|
|
|
|
s->currentYSpeed = s->fastVSpeed;
|
|
|
|
|
s->currentYPos = 0;
|
|
|
|
|
s->yFraction = 0.0;
|
|
|
|
|
SetCursorPos(s->xPosSnapshot, s->currentYPos);
|
|
|
|
|
InclusiveCrosshairsRequestUpdatePosition();
|
|
|
|
|
m_glideState = 3;
|
|
|
|
|
StartYTimer();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 3:
|
|
|
|
|
{
|
|
|
|
|
// Slow vertical
|
|
|
|
|
s->currentYSpeed = s->slowVSpeed;
|
|
|
|
|
m_glideState = 4;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 4:
|
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
// Stop vertical, click, turn crosshairs off, re-enable internal tracking, reset state
|
|
|
|
|
StopYTimer();
|
|
|
|
|
m_glideState = 0;
|
|
|
|
|
LeftClick();
|
|
|
|
|
InclusiveCrosshairsEnsureOff();
|
|
|
|
|
InclusiveCrosshairsSetExternalControl(false);
|
|
|
|
|
s->xFraction = 0.0;
|
|
|
|
|
s->yFraction = 0.0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-24 13:29:16 +00:00
|
|
|
}
|
Implement "Gliding cursor" accessibility feature (#41221)
## Summary of the Pull Request
Added '[Gliding
Cursor](https://github.com/microsoft/PowerToys/issues/37097)'
functionality to Mouse Pointer Crosshairs, this enables a single
hotkey/Microsoft Adaptive Hub + button to control cursor movement and
clicking. This is implemented as an extension to the existing Mouse
Pointer Crosshairs module.
Testing has been manual, ensuring that the existing Mouse Pointer
Crosshairs functionality is unchanged, and that the new Gliding Cursor
functionality works alongside Mouse Pointer Crosshairs.

<img width="857" height="438" alt="image"
src="https://github.com/user-attachments/assets/b9e7ee72-dfeb-4d20-93a5-a34e8b10d703"
/>
To test this functionality:
- Open Mouse Crosshair settings and make sure the feature is enabled.
- Press the shortcut to start the gliding cursor — a vertical line
appears.
- Press the shortcut again to slow the vertical line.
- Press once more to fix the vertical line; a horizontal line begins
moving.
- Press again to slow the horizontal line.
- When the lines meet at your target, press the shortcut to perform the
click.
## PR Checklist
- [x] Closes: #37097
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **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
The PR includes these changes:
* Updated Mouse Pointer Crosshairs XAML to include a new hotkey to start
the gliding cursor experience
* Added two sliders for fast/slow cursor movement
* mapped the new hotkey/XAML sliders through to the existing
MousePointerHotkeys project, dllmain.cpp
* Added a 10ms tick for Gliding cursor for crosshairs/cursor movement
* Added state for gliding functionality - horiz fast, horiz slow, vert
fast, vert slow, click
* added gates around the existing mouse movement hook to prevent mouse
movement when gliding
## Validation Steps Performed
Manual testing has been completed on several PCs to confirm the
following:
* Existing Mouse Pointer Crosshairs functionality is unchanged
* Gliding cursor settings are persisted/used by the gliding cursor code
* Gliding cursor restores Mouse Pointer Crosshairs state after the final
click has completed.
---------
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com>
2025-08-21 06:53:20 +01:00
|
|
|
|
2022-01-24 13:29:16 +00:00
|
|
|
// Load the settings file.
|
|
|
|
|
void init_settings()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Load and parse the settings file for this PowerToy.
|
|
|
|
|
PowerToysSettings::PowerToyValues settings =
|
2022-01-26 14:01:24 +00:00
|
|
|
PowerToysSettings::PowerToyValues::load_from_settings_file(MousePointerCrosshairs::get_key());
|
2022-01-24 13:29:16 +00:00
|
|
|
parse_settings(settings);
|
|
|
|
|
}
|
|
|
|
|
catch (std::exception&)
|
|
|
|
|
{
|
2022-01-26 14:01:24 +00:00
|
|
|
Logger::error("Invalid json when trying to load the Mouse Pointer Crosshairs settings json from file.");
|
2022-01-24 13:29:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void parse_settings(PowerToysSettings::PowerToyValues& settings)
|
|
|
|
|
{
|
|
|
|
|
// TODO: refactor to use common/utils/json.h instead
|
|
|
|
|
auto settingsObject = settings.get_raw_json();
|
2022-01-26 14:01:24 +00:00
|
|
|
InclusiveCrosshairsSettings inclusiveCrosshairsSettings;
|
2022-01-24 13:29:16 +00:00
|
|
|
if (settingsObject.GetView().Size())
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
Implement "Gliding cursor" accessibility feature (#41221)
## Summary of the Pull Request
Added '[Gliding
Cursor](https://github.com/microsoft/PowerToys/issues/37097)'
functionality to Mouse Pointer Crosshairs, this enables a single
hotkey/Microsoft Adaptive Hub + button to control cursor movement and
clicking. This is implemented as an extension to the existing Mouse
Pointer Crosshairs module.
Testing has been manual, ensuring that the existing Mouse Pointer
Crosshairs functionality is unchanged, and that the new Gliding Cursor
functionality works alongside Mouse Pointer Crosshairs.

<img width="857" height="438" alt="image"
src="https://github.com/user-attachments/assets/b9e7ee72-dfeb-4d20-93a5-a34e8b10d703"
/>
To test this functionality:
- Open Mouse Crosshair settings and make sure the feature is enabled.
- Press the shortcut to start the gliding cursor — a vertical line
appears.
- Press the shortcut again to slow the vertical line.
- Press once more to fix the vertical line; a horizontal line begins
moving.
- Press again to slow the horizontal line.
- When the lines meet at your target, press the shortcut to perform the
click.
## PR Checklist
- [x] Closes: #37097
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **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
The PR includes these changes:
* Updated Mouse Pointer Crosshairs XAML to include a new hotkey to start
the gliding cursor experience
* Added two sliders for fast/slow cursor movement
* mapped the new hotkey/XAML sliders through to the existing
MousePointerHotkeys project, dllmain.cpp
* Added a 10ms tick for Gliding cursor for crosshairs/cursor movement
* Added state for gliding functionality - horiz fast, horiz slow, vert
fast, vert slow, click
* added gates around the existing mouse movement hook to prevent mouse
movement when gliding
## Validation Steps Performed
Manual testing has been completed on several PCs to confirm the
following:
* Existing Mouse Pointer Crosshairs functionality is unchanged
* Gliding cursor settings are persisted/used by the gliding cursor code
* Gliding cursor restores Mouse Pointer Crosshairs state after the final
click has completed.
---------
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com>
2025-08-21 06:53:20 +01:00
|
|
|
// Parse primary activation HotKey (for centralized hook)
|
2022-01-24 13:29:16 +00:00
|
|
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_ACTIVATION_SHORTCUT);
|
|
|
|
|
auto hotkey = PowerToysSettings::HotkeyObject::from_json(jsonPropertiesObject);
|
|
|
|
|
|
Implement "Gliding cursor" accessibility feature (#41221)
## Summary of the Pull Request
Added '[Gliding
Cursor](https://github.com/microsoft/PowerToys/issues/37097)'
functionality to Mouse Pointer Crosshairs, this enables a single
hotkey/Microsoft Adaptive Hub + button to control cursor movement and
clicking. This is implemented as an extension to the existing Mouse
Pointer Crosshairs module.
Testing has been manual, ensuring that the existing Mouse Pointer
Crosshairs functionality is unchanged, and that the new Gliding Cursor
functionality works alongside Mouse Pointer Crosshairs.

<img width="857" height="438" alt="image"
src="https://github.com/user-attachments/assets/b9e7ee72-dfeb-4d20-93a5-a34e8b10d703"
/>
To test this functionality:
- Open Mouse Crosshair settings and make sure the feature is enabled.
- Press the shortcut to start the gliding cursor — a vertical line
appears.
- Press the shortcut again to slow the vertical line.
- Press once more to fix the vertical line; a horizontal line begins
moving.
- Press again to slow the horizontal line.
- When the lines meet at your target, press the shortcut to perform the
click.
## PR Checklist
- [x] Closes: #37097
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **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
The PR includes these changes:
* Updated Mouse Pointer Crosshairs XAML to include a new hotkey to start
the gliding cursor experience
* Added two sliders for fast/slow cursor movement
* mapped the new hotkey/XAML sliders through to the existing
MousePointerHotkeys project, dllmain.cpp
* Added a 10ms tick for Gliding cursor for crosshairs/cursor movement
* Added state for gliding functionality - horiz fast, horiz slow, vert
fast, vert slow, click
* added gates around the existing mouse movement hook to prevent mouse
movement when gliding
## Validation Steps Performed
Manual testing has been completed on several PCs to confirm the
following:
* Existing Mouse Pointer Crosshairs functionality is unchanged
* Gliding cursor settings are persisted/used by the gliding cursor code
* Gliding cursor restores Mouse Pointer Crosshairs state after the final
click has completed.
---------
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com>
2025-08-21 06:53:20 +01:00
|
|
|
// Map to legacy Hotkey for multi-hotkey API
|
|
|
|
|
m_activationHotkey.win = hotkey.win_pressed();
|
|
|
|
|
m_activationHotkey.ctrl = hotkey.ctrl_pressed();
|
|
|
|
|
m_activationHotkey.shift = hotkey.shift_pressed();
|
|
|
|
|
m_activationHotkey.alt = hotkey.alt_pressed();
|
|
|
|
|
m_activationHotkey.key = static_cast<unsigned char>(hotkey.get_code());
|
2022-01-24 13:29:16 +00:00
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
2022-01-26 14:01:24 +00:00
|
|
|
Logger::warn("Failed to initialize Mouse Pointer Crosshairs activation shortcut");
|
2022-01-24 13:29:16 +00:00
|
|
|
}
|
|
|
|
|
try
|
Implement "Gliding cursor" accessibility feature (#41221)
## Summary of the Pull Request
Added '[Gliding
Cursor](https://github.com/microsoft/PowerToys/issues/37097)'
functionality to Mouse Pointer Crosshairs, this enables a single
hotkey/Microsoft Adaptive Hub + button to control cursor movement and
clicking. This is implemented as an extension to the existing Mouse
Pointer Crosshairs module.
Testing has been manual, ensuring that the existing Mouse Pointer
Crosshairs functionality is unchanged, and that the new Gliding Cursor
functionality works alongside Mouse Pointer Crosshairs.

<img width="857" height="438" alt="image"
src="https://github.com/user-attachments/assets/b9e7ee72-dfeb-4d20-93a5-a34e8b10d703"
/>
To test this functionality:
- Open Mouse Crosshair settings and make sure the feature is enabled.
- Press the shortcut to start the gliding cursor — a vertical line
appears.
- Press the shortcut again to slow the vertical line.
- Press once more to fix the vertical line; a horizontal line begins
moving.
- Press again to slow the horizontal line.
- When the lines meet at your target, press the shortcut to perform the
click.
## PR Checklist
- [x] Closes: #37097
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **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
The PR includes these changes:
* Updated Mouse Pointer Crosshairs XAML to include a new hotkey to start
the gliding cursor experience
* Added two sliders for fast/slow cursor movement
* mapped the new hotkey/XAML sliders through to the existing
MousePointerHotkeys project, dllmain.cpp
* Added a 10ms tick for Gliding cursor for crosshairs/cursor movement
* Added state for gliding functionality - horiz fast, horiz slow, vert
fast, vert slow, click
* added gates around the existing mouse movement hook to prevent mouse
movement when gliding
## Validation Steps Performed
Manual testing has been completed on several PCs to confirm the
following:
* Existing Mouse Pointer Crosshairs functionality is unchanged
* Gliding cursor settings are persisted/used by the gliding cursor code
* Gliding cursor restores Mouse Pointer Crosshairs state after the final
click has completed.
---------
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com>
2025-08-21 06:53:20 +01:00
|
|
|
{
|
|
|
|
|
// Parse Gliding Cursor HotKey
|
|
|
|
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_GLIDING_ACTIVATION_SHORTCUT);
|
|
|
|
|
auto hotkey = PowerToysSettings::HotkeyObject::from_json(jsonPropertiesObject);
|
|
|
|
|
m_glidingHotkey.win = hotkey.win_pressed();
|
|
|
|
|
m_glidingHotkey.ctrl = hotkey.ctrl_pressed();
|
|
|
|
|
m_glidingHotkey.shift = hotkey.shift_pressed();
|
|
|
|
|
m_glidingHotkey.alt = hotkey.alt_pressed();
|
|
|
|
|
m_glidingHotkey.key = static_cast<unsigned char>(hotkey.get_code());
|
|
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
|
|
|
|
// note that this is also defined in src\settings-ui\Settings.UI.Library\MousePointerCrosshairsProperties.cs, DefaultGlidingCursorActivationShortcut
|
|
|
|
|
// both need to be kept in sync!
|
|
|
|
|
Logger::warn("Failed to initialize Gliding Cursor activation shortcut. Using default Win+Alt+.");
|
|
|
|
|
m_glidingHotkey.win = true;
|
|
|
|
|
m_glidingHotkey.alt = true;
|
|
|
|
|
m_glidingHotkey.ctrl = false;
|
|
|
|
|
m_glidingHotkey.shift = false;
|
|
|
|
|
m_glidingHotkey.key = VK_OEM_PERIOD;
|
|
|
|
|
}
|
|
|
|
|
try
|
2022-01-24 13:29:16 +00:00
|
|
|
{
|
|
|
|
|
// Parse Opacity
|
2022-01-26 14:01:24 +00:00
|
|
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_CROSSHAIRS_OPACITY);
|
2023-02-08 11:01:35 +00:00
|
|
|
int value = static_cast<uint8_t>(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE));
|
|
|
|
|
if (value >= 0)
|
|
|
|
|
{
|
|
|
|
|
inclusiveCrosshairsSettings.crosshairsOpacity = value;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-08-24 14:53:48 +02:00
|
|
|
throw std::runtime_error("Invalid Opacity value");
|
2023-02-08 11:01:35 +00:00
|
|
|
}
|
2022-01-24 13:29:16 +00:00
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
|
|
|
|
Logger::warn("Failed to initialize Opacity from settings. Will use default value");
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
2022-01-26 14:01:24 +00:00
|
|
|
// Parse crosshairs color
|
|
|
|
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_CROSSHAIRS_COLOR);
|
|
|
|
|
auto crosshairsColor = (std::wstring)jsonPropertiesObject.GetNamedString(JSON_KEY_VALUE);
|
2022-01-24 13:29:16 +00:00
|
|
|
uint8_t r, g, b;
|
2022-01-26 14:01:24 +00:00
|
|
|
if (!checkValidRGB(crosshairsColor, &r, &g, &b))
|
2022-01-24 13:29:16 +00:00
|
|
|
{
|
2022-01-26 14:01:24 +00:00
|
|
|
Logger::error("Crosshairs color RGB value is invalid. Will use default value");
|
2022-01-24 13:29:16 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-01-26 14:01:24 +00:00
|
|
|
inclusiveCrosshairsSettings.crosshairsColor = winrt::Windows::UI::ColorHelper::FromArgb(255, r, g, b);
|
2022-01-24 13:29:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
2022-01-26 14:01:24 +00:00
|
|
|
Logger::warn("Failed to initialize crosshairs color from settings. Will use default value");
|
2022-01-24 13:29:16 +00:00
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Parse Radius
|
2022-01-26 14:01:24 +00:00
|
|
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_CROSSHAIRS_RADIUS);
|
2023-02-08 11:01:35 +00:00
|
|
|
int value = static_cast<int>(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE));
|
|
|
|
|
if (value >= 0)
|
|
|
|
|
{
|
|
|
|
|
inclusiveCrosshairsSettings.crosshairsRadius = value;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-08-24 14:53:48 +02:00
|
|
|
throw std::runtime_error("Invalid Radius value");
|
2023-02-08 11:01:35 +00:00
|
|
|
}
|
2022-01-24 13:29:16 +00:00
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
|
|
|
|
Logger::warn("Failed to initialize Radius from settings. Will use default value");
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Parse Thickness
|
2022-01-26 14:01:24 +00:00
|
|
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_CROSSHAIRS_THICKNESS);
|
2023-02-08 11:01:35 +00:00
|
|
|
int value = static_cast<int>(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE));
|
|
|
|
|
if (value >= 0)
|
|
|
|
|
{
|
|
|
|
|
inclusiveCrosshairsSettings.crosshairsThickness = value;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-08-24 14:53:48 +02:00
|
|
|
throw std::runtime_error("Invalid Thickness value");
|
2023-02-08 11:01:35 +00:00
|
|
|
}
|
2022-01-24 13:29:16 +00:00
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
|
|
|
|
Logger::warn("Failed to initialize Thickness from settings. Will use default value");
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
2022-01-26 14:01:24 +00:00
|
|
|
// Parse crosshairs border color
|
|
|
|
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_CROSSHAIRS_BORDER_COLOR);
|
|
|
|
|
auto crosshairsBorderColor = (std::wstring)jsonPropertiesObject.GetNamedString(JSON_KEY_VALUE);
|
2022-01-24 13:29:16 +00:00
|
|
|
uint8_t r, g, b;
|
2022-01-26 14:01:24 +00:00
|
|
|
if (!checkValidRGB(crosshairsBorderColor, &r, &g, &b))
|
2022-01-24 13:29:16 +00:00
|
|
|
{
|
2022-01-26 14:01:24 +00:00
|
|
|
Logger::error("Crosshairs border color RGB value is invalid. Will use default value");
|
2022-01-24 13:29:16 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-01-26 14:01:24 +00:00
|
|
|
inclusiveCrosshairsSettings.crosshairsBorderColor = winrt::Windows::UI::ColorHelper::FromArgb(255, r, g, b);
|
2022-01-24 13:29:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
2022-01-26 14:01:24 +00:00
|
|
|
Logger::warn("Failed to initialize crosshairs border color from settings. Will use default value");
|
2022-01-24 13:29:16 +00:00
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Parse border size
|
2022-01-26 14:01:24 +00:00
|
|
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_CROSSHAIRS_BORDER_SIZE);
|
Implement "Gliding cursor" accessibility feature (#41221)
## Summary of the Pull Request
Added '[Gliding
Cursor](https://github.com/microsoft/PowerToys/issues/37097)'
functionality to Mouse Pointer Crosshairs, this enables a single
hotkey/Microsoft Adaptive Hub + button to control cursor movement and
clicking. This is implemented as an extension to the existing Mouse
Pointer Crosshairs module.
Testing has been manual, ensuring that the existing Mouse Pointer
Crosshairs functionality is unchanged, and that the new Gliding Cursor
functionality works alongside Mouse Pointer Crosshairs.

<img width="857" height="438" alt="image"
src="https://github.com/user-attachments/assets/b9e7ee72-dfeb-4d20-93a5-a34e8b10d703"
/>
To test this functionality:
- Open Mouse Crosshair settings and make sure the feature is enabled.
- Press the shortcut to start the gliding cursor — a vertical line
appears.
- Press the shortcut again to slow the vertical line.
- Press once more to fix the vertical line; a horizontal line begins
moving.
- Press again to slow the horizontal line.
- When the lines meet at your target, press the shortcut to perform the
click.
## PR Checklist
- [x] Closes: #37097
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **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
The PR includes these changes:
* Updated Mouse Pointer Crosshairs XAML to include a new hotkey to start
the gliding cursor experience
* Added two sliders for fast/slow cursor movement
* mapped the new hotkey/XAML sliders through to the existing
MousePointerHotkeys project, dllmain.cpp
* Added a 10ms tick for Gliding cursor for crosshairs/cursor movement
* Added state for gliding functionality - horiz fast, horiz slow, vert
fast, vert slow, click
* added gates around the existing mouse movement hook to prevent mouse
movement when gliding
## Validation Steps Performed
Manual testing has been completed on several PCs to confirm the
following:
* Existing Mouse Pointer Crosshairs functionality is unchanged
* Gliding cursor settings are persisted/used by the gliding cursor code
* Gliding cursor restores Mouse Pointer Crosshairs state after the final
click has completed.
---------
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com>
2025-08-21 06:53:20 +01:00
|
|
|
int value = static_cast<int>(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE));
|
2023-02-08 11:01:35 +00:00
|
|
|
if (value >= 0)
|
|
|
|
|
{
|
|
|
|
|
inclusiveCrosshairsSettings.crosshairsBorderSize = value;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-08-24 14:53:48 +02:00
|
|
|
throw std::runtime_error("Invalid Border Color value");
|
2023-02-08 11:01:35 +00:00
|
|
|
}
|
2022-01-24 13:29:16 +00:00
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
|
|
|
|
Logger::warn("Failed to initialize border color from settings. Will use default value");
|
|
|
|
|
}
|
2023-07-18 14:33:32 +02:00
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Parse auto hide
|
|
|
|
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_CROSSHAIRS_AUTO_HIDE);
|
2023-08-08 18:01:23 +02:00
|
|
|
inclusiveCrosshairsSettings.crosshairsAutoHide = jsonPropertiesObject.GetNamedBoolean(JSON_KEY_VALUE);
|
2023-07-18 14:33:32 +02:00
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
|
|
|
|
Logger::warn("Failed to initialize auto hide from settings. Will use default value");
|
|
|
|
|
}
|
2023-07-19 07:24:47 -07:00
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Parse whether the fixed length is enabled
|
|
|
|
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_CROSSHAIRS_IS_FIXED_LENGTH_ENABLED);
|
|
|
|
|
bool value = jsonPropertiesObject.GetNamedBoolean(JSON_KEY_VALUE);
|
|
|
|
|
inclusiveCrosshairsSettings.crosshairsIsFixedLengthEnabled = value;
|
|
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
|
|
|
|
Logger::warn("Failed to initialize fixed length enabled from settings. Will use default value");
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Parse fixed length
|
|
|
|
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_CROSSHAIRS_FIXED_LENGTH);
|
|
|
|
|
int value = static_cast<int>(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE));
|
|
|
|
|
if (value >= 0)
|
|
|
|
|
{
|
|
|
|
|
inclusiveCrosshairsSettings.crosshairsFixedLength = value;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-08-24 14:53:48 +02:00
|
|
|
throw std::runtime_error("Invalid Fixed Length value");
|
2023-07-19 07:24:47 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
|
|
|
|
Logger::warn("Failed to initialize fixed length from settings. Will use default value");
|
|
|
|
|
}
|
2023-08-08 18:01:23 +02:00
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Parse auto activate
|
|
|
|
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_AUTO_ACTIVATE);
|
|
|
|
|
inclusiveCrosshairsSettings.autoActivate = jsonPropertiesObject.GetNamedBoolean(JSON_KEY_VALUE);
|
|
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
|
|
|
|
Logger::warn("Failed to initialize auto activate from settings. Will use default value");
|
|
|
|
|
}
|
Implement "Gliding cursor" accessibility feature (#41221)
## Summary of the Pull Request
Added '[Gliding
Cursor](https://github.com/microsoft/PowerToys/issues/37097)'
functionality to Mouse Pointer Crosshairs, this enables a single
hotkey/Microsoft Adaptive Hub + button to control cursor movement and
clicking. This is implemented as an extension to the existing Mouse
Pointer Crosshairs module.
Testing has been manual, ensuring that the existing Mouse Pointer
Crosshairs functionality is unchanged, and that the new Gliding Cursor
functionality works alongside Mouse Pointer Crosshairs.

<img width="857" height="438" alt="image"
src="https://github.com/user-attachments/assets/b9e7ee72-dfeb-4d20-93a5-a34e8b10d703"
/>
To test this functionality:
- Open Mouse Crosshair settings and make sure the feature is enabled.
- Press the shortcut to start the gliding cursor — a vertical line
appears.
- Press the shortcut again to slow the vertical line.
- Press once more to fix the vertical line; a horizontal line begins
moving.
- Press again to slow the horizontal line.
- When the lines meet at your target, press the shortcut to perform the
click.
## PR Checklist
- [x] Closes: #37097
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **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
The PR includes these changes:
* Updated Mouse Pointer Crosshairs XAML to include a new hotkey to start
the gliding cursor experience
* Added two sliders for fast/slow cursor movement
* mapped the new hotkey/XAML sliders through to the existing
MousePointerHotkeys project, dllmain.cpp
* Added a 10ms tick for Gliding cursor for crosshairs/cursor movement
* Added state for gliding functionality - horiz fast, horiz slow, vert
fast, vert slow, click
* added gates around the existing mouse movement hook to prevent mouse
movement when gliding
## Validation Steps Performed
Manual testing has been completed on several PCs to confirm the
following:
* Existing Mouse Pointer Crosshairs functionality is unchanged
* Gliding cursor settings are persisted/used by the gliding cursor code
* Gliding cursor restores Mouse Pointer Crosshairs state after the final
click has completed.
---------
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com>
2025-08-21 06:53:20 +01:00
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Parse Travel speed (fast speed mapping)
|
|
|
|
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_GLIDE_TRAVEL_SPEED);
|
|
|
|
|
int value = static_cast<int>(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE));
|
|
|
|
|
if (value >= 5 && value <= 60)
|
|
|
|
|
{
|
|
|
|
|
m_state->fastHSpeed = value;
|
|
|
|
|
m_state->fastVSpeed = value;
|
|
|
|
|
}
|
|
|
|
|
else if (value < 5)
|
|
|
|
|
{
|
|
|
|
|
m_state->fastHSpeed = 5; m_state->fastVSpeed = 5;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_state->fastHSpeed = 60; m_state->fastVSpeed = 60;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
|
|
|
|
Logger::warn("Failed to initialize gliding travel speed from settings. Using default 25.");
|
|
|
|
|
if (m_state)
|
|
|
|
|
{
|
|
|
|
|
m_state->fastHSpeed = 25;
|
|
|
|
|
m_state->fastVSpeed = 25;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Parse Delay speed (slow speed mapping)
|
|
|
|
|
auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_GLIDE_DELAY_SPEED);
|
|
|
|
|
int value = static_cast<int>(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE));
|
|
|
|
|
if (value >= 5 && value <= 60)
|
|
|
|
|
{
|
|
|
|
|
m_state->slowHSpeed = value;
|
|
|
|
|
m_state->slowVSpeed = value;
|
|
|
|
|
}
|
|
|
|
|
else if (value < 5)
|
|
|
|
|
{
|
|
|
|
|
m_state->slowHSpeed = 5; m_state->slowVSpeed = 5;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_state->slowHSpeed = 60; m_state->slowVSpeed = 60;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
|
|
|
|
Logger::warn("Failed to initialize gliding delay speed from settings. Using default 5.");
|
|
|
|
|
if (m_state)
|
|
|
|
|
{
|
|
|
|
|
m_state->slowHSpeed = 5;
|
|
|
|
|
m_state->slowVSpeed = 5;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-24 13:29:16 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-01-26 14:01:24 +00:00
|
|
|
Logger::info("Mouse Pointer Crosshairs settings are empty");
|
2022-01-24 13:29:16 +00:00
|
|
|
}
|
Implement "Gliding cursor" accessibility feature (#41221)
## Summary of the Pull Request
Added '[Gliding
Cursor](https://github.com/microsoft/PowerToys/issues/37097)'
functionality to Mouse Pointer Crosshairs, this enables a single
hotkey/Microsoft Adaptive Hub + button to control cursor movement and
clicking. This is implemented as an extension to the existing Mouse
Pointer Crosshairs module.
Testing has been manual, ensuring that the existing Mouse Pointer
Crosshairs functionality is unchanged, and that the new Gliding Cursor
functionality works alongside Mouse Pointer Crosshairs.

<img width="857" height="438" alt="image"
src="https://github.com/user-attachments/assets/b9e7ee72-dfeb-4d20-93a5-a34e8b10d703"
/>
To test this functionality:
- Open Mouse Crosshair settings and make sure the feature is enabled.
- Press the shortcut to start the gliding cursor — a vertical line
appears.
- Press the shortcut again to slow the vertical line.
- Press once more to fix the vertical line; a horizontal line begins
moving.
- Press again to slow the horizontal line.
- When the lines meet at your target, press the shortcut to perform the
click.
## PR Checklist
- [x] Closes: #37097
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **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
The PR includes these changes:
* Updated Mouse Pointer Crosshairs XAML to include a new hotkey to start
the gliding cursor experience
* Added two sliders for fast/slow cursor movement
* mapped the new hotkey/XAML sliders through to the existing
MousePointerHotkeys project, dllmain.cpp
* Added a 10ms tick for Gliding cursor for crosshairs/cursor movement
* Added state for gliding functionality - horiz fast, horiz slow, vert
fast, vert slow, click
* added gates around the existing mouse movement hook to prevent mouse
movement when gliding
## Validation Steps Performed
Manual testing has been completed on several PCs to confirm the
following:
* Existing Mouse Pointer Crosshairs functionality is unchanged
* Gliding cursor settings are persisted/used by the gliding cursor code
* Gliding cursor restores Mouse Pointer Crosshairs state after the final
click has completed.
---------
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com>
2025-08-21 06:53:20 +01:00
|
|
|
|
|
|
|
|
if (m_activationHotkey.key == 0)
|
|
|
|
|
{
|
|
|
|
|
m_activationHotkey.win = true;
|
|
|
|
|
m_activationHotkey.alt = true;
|
|
|
|
|
m_activationHotkey.ctrl = false;
|
|
|
|
|
m_activationHotkey.shift = false;
|
|
|
|
|
m_activationHotkey.key = 'P';
|
|
|
|
|
}
|
|
|
|
|
if (m_glidingHotkey.key == 0)
|
2022-01-24 13:29:16 +00:00
|
|
|
{
|
Implement "Gliding cursor" accessibility feature (#41221)
## Summary of the Pull Request
Added '[Gliding
Cursor](https://github.com/microsoft/PowerToys/issues/37097)'
functionality to Mouse Pointer Crosshairs, this enables a single
hotkey/Microsoft Adaptive Hub + button to control cursor movement and
clicking. This is implemented as an extension to the existing Mouse
Pointer Crosshairs module.
Testing has been manual, ensuring that the existing Mouse Pointer
Crosshairs functionality is unchanged, and that the new Gliding Cursor
functionality works alongside Mouse Pointer Crosshairs.

<img width="857" height="438" alt="image"
src="https://github.com/user-attachments/assets/b9e7ee72-dfeb-4d20-93a5-a34e8b10d703"
/>
To test this functionality:
- Open Mouse Crosshair settings and make sure the feature is enabled.
- Press the shortcut to start the gliding cursor — a vertical line
appears.
- Press the shortcut again to slow the vertical line.
- Press once more to fix the vertical line; a horizontal line begins
moving.
- Press again to slow the horizontal line.
- When the lines meet at your target, press the shortcut to perform the
click.
## PR Checklist
- [x] Closes: #37097
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **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
The PR includes these changes:
* Updated Mouse Pointer Crosshairs XAML to include a new hotkey to start
the gliding cursor experience
* Added two sliders for fast/slow cursor movement
* mapped the new hotkey/XAML sliders through to the existing
MousePointerHotkeys project, dllmain.cpp
* Added a 10ms tick for Gliding cursor for crosshairs/cursor movement
* Added state for gliding functionality - horiz fast, horiz slow, vert
fast, vert slow, click
* added gates around the existing mouse movement hook to prevent mouse
movement when gliding
## Validation Steps Performed
Manual testing has been completed on several PCs to confirm the
following:
* Existing Mouse Pointer Crosshairs functionality is unchanged
* Gliding cursor settings are persisted/used by the gliding cursor code
* Gliding cursor restores Mouse Pointer Crosshairs state after the final
click has completed.
---------
Signed-off-by: Shawn Yuan <shuaiyuan@microsoft.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Shawn Yuan <shuaiyuan@microsoft.com>
2025-08-21 06:53:20 +01:00
|
|
|
m_glidingHotkey.win = true;
|
|
|
|
|
m_glidingHotkey.alt = true;
|
|
|
|
|
m_glidingHotkey.ctrl = false;
|
|
|
|
|
m_glidingHotkey.shift = false;
|
|
|
|
|
m_glidingHotkey.key = VK_OEM_PERIOD;
|
2022-01-24 13:29:16 +00:00
|
|
|
}
|
2022-01-26 14:01:24 +00:00
|
|
|
m_inclusiveCrosshairsSettings = inclusiveCrosshairsSettings;
|
2022-01-24 13:29:16 +00:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create()
|
|
|
|
|
{
|
2022-01-26 14:01:24 +00:00
|
|
|
return new MousePointerCrosshairs();
|
2022-01-24 13:29:16 +00:00
|
|
|
}
|