mirror of
https://github.com/jonasbark/swiftcontrol.git
synced 2026-12-04 20:52:23 +01:00
fix hid device functionality when accessibility service is active
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
### 4.0.0 (unreleased)
|
||||
|
||||
**Features:**
|
||||
- a brand new design
|
||||
- a brand-new design
|
||||
- Accessibility Permission is now optional on Android
|
||||
- Zwift is now fully supported on all operating systems
|
||||
- you can choose between network based control or bluetooth based control
|
||||
- BikeControl is now translated to German and French (contact me if you want to help with more translations)
|
||||
- support for KICKR BIKE PRO
|
||||
- BikeControl is now translated to German and French (contact me if you'd like to help with more translations)
|
||||
- support for Wahoo KICKR BIKE PRO
|
||||
- support for the OpenBikeControl protocol for supported Trainer apps
|
||||
- this enables seamless and official integration, independent of the operating system
|
||||
- learn more at https://openbikecontrol.org
|
||||
|
||||
@@ -149,12 +149,16 @@ abstract class BaseDevice {
|
||||
Widget showInformation(BuildContext context);
|
||||
|
||||
ControllerButton? getOrAddButton(String key, ControllerButton Function() creator) {
|
||||
final button = core.actionHandler.supportedApp?.keymap.getOrAddButton(key, creator);
|
||||
if (core.actionHandler.supportedApp is CustomApp) {
|
||||
final button = core.actionHandler.supportedApp?.keymap.getOrAddButton(key, creator);
|
||||
|
||||
if (button != null && availableButtons.none((e) => e.name == button.name)) {
|
||||
availableButtons.add(button);
|
||||
core.settings.setKeyMap(core.actionHandler.supportedApp!);
|
||||
if (button != null && availableButtons.none((e) => e.name == button.name)) {
|
||||
availableButtons.add(button);
|
||||
core.settings.setKeyMap(core.actionHandler.supportedApp!);
|
||||
}
|
||||
return button;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return button;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import 'package:swift_control/bluetooth/devices/hid/hid_device.dart';
|
||||
import 'package:swift_control/gen/l10n.dart';
|
||||
import 'package:swift_control/utils/actions/base_actions.dart';
|
||||
import 'package:swift_control/utils/core.dart';
|
||||
import 'package:swift_control/utils/keymap/apps/custom_app.dart';
|
||||
import 'package:swift_control/utils/keymap/buttons.dart';
|
||||
import 'package:swift_control/widgets/keymap_explanation.dart';
|
||||
|
||||
@@ -29,20 +28,18 @@ class AndroidActions extends BaseActions {
|
||||
});
|
||||
|
||||
hidKeyPressed().listen((keyPressed) {
|
||||
if (supportedApp is CustomApp) {
|
||||
final hidDevice = HidDevice(keyPressed.source);
|
||||
final button = hidDevice.getOrAddButton(keyPressed.hidKey, () => ControllerButton(keyPressed.hidKey))!;
|
||||
final hidDevice = HidDevice(keyPressed.source);
|
||||
final button = hidDevice.getOrAddButton(keyPressed.hidKey, () => ControllerButton(keyPressed.hidKey))!;
|
||||
|
||||
var availableDevice = core.connection.controllerDevices.firstOrNullWhere((e) => e.name == hidDevice.name);
|
||||
if (availableDevice == null) {
|
||||
core.connection.addDevices([hidDevice]);
|
||||
availableDevice = hidDevice;
|
||||
}
|
||||
if (keyPressed.keyDown) {
|
||||
availableDevice.handleButtonsClicked([button]);
|
||||
} else if (keyPressed.keyUp) {
|
||||
availableDevice.handleButtonsClicked([]);
|
||||
}
|
||||
var availableDevice = core.connection.controllerDevices.firstOrNullWhere((e) => e.name == hidDevice.name);
|
||||
if (availableDevice == null) {
|
||||
core.connection.addDevices([hidDevice]);
|
||||
availableDevice = hidDevice;
|
||||
}
|
||||
if (keyPressed.keyDown) {
|
||||
availableDevice.handleButtonsClicked([button]);
|
||||
} else if (keyPressed.keyUp) {
|
||||
availableDevice.handleButtonsClicked([]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -141,6 +141,9 @@ class _ScanWidgetState extends State<ScanWidget> {
|
||||
setState(() {
|
||||
_needsPermissions = permissions;
|
||||
});
|
||||
if (permissions.isEmpty) {
|
||||
core.connection.performScanning();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user