Files
swiftcontrol/accessibility/api.dart
copilot-swe-agent[bot] 823eb9e9a4 Change approach: Use keymap-based filtering for HID key events
- Add setHandledKeys API to pass list of keys with keymaps to Android side
- Android AccessibilityService checks if key is in handled keys set before swallowing
- Dart side updates handled keys list whenever keymap changes
- Remove hardcoded media/volume key filtering
- This allows keyboards to work for typing while still capturing mapped keys

Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2026-01-12 16:49:19 +00:00

52 lines
1.0 KiB
Dart

import 'package:pigeon/pigeon.dart';
@HostApi()
abstract class Accessibility {
bool hasPermission();
void openPermissions();
void performTouch(double x, double y, {bool isKeyDown = true, bool isKeyUp = false});
void controlMedia(MediaAction action);
bool isRunning();
void ignoreHidDevices();
void setHandledKeys(List<String> keys);
}
enum MediaAction { playPause, next, volumeUp, volumeDown }
class WindowEvent {
final String packageName;
final int top;
final int bottom;
final int right;
final int left;
WindowEvent({
required this.packageName,
required this.left,
required this.right,
required this.top,
required this.bottom,
});
}
class AKeyEvent {
final String source;
final String hidKey;
final bool keyDown;
final bool keyUp;
AKeyEvent({required this.source, required this.hidKey, required this.keyDown, required this.keyUp});
}
@EventChannelApi()
abstract class EventChannelMethods {
WindowEvent streamEvents();
AKeyEvent hidKeyPressed();
}