Skip to content

Commit

Permalink
Fix input button mapping not working on multiple button presses, closes
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Oct 10, 2024
1 parent b94d113 commit fcdaa74
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 35 deletions.
4 changes: 2 additions & 2 deletions api/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion app/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5 changes: 3 additions & 2 deletions app/lib/settings/inputs/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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),
Expand Down
17 changes: 9 additions & 8 deletions app/lib/views/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,24 @@ class _MainViewViewportState extends State<MainViewViewport>
final config = context.read<SettingsCubit>().state.inputConfiguration;
final cubit = context.read<CurrentIndexCubit>();
final bloc = context.read<DocumentBloc>();
// 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;
Expand Down
40 changes: 20 additions & 20 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -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
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
6 changes: 5 additions & 1 deletion metadata/en-US/changelogs/118.txt
Original file line number Diff line number Diff line change
@@ -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
* 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

0 comments on commit fcdaa74

Please sign in to comment.