Skip to content

Add device source detection for Windows media hotkeys via Raw Input API#291

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/add-media-key-source-detection
Draft

Add device source detection for Windows media hotkeys via Raw Input API#291
Copilot wants to merge 4 commits intomainfrom
copilot/add-media-key-source-detection

Conversation

Copy link
Contributor

Copilot AI commented Feb 4, 2026

Windows media hotkey events previously lacked device source information, preventing users with multiple bluetooth controllers from configuring device-specific actions.

Changes

Windows Plugin (C++)

  • Integrated Raw Input API (WM_INPUT) to capture device handles alongside media key events
  • Extract device identifiers via GetRawInputDeviceInfo containing vendor/product IDs
  • Cache device identifiers for performance
  • Maintain RegisterHotKey (WM_HOTKEY) fallback for compatibility

Platform Interface (Dart)

  • Add addListenerWithDevice(MediaKey, String deviceId) API
  • Event format now supports both int (legacy) and Map<'key', 'device'> (new)
  • Existing addListener(MediaKey) unchanged for backward compatibility

Application Integration

  • HidDevice instances now created per unique device identifier
  • Device path (e.g., \\?\HID#VID_046D&PID_C52B#...) used as device name
  • Each physical controller appears as separate configurable device in UI

API Usage

// New device-aware listener
mediaKeyDetector.addListenerWithDevice((MediaKey key, String deviceId) {
  if (deviceId.contains('VID_046D')) {
    handleLogitechRemote(key);
  } else if (deviceId.contains('VID_05AC')) {
    handleAppleKeyboard(key);
  }
});

// Existing API still works
mediaKeyDetector.addListener((MediaKey key) { ... });

Backward Compatibility

All existing code continues to work without modification. Device information is optional in all APIs.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits February 4, 2026 14:11
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
Copilot AI changed the title [WIP] Add source detection for media hotkey presses Add device source detection for Windows media hotkeys via Raw Input API Feb 4, 2026
Copilot AI requested a review from jonasbark February 4, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants