From fcdaa74bf53ed54af78089195f58ae6f3d8b390e Mon Sep 17 00:00:00 2001 From: CodeDoctorDE Date: Thu, 10 Oct 2024 13:44:02 +0200 Subject: [PATCH] Fix input button mapping not working on multiple button presses, closes #748 --- api/pubspec.lock | 4 ++-- app/android/app/build.gradle | 2 +- app/lib/settings/inputs/home.dart | 5 ++-- app/lib/views/view.dart | 17 ++++++------- app/pubspec.lock | 40 +++++++++++++++---------------- app/scripts/build.sh | 2 +- metadata/en-US/changelogs/118.txt | 6 ++++- 7 files changed, 41 insertions(+), 35 deletions(-) diff --git a/api/pubspec.lock b/api/pubspec.lock index 6e9b5006a340..0b43aff7b5ba 100644 --- a/api/pubspec.lock +++ b/api/pubspec.lock @@ -194,10 +194,10 @@ packages: dependency: transitive description: name: file - sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" + sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 url: "https://pub.dev" source: hosted - version: "7.0.0" + version: "7.0.1" fixnum: dependency: transitive description: diff --git a/app/android/app/build.gradle b/app/android/app/build.gradle index 620eb385fd58..b325108d06d7 100644 --- a/app/android/app/build.gradle +++ b/app/android/app/build.gradle @@ -96,7 +96,7 @@ flutter { dependencies { testImplementation 'junit:junit:5.8.2' - testImplementation "com.google.truth:truth:1.1.3" + testImplementation 'com.google.truth:truth:1.4.4' androidTestImplementation 'androidx.test:runner:1.6.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' api 'androidx.test:core:1.6.1' diff --git a/app/lib/settings/inputs/home.dart b/app/lib/settings/inputs/home.dart index 03b2e50de6d5..f6d733fbfd7f 100644 --- a/app/lib/settings/inputs/home.dart +++ b/app/lib/settings/inputs/home.dart @@ -16,7 +16,7 @@ class InputsSettingsPage extends StatelessWidget { @override Widget build(BuildContext context) { PointerDeviceKind? kind; - int? buttons; + int buttons = 0; double? pressure; Color? pressed; return Scaffold( @@ -180,7 +180,8 @@ class InputsSettingsPage extends StatelessWidget { ), ListTile( title: Text(AppLocalizations.of(context).input), - subtitle: Text(buttons.toString()), + subtitle: + Text('$buttons (${buttons.toRadixString(2)})'), ), ListTile( title: Text(AppLocalizations.of(context).pressure), diff --git a/app/lib/views/view.dart b/app/lib/views/view.dart index 9c129a623156..5d106c25293e 100644 --- a/app/lib/views/view.dart +++ b/app/lib/views/view.dart @@ -125,23 +125,24 @@ class _MainViewViewportState extends State final config = context.read().state.inputConfiguration; final cubit = context.read(); final bloc = context.read(); + // Mapped to the priority of the buttons switch (kind) { case PointerDeviceKind.touch: nextPointerIndex = config.touch; case PointerDeviceKind.mouse: - if (buttons == kPrimaryMouseButton) { - nextPointerIndex = config.leftMouse; - } else if (buttons == kMiddleMouseButton) { - nextPointerIndex = config.middleMouse; - } else if (buttons == kSecondaryMouseButton) { + if ((buttons & kSecondaryMouseButton) != 0) { nextPointerIndex = config.rightMouse; + } else if ((buttons & kMiddleMouseButton) != 0) { + nextPointerIndex = config.middleMouse; + } else if ((buttons & kPrimaryMouseButton) != 0) { + nextPointerIndex = config.leftMouse; } case PointerDeviceKind.stylus: nextPointerIndex = config.pen; - if (buttons == kPrimaryStylusButton) { - nextPointerIndex = config.firstPenButton; - } else if (buttons == kSecondaryStylusButton) { + if ((buttons & kSecondaryStylusButton) != 0) { nextPointerIndex = config.secondPenButton; + } else if ((buttons & kPrimaryStylusButton) != 0) { + nextPointerIndex = config.firstPenButton; } default: nextPointerIndex = null; diff --git a/app/pubspec.lock b/app/pubspec.lock index c23a2deebfe5..f0f496eac604 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -185,18 +185,18 @@ packages: dependency: transitive description: name: camera_android_camerax - sha256: "59a01443c280cf969449f4b72db9396e80e5a9e8f07a2500a042906a157ce894" + sha256: e3627fdc2132d89212b8a8676679f5b07008c7e3d8ae00cea775c3397f9e742b url: "https://pub.dev" source: hosted - version: "0.6.9+2" + version: "0.6.10" camera_avfoundation: dependency: transitive description: name: camera_avfoundation - sha256: "7c28969a975a7eb2349bc2cb2dfe3ad218a33dba9968ecfb181ce08c87486655" + sha256: "0d04cec8715b59fb6dc60eefb47e69024f51233c570e475b886dc9290568bca7" url: "https://pub.dev" source: hosted - version: "0.9.17+3" + version: "0.9.17+4" camera_platform_interface: dependency: transitive description: @@ -899,10 +899,10 @@ packages: dependency: transitive description: name: mime - sha256: "801fd0b26f14a4a58ccb09d5892c3fbdeff209594300a542492cf13fba9d247a" + sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6" url: "https://pub.dev" source: hosted - version: "1.0.6" + version: "2.0.0" nested: dependency: transitive description: @@ -957,10 +957,10 @@ packages: dependency: "direct main" description: name: package_info_plus - sha256: a75164ade98cb7d24cfd0a13c6408927c6b217fa60dee5a7ff5c116a58f28918 + sha256: "894f37107424311bdae3e476552229476777b8752c5a2a2369c0cb9a2d5442ef" url: "https://pub.dev" source: hosted - version: "8.0.2" + version: "8.0.3" package_info_plus_platform_interface: dependency: transitive description: @@ -997,10 +997,10 @@ packages: dependency: transitive description: name: path_provider_android - sha256: f7544c346a0742aee1450f9e5c0f5269d7c602b9c95fdbcd9fb8f5b1df13b1cc + sha256: c464428172cb986b758c6d1724c603097febb8fb855aa265aeecc9280c294d4a url: "https://pub.dev" source: hosted - version: "2.2.11" + version: "2.2.12" path_provider_foundation: dependency: transitive description: @@ -1206,18 +1206,18 @@ packages: dependency: "direct main" description: name: share_plus - sha256: "468c43f285207c84bcabf5737f33b914ceb8eb38398b91e5e3ad1698d1b72a52" + sha256: fec12c3c39f01e4df1ec6ad92b6e85503c5ca64ffd6e28d18c9ffe53fcc4cb11 url: "https://pub.dev" source: hosted - version: "10.0.2" + version: "10.0.3" share_plus_platform_interface: dependency: transitive description: name: share_plus_platform_interface - sha256: "6ababf341050edff57da8b6990f11f4e99eaba837865e2e6defe16d039619db5" + sha256: c57c0bbfec7142e3a0f55633be504b796af72e60e3c791b44d5a017b985f7a48 url: "https://pub.dev" source: hosted - version: "5.0.0" + version: "5.0.1" shared_preferences: dependency: "direct main" description: @@ -1363,18 +1363,18 @@ packages: dependency: "direct main" description: name: super_clipboard - sha256: cfeb142360fac67e0da1ca339accb892eb790c6528a218a008eef1709d96ed0f + sha256: bfbfc602becb256c675c37332a0c5083a870f20806092938a247c36b3d6ecb88 url: "https://pub.dev" source: hosted - version: "0.8.22" + version: "0.8.23" super_native_extensions: dependency: transitive description: name: super_native_extensions - sha256: "6a7cfb7d212da7023b86fb99c736081e9c2cd982265d15dc5fe6381a32dbc875" + sha256: "8fe12946dbee374937eacb8aea2658369e66306708319675fda641f7f13874ac" url: "https://pub.dev" source: hosted - version: "0.8.22" + version: "0.8.23" sync_http: dependency: transitive description: @@ -1443,10 +1443,10 @@ packages: dependency: "direct main" description: name: url_launcher - sha256: "21b704ce5fa560ea9f3b525b43601c678728ba46725bab9b01187b4831377ed3" + sha256: "9d06212b1362abc2f0f0d78e6f09f726608c74e3b9462e8368bb03314aa8d603" url: "https://pub.dev" source: hosted - version: "6.3.0" + version: "6.3.1" url_launcher_android: dependency: transitive description: diff --git a/app/scripts/build.sh b/app/scripts/build.sh index e9e73ed9ee50..970ad980099d 100644 --- a/app/scripts/build.sh +++ b/app/scripts/build.sh @@ -1,3 +1,3 @@ FLUTTER_VERSION=$(grep -oP 'flutter:\s*\K\d+\.\d+\.\d+' pubspec.yaml) BUTTERFLY_FLAVOR=$([[ "$BUTTERFLY_NIGHTLY" == "true" ]] && echo "nightly" || echo "stable") -if [ "$BUTTERFLY_NIGHTLY" = "true" ]; then cp -r web_nightly/** web; fi && if cd flutter; then git pull && cd ..; else git clone https://github.com/flutter/flutter.git -b $FLUTTER_VERSION; fi && flutter/bin/flutter config --enable-web && flutter/bin/flutter build web --wasm --release --dart-define=FLUTTER_WEB_CANVASKIT_URL=/canvaskit/ --dart-define=flavor=$BUTTERFLY_FLAVOR \ No newline at end of file +if [ "$BUTTERFLY_NIGHTLY" = "true" ]; then cp -r web_nightly/** web; fi && if cd flutter; then git pull && cd ..; else git clone https://github.com/flutter/flutter.git -b $FLUTTER_VERSION; fi && flutter/bin/flutter config --enable-web && flutter/bin/flutter build web --wasm --release --no-web-resources-cdn --dart-define=flavor=$BUTTERFLY_FLAVOR \ No newline at end of file diff --git a/metadata/en-US/changelogs/118.txt b/metadata/en-US/changelogs/118.txt index 6b303bc7a39a..32bd21af57ff 100644 --- a/metadata/en-US/changelogs/118.txt +++ b/metadata/en-US/changelogs/118.txt @@ -1,2 +1,6 @@ +* Add bit mapping of buttons in pointer test * Fix unstable sort algorithm if layer is the same -* Fix switching data directory not working \ No newline at end of file +* Fix switching data directory not working +* Fix input button mapping not working on multiple button presses ([#748](https://github.com/LinwoodDev/Butterfly/issues/748)) + +Read more here: https://linwood.dev/butterfly/2.2.1-rc.1 \ No newline at end of file