Compare commits

...

585 Commits

Author SHA1 Message Date
Jonas Bark
02c038daaa additional fixes 2026-02-16 18:32:31 +01:00
Jonas Bark
05352d7118 additional fixes 2026-02-16 18:22:16 +01:00
Jonas Bark
5c7e8b923b fix shimano di2 implementation 2026-02-16 17:58:10 +01:00
Jonas Bark
ceeca9dd02 training peaks BLE workaround 2026-02-16 12:10:05 +01:00
Jonas Bark
ab379cf74b shorebird cleanup 2026-02-16 11:02:59 +01:00
Jonas Bark
ad7bd646f3 cleanup 2026-02-16 11:00:20 +01:00
Jonas Bark
7ed1ba4397 fix import 2026-02-15 21:49:28 +01:00
Jonas Bark
a9cb929b01 cleanup ui 2026-02-15 21:48:04 +01:00
Jonas Bark
8d056b526e Di2: resolve issue #233 2026-02-15 21:44:02 +01:00
Jonas Bark
7a77acaf94 local connection tile always show as suggested 2026-02-15 13:40:33 +01:00
Jonas Bark
216dc97517 zwift click: send 0xff command again 2026-02-15 12:20:17 +01:00
Jonas Bark
746a680449 cleanup 2026-02-15 10:11:43 +01:00
Jonas Bark
b1385e70cc actions 2026-02-14 10:34:17 +01:00
Jonas Bark
aec24bba61 enable audio button capture on iOS 2026-02-14 10:11:25 +01:00
Jonas Bark
226824c14a actions 2026-02-14 10:06:53 +01:00
Jonas Bark
8c4816ffd0 actions 2026-02-14 10:06:29 +01:00
Jonas Bark
07423fc0f6 fix unit test 2026-02-14 09:54:32 +01:00
Jonas Bark
812a4efe13 Merge remote-tracking branch 'origin/copilot/fix-vs200-double-shifting'
# Conflicts:
#	test/thinkrider_vs200_test.dart
2026-02-14 09:51:29 +01:00
Jonas Bark
8dadc07e07 fix unit tests 2026-02-14 09:50:36 +01:00
copilot-swe-agent[bot]
15dc34b2ea Add clarifying comments for two-call pattern in handleButtonsClickedWithoutLongPressSupport
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2026-02-14 07:51:10 +00:00
copilot-swe-agent[bot]
d8a528017d Add comprehensive tests for VS200 single-click behavior
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2026-02-14 07:50:25 +00:00
copilot-swe-agent[bot]
d2a41fc2fa Fix VS200 double shifting by handling non-long-press buttons correctly
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2026-02-14 07:49:25 +00:00
copilot-swe-agent[bot]
7b2f16772d Initial plan 2026-02-14 07:42:09 +00:00
Jonas Bark
edf19e3ffa fix MyWhoosh Link issue 2026-02-12 18:23:14 +01:00
Jonas Bark
ec4e4fc375 fix public compilation 2026-02-11 09:00:00 +01:00
Jonas Bark
59141c81af support Zwift Ride with old firmware 2026-02-11 08:56:10 +01:00
Jonas Bark
732bb4a150 version++ 2026-02-10 15:15:18 +01:00
Jonas Bark
84d9d1e312 accessories should not be displayed in keymap customize tab 2026-02-10 15:15:01 +01:00
Jonas Bark
3b6f9f6f29 version++ 2026-02-10 09:44:40 +01:00
Jonas Bark
21f7636cee patch it 2026-02-10 09:13:44 +01:00
Jonas Bark
3eda3b590a update submodule 2026-02-10 09:12:38 +01:00
Jonas Bark
f844681f4c kickr headwind adjustments #11 2026-02-10 09:11:39 +01:00
Jonas Bark
5c22851d66 Merge branch 'test' 2026-02-10 08:56:49 +01:00
jonasbark
fb2068a08a Merge pull request #296 from OpenBikeControl/copilot/fix-button-press-headwind-issue
Add delay between mode change and speed commands for Wahoo KICKR Headwind
2026-02-10 08:55:43 +01:00
copilot-swe-agent[bot]
f7a0b8dca8 Fix headwind first button press issue by adding delay between mode and speed commands
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2026-02-10 07:44:37 +00:00
copilot-swe-agent[bot]
76c59537c1 Initial plan 2026-02-10 07:42:07 +00:00
Jonas Bark
81f14f16fd openbikecontrol via dircon 2026-02-08 11:28:48 +01:00
Jonas Bark
c4a8d1ef9c remove BLE services when disconnecting 2026-02-08 10:02:12 +01:00
Jonas Bark
a1cfe43ef9 cleanup toast handling 2026-02-08 10:01:54 +01:00
Jonas Bark
14f5486ab6 fix potential crash 2026-02-07 09:56:35 +01:00
jonasbark
a7e2b5bc26 Update Windows Store version from 4.6.2 to 4.7.2 2026-02-06 19:26:03 +01:00
Jonas Bark
8bea3b36cc fix patch yaml 2026-02-06 14:23:45 +01:00
Jonas Bark
2802ead254 missing methods in shared public 2026-02-06 13:20:50 +01:00
Jonas Bark
5c2ae38951 fix module 2026-02-06 13:17:23 +01:00
Jonas Bark
0dc6ea7fd4 fix module 2026-02-06 13:16:10 +01:00
Jonas Bark
288fbed819 logic fixes 2026-02-06 13:02:21 +01:00
Jonas Bark
497528c75b iOS: keep app alive in background 2026-02-06 12:51:47 +01:00
Jonas Bark
d8ceea9c63 purchasing the app on Android is now finally possible 2026-02-06 10:27:21 +01:00
Jonas Bark
bed3dac98e update submodule 2026-02-05 17:33:39 +01:00
Jonas Bark
9eaa9c53f9 add new remote keyboard connection method 2026-02-05 17:22:21 +01:00
Jonas Bark
ccd1d46128 reenable shorebird, fix button editor for remote setting 2026-02-05 14:45:21 +01:00
Jonas Bark
79edebc8f9 cleanup 2026-02-05 14:30:15 +01:00
Jonas Bark
dbf148c41f fix messages 2026-02-05 14:28:15 +01:00
Jonas Bark
fe898cefda fix #246 2026-02-05 14:23:50 +01:00
Jonas Bark
f662d0a36a Merge branch 'main' of github.com:OpenBikeControl/bikecontrol 2026-02-04 15:28:17 +01:00
jonasbark
5c8a5934f2 Merge pull request #290 from OpenBikeControl/copilot/save-enable-media-key-setting
Persist media key detection setting across app restarts
2026-02-04 15:27:49 +01:00
copilot-swe-agent[bot]
c7e845086a Simplify assignment per code review feedback
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2026-02-04 14:08:10 +00:00
copilot-swe-agent[bot]
67a4144ab0 Implement media key detection persistence
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2026-02-04 14:07:07 +00:00
copilot-swe-agent[bot]
bfeb72a775 Initial plan 2026-02-04 14:03:54 +00:00
Jonas Bark
799234c323 set long press by default for steering actions 2026-02-04 12:44:27 +01:00
jonasbark
ab49da1cea Merge pull request #286 from OpenBikeControl/copilot/update-window-title-to-bikecontrol
Fix Windows window title to display "BikeControl"
2026-02-03 10:47:52 +01:00
copilot-swe-agent[bot]
0f41c85590 Fix Windows window title to display "BikeControl"
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2026-02-03 09:39:52 +00:00
copilot-swe-agent[bot]
175ff75637 Update window title from bike_control to BikeControl
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2026-02-03 09:38:20 +00:00
copilot-swe-agent[bot]
6b60046fd5 Initial plan 2026-02-03 09:37:00 +00:00
Jonas Bark
8ecac5d619 bug fixes around keymap 2026-02-03 09:40:57 +01:00
Jonas Bark
1a463f74be reset trial period on Android 2026-02-03 08:41:12 +01:00
Jonas Bark
6fd319ffb2 reset trial period on Android 2026-02-03 08:40:31 +01:00
Jonas Bark
551ed28310 reenable web builds 2026-02-02 10:34:05 +01:00
Jonas Bark
6606586cef introduce prop_public package with stubs, fixes issue #281 2026-02-02 10:29:40 +01:00
Jonas Bark
5157f74714 Merge branch 'main' of github.com:OpenBikeControl/bikecontrol 2026-02-02 09:39:08 +01:00
Jonas Bark
8b30b9bc29 optional: use magnetometer mode in phone steering 2026-02-02 09:17:41 +01:00
jonasbark
9a74a14804 Revise MyWhoosh Link connection instructions
Updated instructions for using the MyWhoosh 'Link' connection method, including clarification on app usage and connection steps.
2026-02-01 20:02:17 +01:00
Jonas Bark
4d16eab3a7 fix shorebird, button editor being opened without copying keymap 2026-02-01 19:47:31 +01:00
Jonas Bark
76bcf2af68 fix shorebird? 2026-02-01 17:53:25 +01:00
Jonas Bark
269fb23c94 fix shorebird? 2026-02-01 17:52:31 +01:00
Jonas Bark
459597aca8 fix 2026-02-01 17:19:21 +01:00
Jonas Bark
2c153f6c22 fix 2026-02-01 17:18:49 +01:00
Jonas Bark
b66285bc83 version++ 2026-02-01 16:56:59 +01:00
Jonas Bark
e1bc66a1b6 update translations 2026-02-01 16:54:31 +01:00
Jonas Bark
fd4e5f5ce8 cleanup, proxy work 2026-02-01 16:33:03 +01:00
Jonas Bark
40a0eae187 move predefined actions for keymap 2026-02-01 10:50:35 +01:00
Jonas Bark
d26cf5eb7b cleanup streams on exit 2026-02-01 10:08:31 +01:00
Jonas Bark
2404f0fdf5 show a message in configuration when no buttons available for a device 2026-02-01 10:00:43 +01:00
Jonas Bark
50199ef077 update license notice 2026-01-31 13:59:45 +01:00
Jonas Bark
11095cf052 move repository, adjust references, license 2026-01-31 13:53:54 +01:00
Jonas Bark
69afc698dc less messages when calibrating 2026-01-30 18:06:13 +01:00
Jonas Bark
babe564f3a fix action assignment 2026-01-30 17:46:58 +01:00
jonasbark
c10666be80 Update Windows Store version to 4.6.2 2026-01-30 12:29:19 +01:00
jonasbark
67ad3fb8c5 Change YouTube video link in README.md
Updated YouTube video link in README.
2026-01-30 10:41:51 +01:00
Jonas Bark
586b17c2d2 version++ 2026-01-29 16:22:46 +01:00
Jonas Bark
4909a1a47f fix issue when duplicating keymap 2026-01-29 16:22:32 +01:00
Jonas Bark
99e603413c improve click V2 unlock logic 2026-01-29 14:57:55 +01:00
Jonas Bark
875f5cb656 fix issue #282 2026-01-29 14:56:47 +01:00
Jonas Bark
7ad65ba5dc version++ 2026-01-28 15:20:11 +01:00
Jonas Bark
7e969b1a94 Merge remote-tracking branch 'origin/main' 2026-01-28 15:19:31 +01:00
Jonas Bark
5689980c87 potentially fix #276 2026-01-28 15:19:24 +01:00
jonasbark
b14a6451ed Update README with YouTube video and clean up links
Added a YouTube video link and removed an outdated asset link.
2026-01-28 15:04:01 +01:00
Jonas Bark
7a52828bd1 fix build for Windows 2026-01-28 12:46:12 +01:00
Jonas Bark
6926f5d3d5 fix build for Windows 2026-01-28 12:36:34 +01:00
Jonas Bark
cb6283364a fix build for Windows 2026-01-28 12:36:06 +01:00
Jonas Bark
1e220799be fix build for Windows 2026-01-28 12:34:13 +01:00
Jonas Bark
f0ad53e9d4 Merge branch 'zcv2' 2026-01-28 11:58:19 +01:00
Jonas Bark
b0bf0bd802 version++ 2026-01-28 11:57:47 +01:00
Jonas Bark
e3fc35211f cleanup 2026-01-28 11:56:01 +01:00
Jonas Bark
8c77bcea2a update translations 2026-01-28 09:59:18 +01:00
Jonas Bark
1693605305 move scan settings 2026-01-28 08:40:24 +01:00
jonasbark
93ad9d3a30 Update Wi-Fi SSID instructions for MyWhoosh Link
Clarify instructions regarding device connections for MyWhoosh Link.
2026-01-27 13:22:37 +01:00
Jonas Bark
15bc4ab2af version++ 2026-01-26 15:53:47 +01:00
Jonas Bark
6c0942acad make phone steering option more clear 2026-01-26 15:53:19 +01:00
Jonas Bark
351e702238 cleanup 2026-01-26 09:27:07 +01:00
Jonas Bark
8119d69c1a cleanup 2026-01-26 09:00:52 +01:00
Jonas Bark
13d11dd927 adjust logic 2026-01-24 14:22:12 +01:00
Jonas Bark
f4c47071fb fix build 2026-01-23 20:03:19 +01:00
Jonas Bark
7043d16108 actions 2026-01-23 19:05:42 +01:00
Jonas Bark
eb587c4341 actions 2026-01-23 18:48:06 +01:00
Jonas Bark
80bd4725d1 actions, logs fix 2026-01-23 18:31:28 +01:00
Jonas Bark
25ff46d527 update changelog, actions 2026-01-23 17:58:04 +01:00
Jonas Bark
7acd86fc94 UI adjustments 2026-01-23 17:48:29 +01:00
Jonas Bark
26047da35c update changelog, actions 2026-01-23 15:52:19 +01:00
Jonas Bark
d3ab4f8804 group buttons by device, add new unlock mechanism 2026-01-23 15:27:32 +01:00
Jonas Bark
29940d45ba version++ 2026-01-22 18:41:45 +01:00
Jonas Bark
c6296b009a version++ 2026-01-22 18:38:50 +01:00
Jonas Bark
130a638e2b version++ 2026-01-22 18:30:12 +01:00
Jonas Bark
12a5d9e52b version++ 2026-01-22 18:13:32 +01:00
Jonas Bark
2e69cdb593 version++ 2026-01-22 17:47:00 +01:00
Jonas Bark
6d6427f8cd fix macOS build issue 2026-01-22 17:31:52 +01:00
Jonas Bark
2d73d8577e fix macOS build issue 2026-01-22 17:11:17 +01:00
Jonas Bark
19e72af527 version++ 2026-01-22 16:44:48 +01:00
Jonas Bark
1692c584f4 update flutter 2026-01-22 16:44:26 +01:00
Jonas Bark
ab8e1b6afe fix build 2026-01-22 15:40:23 +01:00
Jonas Bark
9a7c4bb13a update changelog, translations 2026-01-22 14:47:17 +01:00
Jonas Bark
b97298099c Windows & macOS: allow configuration of volume keys on Bluetooth HID devices 2026-01-22 14:29:57 +01:00
Jonas Bark
a7a91e00a2 inform user to enable local connection method on Android 2026-01-22 14:10:15 +01:00
Jonas Bark
ad7d8276a2 update changelog 2026-01-22 08:22:55 +01:00
Jonas Bark
6d652ad70b show side identifier for Zwift Play 2026-01-21 13:06:26 +01:00
Jonas Bark
94d5b4ad92 improve default actions 2026-01-21 12:52:27 +01:00
Jonas Bark
792d2733ff add missing openbikecontrol actions 2026-01-21 10:33:17 +01:00
Jonas Bark
07e4b5e89f cleanup 2026-01-19 16:57:54 +01:00
Jonas Bark
fe271038cb fix media key buttons 2026-01-19 16:57:39 +01:00
Jonas Bark
51cb4859e3 fix import, adjust changelog 2026-01-19 11:18:43 +01:00
jonasbark
b4667ca894 Merge pull request #270 from jonasbark/copilot/add-device-button-config
Generalize per-device mappings for Bluetooth controllers and persist device IDs in keymaps
2026-01-19 11:02:00 +01:00
Jonas Bark
f79cfb6319 Merge branch 'main' of github.com:jonasbark/swiftcontrol 2026-01-19 11:01:45 +01:00
Jonas Bark
97279b7c16 update dependencies 2026-01-19 11:01:42 +01:00
copilot-swe-agent[bot]
5b8a64c356 refactor: generalize per-device button handling
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2026-01-19 09:55:00 +00:00
copilot-swe-agent[bot]
29777d86e0 feat: device-specific thinkrider mapping
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2026-01-19 09:37:14 +00:00
copilot-swe-agent[bot]
58440148b3 chore: update progress checklist
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2026-01-19 09:26:30 +00:00
copilot-swe-agent[bot]
bfcf43d428 feat: per-device cycplus mapping
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2026-01-19 09:23:06 +00:00
copilot-swe-agent[bot]
b8448d57e5 Initial plan 2026-01-19 09:13:25 +00:00
Jonas Bark
000104365c add OpenBikeControl protocol to onboarding 2026-01-19 08:23:30 +01:00
jonasbark
8141310f7b Update Windows Store version to 4.4.1 2026-01-17 19:08:48 +01:00
jonasbark
f432d9d187 Merge pull request #265 from jonasbark/copilot/add-special-keys-to-buttoneditor
Add Android global actions to local control button editor
2026-01-17 14:51:54 +01:00
Jonas Bark
5ab8ccc8c8 Merge branch 'copilot/add-special-keys-to-buttoneditor' of github.com:jonasbark/swiftcontrol into copilot/add-special-keys-to-buttoneditor
# Conflicts:
#	CHANGELOG.md
2026-01-17 14:48:25 +01:00
Jonas Bark
fd9818707e PR feedback 2026-01-17 14:46:22 +01:00
jonasbark
7422ff8624 Update CHANGELOG.md
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-17 14:39:56 +01:00
Jonas Bark
58cf7b5bf3 update changelog 2026-01-17 14:19:47 +01:00
Jonas Bark
87d71e1213 Android: simulate additional actions for local connection method (Left, Down, Right, Up, Down, Select, Back, Home, Recent Apps), allowing you to navigate in the trainer app, if supported 2026-01-17 13:52:27 +01:00
Jonas Bark
a0cde5352f Merge branch 'main' into copilot/add-special-keys-to-buttoneditor 2026-01-17 13:14:15 +01:00
copilot-swe-agent[bot]
b6ed1c047d Add Android global actions support
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2026-01-17 12:06:48 +00:00
Jonas Bark
8d8cb7381a fix configuration not updating for new buttons 2026-01-17 12:59:39 +01:00
copilot-swe-agent[bot]
f3bbf5e06c Initial plan 2026-01-17 11:50:53 +00:00
Jonas Bark
a5f9b42e6f Windows: fix media key detection 2026-01-17 12:11:14 +01:00
Jonas Bark
d053101c14 Merge branch 'main' of github.com:jonasbark/swiftcontrol 2026-01-17 12:01:26 +01:00
jonasbark
3022b15d3a Merge pull request #264 from jonasbark/copilot/fix-bikecontrol-gear-change-issue
Allow Rouvy gear changes while app is in background
2026-01-17 12:00:33 +01:00
jonas.bark@gmx.de
6b541e1d14 allow all apps to execute keyboard key in background 2026-01-17 11:58:15 +01:00
copilot-swe-agent[bot]
586b148ed3 Allow Rouvy gear changes while app is in background
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2026-01-17 09:11:34 +00:00
copilot-swe-agent[bot]
cf47a758ee Refine background window handling
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2026-01-17 09:10:56 +00:00
copilot-swe-agent[bot]
89230815a2 Allow background keypress for Rouvy
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2026-01-17 09:10:17 +00:00
copilot-swe-agent[bot]
60a176bba2 Initial plan 2026-01-17 09:07:01 +00:00
Jonas Bark
44b5c010ba cleanup 2026-01-16 13:29:44 +01:00
Jonas Bark
425c65528b change notification icon 2026-01-16 12:59:39 +01:00
Jonas Bark
8ac6f58d8e fix detection for hardware buttons when BikeControl is in foreground, change notification icon 2026-01-16 12:38:10 +01:00
Jonas Bark
f6ac724c60 fix iap logic on Android 2026-01-16 11:59:50 +01:00
Jonas Bark
9010346c0b cleanup 2026-01-16 00:44:08 +01:00
Jonas Bark
41a3a8f14d update changelog 2026-01-16 00:21:01 +01:00
Jonas Bark
a883abcd1c Merge remote-tracking branch 'origin/main' 2026-01-16 00:20:40 +01:00
Jonas Bark
ab37de8f40 fix issue #258 2026-01-16 00:20:30 +01:00
jonasbark
ac0e15eaa7 Update instructions for MyWhoosh Link connectivity 2026-01-15 17:06:46 +01:00
Jonas Bark
a6a7e7f0c2 show logs file path 2026-01-15 14:35:18 +01:00
Jonas Bark
3cacdf9a3a update changelog 2026-01-15 14:25:36 +01:00
Jonas Bark
3ebbda3690 kickr headwind: write without response to potentially fix #11 2026-01-15 08:55:03 +01:00
Jonas Bark
74abb13acf skip powermeters from connecting 2026-01-14 12:12:19 +01:00
Jonas Bark
86addc00fd Merge remote-tracking branch 'origin/win' 2026-01-13 18:42:52 +01:00
jonas.bark@gmx.de
9cebea225c fix import 2026-01-13 18:42:42 +01:00
jonasbark
59bdb30321 Merge pull request #255 from jonasbark/win
Win
2026-01-13 18:20:52 +01:00
Jonas Bark
d51fb7dfa2 update translations 2026-01-13 18:20:25 +01:00
jonas.bark@gmx.de
b955c51a91 cleanup 2026-01-13 18:07:35 +01:00
Jonas Bark
86ecd1ad20 check win package format 2026-01-13 17:57:01 +01:00
jonas.bark@gmx.de
c089b3bdbd fix test phase logic 2026-01-13 17:49:17 +01:00
Jonas Bark
9612b213aa adjust instructions 2026-01-13 11:49:27 +01:00
Jonas Bark
83c9b52708 Merge branch 'copilot/fix-bluetooth-keyboard-issue' 2026-01-12 18:43:46 +01:00
Jonas Bark
a7bde7c08a UI fix 2026-01-12 18:43:10 +01:00
Jonas Bark
c8613b5975 fix implementation 2026-01-12 18:42:54 +01:00
jonasbark
87bb728601 Merge pull request #253 from jonasbark/copilot/add-support-thinkrider-vs200
Add support for Thinkrider VS200 virtual shifter
2026-01-12 17:55:47 +01:00
copilot-swe-agent[bot]
e1f9d4fb08 Add debug logging for all received hexValues while in beta
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2026-01-12 16:55:12 +00:00
copilot-swe-agent[bot]
14e6c1186c Address code review feedback: memory leak and thread safety
- Store keymap update subscription to allow cancellation on re-init
- Fix List<String?> to List<String> in setHandledKeys signature
- Use ConcurrentHashMap.newKeySet() for thread-safe handledKeys access
- Clear and update the set instead of replacing it

Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2026-01-12 16:52:22 +00:00
copilot-swe-agent[bot]
abeb142f0b Fix case-insensitive pattern matching for VS200
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2026-01-12 16:50:52 +00:00
copilot-swe-agent[bot]
d416756614 Update VS200 logic: use only FEA0 service with specific byte patterns
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2026-01-12 16:49:48 +00:00
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
copilot-swe-agent[bot]
6579092f4a Update README with Thinkrider VS200 support
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2026-01-12 16:37:23 +00:00
copilot-swe-agent[bot]
c242c09025 Add support for Thinkrider VS200 virtual shifter
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2026-01-12 16:36:53 +00:00
copilot-swe-agent[bot]
89c9ed598c Fix Android accessibility service to only intercept media/volume keys
- Add isMediaOrVolumeKey() helper to filter key events by key code
- Only swallow media and volume keys (play/pause, next, volume up/down, etc.)
- Let all other keys (typing keys, navigation, etc.) pass through to the system
- This fixes Bluetooth keyboard interference when BikeControl is running

Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2026-01-12 16:36:18 +00:00
copilot-swe-agent[bot]
a3a592bd16 Initial plan 2026-01-12 16:31:49 +00:00
copilot-swe-agent[bot]
a161829913 Initial plan 2026-01-12 16:31:43 +00:00
Jonas Bark
b4473ad067 patch it 2026-01-11 15:48:57 +01:00
jonas.bark@gmx.de
4752f99fcf fix windows issue 2026-01-11 15:47:29 +01:00
Jonas Bark
6e757cf15c list supported actions of connection method 2026-01-11 13:01:10 +01:00
Jonas Bark
a87810db88 list supported actions of connection method 2026-01-11 13:00:43 +01:00
Jonas Bark
0ddb3e8081 clenaup 2026-01-11 12:11:28 +01:00
Jonas Bark
e29aed8bcf version++ 2026-01-11 11:28:43 +01:00
Jonas Bark
d99a3257af optional notification permission on macOS 2026-01-11 11:28:29 +01:00
Jonas Bark
a772b210cd don't connect to both Zwift Ride instances 2026-01-11 11:25:20 +01:00
Jonas Bark
860700ab91 version++ 2026-01-08 10:37:51 +01:00
Jonas Bark
ff5d90d468 fix Apple full version detection 2026-01-08 10:37:36 +01:00
Jonas Bark
43773310d5 ui fix, sync purchases once, Zwift Ride adjustment 2026-01-08 09:43:52 +01:00
jonasbark
2da65645b0 Update Windows Store version to 4.3.0 2026-01-07 14:04:51 +01:00
Jonas Bark
0c62d64987 version++ 2026-01-07 11:21:22 +01:00
Jonas Bark
546f6c2f8f version++ 2026-01-07 11:03:03 +01:00
Jonas Bark
a6ee15e3ba changelog adjustment 2026-01-07 10:37:46 +01:00
Jonas Bark
51793847cf performance & ui fixes 2026-01-07 10:36:41 +01:00
Jonas Bark
f308aa3847 performance & ui fixes 2026-01-07 10:19:21 +01:00
Jonas Bark
695b994577 fix shorebird logic 2026-01-06 18:08:56 +01:00
Jonas Bark
2301d04c61 refactor update UI 2026-01-06 09:10:27 +01:00
Jonas Bark
e46ec5172c OBC adjustments 2026-01-05 13:23:33 +01:00
Jonas Bark
691e108c82 OBC adjustments 2026-01-05 13:22:23 +01:00
Jonas Bark
166146a8f8 Web fixes 2026-01-03 20:50:06 +01:00
Jonas Bark
2a42cfc80f make notifications optional on macOS & iOS 2026-01-03 09:42:03 +01:00
Jonas Bark
aff1f20ebe Merge branch '4.2.4'
# Conflicts:
#	CHANGELOG.md
#	lib/utils/iap/revenuecat_service.dart
2026-01-02 21:02:54 +01:00
Jonas Bark
804fed799d fix logic 2026-01-02 21:02:02 +01:00
Jonas Bark
b6450ba47c restore button 2026-01-02 20:42:23 +01:00
Jonas Bark
14a4234583 instructions UI change 2026-01-02 15:03:46 +01:00
Jonas Bark
72cd165992 instructions for local connection method 2026-01-02 14:03:08 +01:00
Jonas Bark
239aec2083 onboarding UI 2026-01-01 13:50:02 +01:00
Jonas Bark
a43ab60dcb onboarding UI 2026-01-01 13:47:17 +01:00
Jonas Bark
484b7f74e6 onboarding UI 2026-01-01 13:44:45 +01:00
Jonas Bark
8c1ddcb019 ui adjustments 2026-01-01 12:40:45 +01:00
Jonas Bark
306a5badef onboarding for new users 2025-12-31 16:26:40 +01:00
Jonas Bark
e82003cd57 onboarding for new users 2025-12-31 16:16:37 +01:00
Jonas Bark
6a6aafe0a9 onboarding for new users 2025-12-31 15:52:30 +01:00
Jonas Bark
4bd440e167 ui adjustments 2025-12-31 13:51:47 +01:00
Jonas Bark
80d198787f ui adjustments 2025-12-31 12:26:34 +01:00
Jonas Bark
7f7bae477b debug text adjustments 2025-12-31 12:11:06 +01:00
Jonas Bark
2917814ecc alternative title during button editor 2025-12-30 17:45:06 +01:00
Jonas Bark
e268a86f20 fix media key icons 2025-12-30 14:12:55 +01:00
jonasbark
9a13831e91 Merge pull request #240 from jonasbark/copilot/enable-media-key-dispatching
Add media key dispatching for Desktop platforms
2025-12-30 14:04:12 +01:00
copilot-swe-agent[bot]
9f6e57b9ff Fix Windows compilation error: Cast UINT to WORD for wVk field
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-30 12:57:32 +00:00
Jonas Bark
86cf7491c3 Revert "issue"
This reverts commit 681ec710a1.
2025-12-30 13:55:30 +01:00
jonas.bark@gmx.de
681ec710a1 issue 2025-12-30 13:54:34 +01:00
Jonas Bark
dc40d61766 fix dart 2025-12-30 13:46:30 +01:00
copilot-swe-agent[bot]
326ff4ce24 Style: Fix code formatting and remove trailing comma in C++
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-30 12:43:50 +00:00
copilot-swe-agent[bot]
ca81642c5c Optimize: Make key maps static const for better performance
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-30 12:42:38 +00:00
copilot-swe-agent[bot]
32e4b9762b Refactor: Use maps instead of if-else chains for key mappings
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-30 12:41:13 +00:00
copilot-swe-agent[bot]
0c94852246 Use string identifiers instead of keyCode for media keys
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-30 12:39:26 +00:00
copilot-swe-agent[bot]
d2f67e402b Complete media key dispatching implementation
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-30 12:36:10 +00:00
copilot-swe-agent[bot]
145e55fe68 Add proper error handling for media key dispatch
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-30 12:34:41 +00:00
copilot-swe-agent[bot]
fd6358c233 Fix command count increment order for media keys
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-30 12:33:21 +00:00
copilot-swe-agent[bot]
1d047ce9ef Fix code review issues: error message and type mismatch
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-30 12:31:44 +00:00
copilot-swe-agent[bot]
a27a0b8872 Improve documentation for macOS media stop key behavior
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-30 12:30:10 +00:00
copilot-swe-agent[bot]
0e98a9d500 Add media key dispatching support for Desktop platforms
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-30 12:27:55 +00:00
copilot-swe-agent[bot]
728b2e0b53 Initial plan 2025-12-30 12:21:42 +00:00
jonas.bark@gmx.de
220ffa49c6 fix windows notifications 2025-12-30 13:19:56 +01:00
jonas.bark@gmx.de
74d1ec58de fix a companion mode issue with delayed dispatches 2025-12-30 12:44:02 +01:00
Jonas Bark
b2d19f7e70 ignore messages when in background 2025-12-30 09:44:27 +01:00
Jonas Bark
7db8dfec62 message permission fix 2025-12-29 15:08:46 +01:00
Jonas Bark
b0c0767dc7 obp adjustments 2025-12-29 10:15:36 +01:00
Jonas Bark
2e880869f3 restore purchase 2025-12-29 09:19:06 +01:00
Jonas Bark
1edf949a7a Merge branch 'revenuecat' 2025-12-28 13:14:16 +01:00
Jonas Bark
04c85668fe Merge branch 'main' of github.com:jonasbark/swiftcontrol 2025-12-28 13:14:13 +01:00
Jonas Bark
fcefd863cd version++ 2025-12-28 13:13:57 +01:00
Jonas Bark
64bac7e50f revenue cat changes, italian translation 2025-12-28 13:12:20 +01:00
Jonas Bark
f94c1b1851 check original app version 2025-12-27 09:08:29 +01:00
Jonas Bark
3a013db311 Merge remote-tracking branch 'origin/main' into revenuecat 2025-12-27 09:04:13 +01:00
jonasbark
0fd141316e Revise MyWhoosh Link connection instructions
Updated instructions for using MyWhoosh Link connection method to clarify optional steps and improve readability.
2025-12-27 00:23:16 +01:00
Jonas Bark
2ed4f389c9 Merge branch 'main' into revenuecat 2025-12-26 23:15:47 +01:00
Jonas Bark
9a1a25ed17 unlock for now 2025-12-26 23:15:24 +01:00
Jonas Bark
173fae7472 handle old migrated purchases 2025-12-26 22:57:43 +01:00
Jonas Bark
82c9df2214 fix podfile 2025-12-26 20:35:59 +01:00
Jonas Bark
a49b6b81ae fix podfile 2025-12-26 20:35:53 +01:00
Jonas Bark
dffa7003bc Merge branch 'copilot/integrate-revenuecat-sdk' 2025-12-26 19:44:12 +01:00
Jonas Bark
818ff4909a implement logic 2025-12-26 19:36:20 +01:00
Jonas Bark
d1e054d5c5 implement logic 2025-12-26 18:48:57 +01:00
copilot-swe-agent[bot]
7689da9acd Add future improvements documentation
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-26 13:03:53 +00:00
copilot-swe-agent[bot]
0bf336643d Add implementation summary documentation
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-26 13:01:51 +00:00
copilot-swe-agent[bot]
70dc5d19e7 Fix async handling and improve error messages
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-26 13:00:52 +00:00
copilot-swe-agent[bot]
4da91b0fa3 Fix circular dependency and async issues in RevenueCat service
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-26 12:58:50 +00:00
copilot-swe-agent[bot]
cb219c57c4 Add comprehensive RevenueCat setup and configuration documentation
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-26 12:55:16 +00:00
copilot-swe-agent[bot]
0be5500d78 Add RevenueCat SDK integration with paywall and customer center support
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-26 12:53:51 +00:00
copilot-swe-agent[bot]
94dcccdce3 Initial plan 2025-12-26 12:48:20 +00:00
Jonas Bark
91b6ffdbe2 version++ 2025-12-24 22:38:30 +01:00
Jonas Bark
baa3a73984 Merge branch 'hotfix' 2025-12-24 10:46:53 +01:00
Jonas Bark
dd5c231c47 hopefully fix iap issue on Android 2025-12-24 10:28:58 +01:00
Jonas Bark
3a0d4e1cbc hopefully fix iap issue on Android 2025-12-24 10:08:55 +01:00
Jonas Bark
631f031daa unit test adjustments 2025-12-23 09:10:05 +01:00
Jonas Bark
a487539e6a hotfix 2025-12-22 20:37:44 +01:00
Jonas Bark
ad7454236a hotfix 2025-12-22 20:17:27 +01:00
Jonas Bark
e182fea4d1 hotfix 2025-12-22 20:05:09 +01:00
Jonas Bark
6615061658 hotfix macOS 2025-12-22 20:00:17 +01:00
jonasbark
5c1d423806 Update CHANGELOG.md 2025-12-22 19:34:37 +01:00
Jonas Bark
171f97645f Merge branch 'main' of github.com:jonasbark/swiftcontrol 2025-12-22 19:24:14 +01:00
jonasbark
9511c233a2 Add iPadOS support to connection methods in README
Updated README to include iPadOS in connection methods.
2025-12-22 18:23:47 +01:00
jonasbark
adfc2bd8cf Update Windows Store version to 4.2.2 2025-12-22 15:29:26 +01:00
jonasbark
2adba27dca Fix formatting and clarify trainer app connection 2025-12-22 11:41:41 +01:00
Jonas Bark
b18c85fc8e improve Android notification action handling 2025-12-22 11:13:37 +01:00
Jonas Bark
2e79a43827 axs info 2025-12-22 08:21:02 +01:00
Jonas Bark
0fec34bb56 allow redeeming manually 2025-12-21 22:21:40 +01:00
Jonas Bark
db3e133199 allow redeeming manually 2025-12-21 22:17:47 +01:00
Jonas Bark
971cb91615 allow redeeming manually 2025-12-21 22:16:12 +01:00
Jonas Bark
e5e04f3d59 clarify Android transition 2025-12-21 20:33:51 +01:00
Jonas Bark
fd9f7388e8 check purchases once a day 2025-12-21 16:41:30 +01:00
Jonas Bark
6ae2297246 version++ 2025-12-21 16:00:10 +01:00
Jonas Bark
c6fb2e68b5 win fix 2025-12-21 15:43:44 +01:00
jonas.bark@gmx.de
c84c685a8f attempt to fix remaining trial days calculation 2025-12-21 15:42:17 +01:00
Jonas Bark
102f4a8818 add info for Android users regarding existing purchase 2025-12-21 13:54:08 +01:00
Jonas Bark
661d72fa8c windows adjustments 2025-12-21 10:29:53 +01:00
jonas.bark@gmx.de
38df962e43 windows trial changes 2025-12-21 10:25:52 +01:00
Jonas Bark
e02563733f fix missing entitlements on release builds for macOS 2025-12-20 20:40:53 +01:00
Jonas Bark
c246d2d1fe fix missing entitlements on release builds for macOS 2025-12-20 20:40:12 +01:00
Jonas Bark
8dbed9a8b5 wrong translation 2025-12-20 18:08:13 +01:00
Jonas Bark
6ea4fa82a7 version++ 2025-12-20 11:39:02 +01:00
Jonas Bark
0d78ca6352 version++ 2025-12-20 11:20:39 +01:00
Jonas Bark
b82ad80d1c fix windows build version 2025-12-20 10:56:19 +01:00
Jonas Bark
eece2ce7dc update changelog 2025-12-20 10:30:32 +01:00
jonasbark
3bfd7dd7ab Merge pull request #222 from jonasbark/copilot/implement-in-app-purchase
Implement IAP system with 5-day trial and command limiting
2025-12-20 10:13:33 +01:00
Jonas Bark
b0f3dffc3c screenshots 2025-12-20 10:13:20 +01:00
Jonas Bark
f5234d0c11 update changelog 2025-12-20 10:06:57 +01:00
Jonas Bark
8a12ccb01e cleanup 2025-12-20 10:04:44 +01:00
Jonas Bark
fac2e86240 bugfixes and clarifications 2025-12-20 10:01:37 +01:00
Jonas Bark
39b49bb9de sram fix 2025-12-19 21:06:13 +01:00
Jonas Bark
406ccfa2ce adjust iOS receipt logic 2025-12-19 20:41:45 +01:00
Jonas Bark
16e6b96cc7 SRAM AXS support 2025-12-19 20:41:27 +01:00
Jonas Bark
1e37c8a742 press longer for the simulator, enable long press for devices not supporting long press (e.g. Shimano Di2) 2025-12-19 11:40:07 +01:00
Jonas Bark
5f0389b36f press longer for the simulator, enable long press for devices not supporting long press (e.g. Shimano Di2) 2025-12-19 11:38:30 +01:00
Jonas Bark
8762d85d57 press longer for the simulator, enable long press for devices not supporting long press (e.g. Shimano Di2) 2025-12-19 11:33:13 +01:00
Jonas Bark
018bbd43f1 fix 2025-12-19 10:13:01 +01:00
Jonas Bark
756e3fc556 version++ 2025-12-19 10:09:06 +01:00
Jonas Bark
7ac5f5dbcb fine tune gryoscope logic to react more quickly 2025-12-19 09:29:19 +01:00
Jonas Bark
65c613fd24 fine tune gryoscope logic to react more quickly 2025-12-19 09:29:05 +01:00
Jonas Bark
e0ad9007a4 ui adjustments 2025-12-19 09:21:11 +01:00
Jonas Bark
c3cda5f547 ui adjustments, add polish translations 2025-12-19 08:56:14 +01:00
Jonas Bark
12f379c03d screenshot fix 2025-12-18 15:39:16 +01:00
Jonas Bark
e760c34ede unit test fixes 2025-12-18 15:30:14 +01:00
Jonas Bark
187a15a55d improve trainer controller view 2025-12-18 14:51:49 +01:00
Jonas Bark
3e4751a6b5 refactor sensor logic 2025-12-18 12:24:52 +01:00
Jonas Bark
b05d87196a implement functionality, refactoring 2025-12-18 12:06:34 +01:00
Jonas Bark
b8297848f6 Merge branch 'copilot/add-steering-detection-algorithm' into copilot/implement-in-app-purchase 2025-12-18 11:37:39 +01:00
Jonas Bark
de0f004a48 implement functionality, refactoring 2025-12-18 11:37:21 +01:00
Jonas Bark
0bc9c1d4d2 implement functionality, refactoring 2025-12-18 11:33:14 +01:00
Jonas Bark
3fccb59544 Merge branch 'copilot/implement-in-app-purchase' into copilot/add-steering-detection-algorithm 2025-12-18 09:46:45 +01:00
Jonas Bark
ea76aabf91 update changelog 2025-12-18 09:46:32 +01:00
Jonas Bark
dc1c900bd2 bugfix and animation 2025-12-18 09:26:25 +01:00
Jonas Bark
b1e59d8f2a auto-open key editor on key press 2025-12-18 08:46:31 +01:00
Jonas Bark
006148dbd0 move button simulator page button 2025-12-18 08:33:04 +01:00
Jonas Bark
974ba258f5 teaser new connection methods 2025-12-18 08:11:06 +01:00
copilot-swe-agent[bot]
29d833e9d1 Update README with gyroscope steering device information
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-18 06:55:33 +00:00
copilot-swe-agent[bot]
eea72405bb Fix code review issues in gyroscope steering implementation
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-18 06:54:42 +00:00
copilot-swe-agent[bot]
e500f1ed0b Add unit tests for gyroscope steering algorithm
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-18 06:52:39 +00:00
copilot-swe-agent[bot]
6c3bd2e6a1 Add gyroscope/accelerometer steering support with sensor fusion
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-18 06:51:43 +00:00
copilot-swe-agent[bot]
e54d8968e8 Initial plan 2025-12-18 06:44:46 +00:00
Jonas Bark
9dca2e989a check sandbox on iOS / macOS 2025-12-17 15:57:44 +01:00
Jonas Bark
610c5d6ef5 check sandbox on iOS / macOS 2025-12-17 15:48:30 +01:00
Jonas Bark
7797b34852 improve keymap UI 2025-12-17 14:34:08 +01:00
Jonas Bark
99e9f326f7 fix build 2025-12-17 13:05:05 +01:00
Jonas Bark
0f2d73239b fix build 2025-12-17 12:57:32 +01:00
Jonas Bark
497b489ea9 remove Podfile.loc 2025-12-17 12:40:29 +01:00
Jonas Bark
51581f106a cleanup README.md 2025-12-17 12:17:00 +01:00
Jonas Bark
43e9aa02e0 cleanup README.md 2025-12-17 12:13:23 +01:00
Jonas Bark
089a41cc2b translations and ux changes 2025-12-17 11:39:39 +01:00
Jonas Bark
279ab101cc macOS fix 2025-12-17 11:13:42 +01:00
Jonas Bark
c0f278652e show connection update notifications 2025-12-17 10:54:16 +01:00
Jonas Bark
ac02cc78bc show connection update notifications 2025-12-17 10:34:40 +01:00
Jonas Bark
d42ac3af6b notifications on iOS 2025-12-17 10:20:36 +01:00
Jonas Bark
20cfe76091 limit to 80 on Android during trial period, only count sent out commands 2025-12-17 10:02:32 +01:00
Jonas Bark
b68170b489 fix purchause logic 2025-12-17 09:08:28 +01:00
Jonas Bark
21273fa9ca Merge branch 'main' into copilot/implement-in-app-purchase
# Conflicts:
#	CHANGELOG.md
#	lib/bluetooth/devices/base_device.dart
#	pubspec.yaml
2025-12-17 08:41:47 +01:00
jonasbark
700afb1050 Document local connection method for Rouvy
Added instructions for the local connection method in Rouvy.
2025-12-16 19:56:56 +01:00
Jonas Bark
d943544e56 Merge branch 'main' of github.com:jonasbark/swiftcontrol 2025-12-16 19:53:42 +01:00
Jonas Bark
e994eb01dd less confusing messages 2025-12-16 19:53:25 +01:00
jonasbark
59d953bbc4 Update Windows Store version to 4.1.0 2025-12-16 14:36:30 +01:00
Jonas Bark
12ecbf80e1 version++ 2025-12-16 12:19:03 +01:00
Jonas Bark
a5b76b43bf build fix 2025-12-16 11:25:25 +01:00
Jonas Bark
383055bfe2 flutter version 2025-12-16 10:57:28 +01:00
Jonas Bark
24212e8e4c update changelog 2025-12-16 10:50:36 +01:00
Jonas Bark
1513a53dd4 update MyWhoosh keymap to use A and D keyboard keys for steering 2025-12-16 10:41:10 +01:00
Jonas Bark
fe9dd29964 cleanup, translations 2025-12-16 10:14:48 +01:00
Jonas Bark
eece2bcc0f Merge branch 'main' into copilot/implement-in-app-purchase
# Conflicts:
#	lib/bluetooth/devices/openbikecontrol/obc_ble_emulator.dart
2025-12-16 09:19:50 +01:00
Jonas Bark
3ca63c0523 permission order 2025-12-16 09:19:06 +01:00
Jonas Bark
b46982918d resolve #224 2025-12-15 20:16:30 +01:00
Jonas Bark
13b075a1f3 only show supported actions 2025-12-15 13:48:18 +01:00
Jonas Bark
f71a417ac5 only show supported actions 2025-12-15 13:47:43 +01:00
Jonas Bark
27065f2906 prefill obp keymap actions 2025-12-15 13:42:54 +01:00
Jonas Bark
b5d938fd47 error reporting when starting connection method 2025-12-15 13:13:57 +01:00
Jonas Bark
46300fc0d4 hide other connection methods in an accordion 2025-12-15 13:03:37 +01:00
Jonas Bark
93882b8b36 prioritize OBP connection methods when available 2025-12-15 12:48:19 +01:00
jonas.bark@gmx.de
f19c6b8dd0 fix windows implementation 2025-12-15 11:12:06 +01:00
Jonas Bark
968e2c5928 fix button mapping for OpenBikeControl, button simulator changes 2025-12-15 09:49:07 +01:00
Jonas Bark
44599b2d33 fix button mapping for OpenBikeControl, button simulator changes 2025-12-15 09:48:36 +01:00
Jonas Bark
613f75fd25 Merge branch 'main' into copilot/implement-in-app-purchase 2025-12-15 09:22:18 +01:00
Jonas Bark
c09ab5482e fix button mapping for OpenBikeControl 2025-12-15 09:13:44 +01:00
Jonas Bark
6f68e6cb62 iap adjustment 2025-12-15 08:37:56 +01:00
Jonas Bark
43ac412efd iap adjustment 2025-12-14 21:35:06 +01:00
Jonas Bark
7149c98564 windows #2 2025-12-14 20:15:33 +01:00
Jonas Bark
0f4e46a758 windows #1 2025-12-14 19:54:41 +01:00
Jonas Bark
23fb927cd6 in app purchase implementation on macOS / iOS 2025-12-14 19:32:23 +01:00
Jonas Bark
d055a260ab fix shadcn design usage 2025-12-14 16:48:04 +01:00
Jonas Bark
d55fa5f7c0 Merge branch 'main' into copilot/implement-in-app-purchase
# Conflicts:
#	lib/bluetooth/devices/base_device.dart
#	lib/pages/configuration.dart
#	lib/utils/settings/settings.dart
2025-12-14 16:42:50 +01:00
Jonas Bark
5cc49bd246 no device information service on Windows 2025-12-14 16:31:14 +01:00
Jonas Bark
c3c49decd1 remove remains of swift_control 2025-12-14 16:22:07 +01:00
Jonas Bark
127c997ea1 less warnings for Click V2 users 2025-12-13 15:17:28 +01:00
Jonas Bark
724d52ba10 add keyboard input to supported devices 2025-12-13 10:22:55 +01:00
Jonas Bark
5cee0fbf55 use latest flutter 2025-12-13 10:11:28 +01:00
Jonas Bark
e44760d0e3 Revert "patch Android only"
This reverts commit 0eba068910.
2025-12-12 10:48:24 +01:00
Jonas Bark
29be3c4411 Merge remote-tracking branch 'origin/main' 2025-12-12 09:08:17 +01:00
Jonas Bark
0eba068910 patch Android only 2025-12-12 09:08:07 +01:00
Jonas Bark
04dee3f14c fix wrong permission for BLE advertising on Android 2025-12-12 09:06:33 +01:00
copilot-swe-agent[bot]
f4fd658c36 Refactor to reduce code duplication and use constants for magic numbers
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-12 07:47:41 +00:00
copilot-swe-agent[bot]
0e80d5612c Fix code review issues: remove unused import and fix negative counter display
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-12 07:45:29 +00:00
copilot-swe-agent[bot]
9302ebc667 Add restore purchases functionality to IAP widget
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-12 07:43:00 +00:00
copilot-swe-agent[bot]
2265866f58 Clarify existing user detection logic with comments
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-12 07:41:11 +00:00
copilot-swe-agent[bot]
8ec6ee5ef0 Improve IAP error handling and add documentation
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-12 07:39:13 +00:00
copilot-swe-agent[bot]
a03d250bdb Add IAP service implementation with trial and command limiting
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-12 07:37:15 +00:00
copilot-swe-agent[bot]
a0ebac41ea Initial plan 2025-12-12 07:29:07 +00:00
jonasbark
b4b3f5db67 Improve Click V2 connection instructions
Updated troubleshooting steps for Click V2 connection reliability.
2025-12-11 23:47:15 +01:00
Jonas Bark
b291f59e10 change icons 2025-12-11 22:55:54 +01:00
Jonas Bark
02de453952 Windows: fix version check URL 2025-12-11 22:53:16 +01:00
Jonas Bark
4c53f6e408 adjust windows logo 2025-12-11 22:27:29 +01:00
Jonas Bark
4f4d67cccc Merge remote-tracking branch 'origin/main' 2025-12-11 20:44:51 +01:00
Jonas Bark
ef056f0503 web log debugging 2025-12-11 20:44:41 +01:00
jonasbark
a6f5755b42 Update MyWhoosh Link instructions for clarity
Emphasized the importance of closing MyWhoosh Link and added clarification about app connectivity issues.
2025-12-11 19:38:02 +01:00
jonasbark
5ce6e37973 Add troubleshooting section for MyWhoosh clicks
Added troubleshooting tip for unrecognized clicks in MyWhoosh.
2025-12-11 18:27:40 +01:00
Jonas Bark
ebebd7ad8b version++ 2025-12-11 10:22:26 +01:00
Jonas Bark
f6c47e3dab fix markdown theme colors 2025-12-11 10:21:28 +01:00
jonasbark
de711e12dc Merge pull request #221 from jonasbark/copilot/configure-hotkeys-for-buttons
Add keyboard hotkey configuration for button simulator
2025-12-11 08:26:35 +00:00
Jonas Bark
b94fed2f21 add wahoo kickr support to readme 2025-12-11 09:26:08 +01:00
Jonas Bark
9316881048 button simulator adjustments 2025-12-11 09:20:02 +01:00
copilot-swe-agent[bot]
c60a990938 Add mounted check in delayed callback and length validation for keys
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-11 07:24:50 +00:00
copilot-swe-agent[bot]
e9aaa96185 Fix remaining code review issues: remove redundant check and await settings save
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-11 07:23:15 +00:00
copilot-swe-agent[bot]
cb497daee4 Address code review feedback: extract constants and fix async handling
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-11 07:21:57 +00:00
copilot-swe-agent[bot]
4881fe4778 Add test for button simulator hotkeys and fix trailing comma
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-11 07:19:28 +00:00
copilot-swe-agent[bot]
5d5d8ffb18 Add keyboard hotkey configuration for button simulator
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-11 07:17:31 +00:00
copilot-swe-agent[bot]
b707812a7e Initial plan 2025-12-11 07:12:08 +00:00
Jonas Bark
9de50dc6fc markdown changes 2025-12-11 08:09:50 +01:00
Jonas Bark
11d308b53b markdown changes 2025-12-11 08:07:12 +01:00
Jonas Bark
0e03ec4a03 clarify mywhoosh link 2025-12-10 21:26:43 +01:00
Jonas Bark
68a04fad96 handling fix 2025-12-10 21:21:23 +01:00
Jonas Bark
ce75fd0f34 add more instructions, clarify mail support 2025-12-10 21:17:49 +01:00
Jonas Bark
d46b71b2d0 md #1 2025-12-10 20:23:41 +01:00
Jonas Bark
6492afc46f MyWhoosh: updated default keymap to use steering instead of navigating 2025-12-10 19:14:13 +01:00
Jonas Bark
c9b068e1b3 control your trainer manually without requiring a controller - just like a Companion app 2025-12-10 18:57:08 +01:00
Jonas Bark
5cdf15a419 UI adjustments 2025-12-10 17:26:00 +01:00
Jonas Bark
24db720927 don't show firmware update warning when we don't have that info, yet 2025-12-10 09:16:57 +01:00
Jonas Bark
94754d3d9b Rouvy doesn't support network controllers, yet 2025-12-10 09:14:07 +01:00
Jonas Bark
bffdae1a9b enable local connection on Windows if the app doesn't support OBP 2025-12-10 09:08:54 +01:00
Jonas Bark
a8b68c2d89 disable MyWhoosh Link connection method when running BikeControl and MyWhoosh on Windows on the same device 2025-12-10 09:03:58 +01:00
Jonas Bark
84f70f13d8 Gamepads: handle analog values correctly on Windows 2025-12-10 08:58:41 +01:00
Jonas Bark
ef1048ec08 adjust Headwind logic according to comment from https://github.com/jonasbark/swiftcontrol/issues/11#issuecomment-3634041684 2025-12-09 21:56:45 +01:00
Jonas Bark
37bc2110f5 update screenshots 2025-12-09 17:59:10 +01:00
Jonas Bark
84fd828d36 work on issue #11 2025-12-09 09:00:01 +01:00
Jonas Bark
a51b4d7958 version++ 2025-12-08 20:15:41 +01:00
Jonas Bark
117467d708 fix issue #215 2025-12-08 19:11:03 +01:00
Jonas Bark
789509f9cf fix build 2025-12-08 18:01:47 +01:00
Jonas Bark
a323dc213d fix build 2025-12-08 18:00:02 +01:00
jonasbark
0ec998a618 Merge pull request #212 from jonasbark/copilot/add-headwind-support
Add KICKR Headwind fan control support
2025-12-08 16:50:23 +00:00
copilot-swe-agent[bot]
0f5e9d59a8 Implement proper Headwind protocol with state tracking and mode switching
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-08 16:48:56 +00:00
copilot-swe-agent[bot]
2280fda916 Use firstOrNull to avoid potential race condition
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-08 16:29:55 +00:00
copilot-swe-agent[bot]
8d4db788a3 Refactor Headwind control logic and remove buttons
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-08 16:27:47 +00:00
Jonas Bark
c2bfc472fe fix patch pipeline 2025-12-08 11:20:31 +01:00
Jonas Bark
09ffd258b7 version++ 2025-12-08 11:09:43 +01:00
Jonas Bark
4ae92ca557 Merge remote-tracking branch 'origin/main' 2025-12-08 11:08:04 +01:00
Jonas Bark
e066054681 fix Di2 buttons not triggering an event 2025-12-08 11:07:55 +01:00
Jonas Bark
a0f4aadd37 fix repeated clicks on analog buttons for gamepads 2025-12-08 10:48:15 +01:00
copilot-swe-agent[bot]
3566dbc37c Address code review feedback: improve type annotations and validation
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-08 08:26:29 +00:00
copilot-swe-agent[bot]
73a23e06ba Fix syntax issues in ButtonEditPage and add missing import
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-08 08:25:09 +00:00
copilot-swe-agent[bot]
a03576d415 Add KICKR Headwind support implementation
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-08 08:23:27 +00:00
copilot-swe-agent[bot]
079db14127 Initial plan 2025-12-08 08:16:38 +00:00
jonasbark
2f4764a01f Update Windows Store version to 4.0.0 2025-12-08 08:57:21 +01:00
Jonas Bark
2671a9807b cleanup 2025-12-07 14:41:06 +01:00
Jonas Bark
da46deb495 fix build 2025-12-07 13:03:54 +01:00
Jonas Bark
0700bd331f fix build 2025-12-07 12:41:14 +01:00
Jonas Bark
14676d9277 Merge branch 'feature/openbikecontrol' 2025-12-07 12:37:05 +01:00
Jonas Bark
3f9c3611ec fix build 2025-12-07 12:36:57 +01:00
jonasbark
26263f4d6b Merge pull request #208 from jonasbark/feature/openbikecontrol
4.0.0
2025-12-07 11:13:09 +00:00
Jonas Bark
105a644599 better web compatibility 2025-12-07 12:10:53 +01:00
Jonas Bark
ba54234734 better web compatibility 2025-12-07 12:05:52 +01:00
Jonas Bark
d39af2c8ff show keys instead of toast 2025-12-07 11:30:06 +01:00
Jonas Bark
eb07b78cce show keys instead of toast 2025-12-07 11:27:14 +01:00
Jonas Bark
f9a13a90a8 fix pairing permission issues 2025-12-07 11:03:21 +01:00
Jonas Bark
6302091c54 improve handling of analog gamepad events 2025-12-07 10:41:21 +01:00
Jonas Bark
1647fe9818 improve handling of analog gamepad events 2025-12-07 10:33:54 +01:00
Jonas Bark
3ece6cb4db cleanup logs, improve handling of analog gamepad events 2025-12-07 10:28:39 +01:00
Jonas Bark
b04732cc24 adjust changelog 2025-12-06 15:43:31 +01:00
Jonas Bark
828819907b refactoring 2025-12-06 15:06:12 +01:00
Jonas Bark
c8c449d2ef screenshot work 2025-12-06 13:42:18 +01:00
Jonas Bark
6b5c202e93 resolve issue #207 2025-12-06 11:56:08 +01:00
Jonas Bark
56c67ae9a5 refactoring 2025-12-06 11:46:18 +01:00
Jonas Bark
94d9467bc3 ui adjustments, fixes 2025-12-06 10:02:56 +01:00
Jonas Bark
fb65616cee create duplicate keymap if needed 2025-12-05 21:35:40 +01:00
Jonas Bark
7e488b3cb1 fix hid device functionality when accessibility service is active 2025-12-05 20:07:48 +01:00
Jonas Bark
9c6084397e fix hid device functionality when accessibility service is active 2025-12-05 20:00:07 +01:00
Jonas Bark
73a0fe6203 fix hid device functionality when accessibility service is active 2025-12-05 19:48:34 +01:00
Jonas Bark
cac1872459 resolve issue #176 2025-12-05 18:08:54 +01:00
Jonas Bark
65f4ca6356 media key detection Windows 2025-12-05 17:57:11 +01:00
Jonas Bark
d771b3da57 cleanup, refactoring 2025-12-05 15:40:04 +01:00
Jonas Bark
d52a062e0c cleanup, refactoring 2025-12-05 13:22:52 +01:00
Jonas Bark
ef350398e1 work on mDNS 2025-12-05 11:14:16 +01:00
Jonas Bark
69fa8834ee work on mDNS 2025-12-05 10:51:40 +01:00
Jonas Bark
ac9bbd3986 work on screenshots 2025-12-04 21:51:16 +00:00
Jonas Bark
6f99f0762a keydown / key up handling for direct connections 2025-12-04 21:17:43 +00:00
Jonas Bark
999fc3faba ui, fixes 2025-12-04 20:59:07 +00:00
Jonas Bark
ebd33666fc ui, fixes 2025-12-04 20:27:53 +00:00
Jonas Bark
8537c5b8c3 ui, fixes 2025-12-04 20:00:01 +00:00
Jonas Bark
3ff59eff6e ui, fixes 2025-12-04 19:42:19 +00:00
Jonas Bark
46752de0e8 ui, fixes 2025-12-04 19:32:02 +00:00
Jonas Bark
27629db924 connection method badges 2025-12-04 14:00:39 +00:00
Jonas Bark
1f00fd9d6c add openbikecontrol as app 2025-12-04 13:27:40 +00:00
Jonas Bark
637bf87dad ui adjustments 2025-12-04 12:58:31 +00:00
Jonas Bark
41415432db ui adjustments 2025-12-01 22:58:29 +00:00
Jonas Bark
745d26dade ui adjustments 2025-12-01 22:01:41 +00:00
Jonas Bark
134de0fcd9 Merge remote-tracking branch 'origin/copilot/ensure-ble-hid-support-windows' into feature/openbikecontrol
# Conflicts:
#	.gitignore
2025-12-01 18:23:14 +00:00
Jonas Bark
ee0c4c083f screenshot adjustments 2025-12-01 18:14:16 +00:00
Jonas Bark
5873ce34e4 translations 2025-12-01 16:58:08 +00:00
Jonas Bark
9904999dd2 translations 2025-12-01 15:46:02 +00:00
Jonas Bark
f5a35ad04b Merge remote-tracking branch 'origin/copilot/extract-translations-to-arb' into feature/openbikecontrol
# Conflicts:
#	lib/pages/trainer.dart
2025-12-01 15:35:54 +00:00
Jonas Bark
7301734b82 zwift keep alive 2025-12-01 15:34:50 +00:00
copilot-swe-agent[bot]
19ada28cf3 Add i18n_extension.dart and fix import/export keys, update imports
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-01 14:48:45 +00:00
copilot-swe-agent[bot]
7655b35b77 Update remaining files to use localized strings
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-01 14:41:28 +00:00
copilot-swe-agent[bot]
0c200eae20 Update widgets and utils to use localized strings
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-01 14:35:11 +00:00
copilot-swe-agent[bot]
18d6c9ec1f Extract translations to intl_en.arb and update pages to use i18n
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-01 14:18:47 +00:00
copilot-swe-agent[bot]
cc16a2c8de Add volume up/down hotkey support for Windows media key detection
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-12-01 14:16:21 +00:00
copilot-swe-agent[bot]
91a6502310 Initial plan 2025-12-01 14:04:35 +00:00
Jonas Bark
bb8720247e add intl 2025-12-01 13:52:20 +00:00
Jonas Bark
b01470339b add intl 2025-12-01 13:50:15 +00:00
Jonas Bark
855fe00346 wording 2025-12-01 13:40:48 +00:00
Jonas Bark
f957258a2c wording 2025-12-01 13:40:00 +00:00
Jonas Bark
945a247274 toast changes 2025-12-01 12:02:41 +00:00
Jonas Bark
59ecfe5186 UI changes 2025-12-01 11:42:54 +00:00
Jonas Bark
dc5e9939c7 UI changes, cleanup 2025-12-01 10:57:23 +00:00
Jonas Bark
79821783e2 auto start connection methods and scanning 2025-12-01 09:30:21 +00:00
jonasbark
531e53eaec Update WINDOWS_STORE_VERSION.txt 2025-11-30 21:08:53 +01:00
Jonas Bark
4f01f23458 Merge branch 'main' into feature/openbikecontrol
# Conflicts:
#	lib/utils/actions/base_actions.dart
2025-11-30 18:46:15 +00:00
Jonas Bark
3760b84fb7 only use direct connection method if they are connected 2025-11-30 18:45:20 +00:00
Jonas Bark
afdb442597 Merge branch 'main' into feature/openbikecontrol
# Conflicts:
#	lib/pages/device.dart
#	lib/widgets/logviewer.dart
2025-11-30 01:09:03 +00:00
Jonas Bark
eadcd17bbb less noise 2025-11-30 01:08:25 +00:00
Jonas Bark
67ca63b047 Merge branch 'feature/kickrbikepro' into feature/openbikecontrol 2025-11-30 01:07:51 +00:00
Jonas Bark
17d3450bd2 fix 2025-11-30 01:07:42 +00:00
Jonas Bark
d7c700a4e5 heureka 2025-11-30 00:44:45 +00:00
Jonas Bark
fd659e40fe heureka 2025-11-29 23:55:43 +00:00
Jonas Bark
bdd7c75ebd attempt to support Wahoo Kickr Bike Pro #195 2025-11-29 21:54:24 +00:00
Jonas Bark
ca5648fec4 attempt to support Wahoo Kickr Bike Pro #195 2025-11-29 19:40:32 +00:00
Jonas Bark
978325ceff attempt to support Wahoo Kickr Bike Pro #195 2025-11-29 19:36:35 +00:00
Jonas Bark
87ad9c630d try kickr 2025-11-29 19:05:38 +00:00
Jonas Bark
6b0ca1b6dd fix 2025-11-29 19:05:22 +00:00
Jonas Bark
3c9a505f4f Merge branch 'main' of github.com:jonasbark/swiftcontrol 2025-11-29 18:42:37 +00:00
Jonas Bark
7bb4ace875 openbikeprotocol Bluetooth emulator 2025-11-29 17:46:12 +00:00
Jonas Bark
499cd86955 openbikeprotocol Bluetooth emulator 2025-11-29 17:10:23 +00:00
Jonas Bark
79bad50ce3 openbikeprotocol emulator 2025-11-29 15:35:09 +00:00
Jonas Bark
2dff9c92fd ftms emulator 2025-11-29 14:45:44 +00:00
Jonas Bark
d05557819e ui adjustments, fixes 2025-11-29 14:37:43 +00:00
Jonas Bark
22a39406ff fix wrong check 2025-11-29 13:51:36 +00:00
Jonas Bark
91d0fd656e consolidate messages 2025-11-29 13:51:05 +00:00
Jonas Bark
4440a04ab8 consolidate messages 2025-11-29 13:46:57 +00:00
Jonas Bark
5bf617d1db move service running message 2025-11-29 13:35:57 +00:00
Jonas Bark
3cf209edd9 less god objects 2025-11-29 13:12:09 +00:00
Jonas Bark
ad95ce23ec add implementation for open bike protocol devices 2025-11-29 12:53:04 +00:00
Jonas Bark
9e29d5dd04 ui adjustments 2025-11-29 10:57:14 +00:00
Jonas Bark
4678ac0255 ui adjustments 2025-11-29 10:54:04 +00:00
Jonas Bark
8660f979b9 ignore device for session fix, logs page 2025-11-29 09:35:38 +00:00
Jonas Bark
c20265ddf8 new ui, BLE fixes 2025-11-28 22:31:18 +00:00
Jonas Bark
2b90606d9c inline permission requests, make them optional unless required 2025-11-28 22:00:48 +00:00
Jonas Bark
c75fd8ab80 Merge remote-tracking branch 'origin/main' into feature/openbikecontrol
# Conflicts:
#	lib/widgets/menu.dart
2025-11-28 20:21:32 +00:00
Jonas Bark
e4ea924b1a fix Windows app icon 2025-11-28 17:49:49 +00:00
Jonas Bark
f9b5dda123 new UI 2025-11-28 08:31:34 +00:00
Jonas Bark
4cd38d4502 new UI 2025-11-28 00:26:21 +00:00
Jonas Bark
70c9a5b6a3 new UI 2025-11-27 23:38:00 +00:00
Jonas Bark
4fb46de074 new UI 2025-11-27 23:31:29 +00:00
Jonas Bark
b0487f534c new UI 2025-11-27 22:36:19 +00:00
Jonas Bark
719eb9b50f new UI 2025-11-27 19:59:49 +00:00
Jonas Bark
f3148405d7 Merge branch 'main' into feature/openbikecontrol 2025-11-27 18:10:26 +00:00
Jonas Bark
6da13f18af UI fix 2025-11-27 17:03:14 +00:00
Jonas Bark
b3b6f510d8 work on new ui 2025-11-27 13:22:14 +00:00
Jonas Bark
01400ab955 work on new ui 2025-11-27 12:49:21 +00:00
Jonas Bark
8348848ef8 work on new ui 2025-11-27 09:44:26 +00:00
copilot-swe-agent[bot]
7ecce43a3d Add documentation for Windows global media key detection
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-11-10 07:53:16 +00:00
copilot-swe-agent[bot]
82cb41c207 Remove CodeQL artifact from repository
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-11-10 07:52:26 +00:00
copilot-swe-agent[bot]
c356242a8f Improve hotkey registration error handling
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-11-10 07:52:01 +00:00
copilot-swe-agent[bot]
61ad7c2eef Implement global media key detection for Windows using RegisterHotKey API
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-11-10 07:49:27 +00:00
copilot-swe-agent[bot]
311104ddf0 Initial plan 2025-11-10 07:44:08 +00:00
307 changed files with 21884 additions and 9344 deletions

View File

@@ -28,15 +28,10 @@ on:
required: false
default: true
type: boolean
build_web:
description: 'Build for Web'
required: false
default: false
type: boolean
env:
SHOREBIRD_TOKEN: ${{ secrets.SHOREBIRD_TOKEN }}
FLUTTER_VERSION: 3.35.5
FLUTTER_VERSION: 3.41.0
jobs:
build:
@@ -52,6 +47,17 @@ jobs:
#1 Checkout Repository
- name: Checkout Repository
uses: actions/checkout@v3
with:
submodules: recursive
token: ${{ secrets.PAT_TOKEN }}
- name: rename pubspec_overrides_ci.yaml to pubspec_overrides.yaml
run: |
if [ -f pubspec_overrides_ci.yaml ]; then
mv pubspec_overrides_ci.yaml pubspec_overrides.yaml
else
echo "No pubspec_overrides_ci.yaml found, skipping rename."
fi
- name: Install certificates
if: inputs.build_mac || inputs.build_ios
@@ -97,17 +103,35 @@ jobs:
cp $PP_PATH_MACOS ~/Library/MobileDevice/Provisioning\ Profiles
- name: 🐦 Setup Shorebird
if: inputs.build_mac || inputs.build_android || inputs.build_ios || inputs.build_web
#if: inputs.build_mac || inputs.build_android || inputs.build_ios
if: inputs.build_android || inputs.build_ios
uses: shorebirdtech/setup-shorebird@v1
with:
cache: true
- name: Set Up Flutter maCOS
uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: ${{ env.FLUTTER_VERSION }}
- name: Generate translation files
run: |
flutter pub global activate intl_utils;
flutter pub global run intl_utils:generate;
- name: 🚀 Shorebird Release macOS
if: inputs.build_mac
if: inputs.build_mac && false
uses: shorebirdtech/shorebird-release@v1
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
platform: macos
args: "-- --obfuscate --split-debug-info=symbols --dart-define=VERIFYING_SHARED_SECRET=${{ secrets.VERIFYING_SHARED_SECRET }} --dart-define=REVENUECAT_API_KEY_IOS=${{ secrets.REVENUECAT_API_KEY_IOS }}"
- name: Flutter Release macOS
if: inputs.build_mac
run:
flutter build macos --release --obfuscate --split-debug-info=symbols --dart-define=VERIFYING_SHARED_SECRET=${{ secrets.VERIFYING_SHARED_SECRET }} --dart-define=REVENUECAT_API_KEY_IOS=${{ secrets.REVENUECAT_API_KEY_IOS }}
- name: Decode Keystore
if: inputs.build_android
@@ -121,29 +145,7 @@ jobs:
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
platform: android
args: "--artifact=apk"
- name: Set Up Flutter
if: inputs.build_web
uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: ${{ env.FLUTTER_VERSION }}
- name: Build Web
if: inputs.build_web
run: flutter build web --release --base-href "/swiftcontrol/"
- name: Upload static files as artifact
if: inputs.build_web
id: deployment
uses: actions/upload-pages-artifact@v3
with:
path: build/web
- name: Web Deploy
if: inputs.build_web
uses: actions/deploy-pages@v4
args: "-- --obfuscate --split-debug-info=symbols --dart-define=REVENUECAT_API_KEY_ANDROID=${{ secrets.REVENUECAT_API_KEY_ANDROID }}"
- name: Extract latest changelog
id: changelog
@@ -158,27 +160,13 @@ jobs:
chmod +x scripts/generate_release_body.sh
./scripts/generate_release_body.sh > /tmp/release_body.md
- name: Set Up Flutter for Screenshots
if: inputs.build_github
uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: ${{ env.FLUTTER_VERSION }}
- name: Generate screenshots for App Stores
if: inputs.build_github
run: |
flutter test test/screenshot_test.dart
zip -r BikeControl.storeassets.zip screenshots
echo "Screenshots generated successfully"
- name: 🚀 Shorebird Release iOS
if: inputs.build_ios
uses: shorebirdtech/shorebird-release@v1
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
platform: ios
args: "--export-options-plist ios/ExportOptions.plist"
args: "--export-options-plist ios/ExportOptions.plist -- --dart-define=VERIFYING_SHARED_SECRET=${{ secrets.VERIFYING_SHARED_SECRET }} --dart-define=REVENUECAT_API_KEY_IOS=${{ secrets.REVENUECAT_API_KEY_IOS }}"
- name: Prepare App Store authentication key
if: inputs.build_ios || inputs.build_mac
@@ -196,7 +184,7 @@ jobs:
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
packageName: de.jonasbark.swiftcontrol
releaseFiles: build/app/outputs/bundle/release/app-release.aab
track: production
track: ${{ github.ref == 'refs/heads/main' && 'production' || 'alpha' }}
whatsNewDirectory: whatsnew
- name: Upload to macOS App Store
@@ -216,51 +204,6 @@ jobs:
run: |
xcrun altool --upload-app -f build/ios/ipa/swift_play.ipa -t ios --apiKey "$APPSTORE_API_KEY" --apiIssuer "$APPSTORE_API_ISSUER_ID";
- name: Handle Android archives
if: inputs.build_android && inputs.build_github
run: |
cp build/app/outputs/flutter-apk/app-release.apk build/app/outputs/flutter-apk/BikeControl.android.apk
- name: Code Signing of macOS app
if: inputs.build_mac && inputs.build_github
run: /usr/bin/codesign --deep --force -s "$DEVELOPER_ID_APPLICATION_SIGNING_IDENTITY" --entitlements ../../../../../macos/Runner/Release.entitlements --options runtime BikeControl.app -v
working-directory: build/macos/Build/Products/Release
env:
DEVELOPER_ID_APPLICATION_SIGNING_IDENTITY: ${{ secrets.DEVELOPER_ID_APPLICATION_SIGNING_IDENTITY }}
- name: Handle macOS archives
if: inputs.build_mac && inputs.build_github
run: |
cd build/macos/Build/Products/Release/
zip -r BikeControl.macos.zip BikeControl.app/
- name: Upload Android Artifacts
if: inputs.build_android && inputs.build_github
uses: actions/upload-artifact@v4
with:
overwrite: true
name: Releases
path: |
build/app/outputs/flutter-apk/BikeControl.android.apk
- name: Upload macOS Artifacts
if: inputs.build_mac && inputs.build_github
uses: actions/upload-artifact@v4
with:
overwrite: true
name: Releases
path: |
build/macos/Build/Products/Release/BikeControl.macos.zip
- name: Upload Screenshots Artifacts
if: inputs.build_github
uses: actions/upload-artifact@v4
with:
overwrite: true
name: Releases
path: |
screenshots/device-GitHub-600x900.png
build/BikeControl.screenshots.zip
#10 Extract Version
- name: Extract version from pubspec.yaml
@@ -270,12 +213,19 @@ jobs:
version=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2 | tr -d '\r')
echo "VERSION=$version" >> $GITHUB_ENV
- name: Upload Symbols
uses: actions/upload-artifact@v4
with:
overwrite: true
name: Symbols
path: symbols/
#13 Create Release
- name: Create Release
if: inputs.build_github
uses: ncipollo/release-action@v1
with:
artifacts: "build/app/outputs/flutter-apk/BikeControl.android.apk,build/macos/Build/Products/Release/BikeControl.macos.zip,build/BikeControl.screenshots.zip,screenshots/device-GitHub-600x900.png"
artifacts: "build/app/outputs/flutter-apk/BikeControl.android.apk,build/macos/Build/Products/Release/BikeControl.macos.zip"
allowUpdates: true
prerelease: true
bodyFile: /tmp/release_body.md
@@ -291,7 +241,18 @@ jobs:
#1 Checkout Repository
- name: Checkout Repository
uses: actions/checkout@v3
with:
submodules: recursive
token: ${{ secrets.PAT_TOKEN }}
- name: rename pubspec_overrides_ci.yaml to pubspec_overrides.yaml
shell: pwsh
run: |
if (Test-Path pubspec_overrides_ci.yaml) {
Rename-Item -Path pubspec_overrides_ci.yaml -NewName pubspec_overrides.yaml
} else {
Write-Output "No pubspec_overrides_ci.yaml found, skipping rename."
}
- name: Extract version from pubspec.yaml (Windows)
shell: pwsh
@@ -306,11 +267,23 @@ jobs:
with:
cache: true
- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: ${{ env.FLUTTER_VERSION }}
- name: Generate translation files
run: |
flutter pub global activate intl_utils;
flutter pub global run intl_utils:generate;
- name: 🚀 Shorebird Release Windows
uses: shorebirdtech/shorebird-release@v1
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
platform: windows
args: "-- --obfuscate --split-debug-info=symbols-win"
- name: Zip directory (Windows)
shell: pwsh
@@ -334,7 +307,7 @@ jobs:
Write-Warning "$dll not found in $source"
}
}
Compress-Archive -Path "build/windows/x64/runner/Release/*" -DestinationPath "build/windows/x64/runner/Release/BikeControl.windows.zip"
Compress-Archive -Path "build/windows/x64/runner/Release/*" -DestinationPath "build/windows/x64/runner/Release/bike_control.windows.zip"
- uses: microsoft/setup-msstore-cli@v1
if: false
@@ -343,12 +316,6 @@ jobs:
if: false
run: msstore reconfigure --tenantId $ --clientId $ --clientSecret $ --sellerId $
- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: ${{ env.FLUTTER_VERSION }}
- name: Create MSIX package
run: dart run msix:create
@@ -356,25 +323,11 @@ jobs:
if: false
run: msstore publish -v "build/windows/x64/runner/Release/"
- name: Rename swift_control.msix to BikeControl.windows.msix
shell: pwsh
run: |
Rename-Item -Path "build/windows/x64/runner/Release/swift_control.msix" -NewName "BikeControl.windows.msix"
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
overwrite: true
name: Releases
path: |
build/windows/x64/runner/Release/BikeControl.windows.zip
build/windows/x64/runner/Release/BikeControl.windows.msix
- name: Update Release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: "build/windows/x64/runner/Release/BikeControl.windows.zip,build/windows/x64/runner/Release/BikeControl.windows.msix"
prerelease: true
tag: v${{ env.VERSION }}
token: ${{ secrets.TOKEN }}
build/windows/x64/runner/Release/bike_control.msix
symbols-win/

View File

@@ -5,7 +5,7 @@ on:
env:
SHOREBIRD_TOKEN: ${{ secrets.SHOREBIRD_TOKEN }}
FLUTTER_VERSION: 3.35.5
FLUTTER_VERSION: 3.38.5
jobs:
build:
@@ -21,12 +21,34 @@ jobs:
#1 Checkout Repository
- name: Checkout Repository
uses: actions/checkout@v3
with:
submodules: recursive
token: ${{ secrets.PAT_TOKEN }}
- name: rename pubspec_overrides_ci.yaml to pubspec_overrides.yaml
run: |
if [ -f pubspec_overrides_ci.yaml ]; then
mv pubspec_overrides_ci.yaml pubspec_overrides.yaml
else
echo "No pubspec_overrides_ci.yaml found, skipping rename."
fi
- name: 🐦 Setup Shorebird
uses: shorebirdtech/setup-shorebird@v1
with:
cache: true
- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: ${{ env.FLUTTER_VERSION }}
- name: Generate translation files
run: |
flutter pub global activate intl_utils;
flutter pub global run intl_utils:generate;
- name: Install certificates
env:
DEVELOPER_ID_APPLICATION_P12_BASE64_MAC: ${{ secrets.DEVELOPER_ID_APPLICATION_P12_BASE64_MAC }}
@@ -75,76 +97,26 @@ jobs:
echo "${{ secrets.KEYSTORE_PROPERTIES }}" > android/keystore.properties;
- name: 🚀 Shorebird Patch macOS
if: false # patch doesn't work: https://github.com/jonasbark/swiftcontrol/issues/143
if: false # patch doesn't work: https://github.com/OpenBikeControl/bikecontrol/issues/143
uses: shorebirdtech/shorebird-patch@v1
with:
platform: macos
release-version: latest
args: '--allow-asset-diffs --allow-native-diffs'
args: '--allow-asset-diffs --allow-native-diffs -- --dart-define=VERIFYING_SHARED_SECRET=${{ secrets.VERIFYING_SHARED_SECRET }} --dart-define=REVENUECAT_API_KEY_IOS=${{ secrets.REVENUECAT_API_KEY_IOS }}'
- name: 🚀 Shorebird Patch Android
uses: shorebirdtech/shorebird-patch@v1
with:
platform: android
release-version: latest
args: '--allow-asset-diffs --allow-native-diffs'
args: '--allow-asset-diffs --allow-native-diffs -- --obfuscate --split-debug-info=symbols --dart-define=REVENUECAT_API_KEY_ANDROID=${{ secrets.REVENUECAT_API_KEY_ANDROID }}'
- name: 🚀 Shorebird Patch iOS
uses: shorebirdtech/shorebird-patch@v1
with:
platform: ios
release-version: latest
args: '--allow-asset-diffs --allow-native-diffs'
- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: ${{ env.FLUTTER_VERSION }}
# shorebird struggles with the app from GitHub
- name: Build macOS
if: false
run: flutter build macos --release;
- name: Sign macOS build
if: false
env:
DEVELOPER_ID_APPLICATION_SIGNING_IDENTITY: ${{ secrets.DEVELOPER_ID_APPLICATION_SIGNING_IDENTITY }}
run: |
version=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2 | tr -d '\r');
echo "VERSION=$version" >> $GITHUB_ENV;
cd build/macos/Build/Products/Release/;
/usr/bin/codesign --deep --force -s "$DEVELOPER_ID_APPLICATION_SIGNING_IDENTITY" --entitlements ../../../../../macos/Runner/Release.entitlements --options runtime BikeControl.app -v;
zip -r BikeControl.macos.zip BikeControl.app/;
#9 Upload Artifacts
- name: Upload Artifacts
if: false
uses: actions/upload-artifact@v4
with:
overwrite: true
name: Releases
path: |
build/macos/Build/Products/Release/BikeControl.macos.zip
- name: Generate release body
if: false
run: |
chmod +x scripts/generate_release_body.sh
./scripts/generate_release_body.sh > /tmp/release_body.md
# add artifact to release
- name: Create Release
if: false
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: "build/macos/Build/Products/Release/BikeControl.macos.zip"
bodyFile: /tmp/release_body.md
prerelease: true
tag: v${{ env.VERSION }}
token: ${{ secrets.TOKEN }}
args: '--allow-asset-diffs --allow-native-diffs -- --dart-define=VERIFYING_SHARED_SECRET=${{ secrets.VERIFYING_SHARED_SECRET }} --dart-define=REVENUECAT_API_KEY_IOS=${{ secrets.REVENUECAT_API_KEY_IOS }}'
windows:
name: Patch Windows
@@ -154,15 +126,38 @@ jobs:
#1 Checkout Repository
- name: Checkout Repository
uses: actions/checkout@v3
with:
submodules: recursive
token: ${{ secrets.PAT_TOKEN }}
- name: rename pubspec_overrides_ci.yaml to pubspec_overrides.yaml
shell: pwsh
run: |
if (Test-Path pubspec_overrides_ci.yaml) {
Rename-Item -Path pubspec_overrides_ci.yaml -NewName pubspec_overrides.yaml
} else {
Write-Output "No pubspec_overrides_ci.yaml found, skipping rename."
}
- name: 🐦 Setup Shorebird
uses: shorebirdtech/setup-shorebird@v1
with:
cache: true
- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: ${{ env.FLUTTER_VERSION }}
- name: Generate translation files
run: |
flutter pub global activate intl_utils;
flutter pub global run intl_utils:generate;
- name: 🚀 Shorebird Patch Windows
uses: shorebirdtech/shorebird-patch@v1
with:
platform: windows
release-version: latest
args: '--allow-asset-diffs --allow-native-diffs'
args: '--allow-asset-diffs --allow-native-diffs -- --obfuscate --split-debug-info=symbols'

View File

@@ -4,7 +4,6 @@ on:
push:
branches:
- web
- wahoo_kickr_bike_shift
- main
paths:
- '.github/workflows/web.yml'
@@ -34,12 +33,18 @@ jobs:
with:
channel: 'stable'
- name: Generate translation files
run: |
flutter pub global activate intl_utils;
flutter pub global run intl_utils:generate;
#4 Install Dependencies
- name: Install Dependencies
run: flutter pub get
- name: Build Web
run: flutter build web --release --base-href "/swiftcontrol/"
run: flutter build web --release --base-href "/bikecontrol/"
- name: Upload static files as artifact
id: deployment

6
.gitignore vendored
View File

@@ -41,12 +41,16 @@ app.*.symbols
# Obfuscation related
app.*.map.json
localazy.json
# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
lib/gen/
service-account.json
.env
/screenshots/
lib/generated
pubspec_overrides.yaml

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "prop"]
path = prop
url = git@github.com:OpenBikeControl/prop.git

3
.vscode/launch.json vendored
View File

@@ -5,7 +5,8 @@
{
"name": "swiftcontrol",
"request": "launch",
"type": "dart"
"type": "dart",
"program": "lib/main.dart"
},
{
"name": "swiftcontrol (profile mode)",

View File

@@ -1,3 +1,97 @@
### 4.8.0 (15-02-2026)
**Features**:
- Bluetooth media buttons are now supported on iOS
- Shimano Di2: long press and double clicks are now supported:
- perform steering using long presses
- gear changes are now reflected properly without losing any button presses
### 4.7.0 (04-02-2026)
**Features**:
- new connection method: act as Bluetooth Keyboard:
Your device can now act as Bluetooth keyboard, allowing you to send keyboard shortcuts (e.g. for virtual shifting) directly to your connected device. Especially useful for tablets / iPads.
- added new keyboard shortcuts for Rouvy (Kudos, Pause workout)
**Fixes**:
- you can now finally buy the full version on Android :)
- save "Enable Media Key detection" setting across app restarts
- UI adjustments and fixes in the controller configuration screen
- iOS: Remote pairing now works again
### 4.6.0 (28-01-2026)
**Features**:
- Improve Zwift Click V2 connection and handling
- Buttons in Configuration are now grouped by device
### 4.5.0 (22-01-2026)
**Features**:
- Android: simulate additional actions for local connection method (Left, Down, Right, Up, Select, Back, Home, Recent Apps)
- control your phone with your controller
- control UI within the trainer app (if supported)
- BikeControl now supports individual mapping when you use more than one Cycplus BC2 and ThinkRider VS200 controller
- Windows & macOS: allow configuration of volume keys on Bluetooth HID devices
### 4.4.0 (16-01-2026)
**Features**:
- Support for Thinkrider VS200
**Fixes**:
- Android: Local connection method allows passing keyboard events to the trainer app
- macOS: Compatibility with macOS Tahoe
- Windows: send keyboard events to the correct window when using multiple monitors or when another app is focused
- Windows: fix media key detection
### 4.3.0 (07-01-2026)
**Features**:
- Onboarding for new users
- support controlling music & volume for Windows, macOS and Android
- App is now available in Italian (thanks to Connect_Thanks2613)
**Fixes**:
- Vibration setting now available for Zwift Ride devices
### 4.2.0 (20-12-2025)
BikeControl now offers a free trial period of 5 days for all features, so you can test everything before deciding to purchase a license. Please contact the support if you experience any issues!
**Features**:
- support for SRAM AXS/eTap
- only single or double click is supported (no individual button mapping possible, yet)
- use your phone/tablet for steering by attaching your device on your handlebar!
- App is now available in Polish (thanks to Wandrocek)
**Fixes**:
- You will now be notified when a connection to your controller is lost
- improved UI of the Keymap customization screen
### 4.1.0 (16-12-2025)
**Features**:
- control your trainer manually without requiring a controller - just like a Companion app
- support for Wahoo KICKR HEADWIND: control the fan via your controller
**Fixes**:
- Gamepads: handle analog values correctly on Windows
- MyWhoosh: updated default keymap to use the new A+D keys for steering
### 4.0.0 (07-12-2025)
- 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
- MyWhoosh can now also be controlled with BikeControl running on the same iPad / iPhone
- Translations available in German and French
- 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
### 3.6.0 (23-11-2025)
SwiftControl is now called BikeControl!

View File

@@ -1 +0,0 @@
Instructions will be added soon

View File

@@ -1,12 +1 @@
**Instructions for using the MyWhoosh Direct Connect method**
1) launch MyWhoosh on the device of your choice
2) launch MyWhoosh Link, check if the "Link" connection works
3) close MyWhoosh Link
4) open BikeControl, follow on screen instructions
Once you've confirmed the connection in BikeControl you won't have to repeat step 2 and 3 again in the future. This is just to make sure the connection works in general.
And here's a video with a few explanations:
[![BikeControl Instruction for iOS](https://img.youtube.com/vi/p8sgQhuufeI/0.jpg)](https://www.youtube.com/watch?v=p8sgQhuufeI)
[https://www.youtube.com/watch?v=p8sgQhuufeI](https://www.youtube.com/watch?v=p8sgQhuufeI)
Moved to [INSTRUCTIONS_MYWHOOSH_LINK.md](INSTRUCTIONS_MYWHOOSH_LINK.md)

17
INSTRUCTIONS_LOCAL.md Normal file
View File

@@ -0,0 +1,17 @@
## What is the Local connection method?
*
The Local connection method works by directly controlling the target trainer app on the same device by simulating user input (taps, keyboard inputs). This method does not require any network connection or additional hardware, making it the simplest and most straightforward way to connect to the trainer app.
There are predefined keymaps (touch positions or keyboard shortcuts) for popular trainer apps, allowing users to easily set up and start using the Local connection method without needing to configure anything manually. You can configure these keymaps in the Configuration tab. Note though that supported keyboard keys depend on the trainer app.
## When to use the Local connection method?
*
The Local connection method is ideal for users who:
- Are running the trainer app on the same device as the controller app (e.g., both apps on a smartphone or tablet).
- Do not want to deal with network configurations or potential connectivity issues.
## Limitations of the Local connection method
*
While the Local connection method is easy to set up and use, it has some limitations:
- It may not work well with trainer apps that have complex user interfaces or require precise timing.
- It is limited to the device on which both the controller and trainer apps are running, meaning it cannot be used for remote control scenarios.

View File

@@ -1 +0,0 @@
Instructions will be added soon

View File

@@ -0,0 +1,39 @@
## Instructions for using the MyWhoosh "Link" connection method
*
1) Launch MyWhoosh on the device of your choice
2) Only needed once: open the "MyWhoosh Link" app on the same device where you want to use BikeControl. Make sure the Link app is able to connect to MyWhoosh. If it does, close MyWhoosh Link.
3) Make sure the "MyWhoosh Link" app is not active at the same time as BikeControl
4) Open BikeControl, enable the Link connection method, and follow the on-screen instructions
Here's a video with a few explanations. Note that it uses an older version, but the idea is the same.
[![BikeControl Instruction for iOS](https://img.youtube.com/vi/p8sgQhuufeI/0.jpg)](https://www.youtube.com/watch?v=p8sgQhuufeI)
[https://www.youtube.com/watch?v=p8sgQhuufeI](https://www.youtube.com/watch?v=p8sgQhuufeI)
## MyWhoosh "Link" method never connects
*
This is a network/local-discovery problem. BikeControl needs the same kind of local network access as MyWhoosh Link.
Checklist:
- Use the MyWhoosh Link app to confirm if "Link" works in general
- Use MyWhoosh Link app and connect, then close it, then open up BikeControl - this is key for some users
- Both devices (if you use BikeControl on another device than MyWhoosh) are on the **same WiFi SSID**
- Avoid “Guest” networks
- Avoid “extenders/mesh guest mode” and networks with device isolation
- If your router has it, disable:
- “AP isolation / client isolation”
- Try moving both devices to the same band:
- Prefer **2.4 GHz** (often more reliable for local discovery than mixed/steering)
- Temporarily disable:
- VPNs
- iCloud Private Relay (if enabled)
- “Limit IP Address Tracking” (iOS WiFi option)
- iOS WiFi settings for that network:
- Turn off **Private WiFi Address**
- Turn off **Limit IP Address Tracking**
- Mesh networks: may work, but if it doesnt, test with a simple router or phone hotspot.
Official MyWhoosh troubleshooting links:
- https://mywhoosh.com/troubleshoot/
- https://www.facebook.com/groups/mywhoosh/posts/1323791068858873/

View File

@@ -0,0 +1,13 @@
## Remote control is not working - nothing happens
*
- Try to unpair it from your phone / computer Bluetooth settings, then re-pair it.
- Try restarting the pairing process in BikeControl
- try restarting Bluetooth on your phone and on the device you want to control
- If your other device is an iOS device, go to Settings > Accessibility > Touch > AssistiveTouch > Pointer Devices > Devices and pair your device. Make sure AssistiveTouch is enabled.
- it is very important that both devices (e.g. iPhone and iPad) receive the "pairing dialog" after initial connection. If you miss it, unpair and try again. It may take a few seconds for the dialog to appear. Afterwards you may need to click on "Reconnect" in BikeControl / restart BikeControl.
## Remote control only clicks on a single coordinate on my iPad
*
iOS seems to be buggy here - try this in the iOS settings:
AssistiveTouch settings > Pointer Devices > Devices > Connected Devices > iPhone (or BikeControl iOS) > Button 1
switch the setting to None, then back to Single-Tap and it should work again

4
INSTRUCTIONS_ROUVY.md Normal file
View File

@@ -0,0 +1,4 @@
## Local Connection method
*
The local connection method (avalable on Android, Windows and macOS) allows BikeControl to directly control Rouvy either using touch or keyboard keys. This way you don't need to select any "Controllers" at all in Rouvy.
Make sure the "Virtual Shifting Controls" are enabled: https://support.rouvy.com/hc/en-us/articles/32452137189393-Virtual-Shifting#h_01K9SWGWYMAVQV108SQ9KWQAKC

View File

@@ -1 +0,0 @@
Instructions will be added soon

0
INSTRUCTIONS_ZWIFT.md Normal file
View File

771
LICENSE
View File

@@ -1,674 +1,97 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
License notice:
Versions of this project released prior to repository tag gpl3 were licensed
under GPL-3.0. Those versions remain available under their original
license. Versions released after that point are licensed under the
Non-Commercial License.
NON-COMMERCIAL SOFTWARE LICENSE AGREEMENT
Version 1.0
Copyright (c) 2026 OpenBikeControl UG (haftungsbeschränkt).
All rights reserved.
1. Definitions
“Software” means the source code, object code, binaries, and associated documentation made available by the Licensor under this License.
“Commercial Use” means any use of the Software, directly or indirectly, that is intended for or results in:
• monetary compensation,
• sale, licensing, or subscription fees,
• advertising or sponsorship revenue,
• inclusion in a product or service that is sold or monetized,
• distribution through paid applications or application marketplaces.
“Licensor” means the copyright holder.
2. Grant of License
Subject to the terms of this License, the Licensor grants you a non-exclusive, non-transferable, revocable license to:
• use the Software for personal, educational, or internal evaluation purposes only;
• modify the Software for non-commercial purposes;
• redistribute the Software only in source form, free of charge, and only under this same License.
3. Restrictions
You may not, without prior written permission from the Licensor:
• use the Software for any Commercial Use;
• distribute the Software as part of a paid or monetized product or service;
• distribute the Software via application marketplaces (including but not limited to Apple App Store or Google Play) where the application itself or related services are monetized;
• sublicense, sell, rent, or lease the Software.
4. Attribution
All copies and derivative works must retain:
• this License text;
• all existing copyright notices.
5. No Patent License
This License does not grant any patent rights.
6. Termination
Any violation of this License automatically terminates your rights under this License.
Upon termination, you must cease all use and distribution of the Software.
7. Disclaimer of Warranty
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND.
8. Limitation of Liability
IN NO EVENT SHALL THE LICENSOR BE LIABLE FOR ANY DAMAGES ARISING FROM THE USE OF THE SOFTWARE.
9. Governing Law
This License shall be governed by the laws of [YOUR COUNTRY], excluding conflict-of-law rules.
10. Commercial Licensing
Commercial use is available under separate commercial license terms.
Contact: jonas@openbikecontrol.org
End of License

View File

@@ -4,21 +4,18 @@
## Description
With BikeControl you can **control your favorite trainer app** using your Zwift Click, Zwift Ride, Zwift Play, or other similar devices. Here's what you can do with it, depending on your configuration:
With BikeControl you can **control your favorite trainer app** using your Zwift Click, Zwift Ride, Zwift Play, Shimano Di2, or other similar devices. Here's what you can do with it, depending on your configuration:
- Virtual Gear shifting
- Steering/turning
- Steering / navigation
- adjust workout intensity
- control music on your device
- more? If you can do it via keyboard, mouse, or touch, you can do it with BikeControl
https://github.com/user-attachments/assets/1f81b674-1628-4763-ad66-5f3ed7a3f159
[![Youtube Video](https://github.com/user-attachments/assets/14a45ca1-e31b-4fbd-8d03-95aa60470405)](https://youtu.be/0r3LO5lFlyc)
## Downloads
Best follow our landing page and the "Get Started" button: [bikecontrol.app](https://bikecontrol.app/) to understand on which platform you want to run BikeControl.
## Download
Best follow our landing page and the "Get Started" button: [bikecontrol.app](https://bikecontrol.app/) to understand on which platform you want to run BikeControl. A testing period is available, allowing you to try out the full functionality of BikeControl:
<a href="https://play.google.com/store/apps/details?id=de.jonasbark.swiftcontrol"><img width="270" height="80" alt="GetItOnGooglePlay_Badge_Web_color_English" src="https://github.com/user-attachments/assets/a059d5a1-2efb-4f65-8117-ef6a99823b21" /></a>
@@ -30,11 +27,11 @@ Best follow our landing page and the "Get Started" button: [bikecontrol.app](htt
## Supported Apps
- MyWhoosh
- TrainingPeaks Virtual / indieVelo
- Zwift
- TrainingPeaks Virtual
- Biketerra.com
- Rouvy
- Zwift
- running BikeControl on Android or Windows is required to act as a "Controllable" in Zwift - iOS and macOS are not able to do so
- [OpenBikeControl](https://openbikecontrol.org) compatible apps
- any other!
- You can add custom mapping and adjust touch points or keyboard shortcuts to your liking
@@ -45,46 +42,61 @@ Best follow our landing page and the "Get Started" button: [bikecontrol.app](htt
- Zwift Play
- Shimano Di2
- Configure your levers to use D-Fly channels with Shimano E-Tube app
- SRAM AXS/eTap
- Configure your levers not to do any action in the "SRAM AXS" app
- only single or double click is supported (no individual button mapping possible, yet)
- Wahoo Kickr Bike Shift
- Wahoo Kickr Bike Pro
- CYCPLUS BC2 Virtual Shifter
- Thinkrider VS200 Virtual Shifter (beta)
- Elite Sterzo Smart (for steering support)
- Elite Square Smart Frame (beta)
- Gamepads (beta)
- Your Phone!
- Mount your phone on the handlebar to detect e.g. steering
- Available on Android and iOS
- Gamepads
- Keyboard input
- like a Companion App
- some trainers do not support keyboard input for all functions - now they do!
- useful when remapping keys from other devices using e.g. AutoHotkey
- Cheap Bluetooth buttons such as [these](https://www.amazon.com/s?k=bluetooth+remote) (beta)
- BLE HID devices and classic Bluetooth HID devices are supported
- works on Android
- on iOS and macOS requires BikeControl to act as media player
- works out of the box on Android
- on Windows, iOS and macOS requires BikeControl to act as media player
- We're working on creating an affordable alternative based on an open standard, supported by all major trainer apps
- register your interest [here](https://openbikecontrol.org/#HARDWARE)
Support for other devices can be added; check the issues tab here on GitHub.
Support for other devices can be added; check the issues tab here on GitHub.
## Supported Accessories
- Wahoo KICKR HEADWIND (beta)
- control fan speed using your controller
## Supported Platforms
Follow the "Get Started" button over at [bikecontrol.app](https://bikecontrol.app) to understand on which platform you want to run BikeControl.
You can even try it out in your [Browser](https://jonasbark.github.io/swiftcontrol/), if it supports Bluetooth connections. No controlling possible, though.
You can even try it out in your [Browser](https://openbikecontrol.github.io/bikecontrol/), if it supports Bluetooth connections. No controlling possible, though.
## Troubleshooting
## Help
Check the troubleshooting guide [here](TROUBLESHOOTING.md).
## How does it work?
The app connects to your Controller devices (such as Zwift ones) automatically. It does not connect to your trainer itself.
- **Android**: BikeControl uses the AccessibilityService API to simulate touch gestures on specific parts of your screen to trigger actions in training apps. The service monitors which training app window is currently active to ensure gestures are sent to the correct app.
- **iOS**: use BikeControl as a "remote control" for other devices, such as an iPad. Example scenario:
- your phone (Android/iOS) runs BikeControl and connects to your Controller devices
- your iPad or other tablet runs e.g. MyWhoosh (does not need to have BikeControl installed)
- If you want to use MyWhoosh, you can use the Link method to connect to MyWhoosh directly
- For other trainer apps, you need to pair BikeControl to your iPad / tablet via Bluetooth, and your phone will send the button presses to your iPad / tablet
- **macOS** / **Windows** A keyboard or mouse click is used to trigger the action.
- There are predefined Keymaps for MyWhoosh, indieVelo / Training Peaks, and others
- You can also create your own Keymaps for any other app
- You can also use the mouse to click on a certain part of the screen, or use keyboard shortcuts
## Alternatives
- [qdomyos-zwift](https://www.qzfitness.com/) directly controls the trainer (as opposed to controlling the trainer app). This can be useful if your trainer app does not support virtual shifting.
The app connects to your Controller devices (such as Zwift ones) automatically. BikeControl uses different methods of connecting to the trainer app, depending on the trainer app and operating system:
- Connect to the trainer app on the same device or on another device using Network
- available on Android, iOS, iPadOS, macOS, Windows
- supported by e.g. MyWhoosh, Rouvy and Zwift
- Connect to the trainer app on another device by simulating a Bluetooth device
- available on Android, iOS, iPadOS, macOS, Windows
- supported by e.g. Rouvy and Zwift
- Directly control the trainer app via Accessibility features (simulating touch and keyboard input)
- available on Android, macOS, Windows
- supported by all trainer apps
- Connect to the supported trainer app using the [OpenBikeControl](https://openbikecontrol.org) protocol
- available on Android, iOS, iPadOS, macOS, Windows
## Donate
Please consider donating to support the development of this app :)
- [via PayPal](https://paypal.me/boni)
- [via Credit Card, Google Pay, Apple Pay, etc (USD)](https://donate.stripe.com/8x24gzc5c4ZE3VJdt36J201)
- [via Credit Card, Google Pay, Apple Pay, etc (EUR)](https://donate.stripe.com/9B6aEX0muajY8bZ1Kl6J200)
- [via Credit Card, Google Pay, Apple Pay, etc. (USD)](https://donate.stripe.com/8x24gzc5c4ZE3VJdt36J201)
- [via Credit Card, Google Pay, Apple Pay, etc. (EUR)](https://donate.stripe.com/9B6aEX0muajY8bZ1Kl6J200)

View File

@@ -1,53 +1,38 @@
## Click / Ride device cannot be found
You may need to update the firmware in Zwift Companion app.
*
This means BikeControl does NOT see the device via Bluetooth.
- Put the controller into pairing mode (LED should blink)
- Ensure the controller is NOT connected to another app/device (e.g. Zwift)
- Update controller firmware in Zwift Companion, if available
- Reboot Bluetooth / reboot phone/PC
## Click / Ride device does not send any data
*
You may need to update the firmware in Zwift Companion app.
## My Click v2 disconnects after a minute
Check [this](https://github.com/OpenBikeControl/bikecontrol/issues/68) discussion.
## My Click v2 disconnects after a minute or buttons do not work
*
To make your Click V2 work best you should connect it in the Zwift app once each day.
To make your Click V2 work best you should connect it in the Zwift app once before a workout session.
If you don't do that BikeControl will need to reconnect every minute.
1. Open Zwift app (not the Companion)
2. Log in (subscription not required) and open the device connection screen
3. Connect your Trainer, then connect the Click V2
4. Close the Zwift app again and connect again in BikeControl
2. Log in (subscription not required) device connection screen
3. Connect trainer, then connect Click v2
4. Keep it connected for ~1030 seconds
5. Close Zwift completely, then connect in BikeControl
Details/updates: https://github.com/OpenBikeControl/bikecontrol/issues/68
## Android: Connection works, buttons work but nothing happens in MyWhoosh and similar
*
- especially for Redmi and other chinese Android devices please follow the instructions on [https://dontkillmyapp.com/](https://dontkillmyapp.com/):
- disable battery optimization for BikeControl
- enable auto start of BikeControl
- grant accessibility permission for BikeControl
- see [https://github.com/OpenBikeControl/bikecontrol/issues/38](https://github.com/OpenBikeControl/bikecontrol/issues/38) for more details
## Remote control is not working - nothing happens
- Try to unpair it from your phone / computer Bluetooth settings, then re-pair it.
- Try restarting the pairing process in BikeControl
- try restarting Bluetooth on your phone and on the device you want to control
- If your other device is an iOS device, go to Settings > Accessibility > Touch > AssistiveTouch > Pointer Devices > Devices and pair your device. Make sure AssistiveTouch is enabled.
- it is very important that both devices (e.g. iPhone and iPad) receive the "pairing dialog" after initial connection. If you miss it, unpair and try again. It may take a few seconds for the dialog to appear. Afterwards you may need to click on "Reconnect" in BikeControl / restart BikeControl.
## Remote control only clicks on a single coordinate on my iPad
iOS seems to be buggy here - try this in the iOS settings:
AssistiveTouch settings > Pointer Devices > Devices > Connected Devices > iPhone (or BikeControl iOS) > Button 1
switch the setting to None, then back to Single-Tap and it should work again
## BikeControl crashes on Windows when searching for the device
You're probably running into [this](https://github.com/OpenBikeControl/bikecontrol/issues/70) issue. Disconnect your controller device (e.g. Zwift Play) from Windows Bluetooth settings.
## MyWhoosh Direct Connect never connects
The same network restrictions apply for BikeControl as it applies to MyWhoosh Link app. Please verify with the MyWhoosh Link app if connection is possible at all.
Here are some instructions that can help:
[https://mywhoosh.com/troubleshoot/](https://mywhoosh.com/troubleshoot/)
[https://www.facebook.com/groups/mywhoosh/posts/1323791068858873/](https://www.facebook.com/groups/mywhoosh/posts/1323791068858873/)
[INSTRUCTIONS_IOS.md](INSTRUCTIONS_IOS.md)
In essence:
- your two devices (phone, tablet) need to be on the same WiFi network
- on iOS you have to turn off "Private Wi-Fi Address" in the WiFi settings
- Limit IP Address Tracking may need to be disabled
- mesh networks may not work
## My Clicks do not get recognized in MyWhoosh, but I am connected / use local control
*
Make sure you've enabled Virtual Shifting in MyWhoosh's settings

View File

@@ -1 +1 @@
3.6.0
4.7.2

View File

@@ -90,6 +90,23 @@ enum class MediaAction(val raw: Int) {
}
}
enum class GlobalAction(val raw: Int) {
BACK(0),
DPAD_CENTER(1),
DOWN(2),
RIGHT(3),
UP(4),
LEFT(5),
HOME(6),
RECENTS(7);
companion object {
fun ofRaw(raw: Int): GlobalAction? {
return values().firstOrNull { it.raw == raw }
}
}
}
/** Generated class from Pigeon that represents data sent in messages. */
data class WindowEvent (
val packageName: String,
@@ -129,6 +146,43 @@ data class WindowEvent (
override fun hashCode(): Int = toList().hashCode()
}
/** Generated class from Pigeon that represents data sent in messages. */
data class AKeyEvent (
val source: String,
val hidKey: String,
val keyDown: Boolean,
val keyUp: Boolean
)
{
companion object {
fun fromList(pigeonVar_list: List<Any?>): AKeyEvent {
val source = pigeonVar_list[0] as String
val hidKey = pigeonVar_list[1] as String
val keyDown = pigeonVar_list[2] as Boolean
val keyUp = pigeonVar_list[3] as Boolean
return AKeyEvent(source, hidKey, keyDown, keyUp)
}
}
fun toList(): List<Any?> {
return listOf(
source,
hidKey,
keyDown,
keyUp,
)
}
override fun equals(other: Any?): Boolean {
if (other !is AKeyEvent) {
return false
}
if (this === other) {
return true
}
return AccessibilityApiPigeonUtils.deepEquals(toList(), other.toList()) }
override fun hashCode(): Int = toList().hashCode()
}
private open class AccessibilityApiPigeonCodec : StandardMessageCodec() {
override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? {
return when (type) {
@@ -138,10 +192,20 @@ private open class AccessibilityApiPigeonCodec : StandardMessageCodec() {
}
}
130.toByte() -> {
return (readValue(buffer) as Long?)?.let {
GlobalAction.ofRaw(it.toInt())
}
}
131.toByte() -> {
return (readValue(buffer) as? List<Any?>)?.let {
WindowEvent.fromList(it)
}
}
132.toByte() -> {
return (readValue(buffer) as? List<Any?>)?.let {
AKeyEvent.fromList(it)
}
}
else -> super.readValueOfType(type, buffer)
}
}
@@ -151,8 +215,16 @@ private open class AccessibilityApiPigeonCodec : StandardMessageCodec() {
stream.write(129)
writeValue(stream, value.raw)
}
is WindowEvent -> {
is GlobalAction -> {
stream.write(130)
writeValue(stream, value.raw)
}
is WindowEvent -> {
stream.write(131)
writeValue(stream, value.toList())
}
is AKeyEvent -> {
stream.write(132)
writeValue(stream, value.toList())
}
else -> super.writeValue(stream, value)
@@ -167,9 +239,11 @@ interface Accessibility {
fun hasPermission(): Boolean
fun openPermissions()
fun performTouch(x: Double, y: Double, isKeyDown: Boolean, isKeyUp: Boolean)
fun performGlobalAction(action: GlobalAction)
fun controlMedia(action: MediaAction)
fun isRunning(): Boolean
fun ignoreHidDevices()
fun setHandledKeys(keys: List<String>)
companion object {
/** The codec used by Accessibility. */
@@ -232,6 +306,24 @@ interface Accessibility {
channel.setMessageHandler(null)
}
}
run {
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.accessibility.Accessibility.performGlobalAction$separatedMessageChannelSuffix", codec)
if (api != null) {
channel.setMessageHandler { message, reply ->
val args = message as List<Any?>
val actionArg = args[0] as GlobalAction
val wrapped: List<Any?> = try {
api.performGlobalAction(actionArg)
listOf(null)
} catch (exception: Throwable) {
AccessibilityApiPigeonUtils.wrapError(exception)
}
reply.reply(wrapped)
}
} else {
channel.setMessageHandler(null)
}
}
run {
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.accessibility.Accessibility.controlMedia$separatedMessageChannelSuffix", codec)
if (api != null) {
@@ -281,6 +373,24 @@ interface Accessibility {
channel.setMessageHandler(null)
}
}
run {
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.accessibility.Accessibility.setHandledKeys$separatedMessageChannelSuffix", codec)
if (api != null) {
channel.setMessageHandler { message, reply ->
val args = message as List<Any?>
val keysArg = args[0] as List<String>
val wrapped: List<Any?> = try {
api.setHandledKeys(keysArg)
listOf(null)
} catch (exception: Throwable) {
AccessibilityApiPigeonUtils.wrapError(exception)
}
reply.reply(wrapped)
}
} else {
channel.setMessageHandler(null)
}
}
}
}
}
@@ -334,14 +444,14 @@ abstract class StreamEventsStreamHandler : AccessibilityApiPigeonEventChannelWra
}
}
abstract class HidKeyPressedStreamHandler : AccessibilityApiPigeonEventChannelWrapper<String> {
abstract class HidKeyPressedStreamHandler : AccessibilityApiPigeonEventChannelWrapper<AKeyEvent> {
companion object {
fun register(messenger: BinaryMessenger, streamHandler: HidKeyPressedStreamHandler, instanceName: String = "") {
var channelName: String = "dev.flutter.pigeon.accessibility.EventChannelMethods.hidKeyPressed"
if (instanceName.isNotEmpty()) {
channelName += ".$instanceName"
}
val internalStreamHandler = AccessibilityApiPigeonStreamHandler<String>(streamHandler)
val internalStreamHandler = AccessibilityApiPigeonStreamHandler<AKeyEvent>(streamHandler)
EventChannel(messenger, channelName, AccessibilityApiPigeonMethodCodec).setStreamHandler(internalStreamHandler)
}
}

View File

@@ -1,6 +1,8 @@
package de.jonasbark.accessibility
import AKeyEvent
import Accessibility
import GlobalAction
import HidKeyPressedStreamHandler
import MediaAction
import PigeonEventSink
@@ -65,6 +67,10 @@ class AccessibilityPlugin: FlutterPlugin, Accessibility {
Observable.toService?.performTouch(x = x, y = y, isKeyUp = isKeyUp, isKeyDown = isKeyDown) ?: error("Service not running")
}
override fun performGlobalAction(action: GlobalAction) {
Observable.toService?.performGlobalAction(action) ?: error("Service not running")
}
override fun controlMedia(action: MediaAction) {
val audioService = context.getSystemService(Context.AUDIO_SERVICE) as android.media.AudioManager
when (action) {
@@ -89,6 +95,11 @@ class AccessibilityPlugin: FlutterPlugin, Accessibility {
Observable.ignoreHidDevices = true
}
override fun setHandledKeys(keys: List<String>) {
// Clear and update the concurrent set
Observable.handledKeys = keys.toSet()
}
}
class WindowEventListener : StreamEventsStreamHandler(), Receiver {
@@ -116,9 +127,9 @@ class WindowEventListener : StreamEventsStreamHandler(), Receiver {
class HidEventListener : HidKeyPressedStreamHandler(), Receiver {
private var keyEventSink: PigeonEventSink<String>? = null
private var keyEventSink: PigeonEventSink<AKeyEvent>? = null
override fun onListen(p0: Any?, sink: PigeonEventSink<String>) {
override fun onListen(p0: Any?, sink: PigeonEventSink<AKeyEvent>) {
keyEventSink = sink
}
@@ -128,6 +139,13 @@ class HidEventListener : HidKeyPressedStreamHandler(), Receiver {
override fun onKeyEvent(event: KeyEvent) {
val keyString = KeyEvent.keyCodeToString(event.keyCode)
keyEventSink?.success(keyString)
keyEventSink?.success(
AKeyEvent(
hidKey = keyString,
source = event.device.name,
keyUp = event.action == KeyEvent.ACTION_UP,
keyDown = event.action == KeyEvent.ACTION_DOWN
)
)
}
}

View File

@@ -15,6 +15,7 @@ import android.view.KeyEvent
import android.view.ViewConfiguration
import android.view.accessibility.AccessibilityEvent
import android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
import GlobalAction
class AccessibilityService : AccessibilityService(), Listener {
@@ -70,17 +71,17 @@ class AccessibilityService : AccessibilityService(), Listener {
}
override fun onKeyEvent(event: KeyEvent): Boolean {
if (!Observable.ignoreHidDevices && isBleRemote(event)) {
// Handle media and volume keys from HID devices here
val keyString = KeyEvent.keyCodeToString(event.keyCode)
// if currently active app is BikeControl => handle it, so keymap can be created
if (!Observable.ignoreHidDevices && isBleRemote(event) && (rootInActiveWindow?.packageName == "de.jonasbark.swiftcontrol" || Observable.handledKeys.contains(keyString))) {
// Handle keys that have a keymap defined
Log.d(
"AccessibilityService",
"onKeyEvent: keyCode=${event.keyCode} action=${event.action} scanCode=${event.scanCode} flags=${event.flags}"
)
// Forward key events to the plugin (Flutter) and swallow them so they don't propagate.
if (event.action == KeyEvent.ACTION_DOWN) {
Observable.fromServiceKeys?.onKeyEvent(event)
}
Observable.fromServiceKeys?.onKeyEvent(event)
// Return true to indicate we've handled the event and it should be swallowed.
return true
} else {
@@ -97,6 +98,20 @@ class AccessibilityService : AccessibilityService(), Listener {
}
}
override fun performGlobalAction(action: GlobalAction) {
val mappedAction = when (action) {
GlobalAction.BACK -> android.accessibilityservice.AccessibilityService.GLOBAL_ACTION_BACK
GlobalAction.DPAD_CENTER -> android.accessibilityservice.AccessibilityService.GLOBAL_ACTION_DPAD_CENTER
GlobalAction.DOWN -> android.accessibilityservice.AccessibilityService.GLOBAL_ACTION_DPAD_DOWN
GlobalAction.RIGHT -> android.accessibilityservice.AccessibilityService.GLOBAL_ACTION_DPAD_RIGHT
GlobalAction.UP -> android.accessibilityservice.AccessibilityService.GLOBAL_ACTION_DPAD_UP
GlobalAction.LEFT -> android.accessibilityservice.AccessibilityService.GLOBAL_ACTION_DPAD_LEFT
GlobalAction.HOME -> android.accessibilityservice.AccessibilityService.GLOBAL_ACTION_HOME
GlobalAction.RECENTS -> android.accessibilityservice.AccessibilityService.GLOBAL_ACTION_RECENTS
}
performGlobalAction(mappedAction)
}
override fun performTouch(x: Double, y: Double, isKeyDown: Boolean, isKeyUp: Boolean) {
val gestureBuilder = GestureDescription.Builder()
val path = Path()

View File

@@ -2,16 +2,21 @@ package de.jonasbark.accessibility
import android.graphics.Rect
import android.view.KeyEvent
import GlobalAction
import java.util.concurrent.ConcurrentHashMap
object Observable {
var toService: Listener? = null
var fromServiceWindow: Receiver? = null
var fromServiceKeys: Receiver? = null
var ignoreHidDevices: Boolean = false
// Use concurrent set for thread-safe access from AccessibilityService and plugin
var handledKeys: Set<String> = ConcurrentHashMap.newKeySet()
}
interface Listener {
fun performTouch(x: Double, y: Double, isKeyDown: Boolean, isKeyUp: Boolean)
fun performGlobalAction(action: GlobalAction)
}
interface Receiver {

View File

@@ -8,15 +8,30 @@ abstract class Accessibility {
void performTouch(double x, double y, {bool isKeyDown = true, bool isKeyUp = false});
void performGlobalAction(GlobalAction action);
void controlMedia(MediaAction action);
bool isRunning();
void ignoreHidDevices();
void setHandledKeys(List<String> keys);
}
enum MediaAction { playPause, next, volumeUp, volumeDown }
enum GlobalAction {
back,
dpadCenter,
down,
right,
up,
left,
home,
recents,
}
class WindowEvent {
final String packageName;
final int top;
@@ -33,8 +48,17 @@ class WindowEvent {
});
}
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();
String hidKeyPressed();
AKeyEvent hidKeyPressed();
}

View File

@@ -36,6 +36,17 @@ enum MediaAction {
volumeDown,
}
enum GlobalAction {
back,
dpadCenter,
down,
right,
up,
left,
home,
recents,
}
class WindowEvent {
WindowEvent({
required this.packageName,
@@ -97,6 +108,62 @@ class WindowEvent {
;
}
class AKeyEvent {
AKeyEvent({
required this.source,
required this.hidKey,
required this.keyDown,
required this.keyUp,
});
String source;
String hidKey;
bool keyDown;
bool keyUp;
List<Object?> _toList() {
return <Object?>[
source,
hidKey,
keyDown,
keyUp,
];
}
Object encode() {
return _toList(); }
static AKeyEvent decode(Object result) {
result as List<Object?>;
return AKeyEvent(
source: result[0]! as String,
hidKey: result[1]! as String,
keyDown: result[2]! as bool,
keyUp: result[3]! as bool,
);
}
@override
// ignore: avoid_equals_and_hash_code_on_mutable_classes
bool operator ==(Object other) {
if (other is! AKeyEvent || other.runtimeType != runtimeType) {
return false;
}
if (identical(this, other)) {
return true;
}
return _deepEquals(encode(), other.encode());
}
@override
// ignore: avoid_equals_and_hash_code_on_mutable_classes
int get hashCode => Object.hashAll(_toList())
;
}
class _PigeonCodec extends StandardMessageCodec {
const _PigeonCodec();
@@ -108,8 +175,14 @@ class _PigeonCodec extends StandardMessageCodec {
} else if (value is MediaAction) {
buffer.putUint8(129);
writeValue(buffer, value.index);
} else if (value is WindowEvent) {
} else if (value is GlobalAction) {
buffer.putUint8(130);
writeValue(buffer, value.index);
} else if (value is WindowEvent) {
buffer.putUint8(131);
writeValue(buffer, value.encode());
} else if (value is AKeyEvent) {
buffer.putUint8(132);
writeValue(buffer, value.encode());
} else {
super.writeValue(buffer, value);
@@ -123,7 +196,12 @@ class _PigeonCodec extends StandardMessageCodec {
final int? value = readValue(buffer) as int?;
return value == null ? null : MediaAction.values[value];
case 130:
final int? value = readValue(buffer) as int?;
return value == null ? null : GlobalAction.values[value];
case 131:
return WindowEvent.decode(readValue(buffer)!);
case 132:
return AKeyEvent.decode(readValue(buffer)!);
default:
return super.readValueOfType(type, buffer);
}
@@ -219,6 +297,29 @@ class Accessibility {
}
}
Future<void> performGlobalAction(GlobalAction action) async {
final String pigeonVar_channelName = 'dev.flutter.pigeon.accessibility.Accessibility.performGlobalAction$pigeonVar_messageChannelSuffix';
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
pigeonVar_channelName,
pigeonChannelCodec,
binaryMessenger: pigeonVar_binaryMessenger,
);
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[action]);
final List<Object?>? pigeonVar_replyList =
await pigeonVar_sendFuture as List<Object?>?;
if (pigeonVar_replyList == null) {
throw _createConnectionError(pigeonVar_channelName);
} else if (pigeonVar_replyList.length > 1) {
throw PlatformException(
code: pigeonVar_replyList[0]! as String,
message: pigeonVar_replyList[1] as String?,
details: pigeonVar_replyList[2],
);
} else {
return;
}
}
Future<void> controlMedia(MediaAction action) async {
final String pigeonVar_channelName = 'dev.flutter.pigeon.accessibility.Accessibility.controlMedia$pigeonVar_messageChannelSuffix';
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
@@ -292,6 +393,29 @@ class Accessibility {
return;
}
}
Future<void> setHandledKeys(List<String> keys) async {
final String pigeonVar_channelName = 'dev.flutter.pigeon.accessibility.Accessibility.setHandledKeys$pigeonVar_messageChannelSuffix';
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
pigeonVar_channelName,
pigeonChannelCodec,
binaryMessenger: pigeonVar_binaryMessenger,
);
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[keys]);
final List<Object?>? pigeonVar_replyList =
await pigeonVar_sendFuture as List<Object?>?;
if (pigeonVar_replyList == null) {
throw _createConnectionError(pigeonVar_channelName);
} else if (pigeonVar_replyList.length > 1) {
throw PlatformException(
code: pigeonVar_replyList[0]! as String,
message: pigeonVar_replyList[1] as String?,
details: pigeonVar_replyList[2],
);
} else {
return;
}
}
}
Stream<WindowEvent> streamEvents( {String instanceName = ''}) {
@@ -305,14 +429,14 @@ Stream<WindowEvent> streamEvents( {String instanceName = ''}) {
});
}
Stream<String> hidKeyPressed( {String instanceName = ''}) {
Stream<AKeyEvent> hidKeyPressed( {String instanceName = ''}) {
if (instanceName.isNotEmpty) {
instanceName = '.$instanceName';
}
final EventChannel hidKeyPressedChannel =
EventChannel('dev.flutter.pigeon.accessibility.EventChannelMethods.hidKeyPressed$instanceName', pigeonMethodCodec);
return hidKeyPressedChannel.receiveBroadcastStream().map((dynamic event) {
return event as String;
return event as AKeyEvent;
});
}

View File

@@ -16,7 +16,7 @@ keystoreProperties.load(FileInputStream(keystorePropertiesFile))
android {
namespace = "de.jonasbark.swiftcontrol"
compileSdk = flutter.compileSdkVersion
ndkVersion = "27.0.12077973"
ndkVersion = "28.2.13676358"
compileOptions {
// Flag to enable support for the new language APIs

View File

@@ -3,6 +3,7 @@
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<!-- New Bluetooth permissions in Android 12
https://developer.android.com/about/versions/12/features/bluetooth-permissions -->
@@ -16,6 +17,7 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE"/>
<uses-permission android:name="android.permission.BILLING"/>
<!-- legacy for Android 9 or lower -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="28" tools:replace="android:maxSdkVersion" />

View File

@@ -5,10 +5,10 @@ import android.os.Handler
import android.view.InputDevice
import android.view.KeyEvent
import android.view.MotionEvent
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.android.FlutterFragmentActivity
import org.flame_engine.gamepads_android.GamepadsCompatibleActivity
class MainActivity: FlutterActivity(), GamepadsCompatibleActivity {
class MainActivity: FlutterFragmentActivity(), GamepadsCompatibleActivity {
var keyListener: ((KeyEvent) -> Boolean)? = null
var motionListener: ((MotionEvent) -> Boolean)? = null

Binary file not shown.

After

Width:  |  Height:  |  Size: 785 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
tools:keep="@drawable/*" />

View File

@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip

View File

@@ -18,7 +18,7 @@ pluginManagement {
plugins {
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
id("com.android.application") version "8.7.3" apply false
id("com.android.application") version "8.11.1" apply false
id("org.jetbrains.kotlin.android") version "2.2.20" apply false
}

BIN
assets/silence.mp3 Normal file

Binary file not shown.

View File

@@ -1,5 +1,6 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '13.0'
platform :ios, '15.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

View File

@@ -1,4 +1,6 @@
PODS:
- audio_session (0.0.1):
- Flutter
- bluetooth_low_energy_darwin (0.0.1):
- Flutter
- FlutterMacOS
@@ -7,23 +9,53 @@ PODS:
- Flutter (1.0.0)
- flutter_local_notifications (0.0.1):
- Flutter
- flutter_secure_storage_darwin (10.0.0):
- Flutter
- FlutterMacOS
- flutter_volume_controller (0.0.1):
- Flutter
- gamepads_ios (0.1.1):
- Flutter
- image_picker_ios (0.0.1):
- Flutter
- in_app_purchase_storekit (0.0.1):
- Flutter
- FlutterMacOS
- in_app_review (2.0.0):
- Flutter
- integration_test (0.0.1):
- Flutter
- ios_receipt (0.0.1):
- Flutter
- just_audio (0.0.1):
- Flutter
- FlutterMacOS
- media_key_detector_ios (0.0.1):
- Flutter
- nsd_ios (0.0.1):
- Flutter
- package_info_plus (0.4.5):
- Flutter
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- permission_handler_apple (9.3.0):
- Flutter
- purchases_flutter (9.10.6):
- Flutter
- PurchasesHybridCommon (= 17.27.1)
- purchases_ui_flutter (9.10.6):
- Flutter
- PurchasesHybridCommonUI (= 17.27.1)
- PurchasesHybridCommon (17.27.1):
- RevenueCat (= 5.54.1)
- PurchasesHybridCommonUI (17.27.1):
- PurchasesHybridCommon (= 17.27.1)
- RevenueCatUI (= 5.54.1)
- restart_app (0.0.1):
- Flutter
- RevenueCat (5.54.1)
- RevenueCatUI (5.54.1):
- RevenueCat (= 5.54.1)
- sensors_plus (0.0.1):
- Flutter
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
@@ -36,24 +68,43 @@ PODS:
- Flutter
DEPENDENCIES:
- audio_session (from `.symlinks/plugins/audio_session/ios`)
- bluetooth_low_energy_darwin (from `.symlinks/plugins/bluetooth_low_energy_darwin/darwin`)
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
- Flutter (from `Flutter`)
- flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
- flutter_secure_storage_darwin (from `.symlinks/plugins/flutter_secure_storage_darwin/darwin`)
- flutter_volume_controller (from `.symlinks/plugins/flutter_volume_controller/ios`)
- gamepads_ios (from `.symlinks/plugins/gamepads_ios/ios`)
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
- in_app_purchase_storekit (from `.symlinks/plugins/in_app_purchase_storekit/darwin`)
- in_app_review (from `.symlinks/plugins/in_app_review/ios`)
- integration_test (from `.symlinks/plugins/integration_test/ios`)
- ios_receipt (from `.symlinks/plugins/ios_receipt/ios`)
- just_audio (from `.symlinks/plugins/just_audio/darwin`)
- media_key_detector_ios (from `.symlinks/plugins/media_key_detector_ios/ios`)
- nsd_ios (from `.symlinks/plugins/nsd_ios/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- purchases_flutter (from `.symlinks/plugins/purchases_flutter/ios`)
- purchases_ui_flutter (from `.symlinks/plugins/purchases_ui_flutter/ios`)
- restart_app (from `.symlinks/plugins/restart_app/ios`)
- sensors_plus (from `.symlinks/plugins/sensors_plus/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- universal_ble (from `.symlinks/plugins/universal_ble/darwin`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
- wakelock_plus (from `.symlinks/plugins/wakelock_plus/ios`)
SPEC REPOS:
trunk:
- PurchasesHybridCommon
- PurchasesHybridCommonUI
- RevenueCat
- RevenueCatUI
EXTERNAL SOURCES:
audio_session:
:path: ".symlinks/plugins/audio_session/ios"
bluetooth_low_energy_darwin:
:path: ".symlinks/plugins/bluetooth_low_energy_darwin/darwin"
device_info_plus:
@@ -62,22 +113,40 @@ EXTERNAL SOURCES:
:path: Flutter
flutter_local_notifications:
:path: ".symlinks/plugins/flutter_local_notifications/ios"
flutter_secure_storage_darwin:
:path: ".symlinks/plugins/flutter_secure_storage_darwin/darwin"
flutter_volume_controller:
:path: ".symlinks/plugins/flutter_volume_controller/ios"
gamepads_ios:
:path: ".symlinks/plugins/gamepads_ios/ios"
image_picker_ios:
:path: ".symlinks/plugins/image_picker_ios/ios"
in_app_purchase_storekit:
:path: ".symlinks/plugins/in_app_purchase_storekit/darwin"
in_app_review:
:path: ".symlinks/plugins/in_app_review/ios"
integration_test:
:path: ".symlinks/plugins/integration_test/ios"
ios_receipt:
:path: ".symlinks/plugins/ios_receipt/ios"
just_audio:
:path: ".symlinks/plugins/just_audio/darwin"
media_key_detector_ios:
:path: ".symlinks/plugins/media_key_detector_ios/ios"
nsd_ios:
:path: ".symlinks/plugins/nsd_ios/ios"
package_info_plus:
:path: ".symlinks/plugins/package_info_plus/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
permission_handler_apple:
:path: ".symlinks/plugins/permission_handler_apple/ios"
purchases_flutter:
:path: ".symlinks/plugins/purchases_flutter/ios"
purchases_ui_flutter:
:path: ".symlinks/plugins/purchases_ui_flutter/ios"
restart_app:
:path: ".symlinks/plugins/restart_app/ios"
sensors_plus:
:path: ".symlinks/plugins/sensors_plus/ios"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
universal_ble:
@@ -88,23 +157,37 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/wakelock_plus/ios"
SPEC CHECKSUMS:
bluetooth_low_energy_darwin: 764d8d1ae5abefbcdb839e812b4b25c0061fcf8b
audio_session: 19e9480dbdd4e5f6c4543826b2e8b0e4ab6145fe
bluetooth_low_energy_darwin: 50bc79258e60586e4c4bed5948bd31d925f37fac
device_info_plus: bf2e3232933866d73fe290f2942f2156cdd10342
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
flutter_local_notifications: ff50f8405aaa0ccdc7dcfb9022ca192e8ad9688f
flutter_secure_storage_darwin: 557817588b80e60213cbecb573c45c76b788018d
flutter_volume_controller: e4d5832f08008180f76e30faf671ffd5a425e529
gamepads_ios: 1d2930c7a4450a9a1b57444ebf305a6a6cbeea0b
image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1
image_picker_ios: 4f2f91b01abdb52842a8e277617df877e40f905b
in_app_purchase_storekit: 2342c0a5da86593124d08dd13d920f39a52b273a
in_app_review: 436034b18594851a7328d7f1c2ed5ec235b79cfc
integration_test: 252f60fa39af5e17c3aa9899d35d908a0721b573
ios_receipt: c2d5b4c36953c377a024992393976214ce6951e6
just_audio: a42c63806f16995daf5b219ae1d679deb76e6a79
media_key_detector_ios: 7ff9aefdfea00bb7b71e184132381b7d0e7e1269
nsd_ios: 8c37babdc6538e3350dbed3a52674d2edde98173
package_info_plus: c0502532a26c7662a62a356cebe2692ec5fe4ec4
path_provider_foundation: 0b743cbb62d8e47eab856f09262bb8c1ddcfe6ba
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
purchases_flutter: b3c0792197f69cd7af4c2449b71df6ac6378aace
purchases_ui_flutter: caae6d62ea23c6fe964992a28353211cc74b244a
PurchasesHybridCommon: 027f03312519c51056457eb2e4f7ee1c91b61b8f
PurchasesHybridCommonUI: 48afb5e29204958bff1276b0f7acb8e4b59fe99a
restart_app: 806659942bf932f6ce51c5372f91ce5e81c8c14a
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
RevenueCat: ecbba580fa453b0d4a0475449b904196d74ef678
RevenueCatUI: ac7492873928e9e7f297e5e27a7c4f23f9008326
sensors_plus: 7229095999f30740798f0eeef5cd120357a8f4f2
shared_preferences_foundation: 5086985c1d43c5ba4d5e69a4e8083a389e2909e6
universal_ble: cf52a7b3fd2e7c14d6d7262e9fdadb72ab6b88a6
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe
url_launcher_ios: bb13df5870e8c4234ca12609d04010a21be43dfa
wakelock_plus: 76957ab028e12bfa4e66813c99e46637f367fc7e
PODFILE CHECKSUM: 3c63482e143d1b91d2d2560aee9fb04ecc74ac7e
PODFILE CHECKSUM: 7ebd5c9b932b3af79d5c67e3af873118b74e970f
COCOAPODS: 1.16.2

View File

@@ -65,6 +65,7 @@
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
DFFDC4B9C4D6EF6A3BDE2E73 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = "<group>"; };
EFDECED99A47773C293F8819 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = "<group>"; };
F0D040E82EEF2560009B19C0 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -152,6 +153,7 @@
97C146F01CF9000F007C117D /* Runner */ = {
isa = PBXGroup;
children = (
F0D040E82EEF2560009B19C0 /* Runner.entitlements */,
97C146FA1CF9000F007C117D /* Main.storyboard */,
97C146FD1CF9000F007C117D /* Assets.xcassets */,
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
@@ -278,10 +280,14 @@
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
@@ -370,10 +376,14 @@
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
inputPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
@@ -487,12 +497,14 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = UZRHKPVWN9;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -673,12 +685,14 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = UZRHKPVWN9;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -699,12 +713,14 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = UZRHKPVWN9;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",

View File

@@ -8,6 +8,8 @@ import UIKit
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}

View File

@@ -30,14 +30,22 @@
<true/>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>BikeControl uses Bluetooth to connect to accessories.</string>
<key>NSBonjourServices</key>
<array>
<string>_wahoo-fitness-tnp._tcp</string>
<string>_openbikecontrol._tcp</string>
</array>
<key>NSLocalNetworkUsageDescription</key>
<string>This app connects to your trainer app on your local network.</string>
<key>NSMotionUsageDescription</key>
<string>Access your accelerometer and gyroscope for steering support via your phone.</string>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UIBackgroundModes</key>
<array>
<string>bluetooth-peripheral</string>
<string>bluetooth-central</string>
<string>audio</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>keychain-access-groups</key>
<array/>
</dict>
</plist>

2
ios_receipt/.gitattributes vendored Normal file
View File

@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto

30
ios_receipt/.gitignore vendored Normal file
View File

@@ -0,0 +1,30 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
.packages
build/

30
ios_receipt/.metadata Normal file
View File

@@ -0,0 +1,30 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.
version:
revision: "367f9ea16bfae1ca451b9cc27c1366870b187ae2"
channel: "stable"
project_type: plugin
# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2
base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2
- platform: ios
create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2
base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2
# User provided section
# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'

7
ios_receipt/CHANGELOG.md Normal file
View File

@@ -0,0 +1,7 @@
## 1.1.0
* Migrate to StoreKit2
## 1.0.0
* Implement main method

21
ios_receipt/LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Dmytro O. Kut'ko
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

32
ios_receipt/README.md Normal file
View File

@@ -0,0 +1,32 @@
# IosReceipt
The IosReceipt package allows you to easily fetch the App Store receipt in your Flutter application on the iOS platform.
## Installation
Add the following dependency to your `pubspec.yaml` file:
```yaml
dependencies:
ios_receipt: ^0.0.1 # Use the latest version of the package
```
Then, run flutter pub get to install the package.
## Usage
Method for get transactions with StoreKit2
```dart
final transactions = await IosReceipt.getAllTransactions();
```
## Based on
This package is based on the [appStoreReceiptURL](https://developer.apple.com/documentation/foundation/nsbundle/1407276-appstorereceipturl) from the official Apple documentation.
## Note
- The receipt isn't necessary if you use AppTransaction to validate the app download, or Transaction to validate in-app purchases.
- If the receipt is invalid or missing in your app, use SKReceiptRefreshRequest to request a new receipt.
## Testing Environments
Keep in mind that receipts aren't initially present in iOS and iPadOS apps in the sandbox environment and in Xcode. Apps receive a receipt after the tester completes the first in-app purchase.
## License
This project is licensed under the MIT License.

View File

@@ -0,0 +1,4 @@
include: package:flutter_lints/flutter.yaml
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options

38
ios_receipt/ios/.gitignore vendored Normal file
View File

@@ -0,0 +1,38 @@
.idea/
.vagrant/
.sconsign.dblite
.svn/
.DS_Store
*.swp
profile
DerivedData/
build/
GeneratedPluginRegistrant.h
GeneratedPluginRegistrant.m
.generated/
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
!default.pbxuser
!default.mode1v3
!default.mode2v3
!default.perspectivev3
xcuserdata
*.moved-aside
*.pyc
*sync/
Icon?
.tags*
/Flutter/Generated.xcconfig
/Flutter/ephemeral/
/Flutter/flutter_export_environment.sh

View File

View File

@@ -0,0 +1,73 @@
import Flutter
import UIKit
import StoreKit
public class IosReceiptPlugin: NSObject, FlutterPlugin {
private func getAppleReceipt() -> String? {
guard let url = Bundle.main.appStoreReceiptURL,
FileManager.default.fileExists(atPath: url.path) else {
return nil
}
let data = try? Data(contentsOf: url, options: .alwaysMapped)
return data?.base64EncodedString()
}
private func isSandbox() -> Bool {
guard let path = Bundle.main.appStoreReceiptURL?.path else {
return false
}
return path.contains("CoreSimulator") || path.contains("sandboxReceipt")
}
private func getAllTransactions() async -> [[String: Any]] {
var list: [[String: Any]] = []
if #available(iOS 15.0, *) {
for await result in Transaction.all {
switch result {
case .verified(let tx):
var item: [String: Any] = [
"productId": tx.productID,
"transactionId": String(tx.id),
"originalTransactionId": String(tx.originalID),
"purchaseDate": ISO8601DateFormatter().string(from: tx.purchaseDate)
]
if let revocationDate = tx.revocationDate {
item["revocationDate"] = ISO8601DateFormatter().string(from: revocationDate)
}
if let reason = tx.revocationReason {
item["revocationReason"] = reason.rawValue
}
if #available(iOS 16.0, *) {
item["jws"] = result.jwsRepresentation
}
list.append(item)
case .unverified(_, _):
continue
}
}
}
return list
}
public static func register(with registrar: FlutterPluginRegistrar) {
let channel = FlutterMethodChannel(name: "ios_receipt", binaryMessenger: registrar.messenger())
let instance = IosReceiptPlugin()
registrar.addMethodCallDelegate(instance, channel: channel)
}
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
switch call.method {
case "getAppleReceipt":
result(getAppleReceipt())
case "isSandbox":
result(isSandbox())
case "getAllTransactions":
Task { result(await self.getAllTransactions()) }
default:
result(FlutterMethodNotImplemented)
}
}
}

View File

@@ -0,0 +1,23 @@
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
# Run `pod lib lint ios_receipt.podspec` to validate before publishing.
#
Pod::Spec.new do |s|
s.name = 'ios_receipt'
s.version = '0.0.1'
s.summary = 'A new Flutter plugin project.'
s.description = <<-DESC
A new Flutter plugin project.
DESC
s.homepage = 'http://example.com'
s.license = { :file => '../LICENSE' }
s.author = { 'Your Company' => 'email@example.com' }
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.dependency 'Flutter'
s.platform = :ios, '15.0'
# Flutter.framework does not contain a i386 slice.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
s.swift_version = '5.0'
end

View File

@@ -0,0 +1,22 @@
import 'package:ios_receipt/models/transaction.dart';
import 'ios_receipt_platform_interface.dart';
class IosReceipt {
static Future<String?> getAppleReceipt() {
return IosReceiptPlatform.instance.getAppleReceipt();
}
static Future<bool> isSandbox() {
return IosReceiptPlatform.instance.isSandbox();
}
static Future<List<Transaction>> getAllTransactions() async {
final list = await IosReceiptPlatform.instance.getAllTransactions();
final result = <Transaction>[];
for (var data in list) {
result.add(Transaction.fromMap(data));
}
return result..sort((a, b) => a.purchaseDate.compareTo(b.purchaseDate));
}
}

View File

@@ -0,0 +1,29 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'ios_receipt_platform_interface.dart';
/// An implementation of [IosReceiptPlatform] that uses method channels.
class MethodChannelIosReceipt extends IosReceiptPlatform {
/// The method channel used to interact with the native platform.
@visibleForTesting
final methodChannel = const MethodChannel('ios_receipt');
@override
Future<String?> getAppleReceipt() async {
final version = await methodChannel.invokeMethod<String>('getAppleReceipt');
return version;
}
@override
Future<List<Map<String, dynamic>>> getAllTransactions() async {
final list = await methodChannel.invokeMethod('getAllTransactions');
return (list as List).map((e) => Map<String, dynamic>.from(e)).toList();
}
@override
Future<bool> isSandbox() async {
final isSandbox = await methodChannel.invokeMethod<bool>('isSandbox');
return isSandbox ?? false;
}
}

View File

@@ -0,0 +1,37 @@
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'ios_receipt_method_channel.dart';
abstract class IosReceiptPlatform extends PlatformInterface {
/// Constructs a IosReceiptPlatform.
IosReceiptPlatform() : super(token: _token);
static final Object _token = Object();
static IosReceiptPlatform _instance = MethodChannelIosReceipt();
/// The default instance of [IosReceiptPlatform] to use.
///
/// Defaults to [MethodChannelIosReceipt].
static IosReceiptPlatform get instance => _instance;
/// Platform-specific implementations should set this with their own
/// platform-specific class that extends [IosReceiptPlatform] when
/// they register themselves.
static set instance(IosReceiptPlatform instance) {
PlatformInterface.verifyToken(instance, _token);
_instance = instance;
}
Future<String?> getAppleReceipt() {
throw UnimplementedError('platformVersion() has not been implemented.');
}
Future<List<Map<String, dynamic>>> getAllTransactions() {
throw UnimplementedError('getAllTransactions() has not been implemented.');
}
Future<bool> isSandbox() async {
throw UnimplementedError('isSandbox() has not been implemented.');
}
}

View File

@@ -0,0 +1,41 @@
class Transaction {
const Transaction({
required this.jws,
required this.productId,
required this.transactionId,
required this.purchaseDate,
required this.originalTransactionId,
});
final String? jws;
final String productId;
final String transactionId;
final DateTime purchaseDate;
final String originalTransactionId;
@override
bool operator ==(covariant Transaction other) {
if (identical(this, other)) return true;
return other.jws == jws &&
other.productId == productId &&
other.transactionId == transactionId &&
other.purchaseDate == purchaseDate &&
other.originalTransactionId == originalTransactionId;
}
@override
int get hashCode =>
jws.hashCode ^
productId.hashCode ^
transactionId.hashCode ^
purchaseDate.hashCode ^
originalTransactionId.hashCode;
factory Transaction.fromMap(Map<String, dynamic> map) => Transaction(
jws: map['jws'] as String?,
productId: map['productId'] as String,
transactionId: map['transactionId'] as String,
purchaseDate: DateTime.parse(map['purchaseDate'] as String),
originalTransactionId: map['originalTransactionId'] as String,
);
}

38
ios_receipt/macos/.gitignore vendored Normal file
View File

@@ -0,0 +1,38 @@
.idea/
.vagrant/
.sconsign.dblite
.svn/
.DS_Store
*.swp
profile
DerivedData/
build/
GeneratedPluginRegistrant.h
GeneratedPluginRegistrant.m
.generated/
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
!default.pbxuser
!default.mode1v3
!default.mode2v3
!default.perspectivev3
xcuserdata
*.moved-aside
*.pyc
*sync/
Icon?
.tags*
/Flutter/Generated.xcconfig
/Flutter/ephemeral/
/Flutter/flutter_export_environment.sh

View File

View File

@@ -0,0 +1,73 @@
import FlutterMacOS
import StoreKit
public class IosReceiptPlugin: NSObject, FlutterPlugin {
private func isSandbox() -> Bool {
guard let path = Bundle.main.appStoreReceiptURL?.path else {
return false
}
return path.contains("CoreSimulator") || path.contains("sandboxReceipt")
}
private func getAppleReceipt() -> String? {
guard let url = Bundle.main.appStoreReceiptURL,
FileManager.default.fileExists(atPath: url.path) else {
return nil
}
let data = try? Data(contentsOf: url, options: .alwaysMapped)
return data?.base64EncodedString()
}
private func getAllTransactions() async -> [[String: Any]] {
var list: [[String: Any]] = []
if #available(iOS 15.0, *) {
for await result in Transaction.all {
switch result {
case .verified(let tx):
var item: [String: Any] = [
"productId": tx.productID,
"transactionId": String(tx.id),
"originalTransactionId": String(tx.originalID),
"purchaseDate": ISO8601DateFormatter().string(from: tx.purchaseDate)
]
if let revocationDate = tx.revocationDate {
item["revocationDate"] = ISO8601DateFormatter().string(from: revocationDate)
}
if let reason = tx.revocationReason {
item["revocationReason"] = reason.rawValue
}
if #available(iOS 16.0, *) {
item["jws"] = result.jwsRepresentation
}
list.append(item)
case .unverified(_, _):
continue
}
}
}
return list
}
public static func register(with registrar: FlutterPluginRegistrar) {
let channel = FlutterMethodChannel(name: "ios_receipt", binaryMessenger: registrar.messenger)
let instance = IosReceiptPlugin()
registrar.addMethodCallDelegate(instance, channel: channel)
}
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
switch call.method {
case "getAppleReceipt":
result(getAppleReceipt())
case "isSandbox":
result(isSandbox())
case "getAllTransactions":
Task { result(await self.getAllTransactions()) }
default:
result(FlutterMethodNotImplemented)
}
}
}

View File

@@ -0,0 +1,23 @@
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
# Run `pod lib lint ios_receipt.podspec` to validate before publishing.
#
Pod::Spec.new do |s|
s.name = 'ios_receipt'
s.version = '0.0.1'
s.summary = 'A new Flutter plugin project.'
s.description = <<-DESC
A new Flutter plugin project.
DESC
s.homepage = 'http://example.com'
s.license = { :file => '../LICENSE' }
s.author = { 'Your Company' => 'email@example.com' }
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.dependency 'FlutterMacOS'
s.platform = :osx, '12.00'
# Flutter.framework does not contain a i386 slice.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
s.swift_version = '5.0'
end

26
ios_receipt/pubspec.yaml Normal file
View File

@@ -0,0 +1,26 @@
name: ios_receipt
description: The IosReceipt package allows you to easily fetch the App Store receipt in your Flutter application on the iOS platform.
version: 1.1.0
homepage: https://github.com/DimaKutko/ios_receipt
environment:
sdk: ">=3.8.0 <4.0.0"
flutter: ">=3.32.0"
dependencies:
flutter:
sdk: flutter
plugin_platform_interface: ^2.1.8
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^6.0.0
flutter:
plugin:
platforms:
ios:
pluginClass: IosReceiptPlugin
macos:
pluginClass: IosReceiptPlugin

View File

@@ -38,6 +38,11 @@ class KeyPressSimulator {
return _platform.simulateKeyPress(key: key, modifiers: modifiers, keyDown: false);
}
/// Simulate media key press.
Future<void> simulateMediaKey(PhysicalKeyboardKey mediaKey) {
return _platform.simulateMediaKey(mediaKey);
}
@Deprecated('Please use simulateKeyDown & simulateKeyUp methods.')
Future<void> simulateCtrlCKeyPress() async {
const key = PhysicalKeyboardKey.keyC;

View File

@@ -22,6 +22,9 @@ public class KeypressSimulatorMacosPlugin: NSObject, FlutterPlugin {
case "simulateMouseClick":
simulateMouseClick(call, result: result)
break
case "simulateMediaKey":
simulateMediaKey(call, result: result)
break
default:
result(FlutterMethodNotImplemented)
}
@@ -114,4 +117,62 @@ public class KeypressSimulatorMacosPlugin: NSObject, FlutterPlugin {
eventKeyPress!.flags = flags
return eventKeyPress!
}
public func simulateMediaKey(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
let args:[String: Any] = call.arguments as! [String: Any]
let keyIdentifier: String = args["key"] as! String
// Map string identifier to macOS NX key codes
var mediaKeyCode: Int32 = 0
switch keyIdentifier {
case "playPause":
mediaKeyCode = NX_KEYTYPE_PLAY
case "stop":
// macOS doesn't have a dedicated stop key in its media control API.
// Following macOS conventions, we map stop to play/pause which toggles playback.
// This matches the behavior of the physical media keys on Mac keyboards.
mediaKeyCode = NX_KEYTYPE_PLAY
case "next":
mediaKeyCode = NX_KEYTYPE_FAST
case "previous":
mediaKeyCode = NX_KEYTYPE_REWIND
case "volumeUp":
mediaKeyCode = NX_KEYTYPE_SOUND_UP
case "volumeDown":
mediaKeyCode = NX_KEYTYPE_SOUND_DOWN
default:
result(FlutterError(code: "UNSUPPORTED_KEY", message: "Unsupported media key identifier", details: nil))
return
}
// Create and post the media key event (key down)
let eventDown = NSEvent.otherEvent(
with: .systemDefined,
location: NSPoint.zero,
modifierFlags: NSEvent.ModifierFlags(rawValue: 0xa00),
timestamp: 0,
windowNumber: 0,
context: nil,
subtype: 8,
data1: Int((mediaKeyCode << 16) | (0xa << 8)),
data2: -1
)
eventDown?.cgEvent?.post(tap: .cghidEventTap)
// Create and post the media key event (key up)
let eventUp = NSEvent.otherEvent(
with: .systemDefined,
location: NSPoint.zero,
modifierFlags: NSEvent.ModifierFlags(rawValue: 0xb00),
timestamp: 0,
windowNumber: 0,
context: nil,
subtype: 8,
data1: Int((mediaKeyCode << 16) | (0xb << 8)),
data2: -1
)
eventUp?.cgEvent?.post(tap: .cghidEventTap)
result(true)
}
}

View File

@@ -61,4 +61,27 @@ class MethodChannelKeyPressSimulator extends KeyPressSimulatorPlatform {
};
await methodChannel.invokeMethod('simulateMouseClick', arguments);
}
@override
Future<void> simulateMediaKey(PhysicalKeyboardKey mediaKey) async {
// Map PhysicalKeyboardKey to string identifier since keyCode is null for media keys
final keyMap = {
PhysicalKeyboardKey.mediaPlayPause: 'playPause',
PhysicalKeyboardKey.mediaStop: 'stop',
PhysicalKeyboardKey.mediaTrackNext: 'next',
PhysicalKeyboardKey.mediaTrackPrevious: 'previous',
PhysicalKeyboardKey.audioVolumeUp: 'volumeUp',
PhysicalKeyboardKey.audioVolumeDown: 'volumeDown',
};
final keyIdentifier = keyMap[mediaKey];
if (keyIdentifier == null) {
throw UnsupportedError('Unsupported media key: $mediaKey');
}
final Map<String, Object?> arguments = {
'key': keyIdentifier,
};
await methodChannel.invokeMethod('simulateMediaKey', arguments);
}
}

View File

@@ -42,6 +42,10 @@ abstract class KeyPressSimulatorPlatform extends PlatformInterface {
}
Future<void> simulateMouseClick(Offset position, {required bool keyDown}) {
throw UnimplementedError('simulateKeyPress() has not been implemented.');
throw UnimplementedError('simulateMouseClick() has not been implemented.');
}
Future<void> simulateMediaKey(PhysicalKeyboardKey mediaKey) {
throw UnimplementedError('simulateMediaKey() has not been implemented.');
}
}

View File

@@ -1,17 +1,20 @@
#include "keypress_simulator_windows_plugin.h"
// This must be included before many other Windows headers.
#include <windows.h>
#include <flutter_windows.h>
#include <psapi.h>
#include <string.h>
#include <flutter_windows.h>
#include <windows.h>
#include <flutter/method_channel.h>
#include <flutter/plugin_registrar_windows.h>
#include <flutter/standard_method_codec.h>
#include <algorithm>
#include <memory>
#include <sstream>
#include <unordered_map>
#include <vector>
using flutter::EncodableList;
using flutter::EncodableMap;
@@ -27,7 +30,8 @@ struct FindWindowData {
};
BOOL CALLBACK EnumWindowsCallback(HWND hwnd, LPARAM lParam);
HWND FindTargetWindow(const std::string& processName, const std::string& windowTitle);
HWND FindTargetWindow(const std::string& processName,
const std::string& windowTitle);
// static
void KeypressSimulatorWindowsPlugin::RegisterWithRegistrar(
@@ -68,26 +72,91 @@ void KeypressSimulatorWindowsPlugin::SimulateKeyPress(
}
// List of compatible training apps to look for
std::vector<std::string> compatibleApps = {
"MyWhooshHD.exe",
"indieVelo.exe",
"biketerra.exe"
};
std::vector<std::string> compatibleApps = {"MyWhooshHD.exe", "MyWhoosh.exe",
"indieVelo.exe", "biketerra.exe",
"Rouvy.exe"};
// Try to find and focus a compatible app
// Try to find and focus (or directly target) a compatible app
std::string foundProcessName;
bool supportsBackgroundInput = true;
HWND targetWindow = NULL;
for (const std::string& processName : compatibleApps) {
targetWindow = FindTargetWindow(processName, "");
if (targetWindow != NULL) {
// Only focus the window if it's not already in the foreground
if (GetForegroundWindow() != targetWindow) {
foundProcessName = processName;
if (!supportsBackgroundInput && GetForegroundWindow() != targetWindow) {
SetForegroundWindow(targetWindow);
Sleep(50); // Brief delay to ensure window is focused
Sleep(50); // Brief delay to ensure window is focused
}
break;
}
}
// If we found a target window that supports background input and it's not
// focused, send messages directly
auto postKeyMessage = [](HWND hwnd, UINT vkCode, bool down) {
const WORD scanCode =
static_cast<WORD>(MapVirtualKey(vkCode, MAPVK_VK_TO_VSC));
// Build lParam with repeat count 1 and scan code; set transition states for
// key up
LPARAM lParam = 1 | (static_cast<LPARAM>(scanCode) << 16);
if (vkCode == VK_LEFT || vkCode == VK_RIGHT || vkCode == VK_UP ||
vkCode == VK_DOWN || vkCode == VK_INSERT || vkCode == VK_DELETE ||
vkCode == VK_HOME || vkCode == VK_END || vkCode == VK_PRIOR ||
vkCode == VK_NEXT) {
lParam |= (1 << 24); // extended key
}
if (!down) {
lParam |= (1 << 30); // previous key state
lParam |= (1 << 31); // transition state
}
PostMessage(hwnd, down ? WM_KEYDOWN : WM_KEYUP, vkCode, lParam);
};
auto sendKeyToWindow = [&postKeyMessage](HWND hwnd,
const std::vector<std::string>& mods,
UINT keyCode, bool down) {
auto handleModifier = [&postKeyMessage, hwnd](UINT vk, bool press) {
postKeyMessage(hwnd, vk, press);
};
if (down) {
for (const std::string& modifier : mods) {
if (modifier == "shiftModifier") {
handleModifier(VK_SHIFT, true);
} else if (modifier == "controlModifier") {
handleModifier(VK_CONTROL, true);
} else if (modifier == "altModifier") {
handleModifier(VK_MENU, true);
} else if (modifier == "metaModifier") {
handleModifier(VK_LWIN, true);
}
}
postKeyMessage(hwnd, keyCode, true);
} else {
postKeyMessage(hwnd, keyCode, false);
// release modifiers
for (const std::string& modifier : mods) {
if (modifier == "shiftModifier") {
handleModifier(VK_SHIFT, false);
} else if (modifier == "controlModifier") {
handleModifier(VK_CONTROL, false);
} else if (modifier == "altModifier") {
handleModifier(VK_MENU, false);
} else if (modifier == "metaModifier") {
handleModifier(VK_LWIN, false);
}
}
}
};
if (targetWindow != NULL && !foundProcessName.empty() &&
supportsBackgroundInput && GetForegroundWindow() != targetWindow) {
sendKeyToWindow(targetWindow, modifiers, keyCode, keyDown);
result->Success(flutter::EncodableValue(true));
return;
}
// Helper function to send modifier key events
auto sendModifierKey = [](UINT vkCode, bool down) {
WORD sc = (WORD)MapVirtualKey(vkCode, MAPVK_VK_TO_VSC);
@@ -100,7 +169,8 @@ void KeypressSimulatorWindowsPlugin::SimulateKeyPress(
};
// Helper function to process modifiers
auto processModifiers = [&sendModifierKey](const std::vector<std::string>& mods, bool down) {
auto processModifiers = [&sendModifierKey](
const std::vector<std::string>& mods, bool down) {
for (const std::string& modifier : mods) {
if (modifier == "shiftModifier") {
sendModifierKey(VK_SHIFT, down);
@@ -124,12 +194,13 @@ void KeypressSimulatorWindowsPlugin::SimulateKeyPress(
INPUT in = {0};
in.type = INPUT_KEYBOARD;
in.ki.wVk = 0; // when using SCANCODE, set VK=0
in.ki.wVk = 0; // when using SCANCODE, set VK=0
in.ki.wScan = sc;
in.ki.dwFlags = KEYEVENTF_SCANCODE | (keyDown ? 0 : KEYEVENTF_KEYUP);
if (keyCode == VK_LEFT || keyCode == VK_RIGHT || keyCode == VK_UP || keyCode == VK_DOWN ||
keyCode == VK_INSERT || keyCode == VK_DELETE || keyCode == VK_HOME || keyCode == VK_END ||
keyCode == VK_PRIOR || keyCode == VK_NEXT) {
if (keyCode == VK_LEFT || keyCode == VK_RIGHT || keyCode == VK_UP ||
keyCode == VK_DOWN || keyCode == VK_INSERT || keyCode == VK_DELETE ||
keyCode == VK_HOME || keyCode == VK_END || keyCode == VK_PRIOR ||
keyCode == VK_NEXT) {
in.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
}
SendInput(1, &in, sizeof(INPUT));
@@ -148,7 +219,6 @@ void KeypressSimulatorWindowsPlugin::SimulateKeyPress(
void KeypressSimulatorWindowsPlugin::SimulateMouseClick(
const flutter::MethodCall<flutter::EncodableValue>& method_call,
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result) {
const EncodableMap& args = std::get<EncodableMap>(*method_call.arguments());
double x = 0;
double y = 0;
@@ -156,12 +226,12 @@ void KeypressSimulatorWindowsPlugin::SimulateMouseClick(
bool keyDown = std::get<bool>(args.at(EncodableValue("keyDown")));
auto it_x = args.find(EncodableValue("x"));
if (it_x != args.end() && std::holds_alternative<double>(it_x->second)) {
x = std::get<double>(it_x->second);
x = std::get<double>(it_x->second);
}
auto it_y = args.find(EncodableValue("y"));
if (it_y != args.end() && std::holds_alternative<double>(it_y->second)) {
y = std::get<double>(it_y->second);
y = std::get<double>(it_y->second);
}
// Get the monitor containing the target point and its DPI
@@ -169,7 +239,7 @@ void KeypressSimulatorWindowsPlugin::SimulateMouseClick(
HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST);
UINT dpi = FlutterDesktopGetDpiForMonitor(monitor);
double scale_factor = dpi / 96.0;
// Scale the coordinates according to the DPI scaling
int scaled_x = static_cast<int>(x * scale_factor);
int scaled_y = static_cast<int>(y * scale_factor);
@@ -182,14 +252,14 @@ void KeypressSimulatorWindowsPlugin::SimulateMouseClick(
input.type = INPUT_MOUSE;
if (keyDown) {
// Mouse left button down
input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
SendInput(1, &input, sizeof(INPUT));
// Mouse left button down
input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
SendInput(1, &input, sizeof(INPUT));
} else {
// Mouse left button up
input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
SendInput(1, &input, sizeof(INPUT));
// Mouse left button up
input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
SendInput(1, &input, sizeof(INPUT));
}
result->Success(flutter::EncodableValue(true));
@@ -200,7 +270,7 @@ BOOL CALLBACK EnumWindowsCallback(HWND hwnd, LPARAM lParam) {
// Check if window is visible and not minimized
if (!IsWindowVisible(hwnd) || IsIconic(hwnd)) {
return TRUE; // Continue enumeration
return TRUE; // Continue enumeration
}
// Get window title
@@ -210,7 +280,8 @@ BOOL CALLBACK EnumWindowsCallback(HWND hwnd, LPARAM lParam) {
// Get process name
DWORD processId;
GetWindowThreadProcessId(hwnd, &processId);
HANDLE hProcess = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, processId);
HANDLE hProcess =
OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, processId);
char processName[MAX_PATH];
if (hProcess) {
DWORD size = sizeof(processName);
@@ -218,7 +289,7 @@ BOOL CALLBACK EnumWindowsCallback(HWND hwnd, LPARAM lParam) {
// Extract just the filename from the full path
char* filename = strrchr(processName, '\\');
if (filename) {
filename++; // Skip the backslash
filename++; // Skip the backslash
} else {
filename = processName;
}
@@ -227,7 +298,7 @@ BOOL CALLBACK EnumWindowsCallback(HWND hwnd, LPARAM lParam) {
if (!data->targetProcessName.empty() &&
_stricmp(filename, data->targetProcessName.c_str()) == 0) {
data->foundWindow = hwnd;
return FALSE; // Stop enumeration
return FALSE; // Stop enumeration
}
}
CloseHandle(hProcess);
@@ -237,13 +308,14 @@ BOOL CALLBACK EnumWindowsCallback(HWND hwnd, LPARAM lParam) {
if (!data->targetWindowTitle.empty() &&
_stricmp(windowTitle, data->targetWindowTitle.c_str()) == 0) {
data->foundWindow = hwnd;
return FALSE; // Stop enumeration
return FALSE; // Stop enumeration
}
return TRUE; // Continue enumeration
return TRUE; // Continue enumeration
}
HWND FindTargetWindow(const std::string& processName, const std::string& windowTitle) {
HWND FindTargetWindow(const std::string& processName,
const std::string& windowTitle) {
FindWindowData data;
data.targetProcessName = processName;
data.targetWindowTitle = windowTitle;
@@ -253,7 +325,45 @@ HWND FindTargetWindow(const std::string& processName, const std::string& windowT
return data.foundWindow;
}
void KeypressSimulatorWindowsPlugin::SimulateMediaKey(
const flutter::MethodCall<flutter::EncodableValue>& method_call,
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result) {
const EncodableMap& args = std::get<EncodableMap>(*method_call.arguments());
std::string keyIdentifier =
std::get<std::string>(args.at(EncodableValue("key")));
// Map string identifier to Windows virtual key codes
static const std::unordered_map<std::string, UINT> keyMap = {
{"playPause", VK_MEDIA_PLAY_PAUSE}, {"stop", VK_MEDIA_STOP},
{"next", VK_MEDIA_NEXT_TRACK}, {"previous", VK_MEDIA_PREV_TRACK},
{"volumeUp", VK_VOLUME_UP}, {"volumeDown", VK_VOLUME_DOWN}};
auto it = keyMap.find(keyIdentifier);
if (it == keyMap.end()) {
result->Error("UNSUPPORTED_KEY", "Unsupported media key identifier");
return;
}
UINT vkCode = it->second;
// Send key down event
INPUT inputs[2] = {};
inputs[0].type = INPUT_KEYBOARD;
inputs[0].ki.wVk = static_cast<WORD>(vkCode);
inputs[0].ki.dwFlags = 0; // Key down
// Send key up event
inputs[1].type = INPUT_KEYBOARD;
inputs[1].ki.wVk = static_cast<WORD>(vkCode);
inputs[1].ki.dwFlags = KEYEVENTF_KEYUP;
UINT eventsSent = SendInput(2, inputs, sizeof(INPUT));
if (eventsSent != 2) {
result->Error("SEND_INPUT_FAILED", "Failed to send media key input events");
return;
}
result->Success(flutter::EncodableValue(true));
}
void KeypressSimulatorWindowsPlugin::HandleMethodCall(
const flutter::MethodCall<flutter::EncodableValue>& method_call,
@@ -262,6 +372,8 @@ void KeypressSimulatorWindowsPlugin::HandleMethodCall(
SimulateKeyPress(method_call, std::move(result));
} else if (method_call.method_name().compare("simulateMouseClick") == 0) {
SimulateMouseClick(method_call, std::move(result));
} else if (method_call.method_name().compare("simulateMediaKey") == 0) {
SimulateMediaKey(method_call, std::move(result));
} else {
result->NotImplemented();
}

View File

@@ -30,7 +30,9 @@ class KeypressSimulatorWindowsPlugin : public flutter::Plugin {
const flutter::MethodCall<flutter::EncodableValue>& method_call,
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
void KeypressSimulatorWindowsPlugin::SimulateMediaKey(
const flutter::MethodCall<flutter::EncodableValue>& method_call,
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
// Called when a method is called on this plugin's channel from Dart.
void HandleMethodCall(

View File

@@ -1,23 +1,23 @@
import 'dart:async';
import 'dart:io';
import 'dart:ui';
import 'package:bike_control/bluetooth/devices/bluetooth_device.dart';
import 'package:bike_control/bluetooth/devices/gamepad/gamepad_device.dart';
import 'package:bike_control/bluetooth/devices/gyroscope/gyroscope_steering.dart';
import 'package:bike_control/bluetooth/devices/hid/hid_device.dart';
import 'package:bike_control/bluetooth/devices/wahoo/wahoo_kickr_headwind.dart';
import 'package:bike_control/gen/l10n.dart';
import 'package:bike_control/main.dart';
import 'package:bike_control/utils/core.dart';
import 'package:bike_control/utils/iap/iap_manager.dart';
import 'package:bike_control/utils/requirements/android.dart';
import 'package:dartx/dartx.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:gamepads/gamepads.dart';
import 'package:media_key_detector/media_key_detector.dart';
import 'package:swift_control/bluetooth/devices/bluetooth_device.dart';
import 'package:swift_control/bluetooth/devices/gamepad/gamepad_device.dart';
import 'package:swift_control/bluetooth/devices/hid/hid_device.dart';
import 'package:swift_control/main.dart';
import 'package:swift_control/utils/actions/android.dart';
import 'package:swift_control/utils/keymap/buttons.dart';
import 'package:swift_control/utils/keymap/keymap.dart';
import 'package:swift_control/utils/requirements/android.dart';
import 'package:prop/prop.dart';
import 'package:universal_ble/universal_ble.dart';
import '../utils/keymap/apps/my_whoosh.dart';
import 'devices/base_device.dart';
import 'devices/zwift/constants.dart';
import 'messages/notification.dart';
@@ -27,7 +27,14 @@ class Connection {
List<BluetoothDevice> get bluetoothDevices => devices.whereType<BluetoothDevice>().toList();
List<GamepadDevice> get gamepadDevices => devices.whereType<GamepadDevice>().toList();
List<BaseDevice> get controllerDevices => [...bluetoothDevices, ...gamepadDevices, ...devices.whereType<HidDevice>()];
List<GyroscopeSteering> get gyroscopeDevices => devices.whereType<GyroscopeSteering>().toList();
List<WahooKickrHeadwind> get accessories => devices.whereType<WahooKickrHeadwind>().toList();
List<BaseDevice> get controllerDevices => [
...bluetoothDevices.where((d) => d is! WahooKickrHeadwind),
...gamepadDevices,
...gyroscopeDevices,
...devices.whereType<HidDevice>(),
];
var _androidNotificationsSetup = false;
@@ -42,36 +49,38 @@ class Connection {
final Map<BaseDevice, StreamSubscription<bool>> _connectionSubscriptions = {};
final StreamController<BaseDevice> _connectionStreams = StreamController<BaseDevice>.broadcast();
Stream<BaseDevice> get connectionStream => _connectionStreams.stream;
final StreamController<BluetoothDevice> _rssiConnectionStreams = StreamController<BluetoothDevice>.broadcast();
Stream<BluetoothDevice> get rssiConnectionStream => _rssiConnectionStreams.stream;
final _lastScanResult = <BleDevice>[];
final ValueNotifier<bool> hasDevices = ValueNotifier(false);
final ValueNotifier<bool> isScanning = ValueNotifier(false);
final ValueNotifier<bool> isMediaKeyDetectionEnabled = ValueNotifier(false);
Timer? _gamePadSearchTimer;
void initialize() {
actionStream.listen((log) {
lastLogEntries.add((date: DateTime.now(), entry: log.toString()));
lastLogEntries = lastLogEntries.takeLast(20).toList();
lastLogEntries = lastLogEntries.takeLast(kIsWeb ? 1000 : 60).toList();
});
isMediaKeyDetectionEnabled.addListener(() {
if (!isMediaKeyDetectionEnabled.value) {
mediaKeyDetector.setIsPlaying(isPlaying: false);
mediaKeyDetector.removeListener(_onMediaKeyDetectedListener);
} else {
mediaKeyDetector.addListener(_onMediaKeyDetectedListener);
mediaKeyDetector.setIsPlaying(isPlaying: true);
}
});
if (!kIsWeb && (Platform.isMacOS || Platform.isWindows || Platform.isIOS)) {
core.mediaKeyHandler.initialize();
// Load saved media key detection state
core.mediaKeyHandler.isMediaKeyDetectionEnabled.value = core.settings.getMediaKeyDetectionEnabled();
}
UniversalBle.onAvailabilityChange = (available) {
_actionStreams.add(BluetoothAvailabilityNotification(available == AvailabilityState.poweredOn));
if (available == AvailabilityState.poweredOn && !kIsWeb) {
performScanning();
core.permissions.getScanRequirements().then((perms) {
if (perms.isEmpty) {
performScanning();
}
});
} else if (available == AvailabilityState.poweredOff) {
reset();
disconnectAll();
stop();
}
};
UniversalBle.onScanResult = (result) {
@@ -81,28 +90,42 @@ class Connection {
);
if (existingDevice != null && existingDevice.rssi != result.rssi) {
existingDevice.rssi = result.rssi;
_connectionStreams.add(existingDevice); // Notify UI of update
_rssiConnectionStreams.add(existingDevice); // Notify UI of update
}
if (_lastScanResult.none((e) => e.deviceId == result.deviceId && e.services.contentEquals(result.services))) {
_lastScanResult.add(result);
if (kDebugMode) {
print('Scan result: ${result.name} - ${result.deviceId}');
debugPrint('Scan result: ${result.name} - ${result.deviceId} - Services: ${result.services}');
}
final scanResult = BluetoothDevice.fromScanResult(result);
try {
final scanResult = BluetoothDevice.fromScanResult(result);
if (scanResult != null) {
_actionStreams.add(LogNotification('Found new device: ${scanResult.runtimeType}'));
addDevices([scanResult]);
} else {
final manufacturerData = result.manufacturerDataList;
final data = manufacturerData
.firstOrNullWhere((e) => e.companyId == ZwiftConstants.ZWIFT_MANUFACTURER_ID)
?.payload;
if (data != null && kDebugMode) {
_actionStreams.add(LogNotification('Found unknown device with identifier: ${data.firstOrNull}'));
if (scanResult != null) {
_actionStreams.add(
LogNotification('Found new device: ${kIsWeb ? scanResult.toString() : scanResult.runtimeType}'),
);
addDevices([scanResult]);
} else {
final manufacturerData = result.manufacturerDataList;
final data = manufacturerData
.firstOrNullWhere((e) => e.companyId == ZwiftConstants.ZWIFT_MANUFACTURER_ID)
?.payload;
if (data != null && kDebugMode) {
_actionStreams.add(
LogNotification('Found unknown device ${result.name} with identifier: ${data.firstOrNull}'),
);
}
}
} catch (e, backtrace) {
_actionStreams.add(
LogNotification("Error processing scan result for device ${result.deviceId}: $e\n$backtrace"),
);
if (kDebugMode) {
print(e);
print("backtrace: $backtrace");
}
}
}
@@ -115,12 +138,20 @@ class Connection {
UniversalBle.disconnect(deviceId);
return;
} else {
if (kIsWeb) {
// on web, log all characteristic changes for debugging
_actionStreams.add(
LogNotification(
'Characteristic update for device ${device.toString()}, char: $characteristicUuid, value: ${bytesToReadableHex(value)}',
),
);
}
try {
await device.processCharacteristic(characteristicUuid, value);
} catch (e, backtrace) {
_actionStreams.add(
LogNotification(
"Error processing characteristic for device ${device.name} and char: $characteristicUuid: $e\n$backtrace",
"Error processing characteristic for device ${device.toString()} and char: $characteristicUuid: $e\n$backtrace",
),
);
if (kDebugMode) {
@@ -138,6 +169,17 @@ class Connection {
_lastScanResult.removeWhere((d) => d.deviceId == deviceId);
}
};
if (!kIsWeb && !screenshotMode) {
core.permissions.getScanRequirements().then((perms) {
if (perms.isEmpty) {
performScanning();
}
});
if (core.settings.getPhoneSteeringEnabled()) {
toggleGyroscopeSteering(true);
}
}
}
Future<void> performScanning() async {
@@ -147,6 +189,10 @@ class Connection {
isScanning.value = true;
_actionStreams.add(LogNotification('Scanning for devices...'));
if (screenshotMode) {
return;
}
// does not work on web, may not work on Windows
if (!kIsWeb && !Platform.isWindows) {
UniversalBle.getSystemDevices(
@@ -168,7 +214,7 @@ class Connection {
if (!kIsWeb) {
_gamePadSearchTimer = Timer.periodic(Duration(seconds: 3), (_) {
Gamepads.list().then((list) {
final pads = list.map((pad) => GamepadDevice(pad.name, id: pad.id)).toList();
final pads = list.map((pad) => GamepadDevice(pad.name.isEmpty ? 'Gamepad' : pad.name, id: pad.id)).toList();
addDevices(pads);
final removedDevices = gamepadDevices.where((device) => list.none((pad) => pad.id == device.id)).toList();
@@ -182,44 +228,26 @@ class Connection {
}
});
});
Gamepads.list().then((list) {
final pads = list.map((pad) => GamepadDevice(pad.name, id: pad.id)).toList();
addDevices(pads);
});
}
if (settings.getMyWhooshLinkEnabled() &&
settings.getTrainerApp() is MyWhoosh &&
!whooshLink.isStarted.value &&
whooshLink.isCompatible(settings.getLastTarget()!)) {
startMyWhooshServer().catchError((e) {
_actionStreams.add(
LogNotification(
'Error starting MyWhoosh Direct Connect server. Please make sure the "MyWhoosh Link" app is not already running on this device.\n$e',
),
);
});
}
if (devices.isNotEmpty && !_androidNotificationsSetup && !kIsWeb && Platform.isAndroid) {
_androidNotificationsSetup = true;
// start foreground service only when app is in foreground
NotificationRequirement.setup().catchError((e) {
_actionStreams.add(LogNotification(e.toString()));
});
} else {
isScanning.value = false;
}
}
Future<void> startMyWhooshServer() {
return whooshLink.startServer(
onConnected: (socket) {},
onDisconnected: (socket) {},
);
return core.whooshLink.startServer().catchError((e) {
core.settings.setMyWhooshLinkEnabled(false);
_actionStreams.add(LogNotification('Error starting MyWhoosh "Link" server: $e'));
_actionStreams.add(
AlertNotification(
LogLevel.LOGLEVEL_ERROR,
'Error starting MyWhoosh "Link" server. Please make sure the "MyWhoosh Link" app is not already running on this device.',
),
);
});
}
void addDevices(List<BaseDevice> dev) {
final ignoredDevices = settings.getIgnoredDevices();
final ignoredDevices = core.settings.getIgnoredDevices();
final ignoredDeviceIds = ignoredDevices.map((d) => d.id).toSet();
final newDevices = dev.where((device) {
if (devices.contains(device)) return false;
@@ -241,25 +269,44 @@ class Connection {
hasDevices.value = devices.isNotEmpty;
}
void toggleGyroscopeSteering(bool enable) {
final existing = gyroscopeDevices.firstOrNull;
if (existing != null && !enable) {
// Remove gyroscope steering
disconnect(existing, forget: true, persistForget: false);
} else if (enable) {
// Add gyroscope steering
final gyroDevice = GyroscopeSteering();
addDevices([gyroDevice]);
}
}
void _handleConnectionQueue() {
// windows apparently has issues when connecting to multiple devices at once, so don't
if (_connectionQueue.isNotEmpty && !_handlingConnectionQueue && !screenshotMode) {
_handlingConnectionQueue = true;
final device = _connectionQueue.removeAt(0);
_actionStreams.add(LogNotification('Connecting to: ${device.name}'));
_actionStreams.add(AlertNotification(LogLevel.LOGLEVEL_INFO, 'Connecting to: ${device.toString()}'));
_connect(device)
.then((_) {
_handlingConnectionQueue = false;
_actionStreams.add(LogNotification('Connection finished: ${device.name}'));
_actionStreams.add(AlertNotification(LogLevel.LOGLEVEL_INFO, 'Connection finished: ${device.toString()}'));
if (_connectionQueue.isNotEmpty) {
_handleConnectionQueue();
}
})
.catchError((e) {
device.isConnected = false;
_handlingConnectionQueue = false;
_actionStreams.add(
LogNotification('Connection failed: ${device.name} - $e'),
);
if (e is TimeoutException) {
_actionStreams.add(
AlertNotification(LogLevel.LOGLEVEL_WARNING, 'Unable to connect to ${device.toString()}: Timeout'),
);
} else {
_actionStreams.add(
AlertNotification(LogLevel.LOGLEVEL_ERROR, 'Connection failed: ${device.toString()} - $e'),
);
}
if (_connectionQueue.isNotEmpty) {
_handleConnectionQueue();
}
@@ -273,11 +320,20 @@ class Connection {
_actionStreams.add(data);
});
if (device is BluetoothDevice) {
final connectionStateSubscription = UniversalBle.connectionStream(device.device.deviceId).listen((state) {
final connectionStateSubscription = device.device.connectionStream.listen((state) {
device.isConnected = state;
_connectionStreams.add(device);
core.flutterLocalNotificationsPlugin.show(
1338,
'${device.toString()} ${state ? AppLocalizations.current.connected.decapitalize() : AppLocalizations.current.disconnected.decapitalize()}',
!state ? AppLocalizations.current.tryingToConnectAgain : null,
NotificationDetails(
android: AndroidNotificationDetails('Connection', 'Connection Status'),
iOS: DarwinNotificationDetails(presentAlert: true, presentSound: false),
),
);
if (!device.isConnected) {
disconnect(device, forget: false);
disconnect(device, forget: false, persistForget: false);
// try reconnect
performScanning();
}
@@ -288,22 +344,19 @@ class Connection {
await device.connect();
signalChange(device);
final newButtons = device.availableButtons.filter(
(button) => actionHandler.supportedApp?.keymap.getKeyPair(button) == null,
);
for (final button in newButtons) {
actionHandler.supportedApp?.keymap.addKeyPair(
KeyPair(
touchPosition: Offset.zero,
buttons: [button],
physicalKey: null,
logicalKey: null,
isLongPress: false,
),
);
}
IAPManager.instance.setAttributes();
core.actionHandler.supportedApp?.keymap.addNewButtons(device.availableButtons);
_streamSubscriptions[device] = actionSubscription;
if (devices.isNotEmpty && !_androidNotificationsSetup && !kIsWeb && Platform.isAndroid) {
_androidNotificationsSetup = true;
// start foreground service only when app is in foreground
NotificationRequirement.addPersistentNotification().catchError((e) {
_actionStreams.add(LogNotification(e.toString()));
});
}
} catch (e, backtrace) {
_actionStreams.add(LogNotification("$e\n$backtrace"));
if (kDebugMode) {
@@ -314,31 +367,6 @@ class Connection {
}
}
Future<void> reset() async {
_actionStreams.add(LogNotification('Disconnecting all devices'));
if (actionHandler is AndroidActions) {
AndroidFlutterLocalNotificationsPlugin().stopForegroundService();
_androidNotificationsSetup = false;
}
final isBtEnabled = (await UniversalBle.getBluetoothAvailabilityState()) == AvailabilityState.poweredOn;
if (isBtEnabled) {
UniversalBle.stopScan();
}
isScanning.value = false;
for (var device in bluetoothDevices) {
_streamSubscriptions[device]?.cancel();
_streamSubscriptions.remove(device);
_connectionSubscriptions[device]?.cancel();
_connectionSubscriptions.remove(device);
UniversalBle.disconnect(device.device.deviceId);
signalChange(device);
}
_gamePadSearchTimer?.cancel();
_lastScanResult.clear();
hasDevices.value = false;
devices.clear();
}
void signalNotification(BaseNotification notification) {
_actionStreams.add(notification);
}
@@ -347,20 +375,33 @@ class Connection {
_connectionStreams.add(baseDevice);
}
Future<void> disconnect(BaseDevice device, {required bool forget}) async {
Future<void> disconnect(BaseDevice device, {required bool persistForget, required bool forget}) async {
if (device.isConnected) {
await device.disconnect();
}
if (device is BluetoothDevice) {
if (forget) {
if (persistForget) {
// Add device to ignored list when forgetting
await settings.addIgnoredDevice(device.device.deviceId, device.name);
_actionStreams.add(LogNotification('Device ignored: ${device.name}'));
await core.settings.addIgnoredDevice(device.device.deviceId, device.toString());
_actionStreams.add(LogNotification('Device ignored: ${device.toString()}'));
}
if (!forget) {
// allow reconnection
_lastScanResult.removeWhere((d) => d.deviceId == device.device.deviceId);
}
// Clean up subscriptions and scan results for reconnection
_lastScanResult.removeWhere((b) => b.deviceId == device.device.deviceId);
_streamSubscriptions[device]?.cancel();
_streamSubscriptions.remove(device);
_connectionSubscriptions[device]?.cancel();
_connectionSubscriptions.remove(device);
// Remove device from the list
devices.remove(device);
hasDevices.value = devices.isNotEmpty;
} else if (device is GyroscopeSteering) {
// Clean up subscriptions
_streamSubscriptions[device]?.cancel();
_streamSubscriptions.remove(device);
_connectionSubscriptions[device]?.cancel();
@@ -374,18 +415,28 @@ class Connection {
signalChange(device);
}
void _onMediaKeyDetectedListener(MediaKey mediaKey) {
final hidDevice = HidDevice('HID Device');
final keyPressed = mediaKey.name;
final button = actionHandler.supportedApp!.keymap.getOrAddButton(keyPressed, () => ControllerButton(keyPressed));
var availableDevice = connection.controllerDevices.firstOrNullWhere((e) => e.name == hidDevice.name);
if (availableDevice == null) {
connection.addDevices([hidDevice]);
availableDevice = hidDevice;
Future<void> disconnectAll() async {
_actionStreams.add(LogNotification('Disconnecting all devices'));
for (var device in bluetoothDevices) {
_streamSubscriptions[device]?.cancel();
_streamSubscriptions.remove(device);
_connectionSubscriptions[device]?.cancel();
_connectionSubscriptions.remove(device);
device.disconnect();
signalChange(device);
devices.remove(device);
}
availableDevice.handleButtonsClicked([button]);
availableDevice.handleButtonsClicked([]);
_gamePadSearchTimer?.cancel();
_lastScanResult.clear();
hasDevices.value = false;
}
Future<void> stop() async {
final isBtEnabled = (await UniversalBle.getBluetoothAvailabilityState()) == AvailabilityState.poweredOn;
if (isBtEnabled) {
UniversalBle.stopScan();
}
isScanning.value = false;
_androidNotificationsSetup = false;
}
}

View File

@@ -1,37 +1,66 @@
import 'dart:async';
import 'package:bike_control/bluetooth/devices/zwift/constants.dart';
import 'package:bike_control/gen/l10n.dart';
import 'package:bike_control/main.dart';
import 'package:bike_control/utils/actions/desktop.dart';
import 'package:bike_control/utils/core.dart';
import 'package:bike_control/utils/iap/iap_manager.dart';
import 'package:bike_control/utils/keymap/apps/custom_app.dart';
import 'package:bike_control/utils/keymap/manager.dart';
import 'package:dartx/dartx.dart';
import 'package:flutter/material.dart';
import 'package:swift_control/bluetooth/devices/zwift/constants.dart';
import 'package:swift_control/main.dart';
import 'package:swift_control/utils/actions/base_actions.dart';
import 'package:swift_control/utils/actions/desktop.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:prop/prop.dart' show LogLevel;
import '../../utils/keymap/buttons.dart';
import '../messages/notification.dart';
abstract class BaseDevice {
final String name;
final String? _name;
final bool isBeta;
final String uniqueId;
final List<ControllerButton> availableButtons;
BaseDevice(this.name, {required this.availableButtons, this.isBeta = false});
BaseDevice(
this._name, {
required this.uniqueId,
required this.availableButtons,
this.isBeta = false,
String? buttonPrefix,
}) {
if (availableButtons.isEmpty && core.actionHandler.supportedApp is CustomApp) {
final allButtons = core.actionHandler.supportedApp!.keymap.keyPairs
.flatMap((e) => e.buttons)
.filter(
(e) =>
e.sourceDeviceId == uniqueId ||
(e.sourceDeviceId == null && buttonPrefix != null && e.name.startsWith(buttonPrefix)),
)
.toSet();
availableButtons.addAll(allButtons);
}
}
bool isConnected = false;
Timer? _longPressTimer;
Set<ControllerButton> _previouslyPressedButtons = <ControllerButton>{};
String get name => _name ?? runtimeType.toString();
String get buttonExplanation => isConnected ? 'Connecting...' : 'Click a button on this device to configure them.';
@override
bool operator ==(Object other) =>
identical(this, other) || other is BaseDevice && runtimeType == other.runtimeType && name == other.name;
identical(this, other) ||
other is BaseDevice && runtimeType == other.runtimeType && toString() == other.toString();
@override
int get hashCode => name.hashCode;
@override
String toString() {
return name;
}
String toString() => name;
final StreamController<BaseNotification> actionStreamInternal = StreamController<BaseNotification>.broadcast();
@@ -39,9 +68,32 @@ abstract class BaseDevice {
Future<void> connect();
Future<void> handleButtonsClicked(List<ControllerButton>? buttonsClicked) async {
Future<void> handleButtonsClickedWithoutLongPressSupport(List<ControllerButton> clickedButtons) async {
if (clickedButtons.length == 1) {
final keyPair = core.actionHandler.supportedApp?.keymap.getKeyPair(clickedButtons.single);
if (keyPair != null && (keyPair.isLongPress || keyPair.inGameAction?.isLongPress == true)) {
// For long press actions: perform down, wait, then release
await handleButtonsClicked(clickedButtons, longPress: true);
_longPressTimer?.cancel();
await Future.delayed(const Duration(milliseconds: 800));
await handleButtonsClicked([], longPress: true);
} else {
// For non-long-press actions: perform a single click
// First call performs the click action (isKeyDown: true, isKeyUp: true)
await handleButtonsClicked(clickedButtons);
// Second call cleans up state (clears timer, logs release, clears _previouslyPressedButtons)
// but doesn't perform a release action since longPress: false
await handleButtonsClicked([]);
}
} else {
await handleButtonsClicked(clickedButtons);
await handleButtonsClicked([]);
}
}
Future<void> handleButtonsClicked(List<ControllerButton>? buttonsClicked, {bool longPress = false}) async {
try {
await _handleButtonsClickedInternal(buttonsClicked);
await _handleButtonsClickedInternal(buttonsClicked, longPress: longPress);
} catch (e, st) {
actionStreamInternal.add(
LogNotification('Error handling button clicks: $e\n$st'),
@@ -49,7 +101,7 @@ abstract class BaseDevice {
}
}
Future<void> _handleButtonsClickedInternal(List<ControllerButton>? buttonsClicked) async {
Future<void> _handleButtonsClickedInternal(List<ControllerButton>? buttonsClicked, {required bool longPress}) async {
if (buttonsClicked == null) {
// ignore, no changes
} else if (buttonsClicked.isEmpty) {
@@ -59,8 +111,9 @@ abstract class BaseDevice {
// Handle release events for long press keys
final buttonsReleased = _previouslyPressedButtons.toList();
final isLongPress =
longPress ||
buttonsReleased.singleOrNull != null &&
actionHandler.supportedApp?.keymap.getKeyPair(buttonsReleased.single)?.isLongPress == true;
core.actionHandler.supportedApp?.keymap.getKeyPair(buttonsReleased.single)?.isLongPress == true;
if (buttonsReleased.isNotEmpty && isLongPress) {
await performRelease(buttonsReleased);
}
@@ -71,15 +124,17 @@ abstract class BaseDevice {
// Handle release events for buttons that are no longer pressed
final buttonsReleased = _previouslyPressedButtons.difference(buttonsClicked.toSet()).toList();
final wasLongPress =
longPress ||
buttonsReleased.singleOrNull != null &&
actionHandler.supportedApp?.keymap.getKeyPair(buttonsReleased.single)?.isLongPress == true;
core.actionHandler.supportedApp?.keymap.getKeyPair(buttonsReleased.single)?.isLongPress == true;
if (buttonsReleased.isNotEmpty && wasLongPress) {
await performRelease(buttonsReleased);
}
final isLongPress =
longPress ||
buttonsClicked.singleOrNull != null &&
actionHandler.supportedApp?.keymap.getKeyPair(buttonsClicked.single)?.isLongPress == true;
core.actionHandler.supportedApp?.keymap.getKeyPair(buttonsClicked.single)?.isLongPress == true;
if (!isLongPress &&
!(buttonsClicked.singleOrNull == ZwiftButtons.onOffLeft ||
@@ -101,43 +156,117 @@ abstract class BaseDevice {
}
}
String _getCommandLimitMessage() {
return AppLocalizations.current.dailyCommandLimitReachedNotification;
}
String _getCommandLimitTitle() {
return AppLocalizations.current
.dailyLimitReached(IAPManager.dailyCommandLimit, IAPManager.dailyCommandLimit)
.replaceAll(
'${IAPManager.dailyCommandLimit}/${IAPManager.dailyCommandLimit}',
IAPManager.dailyCommandLimit.toString(),
)
.replaceAll(
'${IAPManager.dailyCommandLimit} / ${IAPManager.dailyCommandLimit}',
IAPManager.dailyCommandLimit.toString(),
);
}
Future<void> performDown(List<ControllerButton> buttonsClicked) async {
for (final action in buttonsClicked) {
// Check IAP status before executing command
if (!IAPManager.instance.canExecuteCommand) {
//actionStreamInternal.add(AlertNotification(LogLevel.LOGLEVEL_ERROR, _getCommandLimitMessage()));
continue;
}
// For repeated actions, don't trigger key down/up events (useful for long press)
final result = await actionHandler.performAction(action, isKeyDown: true, isKeyUp: false);
actionStreamInternal.add(
ActionNotification(result),
);
final result = await core.actionHandler.performAction(action, isKeyDown: true, isKeyUp: false);
actionStreamInternal.add(ActionNotification(result));
}
}
Future<void> performClick(List<ControllerButton> buttonsClicked) async {
for (final action in buttonsClicked) {
final result = await actionHandler.performAction(action, isKeyDown: true, isKeyUp: true);
actionStreamInternal.add(
ActionNotification(result),
);
// Check IAP status before executing command
if (!IAPManager.instance.canExecuteCommand) {
_showCommandLimitAlert();
continue;
}
final result = await core.actionHandler.performAction(action, isKeyDown: true, isKeyUp: true);
actionStreamInternal.add(ActionNotification(result));
}
}
Future<void> performRelease(List<ControllerButton> buttonsReleased) async {
for (final action in buttonsReleased) {
final result = await actionHandler.performAction(action, isKeyDown: false, isKeyUp: true);
actionStreamInternal.add(
ActionNotification(result),
);
// Check IAP status before executing command
if (!IAPManager.instance.canExecuteCommand) {
_showCommandLimitAlert();
continue;
}
final result = await core.actionHandler.performAction(action, isKeyDown: false, isKeyUp: true);
actionStreamInternal.add(LogNotification(result.message));
}
}
Future<void> disconnect() async {
_longPressTimer?.cancel();
// Release any held keys in long press mode
if (actionHandler is DesktopActions) {
await (actionHandler as DesktopActions).releaseAllHeldKeys(_previouslyPressedButtons.toList());
if (core.actionHandler is DesktopActions) {
await (core.actionHandler as DesktopActions).releaseAllHeldKeys(_previouslyPressedButtons.toList());
}
_previouslyPressedButtons.clear();
isConnected = false;
}
Widget showInformation(BuildContext context);
ControllerButton getOrAddButton(String key, ControllerButton Function() creator) {
if (core.actionHandler.supportedApp == null) {
return creator();
}
if (core.actionHandler.supportedApp is! CustomApp) {
final currentProfile = core.actionHandler.supportedApp!.name;
// should we display this to the user?
KeymapManager().duplicateSync(currentProfile, '$currentProfile (Copy)');
}
var createdButton = creator();
if (createdButton.sourceDeviceId == null) {
createdButton = createdButton.copyWith(sourceDeviceId: uniqueId);
}
final button = core.actionHandler.supportedApp!.keymap.getOrAddButton(key, createdButton);
if (availableButtons.none((e) => e.name == button.name)) {
availableButtons.add(button);
core.settings.setKeyMap(core.actionHandler.supportedApp!);
}
return button;
}
void _showCommandLimitAlert() {
actionStreamInternal.add(
AlertNotification(
LogLevel.LOGLEVEL_ERROR,
_getCommandLimitMessage(),
buttonTitle: AppLocalizations.current.purchase,
onTap: () {
IAPManager.instance.purchaseFullVersion(navigatorKey.currentContext!);
},
),
);
core.flutterLocalNotificationsPlugin.show(
1337,
_getCommandLimitTitle(),
_getCommandLimitMessage(),
NotificationDetails(
android: AndroidNotificationDetails('Limit', 'Limit reached'),
iOS: DarwinNotificationDetails(presentAlert: true),
),
);
}
}

View File

@@ -1,32 +1,57 @@
import 'dart:async';
import 'package:bike_control/bluetooth/ble.dart';
import 'package:bike_control/bluetooth/devices/base_device.dart';
import 'package:bike_control/bluetooth/devices/openbikecontrol/openbikecontrol_device.dart';
import 'package:bike_control/bluetooth/devices/proxy/proxy_device.dart';
import 'package:bike_control/bluetooth/devices/shimano/shimano_di2.dart';
import 'package:bike_control/bluetooth/devices/sram/sram_axs.dart';
import 'package:bike_control/bluetooth/devices/wahoo/wahoo_kickr_bike_pro.dart';
import 'package:bike_control/bluetooth/devices/wahoo/wahoo_kickr_bike_shift.dart';
import 'package:bike_control/bluetooth/devices/wahoo/wahoo_kickr_headwind.dart';
import 'package:bike_control/bluetooth/devices/zwift/constants.dart';
import 'package:bike_control/bluetooth/devices/zwift/zwift_click.dart';
import 'package:bike_control/bluetooth/devices/zwift/zwift_clickv2.dart';
import 'package:bike_control/bluetooth/devices/zwift/zwift_device.dart';
import 'package:bike_control/bluetooth/devices/zwift/zwift_play.dart';
import 'package:bike_control/bluetooth/devices/zwift/zwift_ride.dart';
import 'package:bike_control/pages/device.dart';
import 'package:bike_control/utils/core.dart';
import 'package:bike_control/utils/i18n_extension.dart';
import 'package:bike_control/utils/keymap/buttons.dart';
import 'package:bike_control/widgets/ui/beta_pill.dart';
import 'package:bike_control/widgets/ui/device_info.dart';
import 'package:bike_control/widgets/ui/loading_widget.dart';
import 'package:bike_control/widgets/ui/small_progress_indicator.dart';
import 'package:bike_control/widgets/ui/toast.dart';
import 'package:dartx/dartx.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:swift_control/bluetooth/ble.dart';
import 'package:swift_control/bluetooth/devices/base_device.dart';
import 'package:swift_control/bluetooth/devices/shimano/shimano_di2.dart';
import 'package:swift_control/bluetooth/devices/wahoo/wahoo_kickr_bike_shift.dart';
import 'package:swift_control/bluetooth/devices/zwift/constants.dart';
import 'package:swift_control/bluetooth/devices/zwift/zwift_click.dart';
import 'package:swift_control/bluetooth/devices/zwift/zwift_clickv2.dart';
import 'package:swift_control/bluetooth/devices/zwift/zwift_device.dart';
import 'package:swift_control/bluetooth/devices/zwift/zwift_play.dart';
import 'package:swift_control/bluetooth/devices/zwift/zwift_ride.dart';
import 'package:swift_control/main.dart';
import 'package:swift_control/pages/device.dart';
import 'package:swift_control/widgets/beta_pill.dart';
import 'package:shadcn_flutter/shadcn_flutter.dart';
import 'package:universal_ble/universal_ble.dart';
import 'cycplus/cycplus_bc2.dart';
import 'elite/elite_square.dart';
import 'elite/elite_sterzo.dart';
import 'thinkrider/thinkrider_vs200.dart';
abstract class BluetoothDevice extends BaseDevice {
final BleDevice scanResult;
BluetoothDevice(this.scanResult, {required super.availableButtons, super.isBeta = false})
: super(scanResult.name ?? 'Unknown Device') {
BluetoothDevice(
this.scanResult, {
required List<ControllerButton> availableButtons,
bool allowMultiple = false,
bool isBeta = false,
String? buttonPrefix,
}) : super(
scanResult.name,
uniqueId: scanResult.deviceId,
availableButtons: allowMultiple
? availableButtons.toList().map((b) => b.copyWith(sourceDeviceId: scanResult.deviceId)).toList()
: availableButtons.toList(),
isBeta: isBeta,
buttonPrefix: buttonPrefix,
) {
rssi = scanResult.rssi;
}
@@ -36,29 +61,47 @@ abstract class BluetoothDevice extends BaseDevice {
static List<String> servicesToScan = [
ZwiftConstants.ZWIFT_CUSTOM_SERVICE_UUID,
ZwiftConstants.ZWIFT_CUSTOM_SERVICE_SHORT_UUID,
ZwiftConstants.ZWIFT_RIDE_CUSTOM_SERVICE_UUID,
SquareConstants.SERVICE_UUID,
WahooKickrBikeShiftConstants.SERVICE_UUID,
WahooKickrHeadwindConstants.SERVICE_UUID,
SterzoConstants.SERVICE_UUID,
CycplusBc2Constants.SERVICE_UUID,
ShimanoDi2Constants.SERVICE_UUID,
ShimanoDi2Constants.SERVICE_UUID_ALTERNATIVE,
OpenBikeControlConstants.SERVICE_UUID,
ThinkRiderVs200Constants.SERVICE_UUID,
];
static final List<String> _ignoredNames = ['ASSIOMA', 'QUARQ', 'POWERCRANK'];
static BluetoothDevice? fromScanResult(BleDevice scanResult) {
// skip devices with ignored names
if (scanResult.name != null &&
_ignoredNames.any((ignoredName) => scanResult.name!.toUpperCase().startsWith(ignoredName))) {
return null;
}
// Use the name first as the "System Devices" and Web (android sometimes Windows) don't have manufacturer data
BluetoothDevice? device;
if (kIsWeb) {
device = switch (scanResult.name) {
'Zwift Ride' => ZwiftRide(scanResult),
'Zwift Play' => ZwiftPlay(scanResult),
'Zwift Play' => ZwiftPlay(scanResult, deviceType: ZwiftDeviceType.playLeft),
'Zwift Click' => ZwiftClickV2(scanResult),
'SQUARE' => EliteSquare(scanResult),
'OpenBike' => OpenBikeControlDevice(scanResult),
null => null,
_ when scanResult.name!.toUpperCase().startsWith('HEADWIND') => WahooKickrHeadwind(scanResult),
_ when scanResult.name!.toUpperCase().startsWith('STERZO') => EliteSterzo(scanResult),
_ when scanResult.name!.toUpperCase().startsWith('KICKR BIKE SHIFT') => WahooKickrBikeShift(scanResult),
_ when scanResult.name!.toUpperCase().startsWith('KICKR BIKE PRO') => WahooKickrBikePro(scanResult),
_ when scanResult.name!.toUpperCase().startsWith('CYCPLUS') && scanResult.name!.toUpperCase().contains('BC2') =>
CycplusBc2(scanResult),
_ when scanResult.name!.toUpperCase().startsWith('THINK VS') => ThinkRiderVs200(scanResult),
_ when scanResult.name!.toUpperCase().startsWith('RDR') => ShimanoDi2(scanResult),
_ when scanResult.name!.toUpperCase().startsWith('SRAM') => SramAxs(scanResult),
_ => null,
};
} else {
@@ -66,15 +109,29 @@ abstract class BluetoothDevice extends BaseDevice {
null => null,
//'Zwift Ride' => ZwiftRide(scanResult), special case for Zwift Ride: we must only connect to the left controller
// https://www.makinolo.com/blog/2024/07/26/zwift-ride-protocol/
'Zwift Play' => ZwiftPlay(scanResult),
//'Zwift Play' => ZwiftPlay(scanResult),
//'Zwift Click' => ZwiftClick(scanResult), special case for Zwift Click v2: we must only connect to the left controller
_ when scanResult.name!.toUpperCase().startsWith('HEADWIND') => WahooKickrHeadwind(scanResult),
_ when scanResult.name!.toUpperCase().startsWith('SQUARE') => EliteSquare(scanResult),
_ when scanResult.name!.toUpperCase().startsWith('STERZO') => EliteSterzo(scanResult),
_ when scanResult.name!.toUpperCase().contains('KICKR BIKE SHIFT') => WahooKickrBikeShift(scanResult),
_ when scanResult.name!.toUpperCase().startsWith('KICKR BIKE PRO') => WahooKickrBikePro(scanResult),
_ when scanResult.name!.toUpperCase().startsWith('CYCPLUS') && scanResult.name!.toUpperCase().contains('BC2') =>
CycplusBc2(scanResult),
_ when scanResult.services.contains(CycplusBc2Constants.SERVICE_UUID.toLowerCase()) => CycplusBc2(scanResult),
_ when scanResult.name!.toUpperCase().startsWith('THINK VS') => ThinkRiderVs200(scanResult),
//_ when scanResult.services.contains(CycplusBc2Constants.SERVICE_UUID.toLowerCase()) => CycplusBc2(scanResult),
_ when scanResult.services.contains(ShimanoDi2Constants.SERVICE_UUID.toLowerCase()) => ShimanoDi2(scanResult),
_ when scanResult.services.contains(ShimanoDi2Constants.SERVICE_UUID_ALTERNATIVE.toLowerCase()) => ShimanoDi2(
scanResult,
),
_ when scanResult.services.containsAny(ProxyDevice.proxyServiceUUIDs) && kDebugMode => ProxyDevice(scanResult),
_ when scanResult.services.contains(SramAxsConstants.SERVICE_UUID.toLowerCase()) => SramAxs(
scanResult,
),
_ when scanResult.services.contains(OpenBikeControlConstants.SERVICE_UUID.toLowerCase()) =>
OpenBikeControlDevice(scanResult),
_ when scanResult.services.contains(WahooKickrHeadwindConstants.SERVICE_UUID.toLowerCase()) =>
WahooKickrHeadwind(scanResult),
// otherwise the service UUIDs will be used
_ => null,
};
@@ -84,6 +141,7 @@ abstract class BluetoothDevice extends BaseDevice {
return device;
} else if (scanResult.services.containsAny([
ZwiftConstants.ZWIFT_CUSTOM_SERVICE_UUID.toLowerCase(),
ZwiftConstants.ZWIFT_CUSTOM_SERVICE_SHORT_UUID.toLowerCase(),
ZwiftConstants.ZWIFT_RIDE_CUSTOM_SERVICE_UUID.toLowerCase(),
])) {
// otherwise use the manufacturer data to identify the device
@@ -93,23 +151,31 @@ abstract class BluetoothDevice extends BaseDevice {
?.payload;
if (data == null || data.isEmpty) {
return null;
} else {
final type = ZwiftDeviceType.fromManufacturerData(data.first);
device = switch (type) {
ZwiftDeviceType.click => ZwiftClick(scanResult),
ZwiftDeviceType.playRight => ZwiftPlay(scanResult, deviceType: type!),
ZwiftDeviceType.playLeft => ZwiftPlay(scanResult, deviceType: type!),
ZwiftDeviceType.rideLeft => ZwiftRide(scanResult),
//DeviceType.rideRight => ZwiftRide(scanResult), // see comment above
ZwiftDeviceType.clickV2Left => ZwiftClickV2(scanResult),
//DeviceType.clickV2Right => ZwiftClickV2(scanResult), // see comment above
_ => null,
};
}
final type = ZwiftDeviceType.fromManufacturerData(data.first);
return switch (type) {
ZwiftDeviceType.click => ZwiftClick(scanResult),
ZwiftDeviceType.playRight => ZwiftPlay(scanResult),
ZwiftDeviceType.playLeft => ZwiftPlay(scanResult),
ZwiftDeviceType.rideLeft => ZwiftRide(scanResult),
//DeviceType.rideRight => ZwiftRide(scanResult), // see comment above
ZwiftDeviceType.clickV2Left => ZwiftClickV2(scanResult),
//DeviceType.clickV2Right => ZwiftClickV2(scanResult), // see comment above
_ => null,
};
} else {
return null;
}
if (scanResult.name == 'Zwift Ride' &&
device == null &&
core.connection.controllerDevices.none((d) => d is ZwiftRide)) {
// Fallback for Zwift Ride if nothing else matched => old firmware
buildToast(
title: 'You may need to update your Zwift Ride firmware.',
duration: Duration(seconds: 6),
);
}
return device;
}
@override
@@ -120,20 +186,16 @@ abstract class BluetoothDevice extends BaseDevice {
@override
int get hashCode => scanResult.deviceId.hashCode;
@override
String toString() {
return name + (firmwareVersion != null ? ' v$firmwareVersion' : '');
}
BleDevice get device => scanResult;
@override
Future<void> connect() async {
actionStream.listen((message) {
print("Received message: $message");
});
await UniversalBle.connect(device.deviceId);
try {
await UniversalBle.connect(device.deviceId);
} catch (e) {
isConnected = false;
rethrow;
}
if (!kIsWeb) {
await UniversalBle.requestMtu(device.deviceId, 517);
@@ -153,7 +215,8 @@ abstract class BluetoothDevice extends BaseDevice {
firmwareCharacteristic.uuid,
);
firmwareVersion = String.fromCharCodes(firmwareData);
connection.signalChange(this);
core.connection.signalChange(this);
}
final batteryService = services.firstOrNullWhere(
@@ -171,7 +234,7 @@ abstract class BluetoothDevice extends BaseDevice {
);
if (batteryData.isNotEmpty) {
batteryLevel = batteryData.first;
connection.signalChange(this);
core.connection.signalChange(this);
}
}
@@ -189,63 +252,134 @@ abstract class BluetoothDevice extends BaseDevice {
@override
Widget showInformation(BuildContext context) {
return Row(
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
device.name?.screenshot ?? runtimeType.toString(),
style: TextStyle(fontWeight: FontWeight.bold),
),
if (isBeta) BetaPill(),
if (batteryLevel != null) ...[
Icon(switch (batteryLevel!) {
>= 80 => Icons.battery_full,
>= 60 => Icons.battery_6_bar,
>= 50 => Icons.battery_5_bar,
>= 25 => Icons.battery_4_bar,
>= 10 => Icons.battery_2_bar,
_ => Icons.battery_alert,
}),
Text('$batteryLevel%'),
],
if (firmwareVersion != null) Text(' - v$firmwareVersion'),
if (firmwareVersion != null &&
this is ZwiftDevice &&
firmwareVersion != (this as ZwiftDevice).latestFirmwareVersion) ...[
SizedBox(width: 8),
Icon(Icons.warning, color: Theme.of(context).colorScheme.error),
Text(
' (latest: ${(this as ZwiftDevice).latestFirmwareVersion})',
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
],
if (rssi != null)
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Tooltip(
message: 'Signal Strength: $rssi dBm',
child: Icon(
switch (rssi!) {
>= -50 => Icons.signal_cellular_4_bar,
>= -60 => Icons.signal_cellular_alt_2_bar,
>= -70 => Icons.signal_cellular_alt_1_bar,
_ => Icons.signal_cellular_alt,
},
size: 18,
),
Row(
spacing: 8,
children: [
Text(
toString().screenshot ?? runtimeType.toString(),
style: TextStyle(fontWeight: FontWeight.bold),
),
),
Expanded(child: SizedBox()),
PopupMenuButton(
itemBuilder: (c) => [
PopupMenuItem(
child: Text('Disconnect and Forget'),
onTap: () {
connection.disconnect(this, forget: true);
if (isBeta) BetaPill(),
Expanded(child: SizedBox()),
Builder(
builder: (context) {
return LoadingWidget(
futureCallback: () async {
final completer = showDropdown<bool>(
context: context,
builder: (c) => DropdownMenu(
children: [
MenuButton(
child: Text('Disconnect and Forget for this session'),
onPressed: (context) {
closeOverlay(context, false);
},
),
MenuButton(
child: Text('Disconnect and Forget'),
onPressed: (context) {
closeOverlay(context, true);
},
),
],
),
);
final persist = await completer.future;
if (persist != null) {
await core.connection.disconnect(this, forget: true, persistForget: persist);
}
},
renderChild: (isLoading, tap) => IconButton(
variance: ButtonVariance.muted,
icon: isLoading ? SmallProgressIndicator() : Icon(Icons.clear),
onPressed: tap,
),
);
},
),
],
),
Wrap(
spacing: 12,
runSpacing: 12,
children: [
DeviceInfo(
title: context.i18n.connection,
icon: switch (isConnected) {
true => Icons.bluetooth_connected_outlined,
false => Icons.bluetooth_disabled_outlined,
},
value: isConnected ? context.i18n.connected : context.i18n.disconnected,
),
if (batteryLevel != null)
DeviceInfo(
title: context.i18n.battery,
icon: switch (batteryLevel!) {
>= 80 => Icons.battery_full,
>= 60 => Icons.battery_6_bar,
>= 50 => Icons.battery_5_bar,
>= 25 => Icons.battery_4_bar,
>= 10 => Icons.battery_2_bar,
_ => Icons.battery_alert,
},
value: '$batteryLevel%',
),
if (firmwareVersion != null)
DeviceInfo(
title: context.i18n.firmware,
icon: this is ZwiftDevice && firmwareVersion != (this as ZwiftDevice).latestFirmwareVersion
? Icons.warning
: Icons.text_fields_sharp,
value: firmwareVersion!,
additionalInfo: (this is ZwiftDevice && firmwareVersion != (this as ZwiftDevice).latestFirmwareVersion)
? Text(
' (${context.i18n.latestVersion((this as ZwiftDevice).latestFirmwareVersion)})',
style: TextStyle(color: Theme.of(context).colorScheme.destructive, fontSize: 12),
)
: null,
),
if (rssi != null)
StreamBuilder(
stream: core.connection.rssiConnectionStream
.where((device) => device == this)
.map((event) => event.rssi),
builder: (context, rssiValue) {
return DeviceInfo(
title: context.i18n.signal,
icon: switch (rssiValue.data ?? rssi!) {
>= -50 => Icons.signal_cellular_4_bar,
>= -60 => Icons.signal_cellular_alt_2_bar,
>= -70 => Icons.signal_cellular_alt_1_bar,
_ => Icons.signal_cellular_alt,
},
value: '$rssi dBm',
);
},
),
],
),
],
);
}
void debugSubscribeToAll(List<BleService> services) {
for (final service in services) {
for (final characteristic in service.characteristics) {
if (characteristic.properties.contains(CharacteristicProperty.indicate)) {
debugPrint('Subscribing to indications for ${service.uuid} / ${characteristic.uuid}');
UniversalBle.subscribeIndications(device.deviceId, service.uuid, characteristic.uuid);
}
if (characteristic.properties.contains(CharacteristicProperty.notify)) {
debugPrint('Subscribing to notifications for ${service.uuid} / ${characteristic.uuid}');
UniversalBle.subscribeNotifications(device.deviceId, service.uuid, characteristic.uuid);
}
}
}
}
}

View File

@@ -1,8 +1,8 @@
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:swift_control/bluetooth/messages/notification.dart';
import 'package:swift_control/utils/keymap/buttons.dart';
import 'package:bike_control/bluetooth/messages/notification.dart';
import 'package:bike_control/utils/keymap/buttons.dart';
import 'package:universal_ble/universal_ble.dart';
import '../bluetooth_device.dart';
@@ -11,6 +11,7 @@ class CycplusBc2 extends BluetoothDevice {
CycplusBc2(super.scanResult)
: super(
availableButtons: CycplusBc2Buttons.values,
allowMultiple: true,
);
@override
@@ -40,7 +41,7 @@ class CycplusBc2 extends BluetoothDevice {
// Process index 6 (shift up)
final currentByte6 = bytes[6];
if (_shouldTriggerShift(currentByte6, _lastStateIndex6)) {
buttonsToPress.add(CycplusBc2Buttons.shiftUp);
buttonsToPress.add(availableButtons[0]);
_lastStateIndex6 = 0x00; // Reset after successful press
} else {
_updateState(currentByte6, (val) => _lastStateIndex6 = val);
@@ -49,7 +50,7 @@ class CycplusBc2 extends BluetoothDevice {
// Process index 7 (shift down)
final currentByte7 = bytes[7];
if (_shouldTriggerShift(currentByte7, _lastStateIndex7)) {
buttonsToPress.add(CycplusBc2Buttons.shiftDown);
buttonsToPress.add(availableButtons[1]);
_lastStateIndex7 = 0x00; // Reset after successful press
} else {
_updateState(currentByte7, (val) => _lastStateIndex7 = val);

View File

@@ -1,7 +1,6 @@
import 'dart:typed_data';
import 'package:dartx/dartx.dart';
import 'package:swift_control/utils/keymap/buttons.dart';
import 'package:flutter/foundation.dart';
import 'package:bike_control/utils/keymap/buttons.dart';
import 'package:universal_ble/universal_ble.dart';
import '../../messages/notification.dart';
@@ -37,19 +36,19 @@ class EliteSquare extends BluetoothDevice {
if (characteristic == SquareConstants.CHARACTERISTIC_UUID) {
final fullValue = _bytesToHex(bytes);
final currentValue = _extractButtonCode(fullValue);
actionStreamInternal.add(LogNotification('Received $fullValue - vs $currentValue (last: $_lastValue)'));
if (kDebugMode) {
actionStreamInternal.add(LogNotification('Received $fullValue - vs $currentValue (last: $_lastValue)'));
}
if (_lastValue != null) {
final currentRelevantPart = fullValue.length >= 14
? fullValue.substring(6, 14)
: fullValue.substring(6);
final lastRelevantPart = _lastValue!.length >= 14
? _lastValue!.substring(6, 14)
: _lastValue!.substring(6);
final currentRelevantPart = fullValue.length >= 14 ? fullValue.substring(6, 14) : fullValue.substring(6);
final lastRelevantPart = _lastValue!.length >= 14 ? _lastValue!.substring(6, 14) : _lastValue!.substring(6);
if (currentRelevantPart != lastRelevantPart) {
final buttonClicked = SquareConstants.BUTTON_MAPPING[currentValue];
actionStreamInternal.add(LogNotification('Button pressed: $buttonClicked'));
if (kDebugMode) {
actionStreamInternal.add(LogNotification('Button pressed: $buttonClicked'));
}
handleButtonsClicked([
if (buttonClicked != null) buttonClicked,
]);

View File

@@ -5,8 +5,8 @@ import 'package:dartx/dartx.dart';
import 'package:flutter/foundation.dart';
import 'package:http/http.dart' as http;
import 'package:shared_preferences/shared_preferences.dart';
import 'package:swift_control/bluetooth/devices/bluetooth_device.dart';
import 'package:swift_control/utils/keymap/buttons.dart';
import 'package:bike_control/bluetooth/devices/bluetooth_device.dart';
import 'package:bike_control/utils/keymap/buttons.dart';
import 'package:universal_ble/universal_ble.dart';
import '../../messages/notification.dart';

View File

@@ -1,38 +1,61 @@
import 'package:dartx/dartx.dart';
import 'package:flutter/material.dart';
import 'package:gamepads/gamepads.dart';
import 'package:swift_control/bluetooth/devices/base_device.dart';
import 'package:swift_control/bluetooth/messages/notification.dart';
import 'package:swift_control/main.dart';
import 'package:swift_control/pages/device.dart';
import 'package:swift_control/utils/keymap/apps/custom_app.dart';
import 'package:swift_control/utils/keymap/buttons.dart';
import 'package:swift_control/widgets/beta_pill.dart';
import 'dart:io';
import '../../../widgets/warning.dart';
import 'package:bike_control/bluetooth/devices/base_device.dart';
import 'package:bike_control/bluetooth/messages/notification.dart';
import 'package:bike_control/pages/device.dart';
import 'package:bike_control/utils/core.dart';
import 'package:bike_control/utils/keymap/buttons.dart';
import 'package:bike_control/widgets/ui/beta_pill.dart';
import 'package:bike_control/widgets/ui/warning.dart';
import 'package:dartx/dartx.dart';
import 'package:gamepads/gamepads.dart';
import 'package:shadcn_flutter/shadcn_flutter.dart';
class GamepadDevice extends BaseDevice {
final String id;
GamepadDevice(super.name, {required this.id}) : super(availableButtons: [], isBeta: true);
GamepadDevice(super.name, {required this.id}) : super(availableButtons: [], uniqueId: id);
List<ControllerButton> _lastButtonsClicked = [];
@override
Future<void> connect() async {
Gamepads.eventsByGamepad(id).listen((event) {
actionStreamInternal.add(LogNotification('Gamepad event: $event'));
Gamepads.eventsByGamepad(id).listen((event) async {
actionStreamInternal.add(LogNotification('Gamepad event: ${event.key} value ${event.value} type ${event.type}'));
ControllerButton? button = actionHandler.supportedApp?.keymap.getOrAddButton(
event.key,
() => ControllerButton(event.key),
final int normalizedValue = switch (event.value) {
> 1.0 => 1,
< -1.0 => -1,
_ => event.value.toInt(),
};
final buttonKey = event.type == KeyType.analog ? '${event.key}_$normalizedValue' : event.key;
ControllerButton button = getOrAddButton(
buttonKey,
() => ControllerButton(buttonKey, sourceDeviceId: id),
);
final buttonsClicked = event.value == 0.0 && button != null ? [button] : <ControllerButton>[];
if (_lastButtonsClicked.contentEquals(buttonsClicked) == false) {
handleButtonsClicked(buttonsClicked);
switch (event.type) {
case KeyType.analog:
final releasedValue = Platform.isWindows ? 1 : 0;
if (event.value.round().abs() != releasedValue) {
final buttonsClicked = [button];
if (_lastButtonsClicked.contentEquals(buttonsClicked) == false) {
handleButtonsClicked(buttonsClicked);
}
_lastButtonsClicked = buttonsClicked;
} else {
_lastButtonsClicked = [];
handleButtonsClicked([]);
}
case KeyType.button:
final buttonsClicked = event.value.toInt() != 1 ? [button] : <ControllerButton>[];
if (_lastButtonsClicked.contentEquals(buttonsClicked) == false) {
handleButtonsClicked(buttonsClicked);
}
_lastButtonsClicked = buttonsClicked;
}
_lastButtonsClicked = buttonsClicked;
});
}
@@ -44,19 +67,21 @@ class GamepadDevice extends BaseDevice {
spacing: 8,
children: [
Row(
spacing: 8,
children: [
Text(
name.screenshot,
toString().screenshot,
style: TextStyle(fontWeight: FontWeight.bold),
),
if (isBeta) BetaPill(),
],
),
if (actionHandler.supportedApp is! CustomApp)
if (Platform.isAndroid && !core.settings.getLocalEnabled())
Warning(
children: [
Text('Use a custom keymap to use the buttons on $name.'),
Text(
'For it to work properly, even when BikeControl is in the background, you need to enable the local connection method in the next tab.',
).small,
],
),
],

View File

@@ -0,0 +1,485 @@
import 'dart:async';
import 'dart:math';
import 'package:bike_control/bluetooth/devices/base_device.dart';
import 'package:bike_control/bluetooth/devices/gyroscope/steering_estimator.dart';
import 'package:bike_control/bluetooth/messages/notification.dart';
import 'package:bike_control/pages/device.dart';
import 'package:bike_control/utils/core.dart';
import 'package:bike_control/utils/keymap/buttons.dart';
import 'package:bike_control/widgets/ui/beta_pill.dart';
import 'package:bike_control/widgets/ui/device_info.dart';
import 'package:bike_control/widgets/ui/small_progress_indicator.dart';
import 'package:flutter/foundation.dart';
import 'package:sensors_plus/sensors_plus.dart';
import 'package:shadcn_flutter/shadcn_flutter.dart';
/// Gyroscope and Accelerometer based steering device
/// Detects handlebar movement when the phone is mounted on the handlebar
class GyroscopeSteering extends BaseDevice {
GyroscopeSteering()
: super(
'Phone Steering',
availableButtons: GyroscopeSteeringButtons.values,
isBeta: true,
uniqueId: 'gyroscope_steering_device',
buttonPrefix: 'gyro',
);
StreamSubscription<GyroscopeEvent>? _gyroscopeSubscription;
StreamSubscription<AccelerometerEvent>? _accelerometerSubscription;
StreamSubscription<MagnetometerEvent>? _magnetometerSubscription;
// Calibration state
final SteeringEstimator _estimator = SteeringEstimator();
bool _isCalibrated = false;
ControllerButton? _lastSteeringButton;
// Accelerometer raw data
bool _hasAccelData = false;
// Time tracking for integration
DateTime? _lastGyroUpdate;
// Last rounded angle for change detection
int? _lastRoundedAngle;
// Debounce timer for PWM-like keypress behavior
Timer? _keypressTimer;
// Magnetometer mode
bool _useMagnetometer = false;
double? _magnetometerCalibrationHeading;
double _currentMagnetometerAngle = 0.0;
final List<double> _magnetometerCalibrationSamples = [];
// Magnetometer filtering state
double? _filteredMagX;
double? _filteredMagY;
static const double _magnetometerFilterAlpha = 0.15; // Lower = more smoothing
// Configuration (can be made customizable later)
static const double STEERING_THRESHOLD = 5.0; // degrees
static const double LEVEL_DEGREE_STEP = 10.0; // degrees per level
static const int MAX_LEVELS = 5;
static const int KEY_REPEAT_INTERVAL_MS = 40;
static const double COMPLEMENTARY_FILTER_ALPHA = 0.98; // Weight for gyroscope
static const double LOW_PASS_FILTER_ALPHA = 0.9; // Smoothing factor
/// Start listening to the appropriate sensors based on the current mode
Future<void> _startSensorStreams() async {
// Cancel all existing subscriptions first
await _gyroscopeSubscription?.cancel();
await _accelerometerSubscription?.cancel();
await _magnetometerSubscription?.cancel();
_gyroscopeSubscription = null;
_accelerometerSubscription = null;
_magnetometerSubscription = null;
if (_useMagnetometer) {
// Magnetometer mode: only listen to magnetometer
_magnetometerSubscription = magnetometerEventStream().listen(
_handleMagnetometerEvent,
onError: (error) {
actionStreamInternal.add(LogNotification('Magnetometer error: $error'));
},
);
actionStreamInternal.add(LogNotification('Started magnetometer stream'));
} else {
// Gyroscope mode: listen to gyroscope and accelerometer
_gyroscopeSubscription = gyroscopeEventStream().listen(
_handleGyroscopeEvent,
onError: (error) {
actionStreamInternal.add(LogNotification('Gyroscope error: $error'));
},
);
_accelerometerSubscription = accelerometerEventStream().listen(
_handleAccelerometerEvent,
onError: (error) {
actionStreamInternal.add(LogNotification('Accelerometer error: $error'));
},
);
actionStreamInternal.add(LogNotification('Started gyroscope and accelerometer streams'));
}
}
@override
Future<void> connect() async {
if (isConnected) {
return;
}
try {
// Start listening to sensors based on current mode
await _startSensorStreams();
isConnected = true;
actionStreamInternal.add(LogNotification('Gyroscope Steering: Connected - Calibrating...'));
// Reset calibration/estimator
_isCalibrated = false;
_hasAccelData = false;
_estimator.reset();
_lastGyroUpdate = null;
_lastRoundedAngle = null;
_lastSteeringButton = null;
} catch (e) {
actionStreamInternal.add(LogNotification('Failed to connect Gyroscope Steering: $e'));
isConnected = false;
rethrow;
}
}
void _handleGyroscopeEvent(GyroscopeEvent event) {
final now = DateTime.now();
if (!_hasAccelData) {
_lastGyroUpdate = now;
return;
}
final dt = _lastGyroUpdate != null ? (now.difference(_lastGyroUpdate!).inMicroseconds / 1000000.0) : 0.0;
_lastGyroUpdate = now;
if (dt <= 0 || dt >= 1.0) {
return;
}
// iOS drift fix:
// - integrate bias-corrected gyro z (yaw) into an estimator
// - learn bias while the device is still
final angleDeg = _estimator.updateGyro(wz: event.z, dt: dt);
if (!_isCalibrated) {
// Consider calibration complete once we have a bit of stillness and sensor data.
// This gives the bias estimator time to settle.
if (_estimator.stillTimeSec >= 0.6) {
_estimator.calibrate(seedBiasZRadPerSec: _estimator.biasZRadPerSec);
_isCalibrated = true;
/*actionStreamInternal.add(
AlertNotification(LogLevel.LOGLEVEL_INFO, 'Calibration complete.'),
);*/
}
return;
}
_processSteeringAngle(angleDeg);
}
void _handleAccelerometerEvent(AccelerometerEvent event) {
_hasAccelData = true;
_estimator.updateAccel(x: event.x, y: event.y, z: event.z);
}
void _handleMagnetometerEvent(MagnetometerEvent event) {
// Magnetometer mode: calculate heading from X and Y components
// This is more stable than using a single axis
// Apply low-pass filter to reduce noise
if (_filteredMagX == null || _filteredMagY == null) {
// Initialize on first reading
_filteredMagX = event.x;
_filteredMagY = event.y;
} else {
// Exponential moving average (low-pass filter)
_filteredMagX = _magnetometerFilterAlpha * event.x + (1 - _magnetometerFilterAlpha) * _filteredMagX!;
_filteredMagY = _magnetometerFilterAlpha * event.y + (1 - _magnetometerFilterAlpha) * _filteredMagY!;
}
// Calculate heading from filtered X and Y components
// atan2(y, x) gives the angle in radians, convert to degrees
double heading = atan2(_filteredMagY!, _filteredMagX!) * (180 / pi);
// Normalize heading to 0-360 range
if (heading < 0) heading += 360;
if (kDebugMode) {
print(
'Magnetometer - X: ${event.x.toStringAsFixed(2)}, Y: ${event.y.toStringAsFixed(2)}, '
'Filtered X: ${_filteredMagX!.toStringAsFixed(2)}, Filtered Y: ${_filteredMagY!.toStringAsFixed(2)}, '
'Heading: ${heading.toStringAsFixed(2)}°',
);
}
// During calibration, collect heading samples
if (!_isCalibrated) {
_magnetometerCalibrationSamples.add(heading);
// After 30 samples (~1 second at typical rates), calculate calibration heading
if (_magnetometerCalibrationSamples.length >= 30) {
// For heading, we need to handle the circular nature (0° and 360° are the same)
// Use circular mean calculation
double sumSin = 0, sumCos = 0;
for (var h in _magnetometerCalibrationSamples) {
final radians = h * (pi / 180);
sumSin += sin(radians);
sumCos += cos(radians);
}
final avgSin = sumSin / _magnetometerCalibrationSamples.length;
final avgCos = sumCos / _magnetometerCalibrationSamples.length;
_magnetometerCalibrationHeading = atan2(avgSin, avgCos) * (180 / pi);
if (_magnetometerCalibrationHeading! < 0)
_magnetometerCalibrationHeading = _magnetometerCalibrationHeading! + 360;
_magnetometerCalibrationSamples.clear();
_isCalibrated = true;
actionStreamInternal.add(
LogNotification(
'Magnetometer calibration complete. Reference heading: ${_magnetometerCalibrationHeading!.toStringAsFixed(2)}°',
),
);
}
return;
}
// Calculate steering angle relative to calibrated heading
// This is the angular difference, accounting for wrap-around
double angleDeg = heading - _magnetometerCalibrationHeading!;
// Normalize to -180 to +180 range
if (angleDeg > 180) {
angleDeg -= 360;
} else if (angleDeg < -180) {
angleDeg += 360;
}
_currentMagnetometerAngle = angleDeg;
_processSteeringAngle(angleDeg);
}
void _processSteeringAngle(double steeringAngleDeg) {
final roundedAngle = steeringAngleDeg.round();
if (_lastRoundedAngle != roundedAngle) {
if (kDebugMode) {
actionStreamInternal.add(
LogNotification(
'Steering angle: $roundedAngle° (biasZ=${_estimator.biasZRadPerSec.toStringAsFixed(4)} rad/s)',
),
);
}
_lastRoundedAngle = roundedAngle;
_applyPWMSteering(roundedAngle);
}
}
/// Applies PWM-like steering behavior with repeated keypresses proportional to angle magnitude
void _applyPWMSteering(int roundedAngle) {
// Cancel any pending keypress timer
_keypressTimer?.cancel();
// Determine if we're steering
if (roundedAngle.abs() > core.settings.getPhoneSteeringThreshold()) {
// Determine direction
final button = roundedAngle < 0 ? GyroscopeSteeringButtons.rightSteer : GyroscopeSteeringButtons.leftSteer;
if (_lastSteeringButton != button) {
// New steering direction - reset any previous state
_lastSteeringButton = button;
} else {
return;
}
handleButtonsClicked([button]);
} else {
_lastSteeringButton = null;
// Center position - release any held buttons
handleButtonsClicked([]);
}
}
@override
Future<void> disconnect() async {
await _gyroscopeSubscription?.cancel();
await _accelerometerSubscription?.cancel();
await _magnetometerSubscription?.cancel();
_gyroscopeSubscription = null;
_accelerometerSubscription = null;
_magnetometerSubscription = null;
_keypressTimer?.cancel();
isConnected = false;
_isCalibrated = false;
_hasAccelData = false;
_estimator.reset();
_magnetometerCalibrationHeading = null;
_magnetometerCalibrationSamples.clear();
_currentMagnetometerAngle = 0.0;
_filteredMagX = null;
_filteredMagY = null;
actionStreamInternal.add(LogNotification('Gyroscope Steering: Disconnected'));
}
@override
Widget showInformation(BuildContext context) {
return StatefulBuilder(
builder: (c, setState) => Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 12,
children: [
Row(
spacing: 12,
children: [
Text(
toString().screenshot,
style: TextStyle(fontWeight: FontWeight.bold),
),
if (isBeta) BetaPill(),
],
),
// Magnetometer mode toggle
Checkbox(
trailing: Expanded(child: Text('Use Magnetometer Mode')),
state: _useMagnetometer ? CheckboxState.checked : CheckboxState.unchecked,
onChanged: (value) async {
setState(() {
_useMagnetometer = value == CheckboxState.checked;
// Reset calibration when switching modes
_isCalibrated = false;
_hasAccelData = false;
_estimator.reset();
_lastGyroUpdate = null;
_lastRoundedAngle = null;
_lastSteeringButton = null;
_magnetometerCalibrationHeading = null;
_magnetometerCalibrationSamples.clear();
_currentMagnetometerAngle = 0.0;
_filteredMagX = null;
_filteredMagY = null;
});
// Restart sensor streams if device is connected
if (isConnected) {
await _startSensorStreams();
actionStreamInternal.add(
LogNotification(
'Switched to ${_useMagnetometer ? "magnetometer" : "gyroscope + accelerometer"} mode',
),
);
}
},
),
Wrap(
spacing: 12,
runSpacing: 12,
children: [
DeviceInfo(
title: 'Calibration',
icon: BootstrapIcons.wrenchAdjustable,
value: _isCalibrated ? 'Complete' : 'In Progress',
),
DeviceInfo(
title: 'Steering Angle',
icon: RadixIcons.angle,
value: _isCalibrated
? '${(_useMagnetometer ? _currentMagnetometerAngle : _estimator.angleDeg).toStringAsFixed(2)}°'
: 'Calibrating...',
),
if (kDebugMode && !_useMagnetometer)
DeviceInfo(
title: 'Gyro Bias',
icon: BootstrapIcons.speedometer,
value: '${_estimator.biasZRadPerSec.toStringAsFixed(4)} rad/s',
),
if (kDebugMode && _useMagnetometer && _magnetometerCalibrationHeading != null)
DeviceInfo(
title: 'Mag Heading',
icon: BootstrapIcons.compass,
value: '${_magnetometerCalibrationHeading!.toStringAsFixed(2)}°',
),
],
),
Row(
spacing: 8,
children: [
PrimaryButton(
size: ButtonSize.small,
leading: !_isCalibrated ? SmallProgressIndicator() : null,
onPressed: !_isCalibrated
? null
: () {
// Reset calibration
_isCalibrated = false;
if (_useMagnetometer) {
_magnetometerCalibrationHeading = null;
_magnetometerCalibrationSamples.clear();
_currentMagnetometerAngle = 0.0;
_filteredMagX = null;
_filteredMagY = null;
} else {
_hasAccelData = false;
_estimator.reset();
_lastGyroUpdate = null;
}
_lastRoundedAngle = null;
_lastSteeringButton = null;
setState(() {});
},
child: Text(_isCalibrated ? 'Calibrate' : 'Calibrating...'),
),
Builder(
builder: (context) {
return PrimaryButton(
size: ButtonSize.small,
trailing: Container(
padding: EdgeInsets.symmetric(horizontal: 4),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.destructive,
borderRadius: BorderRadius.circular(4),
),
child: Text('${core.settings.getPhoneSteeringThreshold().toInt()}°'),
),
onPressed: () {
final values = [for (var i = 3; i <= 12; i += 1) i];
showDropdown(
context: context,
builder: (b) => DropdownMenu(
children: values
.map(
(v) => MenuButton(
child: Text('$v°'),
onPressed: (c) {
core.settings.setPhoneSteeringThreshold(v);
setState(() {});
},
),
)
.toList(),
),
);
},
child: Text('Trigger Threshold:'),
);
},
),
],
),
if (!_isCalibrated)
Text(
_useMagnetometer
? 'Calibrating the magnetometer now. Attach your phone/tablet on your handlebar and keep it still for a second.'
: 'Calibrating the sensors now. Attach your phone/tablet on your handlebar and keep it still for a second.',
).xSmall,
],
),
);
}
}
class GyroscopeSteeringButtons {
static final ControllerButton leftSteer = ControllerButton(
'gyroLeftSteer',
action: InGameAction.steerLeft,
);
static final ControllerButton rightSteer = ControllerButton(
'gyroRightSteer',
action: InGameAction.steerRight,
);
static List<ControllerButton> get values => [
leftSteer,
rightSteer,
];
}

View File

@@ -0,0 +1,200 @@
import 'dart:math';
/// Pure-Dart steering estimator for phone-on-handlebar steering.
///
/// Design goals:
/// - Avoid long-term drift on platforms like iOS by continuously estimating
/// and subtracting gyro bias.
/// - Keep it testable (no Flutter/sensors dependencies).
///
/// NOTE: This is not a full AHRS. It uses bias-corrected integration and
/// a "stillness" detector to learn gyro bias and optionally auto-recenter.
class SteeringEstimator {
SteeringEstimator({
this.biasLearningRate = 0.02,
this.gyroStillThresholdRadPerSec = 0.03,
this.accelStillThresholdMS2 = 0.6,
this.minStillTimeForBiasSec = 0.35,
this.biasLearningDeadbandDeg = 3.0,
this.minStillTimeForRecenterSec = double.infinity,
this.recenterHalfLifeSec = 0.7,
this.recenterDeadbandDeg = 2.0,
this.maxAngleAbsDeg = 60,
this.lowPassAlpha = 0.9,
// Responsiveness / smoothing tuning.
// When steering changes quickly we reduce smoothing, but keep more
// smoothing when stable to avoid jitter.
this.lowPassAlphaStable = 0.9,
this.lowPassAlphaMoving = 0.55,
this.motionAngleRateDegPerSecForMinAlpha = 90.0,
// Cap dt to avoid "freezing" the estimator on occasional long frames.
this.maxDtSec = 0.05,
});
// Tunables
final double biasLearningRate;
final double gyroStillThresholdRadPerSec;
final double accelStillThresholdMS2;
final double minStillTimeForBiasSec;
final double biasLearningDeadbandDeg;
final double minStillTimeForRecenterSec;
final double recenterHalfLifeSec;
final double recenterDeadbandDeg;
final double maxAngleAbsDeg;
/// Backwards-compatible, kept as-is.
///
/// If you set `lowPassAlpha = 0.0`, filtering is disabled.
final double lowPassAlpha;
/// Smoothing used when the angle is stable.
///
/// Default mirrors the original behavior (`0.9`).
final double lowPassAlphaStable;
/// Smoothing used when the angle is changing quickly.
///
/// Lower alpha => faster response.
final double lowPassAlphaMoving;
/// Angle rate (deg/s) at which we reach `lowPassAlphaMoving`.
final double motionAngleRateDegPerSecForMinAlpha;
/// Maximum timestep used for integration/bias learning.
final double maxDtSec;
// State
double _accelX = 0, _accelY = 0, _accelZ = 0;
bool _hasAccel = false;
double _biasZ = 0.0; // rad/s
double _yawDeg = 0.0;
double _filteredYawDeg = 0.0;
double _stillTimeSec = 0.0;
/// Resets the estimator state.
void reset() {
_biasZ = 0.0;
_yawDeg = 0.0;
_filteredYawDeg = 0.0;
_stillTimeSec = 0.0;
_hasAccel = false;
_accelX = _accelY = _accelZ = 0;
}
/// One-time calibration: assume device is held still and centered.
///
/// This resets yaw and also seeds the bias to the current z gyro rate.
void calibrate({double? seedBiasZRadPerSec}) {
_yawDeg = 0.0;
_filteredYawDeg = 0.0;
_stillTimeSec = 0.0;
if (seedBiasZRadPerSec != null) {
_biasZ = seedBiasZRadPerSec;
}
}
void updateAccel({required double x, required double y, required double z}) {
_accelX = x;
_accelY = y;
_accelZ = z;
_hasAccel = true;
}
/// Update with gyro z-rate (rad/s) and dt (seconds).
///
/// Returns the current filtered steering angle in degrees.
double updateGyro({required double wz, required double dt}) {
if (dt <= 0) {
return angleDeg;
}
// If dt spikes (app paused/jank), cap it instead of bailing out.
// This keeps the estimator responsive and avoids "stuck" output.
final usedDt = dt > maxDtSec ? maxDtSec : dt;
final still = _isStill(wz);
if (still) {
_stillTimeSec += usedDt;
// Learn gyro bias only when we're still AND near our calibrated center.
// Otherwise, if the user holds a steady steering angle, wz≈0 and we'd
// incorrectly move bias towards 0 and cause the angle to be wrong when
// they return to center.
final nearCenter = _yawDeg.abs() <= biasLearningDeadbandDeg;
if (nearCenter && _stillTimeSec >= minStillTimeForBiasSec) {
// Exponential moving average towards the observed rate.
_biasZ = (1.0 - biasLearningRate) * _biasZ + biasLearningRate * wz;
}
// IMPORTANT: only auto-recenter when we're already close to center.
// Users may hold a constant steering angle for several seconds.
final canRecenter = _stillTimeSec >= minStillTimeForRecenterSec && _yawDeg.abs() <= recenterDeadbandDeg;
if (canRecenter) {
_applyRecenter(usedDt);
}
} else {
_stillTimeSec = 0.0;
}
final correctedWz = wz - _biasZ;
_yawDeg += correctedWz * usedDt * (180.0 / pi);
// Clamp to avoid runaway if something goes wrong.
_yawDeg = _yawDeg.clamp(-maxAngleAbsDeg, maxAngleAbsDeg).toDouble();
// Low-pass filter for noise smoothing.
//
// Make it adaptive: when the angle is changing fast, we reduce smoothing
// (more responsive). When stable, we keep stronger smoothing.
//
// If user forces lowPassAlpha=0.0 (existing tests do), we keep behavior
// equivalent (no filtering).
if (lowPassAlpha <= 0.0) {
_filteredYawDeg = _yawDeg;
} else {
final stableAlpha = ((lowPassAlphaStable.isFinite ? lowPassAlphaStable : lowPassAlpha)).clamp(0.0, 0.999);
final movingAlpha = lowPassAlphaMoving.clamp(0.0, stableAlpha);
// Use a rate estimate derived from the filtered-vs-raw divergence.
final rateDegPerSec = ((_yawDeg - _filteredYawDeg).abs()) / usedDt;
final t = (rateDegPerSec / motionAngleRateDegPerSecForMinAlpha).clamp(0.0, 1.0);
final alpha = stableAlpha + (movingAlpha - stableAlpha) * t;
_filteredYawDeg = alpha * _filteredYawDeg + (1 - alpha) * _yawDeg;
}
return angleDeg;
}
double get angleDeg => _filteredYawDeg;
double get biasZRadPerSec => _biasZ;
double get stillTimeSec => _stillTimeSec;
bool _isStill(double wz) {
// If we don't have accel yet, be conservative: don't learn bias.
if (!_hasAccel) return false;
final gyroOk = wz.abs() < gyroStillThresholdRadPerSec;
// Check accel magnitude close to gravity (device not being bumped).
final aMag = sqrt(_accelX * _accelX + _accelY * _accelY + _accelZ * _accelZ);
const g = 9.80665;
final accelOk = (aMag - g).abs() < accelStillThresholdMS2;
return gyroOk && accelOk;
}
void _applyRecenter(double dt) {
// Exponential decay towards 0 with given half-life.
// decay = 0.5^(dt/halfLife)
if (recenterHalfLifeSec <= 0) return;
final decay = pow(0.5, dt / recenterHalfLifeSec).toDouble();
_yawDeg *= decay;
}
}

View File

@@ -1,10 +1,14 @@
import 'package:flutter/material.dart';
import 'package:swift_control/bluetooth/devices/base_device.dart';
import 'package:swift_control/main.dart';
import 'package:swift_control/utils/actions/android.dart';
import 'dart:io';
import 'package:bike_control/bluetooth/devices/base_device.dart';
import 'package:bike_control/utils/actions/android.dart';
import 'package:bike_control/utils/core.dart';
import 'package:bike_control/widgets/ui/warning.dart';
import 'package:flutter/material.dart' show PopupMenuButton, PopupMenuItem;
import 'package:shadcn_flutter/shadcn_flutter.dart';
class HidDevice extends BaseDevice {
HidDevice(super.name, {super.availableButtons = const []});
HidDevice(super.name) : super(availableButtons: [], uniqueId: name!);
@override
Future<void> connect() {
@@ -13,24 +17,37 @@ class HidDevice extends BaseDevice {
@override
Widget showInformation(BuildContext context) {
return Row(
return Column(
children: [
Expanded(child: Text(name)),
PopupMenuButton(
itemBuilder: (c) => [
PopupMenuItem(
child: Text('Ignore'),
onTap: () {
connection.disconnect(this, forget: true);
if (actionHandler is AndroidActions) {
(actionHandler as AndroidActions).ignoreHidDevices();
} else if (connection.isMediaKeyDetectionEnabled.value) {
connection.isMediaKeyDetectionEnabled.value = false;
}
},
Row(
children: [
Expanded(child: Text(toString()).bold),
PopupMenuButton(
itemBuilder: (c) => [
PopupMenuItem(
child: Text('Ignore'),
onTap: () {
core.connection.disconnect(this, forget: true, persistForget: true);
if (core.actionHandler is AndroidActions) {
(core.actionHandler as AndroidActions).ignoreHidDevices();
} else if (core.mediaKeyHandler.isMediaKeyDetectionEnabled.value) {
core.mediaKeyHandler.isMediaKeyDetectionEnabled.value = false;
core.settings.setMediaKeyDetectionEnabled(false);
}
},
),
],
),
],
),
if (Platform.isAndroid && !core.settings.getLocalEnabled())
Warning(
children: [
Text(
'For it to work properly, even when BikeControl is in the background, you need to enable the local connection method in the next tab.',
).small,
],
),
],
);
}

View File

@@ -1,44 +1,49 @@
import 'dart:convert';
import 'dart:io';
import 'package:bike_control/bluetooth/devices/trainer_connection.dart';
import 'package:bike_control/bluetooth/messages/notification.dart';
import 'package:bike_control/gen/l10n.dart';
import 'package:bike_control/utils/actions/base_actions.dart';
import 'package:bike_control/utils/core.dart';
import 'package:bike_control/utils/keymap/buttons.dart';
import 'package:bike_control/utils/keymap/keymap.dart';
import 'package:bike_control/utils/requirements/multi.dart';
import 'package:flutter/foundation.dart';
import 'package:swift_control/utils/actions/base_actions.dart';
import 'package:swift_control/utils/keymap/buttons.dart';
import 'package:swift_control/utils/requirements/multi.dart';
import 'package:prop/prop.dart';
class WhooshLink {
class WhooshLink extends TrainerConnection {
Socket? _socket;
ServerSocket? _server;
static final List<InGameAction> supportedActions = [
InGameAction.shiftUp,
InGameAction.shiftDown,
InGameAction.cameraAngle,
InGameAction.emote,
InGameAction.uturn,
InGameAction.steerLeft,
InGameAction.steerRight,
];
static const String connectionTitle = 'MyWhoosh Link';
final ValueNotifier<bool> isStarted = ValueNotifier(false);
final ValueNotifier<bool> isConnected = ValueNotifier(false);
WhooshLink()
: super(
title: connectionTitle,
supportedActions: [
InGameAction.shiftUp,
InGameAction.shiftDown,
InGameAction.cameraAngle,
InGameAction.emote,
InGameAction.uturn,
InGameAction.steerLeft,
InGameAction.steerRight,
],
);
void stopServer() async {
if (isStarted.value) {
await _socket?.close();
await _server?.close();
isConnected.value = false;
isStarted.value = false;
if (kDebugMode) {
print('Server stopped.');
}
await _socket?.close();
await _server?.close();
isConnected.value = false;
isStarted.value = false;
if (kDebugMode) {
print('Server stopped.');
}
}
Future<void> startServer({
required void Function(Socket socket) onConnected,
required void Function(Socket socket) onDisconnected,
}) async {
Future<void> startServer() async {
isStarted.value = true;
try {
// Create and bind server socket
_server = await ServerSocket.bind(
@@ -55,21 +60,23 @@ class WhooshLink {
isStarted.value = false;
rethrow;
}
isStarted.value = true;
if (kDebugMode) {
print('Server started on port ${_server!.port}');
}
// Accept connection
_server!.listen(
(Socket socket) {
_socket = socket;
onConnected(socket);
isConnected.value = true;
(Socket socket) async {
if (kDebugMode) {
print('Client connected: ${socket.remoteAddress.address}:${socket.remotePort}');
}
SharedLogic.keepAlive();
_socket = socket;
core.connection.signalNotification(
AlertNotification(LogLevel.LOGLEVEL_INFO, AppLocalizations.current.myWhooshLinkConnected),
);
isConnected.value = true;
// Listen for data from the client
socket.listen(
(List<int> data) {
@@ -83,16 +90,21 @@ class WhooshLink {
},
onDone: () {
print('Client disconnected: $socket');
onDisconnected(socket);
SharedLogic.stopKeepAlive();
isConnected.value = false;
core.connection.signalNotification(
AlertNotification(LogLevel.LOGLEVEL_WARNING, 'MyWhoosh Link disconnected'),
);
},
);
},
);
}
ActionResult sendAction(InGameAction action, int? value) {
final jsonObject = switch (action) {
@override
Future<ActionResult> sendAction(KeyPair keyPair, {required bool isKeyDown, required bool isKeyUp}) async {
final jsonObject = switch (keyPair.inGameAction) {
InGameAction.shiftUp => {
'MessageType': 'Controls',
'InGameControls': {
@@ -108,13 +120,13 @@ class WhooshLink {
InGameAction.cameraAngle => {
'MessageType': 'Controls',
'InGameControls': {
'CameraAngle': '$value',
'CameraAngle': '${keyPair.inGameActionValue}',
},
},
InGameAction.emote => {
'MessageType': 'Controls',
'InGameControls': {
'Emote': '$value',
'Emote': '${keyPair.inGameActionValue}',
},
},
InGameAction.uturn => {
@@ -126,13 +138,13 @@ class WhooshLink {
InGameAction.steerLeft => {
'MessageType': 'Controls',
'InGameControls': {
'Steering': '-1',
'Steering': isKeyDown ? '-1' : '0',
},
},
InGameAction.steerRight => {
'MessageType': 'Controls',
'InGameControls': {
'Steering': '1',
'Steering': isKeyDown ? '1' : '0',
},
},
InGameAction.increaseResistance => null,
@@ -143,12 +155,18 @@ class WhooshLink {
_ => null,
};
if (jsonObject != null) {
final supportsIsKeyUpActions = [
InGameAction.steerLeft,
InGameAction.steerRight,
];
if (jsonObject != null && !isKeyDown && !supportsIsKeyUpActions.contains(keyPair.inGameAction)) {
return Ignored('No Action sent on key down for action: ${keyPair.inGameAction}');
} else if (jsonObject != null) {
final jsonString = jsonEncode(jsonObject);
_socket?.writeln(jsonString);
return Success('Sent action to MyWhoosh: $action ${value ?? ''}');
return Success('Sent action to MyWhoosh: ${keyPair.inGameAction} ${keyPair.inGameActionValue ?? ''}');
} else {
return Error('No action available for button: $action');
return NotHandled('No action available for button: ${keyPair.inGameAction}');
}
}
@@ -156,7 +174,7 @@ class WhooshLink {
return kIsWeb
? false
: switch (target) {
Target.thisDevice => Platform.isAndroid || Platform.isWindows,
Target.thisDevice => !Platform.isWindows,
_ => true,
};
}

View File

@@ -0,0 +1,287 @@
import 'dart:io';
import 'package:bike_control/bluetooth/ble.dart';
import 'package:bike_control/bluetooth/devices/openbikecontrol/openbikecontrol_device.dart';
import 'package:bike_control/bluetooth/devices/openbikecontrol/protocol_parser.dart';
import 'package:bike_control/bluetooth/devices/trainer_connection.dart';
import 'package:bike_control/bluetooth/messages/notification.dart' show AlertNotification, LogNotification;
import 'package:bike_control/utils/actions/base_actions.dart';
import 'package:bike_control/utils/core.dart';
import 'package:bike_control/utils/keymap/buttons.dart';
import 'package:bike_control/utils/keymap/keymap.dart';
import 'package:bike_control/widgets/title.dart';
import 'package:bluetooth_low_energy/bluetooth_low_energy.dart';
import 'package:dartx/dartx.dart';
import 'package:flutter/foundation.dart';
import 'package:prop/prop.dart';
class OpenBikeControlBluetoothEmulator extends TrainerConnection {
late final _peripheralManager = PeripheralManager();
final ValueNotifier<AppInfo?> connectedApp = ValueNotifier<AppInfo?>(null);
bool _isServiceAdded = false;
bool _isSubscribedToEvents = false;
Central? _central;
late GATTCharacteristic _buttonCharacteristic;
static const String connectionTitle = 'OpenBikeControl BLE Emulator';
OpenBikeControlBluetoothEmulator()
: super(
title: connectionTitle,
supportedActions: InGameAction.values,
);
Future<void> startServer() async {
isStarted.value = true;
_peripheralManager.stateChanged.forEach((state) {
print('Peripheral manager state: ${state.state}');
});
if (!kIsWeb && Platform.isAndroid) {
_peripheralManager.connectionStateChanged.forEach((state) {
print('Peripheral connection state: ${state.state} of ${state.central.uuid}');
if (state.state == ConnectionState.connected) {
} else if (state.state == ConnectionState.disconnected) {
if (connectedApp.value != null) {
core.connection.signalNotification(
AlertNotification(LogLevel.LOGLEVEL_INFO, 'Disconnected from app: ${connectedApp.value?.appId}'),
);
}
isConnected.value = false;
connectedApp.value = null;
_central = null;
}
});
}
while (_peripheralManager.state != BluetoothLowEnergyState.poweredOn && core.settings.getObpBleEnabled()) {
print('Waiting for peripheral manager to be powered on...');
await Future.delayed(Duration(seconds: 1));
}
_buttonCharacteristic = GATTCharacteristic.mutable(
uuid: UUID.fromString(OpenBikeControlConstants.BUTTON_STATE_CHARACTERISTIC_UUID),
descriptors: [],
properties: [
GATTCharacteristicProperty.notify,
],
permissions: [],
);
if (!_isServiceAdded) {
await Future.delayed(Duration(seconds: 1));
if (!_isSubscribedToEvents) {
_isSubscribedToEvents = true;
_peripheralManager.characteristicReadRequested.forEach((eventArgs) async {
print('Read request for characteristic: ${eventArgs.characteristic.uuid}');
switch (eventArgs.characteristic.uuid.toString().toUpperCase()) {
case BleUuid.DEVICE_INFORMATION_CHARACTERISTIC_BATTERY_LEVEL:
await _peripheralManager.respondReadRequestWithValue(
eventArgs.request,
value: Uint8List.fromList([100]),
);
return;
default:
print('Unhandled read request for characteristic: ${eventArgs.characteristic.uuid}');
}
final request = eventArgs.request;
final trimmedValue = Uint8List.fromList([]);
await _peripheralManager.respondReadRequestWithValue(
request,
value: trimmedValue,
);
// You can respond to read requests here if needed
});
_peripheralManager.characteristicNotifyStateChanged.forEach((char) {
_central = char.central;
print(
'Notify state changed for characteristic: ${char.characteristic.uuid}: ${char.state}',
);
});
Uint8List? firstAppInfoMessage;
_peripheralManager.characteristicWriteRequested.forEach((eventArgs) async {
final characteristic = eventArgs.characteristic;
final request = eventArgs.request;
final value = request.value;
if (kDebugMode) {
print('Write request for characteristic: ${characteristic.uuid}: ${bytesToReadableHex(value)}');
}
switch (eventArgs.characteristic.uuid.toString().toLowerCase()) {
case OpenBikeControlConstants.APPINFO_CHARACTERISTIC_UUID:
try {
// use this fallback if first message is incomplete (e.g. TrainingPeaks on macOS)
AppInfo appInfo = OpenBikeProtocolParser.parseAppInfo(
Uint8List.fromList([...?firstAppInfoMessage, ...value]),
);
firstAppInfoMessage = null;
isConnected.value = true;
connectedApp.value = appInfo;
supportedActions = appInfo.supportedButtons.mapNotNull((b) => b.action).toList();
core.connection.signalNotification(
AlertNotification(LogLevel.LOGLEVEL_INFO, 'Connected to app: ${appInfo.appId}'),
);
core.connection.signalNotification(LogNotification('Parsed App Info: $appInfo'));
} catch (e) {
core.connection.signalNotification(LogNotification('Error parsing App Info ${bytesToHex(value)}: $e'));
if (firstAppInfoMessage == null) {
firstAppInfoMessage = value;
return;
}
}
break;
default:
print('Unhandled write request for characteristic: ${eventArgs.characteristic.uuid}');
}
await _peripheralManager.respondWriteRequest(request);
});
}
if (!Platform.isWindows) {
// Device Information
await _peripheralManager.addService(
GATTService(
uuid: UUID.fromString('180A'),
isPrimary: true,
characteristics: [
GATTCharacteristic.immutable(
uuid: UUID.fromString('2A29'),
value: Uint8List.fromList('BikeControl'.codeUnits),
descriptors: [],
),
GATTCharacteristic.immutable(
uuid: UUID.fromString('2A25'),
value: Uint8List.fromList('1337'.codeUnits),
descriptors: [],
),
GATTCharacteristic.immutable(
uuid: UUID.fromString('2A27'),
value: Uint8List.fromList('1.0'.codeUnits),
descriptors: [],
),
GATTCharacteristic.immutable(
uuid: UUID.fromString('2A26'),
value: Uint8List.fromList((packageInfoValue?.version ?? '1.0.0').codeUnits),
descriptors: [],
),
],
includedServices: [],
),
);
}
// Battery Service
await _peripheralManager.addService(
GATTService(
uuid: UUID.fromString('180F'),
isPrimary: true,
characteristics: [
GATTCharacteristic.mutable(
uuid: UUID.fromString('2A19'),
descriptors: [],
properties: [
GATTCharacteristicProperty.read,
GATTCharacteristicProperty.notify,
],
permissions: [
GATTCharacteristicPermission.read,
],
),
],
includedServices: [],
),
);
// Unknown Service
await _peripheralManager.addService(
GATTService(
uuid: UUID.fromString(OpenBikeControlConstants.SERVICE_UUID),
isPrimary: true,
characteristics: [
_buttonCharacteristic,
GATTCharacteristic.mutable(
uuid: UUID.fromString(OpenBikeControlConstants.APPINFO_CHARACTERISTIC_UUID),
descriptors: [],
properties: [
GATTCharacteristicProperty.writeWithoutResponse,
GATTCharacteristicProperty.write,
],
permissions: [
GATTCharacteristicPermission.read,
GATTCharacteristicPermission.write,
],
),
],
includedServices: [],
),
);
_isServiceAdded = true;
}
final advertisement = Advertisement(
name: 'BikeControl',
serviceUUIDs: [UUID.fromString(OpenBikeControlConstants.SERVICE_UUID)],
);
print('Starting advertising with OpenBikeControl service...');
await _peripheralManager.startAdvertising(advertisement);
}
Future<void> stopServer() async {
if (kDebugMode) {
print('Stopping OpenBikeControl BLE server...');
}
await _peripheralManager.removeAllServices();
_isServiceAdded = false;
await _peripheralManager.stopAdvertising();
isStarted.value = false;
isConnected.value = false;
connectedApp.value = null;
}
@override
Future<ActionResult> sendAction(KeyPair keyPair, {required bool isKeyDown, required bool isKeyUp}) async {
final inGameAction = keyPair.inGameAction;
final mappedButtons = connectedApp.value!.supportedButtons.filter(
(supportedButton) => supportedButton.action == inGameAction,
);
if (inGameAction == null) {
return Error('Invalid in-game action for key pair: $keyPair');
} else if (_central == null) {
return Error('No central connected');
} else if (connectedApp.value == null) {
return Error('No app info received from central');
} else if (mappedButtons.isEmpty) {
return NotHandled('App does not support all buttons for action: ${inGameAction.title}');
}
if (isKeyDown && isKeyUp) {
final responseDataDown = OpenBikeProtocolParser.encodeButtonState(
mappedButtons.map((b) => ButtonState(b, 1)).toList(),
);
await _peripheralManager.notifyCharacteristic(_central!, _buttonCharacteristic, value: responseDataDown);
final responseDataUp = OpenBikeProtocolParser.encodeButtonState(
mappedButtons.map((b) => ButtonState(b, 0)).toList(),
);
await _peripheralManager.notifyCharacteristic(_central!, _buttonCharacteristic, value: responseDataUp);
} else {
final responseData = OpenBikeProtocolParser.encodeButtonState(
mappedButtons.map((b) => ButtonState(b, isKeyDown ? 1 : 0)).toList(),
);
await _peripheralManager.notifyCharacteristic(_central!, _buttonCharacteristic, value: responseData);
}
return Success('Buttons ${inGameAction.title} sent');
}
}

View File

@@ -0,0 +1,39 @@
import 'package:bike_control/bluetooth/devices/openbikecontrol/openbikecontrol_device.dart';
import 'package:prop/emulators/dircon/dircon.dart';
import 'package:universal_ble/universal_ble.dart';
abstract class OnMessage {
void onMessage(List<int> message);
}
class ObcDircon extends DirCon {
final OnMessage onMessageCallback;
ObcDircon({required super.socket, required this.onMessageCallback});
@override
List<BleCharacteristic> getCharacteristics(String serviceUUID) {
if (serviceUUID.toLowerCase() == OpenBikeControlConstants.SERVICE_UUID) {
return [
BleCharacteristic(
OpenBikeControlConstants.BUTTON_STATE_CHARACTERISTIC_UUID,
[CharacteristicProperty.notify],
),
BleCharacteristic(
OpenBikeControlConstants.APPINFO_CHARACTERISTIC_UUID,
[CharacteristicProperty.writeWithoutResponse, CharacteristicProperty.write],
),
];
}
return [];
}
@override
void processWriteCallback(String characteristicUUID, List<int> characteristicData) {
if (characteristicUUID.toLowerCase() == OpenBikeControlConstants.APPINFO_CHARACTERISTIC_UUID) {
onMessageCallback.onMessage(characteristicData);
}
}
@override
List<String> get serviceUUIDs => [OpenBikeControlConstants.SERVICE_UUID];
}

View File

@@ -0,0 +1,248 @@
import 'dart:io';
import 'package:bike_control/bluetooth/devices/openbikecontrol/obc_dircon.dart';
import 'package:bike_control/bluetooth/devices/openbikecontrol/openbikecontrol_device.dart';
import 'package:bike_control/bluetooth/devices/openbikecontrol/protocol_parser.dart';
import 'package:bike_control/bluetooth/devices/trainer_connection.dart';
import 'package:bike_control/bluetooth/messages/notification.dart';
import 'package:bike_control/utils/actions/base_actions.dart';
import 'package:bike_control/utils/core.dart';
import 'package:bike_control/utils/keymap/apps/supported_app.dart';
import 'package:bike_control/utils/keymap/buttons.dart';
import 'package:bike_control/utils/keymap/keymap.dart';
import 'package:dartx/dartx.dart';
import 'package:flutter/foundation.dart';
import 'package:nsd/nsd.dart';
import 'package:prop/prop.dart';
class OpenBikeControlMdnsEmulator extends TrainerConnection implements OnMessage {
ServerSocket? _server;
Registration? _mdnsRegistration;
static const String connectionTitle = 'OpenBikeControl mDNS Emulator';
final ValueNotifier<AppInfo?> connectedApp = ValueNotifier(null);
Socket? _socket;
ObcDircon? _dirCon;
OpenBikeControlMdnsEmulator()
: super(
title: connectionTitle,
supportedActions: InGameAction.values,
);
bool get _useDirCon =>
core.settings.getTrainerApp()?.supportsOpenBikeProtocol.contains(OpenBikeProtocolSupport.dircon) ?? false;
Future<void> startServer() async {
print('Starting mDNS server...');
isStarted.value = true;
// Get local IP
final interfaces = await NetworkInterface.list();
InternetAddress? localIP;
for (final interface in interfaces) {
for (final addr in interface.addresses) {
if (addr.type == InternetAddressType.IPv4 && !addr.isLoopback) {
localIP = addr;
break;
}
}
if (localIP != null) break;
}
if (localIP == null) {
throw 'Could not find network interface';
}
await _createTcpServer();
if (kDebugMode) {
enableLogging(LogTopic.calls);
enableLogging(LogTopic.errors);
}
disableServiceTypeValidation(true);
try {
// Create service
_mdnsRegistration = await register(
Service(
name: 'BikeControl',
type: _useDirCon ? '_wahoo-fitness-tnp._tcp' : '_openbikecontrol._tcp',
port: 36867,
addresses: [localIP],
txt: _useDirCon
? {
'ble-service-uuids': Uint8List.fromList(OpenBikeControlConstants.SERVICE_UUID.codeUnits),
'mac-address': Uint8List.fromList('00:11:22:33:44:55'.codeUnits),
'serial-number': Uint8List.fromList('1234567890'.codeUnits),
}
: {
'version': Uint8List.fromList([0x01]),
'id': Uint8List.fromList('1337'.codeUnits),
'name': Uint8List.fromList('BikeControl'.codeUnits),
'service-uuids': Uint8List.fromList(OpenBikeControlConstants.SERVICE_UUID.codeUnits),
'manufacturer': Uint8List.fromList('OpenBikeControl'.codeUnits),
'model': Uint8List.fromList('BikeControl app'.codeUnits),
},
),
);
print('Service: ${_mdnsRegistration!.id} at ${localIP.address}:$_mdnsRegistration');
print('Server started - advertising service!');
} catch (e, s) {
core.connection.signalNotification(AlertNotification(LogLevel.LOGLEVEL_ERROR, 'Failed to start mDNS server: $e'));
rethrow;
}
}
Future<void> stopServer() async {
if (kDebugMode) {
print('Stopping OpenBikeControl mDNS server...');
}
if (_mdnsRegistration != null) {
unregister(_mdnsRegistration!);
_mdnsRegistration = null;
}
isStarted.value = false;
isConnected.value = false;
connectedApp.value = null;
_socket?.destroy();
_socket = null;
}
Future<void> _createTcpServer() async {
try {
_server = await ServerSocket.bind(
InternetAddress.anyIPv4,
36867,
shared: true,
v6Only: false,
);
} catch (e) {
core.connection.signalNotification(AlertNotification(LogLevel.LOGLEVEL_ERROR, 'Failed to start server: $e'));
rethrow;
}
if (kDebugMode) {
print('Server started on port ${_server!.port}');
}
// Accept connection
_server!.listen(
(Socket socket) async {
SharedLogic.keepAlive();
_socket = socket;
if (kDebugMode) {
print('Client connected: ${socket.remoteAddress.address}:${socket.remotePort}');
}
if (_useDirCon) {
_dirCon = ObcDircon(socket: socket, onMessageCallback: this);
}
// Listen for data from the client
socket.listen(
(List<int> data) {
if (kDebugMode) {
print('Received message: ${bytesToHex(data)}');
}
if (_dirCon != null) {
_dirCon!.handleIncomingData(data);
return;
}
onMessage(data);
},
onDone: () {
_dirCon = null;
SharedLogic.stopKeepAlive();
core.connection.signalNotification(
AlertNotification(LogLevel.LOGLEVEL_INFO, 'Disconnected from app: ${connectedApp.value?.appId}'),
);
isConnected.value = false;
connectedApp.value = null;
_socket = null;
},
);
},
);
}
@override
Future<ActionResult> sendAction(KeyPair keyPair, {required bool isKeyDown, required bool isKeyUp}) async {
final inGameAction = keyPair.inGameAction;
final mappedButtons = connectedApp.value!.supportedButtons.filter(
(supportedButton) => supportedButton.action == inGameAction,
);
if (inGameAction == null) {
return Error('Invalid in-game action for key pair: $keyPair');
} else if (_socket == null) {
print('No client connected, cannot send button press');
return Error('No client connected');
} else if (connectedApp.value == null) {
return Error('No app info received from central');
} else if (mappedButtons.isEmpty) {
return NotHandled('App does not support: ${inGameAction.title}');
}
if (isKeyDown && isKeyUp) {
final responseDataDown = OpenBikeProtocolParser.encodeButtonState(
mappedButtons.map((b) => ButtonState(b, 1)).toList(),
);
_write(_socket!, responseDataDown);
final responseDataUp = OpenBikeProtocolParser.encodeButtonState(
mappedButtons.map((b) => ButtonState(b, 0)).toList(),
);
_write(_socket!, responseDataUp);
} else {
final responseData = OpenBikeProtocolParser.encodeButtonState(
mappedButtons.map((b) => ButtonState(b, isKeyDown ? 1 : 0)).toList(),
);
_write(_socket!, responseData);
}
return Success('Sent ${inGameAction.title} button press');
}
void _write(Socket socket, List<int> responseData) {
debugPrint('Sending response: ${bytesToHex(responseData)}');
if (_dirCon != null) {
_dirCon!.sendCharacteristicNotification(OpenBikeControlConstants.BUTTON_STATE_CHARACTERISTIC_UUID, responseData);
return;
} else {
socket.add(responseData);
}
}
@override
void onMessage(List<int> message) {
if (kDebugMode) {
print('Received message from OBC: ${bytesToHex(message)}');
}
final messageType = message[0];
switch (messageType) {
case OpenBikeProtocolParser.MSG_TYPE_APP_INFO:
try {
final appInfo = OpenBikeProtocolParser.parseAppInfo(Uint8List.fromList(message));
isConnected.value = true;
connectedApp.value = appInfo;
supportedActions = appInfo.supportedButtons.mapNotNull((b) => b.action).toList();
core.connection.signalNotification(
AlertNotification(LogLevel.LOGLEVEL_INFO, 'Connected to app: ${appInfo.appId}'),
);
} catch (e) {
core.connection.signalNotification(LogNotification('Failed to parse app info: $e'));
}
break;
case OpenBikeProtocolParser.MSG_TYPE_HAPTIC_FEEDBACK:
// noop
break;
default:
print('Unknown message type: $messageType');
}
}
}

View File

@@ -0,0 +1,80 @@
import 'dart:typed_data';
import 'package:prop/prop.dart';
import 'package:bike_control/bluetooth/messages/notification.dart';
import 'package:bike_control/widgets/title.dart';
import 'package:universal_ble/universal_ble.dart';
import '../bluetooth_device.dart';
import 'protocol_parser.dart';
class OpenBikeControlDevice extends BluetoothDevice {
OpenBikeControlDevice(super.scanResult)
: super(
availableButtons: OpenBikeProtocolParser.BUTTON_NAMES.values.toList(),
);
@override
Future<void> handleServices(List<BleService> services) async {
final service = services.firstWhere(
(e) => e.uuid.toLowerCase() == OpenBikeControlConstants.SERVICE_UUID.toLowerCase(),
orElse: () => throw Exception('Service not found: ${OpenBikeControlConstants.SERVICE_UUID}'),
);
final characteristic = service.characteristics.firstWhere(
(e) => e.uuid.toLowerCase() == OpenBikeControlConstants.BUTTON_STATE_CHARACTERISTIC_UUID.toLowerCase(),
orElse: () =>
throw Exception('Characteristic not found: ${OpenBikeControlConstants.BUTTON_STATE_CHARACTERISTIC_UUID}'),
);
await UniversalBle.subscribeNotifications(device.deviceId, service.uuid, characteristic.uuid);
final appInfoCharacteristic = service.characteristics.firstWhere(
(e) => e.uuid.toLowerCase() == OpenBikeControlConstants.APPINFO_CHARACTERISTIC_UUID.toLowerCase(),
orElse: () =>
throw Exception('Characteristic not found: ${OpenBikeControlConstants.APPINFO_CHARACTERISTIC_UUID}'),
);
await UniversalBle.write(
device.deviceId,
service.uuid,
appInfoCharacteristic.uuid,
OpenBikeProtocolParser.encodeAppInfo(
appId: 'BikeControl',
appVersion: packageInfoValue!.version,
supportedButtons: OpenBikeProtocolParser.BUTTON_NAMES.values.toList(),
),
);
}
@override
Future<void> processCharacteristic(String characteristic, Uint8List bytes) async {
final charLower = characteristic.toLowerCase();
if (charLower == OpenBikeControlConstants.BUTTON_STATE_CHARACTERISTIC_UUID.toLowerCase()) {
try {
final parsed = OpenBikeProtocolParser.parseButtonState(bytes);
final buttonsToPress = parsed.where((e) => e.state == 1).map((e) => e.button).toList();
await handleButtonsClicked(buttonsToPress);
} catch (e) {
actionStreamInternal.add(AlertNotification(LogLevel.LOGLEVEL_WARNING, 'Error parsing OpenBike message: $e'));
}
}
}
}
class OpenBikeControlConstants {
// OpenBikeControl BLE service and characteristic UUIDs (see BLE.md)
static const String SERVICE_UUID = 'd273f680-d548-419d-b9d1-fa0472345229';
// Button State Characteristic (Notify)
static const String BUTTON_STATE_CHARACTERISTIC_UUID = 'd273f681-d548-419d-b9d1-fa0472345229';
// Haptic Feedback Characteristic (Write)
static const String HAPTIC_CHARACTERISTIC_UUID = 'd273f682-d548-419d-b9d1-fa0472345229';
// App Info Characteristic (Write)
static const String APPINFO_CHARACTERISTIC_UUID = 'd273f683-d548-419d-b9d1-fa0472345229';
}

View File

@@ -0,0 +1,308 @@
// OpenBikeControl Protocol Parser (Dart)
// This file is a translation of the Python `protocol_parser.py` example into Dart.
// It provides simple encoding/decoding utilities for the OpenBikeControl message
// types used in the Python example. This is intentionally a small, focused
// module that mirrors the original Python API.
import 'dart:convert';
import 'dart:typed_data';
import 'package:bike_control/utils/keymap/buttons.dart';
import 'package:dartx/dartx.dart';
import 'package:prop/prop.dart';
class ProtocolParseException implements Exception {
final String message;
final Uint8List? raw;
ProtocolParseException(this.message, [this.raw]);
@override
String toString() => 'ProtocolParseException: $message${raw != null ? ' raw=${bytesToReadableHex(raw!)}' : ''}';
}
class OpenBikeProtocolParser {
// Button ID to name mapping (based on PROTOCOL.md in Python example)
static const Map<int, ControllerButton> BUTTON_NAMES = {
// Gear Shifting (0x01-0x0F)
0x01: ControllerButton('Shift Up', identifier: 0x01, action: InGameAction.shiftUp),
0x02: ControllerButton('Shift Down', identifier: 0x02, action: InGameAction.shiftDown),
0x03: ControllerButton('Gear Set', identifier: 0x03),
// Navigation (0x10-0x1F)
0x10: ControllerButton('Up', identifier: 0x10, action: InGameAction.up),
0x11: ControllerButton('Down', identifier: 0x11, action: InGameAction.down),
0x12: ControllerButton('Left/Look Left', identifier: 0x12, action: InGameAction.navigateLeft),
0x13: ControllerButton('Right/Look Right', identifier: 0x13, action: InGameAction.navigateRight),
0x14: ControllerButton('Select/Confirm', identifier: 0x14, action: InGameAction.select),
0x15: ControllerButton('Back/Cancel', identifier: 0x15, action: InGameAction.back),
0x16: ControllerButton('Menu', identifier: 0x16, action: InGameAction.menu),
0x17: ControllerButton('Home', identifier: 0x17, action: InGameAction.home),
0x18: ControllerButton('Steer Left', identifier: 0x18, action: InGameAction.steerLeft),
0x19: ControllerButton('Steer Right', identifier: 0x19, action: InGameAction.steerRight),
// Social/Emotes (0x20-0x2F)
0x20: ControllerButton('Emote', identifier: 0x20, action: InGameAction.emote),
0x21: ControllerButton('Push to Talk', identifier: 0x21),
// Training Controls (0x30-0x3F)
0x30: ControllerButton('ERG Up', identifier: 0x30, action: InGameAction.increaseResistance),
0x31: ControllerButton('ERG Down', identifier: 0x31, action: InGameAction.decreaseResistance),
0x32: ControllerButton('Skip Interval', identifier: 0x32),
0x33: ControllerButton('Pause', identifier: 0x33),
0x34: ControllerButton('Resume', identifier: 0x34),
0x35: ControllerButton('Lap', identifier: 0x35),
// View Controls (0x40-0x4F)
0x40: ControllerButton('Camera Angle', identifier: 0x40, action: InGameAction.cameraAngle),
0x41: ControllerButton('Camera 1', identifier: 0x41, action: InGameAction.cameraAngle),
0x42: ControllerButton('Camera 2', identifier: 0x42, action: InGameAction.cameraAngle),
0x43: ControllerButton('Camera 3', identifier: 0x43, action: InGameAction.cameraAngle),
0x44: ControllerButton('HUD Toggle', identifier: 0x44, action: InGameAction.toggleUi),
0x45: ControllerButton('Map Toggle', identifier: 0x45),
// Power-ups (0x50-0x5F)
0x50: ControllerButton('Power-up 1', identifier: 0x50, action: InGameAction.usePowerUp),
0x51: ControllerButton('Power-up 2', identifier: 0x51, action: InGameAction.usePowerUp),
0x52: ControllerButton('Power-up 3', identifier: 0x52, action: InGameAction.usePowerUp),
};
// Haptic feedback patterns
static const Map<String, int> HAPTIC_PATTERNS = {
'none': 0x00,
'short': 0x01,
'double': 0x02,
'triple': 0x03,
'long': 0x04,
'success': 0x05,
'warning': 0x06,
'error': 0x07,
};
// Message types (for TCP/mDNS protocol)
static const int MSG_TYPE_BUTTON_STATE = 0x01;
static const int MSG_TYPE_DEVICE_STATUS = 0x02;
static const int MSG_TYPE_HAPTIC_FEEDBACK = 0x03;
static const int MSG_TYPE_APP_INFO = 0x04;
/// Parse button state data from binary format.
/// Data format: [Message_Type, Button_ID_1, State_1, Button_ID_2, State_2, ...]
static List<ButtonState> parseButtonState(Uint8List data) {
final buttons = <ButtonState>[];
if (data.isEmpty) return buttons;
if (data[0] != MSG_TYPE_BUTTON_STATE) return buttons;
for (var i = 1; i < data.length; i += 2) {
if (i + 1 < data.length) {
final buttonId = data[i];
final state = data[i + 1];
if (BUTTON_NAMES[buttonId] != null) {
buttons.add(ButtonState(BUTTON_NAMES[buttonId]!, state));
} else {
throw ProtocolParseException('Unknown button ID: 0x${buttonId.toRadixString(16).padLeft(2, '0')}', data);
}
}
}
return buttons;
}
static Uint8List encodeButtonState(List<ButtonState> buttons) {
final bytes = BytesBuilder();
bytes.addByte(MSG_TYPE_BUTTON_STATE);
for (final b in buttons) {
bytes.addByte(b.button.identifier!);
bytes.addByte(b.state);
}
return bytes.toBytes();
}
static DeviceStatus parseDeviceStatus(Uint8List data) {
if (data.length < 3) {
throw ProtocolParseException('Device status message too short', data);
}
if (data[0] != MSG_TYPE_DEVICE_STATUS) {
throw ProtocolParseException('Invalid message type: ${data[0]}, expected $MSG_TYPE_DEVICE_STATUS', data);
}
final battery = data[1] == 0xFF ? null : data[1];
final connected = data[2] == 0x01;
return DeviceStatus(battery: battery, connected: connected);
}
static Uint8List encodeDeviceStatus({int? battery, bool connected = true}) {
final batteryByte = battery == null ? 0xFF : (battery & 0xFF);
final connectedByte = connected ? 0x01 : 0x00;
return Uint8List.fromList([MSG_TYPE_DEVICE_STATUS, batteryByte, connectedByte]);
}
static Uint8List encodeHapticFeedback({String pattern = 'short', int duration = 0, int intensity = 0}) {
final patternByte = HAPTIC_PATTERNS[pattern] ?? HAPTIC_PATTERNS['short']!;
final bytes = Uint8List(4);
bytes[0] = MSG_TYPE_HAPTIC_FEEDBACK;
bytes[1] = patternByte;
bytes[2] = duration & 0xFF;
bytes[3] = intensity & 0xFF;
return bytes;
}
static HapticFeedbackMessage parseHapticFeedback(Uint8List data) {
if (data.length < 4) {
throw ProtocolParseException('Haptic feedback message too short', data);
}
if (data[0] != MSG_TYPE_HAPTIC_FEEDBACK) {
throw ProtocolParseException('Invalid message type: ${data[0]}', data);
}
final patternByte = data[1];
final duration = data[2];
final intensity = data[3];
String patternName = 'unknown';
HAPTIC_PATTERNS.forEach((name, value) {
if (value == patternByte) patternName = name;
});
return HapticFeedbackMessage(
pattern: patternName,
patternByte: patternByte,
duration: duration,
intensity: intensity,
);
}
static Uint8List encodeAppInfo({
required String appId,
required String appVersion,
required List<ControllerButton> supportedButtons,
}) {
final appIdBytes = utf8.encode(appId).take(32).toList();
final appVersionBytes = utf8.encode(appVersion).take(32).toList();
final builder = BytesBuilder();
builder.addByte(MSG_TYPE_APP_INFO);
builder.addByte(0x01); // Version
builder.addByte(appIdBytes.length);
builder.add(appIdBytes);
builder.addByte(appVersionBytes.length);
builder.add(appVersionBytes);
builder.addByte(supportedButtons.length);
builder.add(supportedButtons.map((e) => e.identifier!).toList());
return builder.toBytes();
}
static AppInfo parseAppInfo(Uint8List data) {
if (data.isEmpty || data[0] != MSG_TYPE_APP_INFO) {
throw ProtocolParseException('Invalid message type', data);
}
var idx = 1;
if (data.length < idx + 3) {
throw ProtocolParseException('App info message too short', data);
}
final version = data[idx];
idx += 1;
if (version != 0x01) {
throw ProtocolParseException('Unsupported app info version: $version', data);
}
if (idx >= data.length) throw ProtocolParseException('Missing app ID length', data);
final appIdLen = data[idx];
idx += 1;
if (idx + appIdLen > data.length) throw ProtocolParseException('App ID length exceeds buffer', data);
final appId = utf8.decode(data.sublist(idx, idx + appIdLen));
idx += appIdLen;
if (idx >= data.length) throw ProtocolParseException('Missing app version length', data);
final appVersionLen = data[idx];
idx += 1;
if (idx + appVersionLen > data.length) throw ProtocolParseException('App version length exceeds buffer', data);
final appVersion = utf8.decode(data.sublist(idx, idx + appVersionLen));
idx += appVersionLen;
if (idx >= data.length) throw ProtocolParseException('Missing button count', data);
final buttonCount = data[idx];
idx += 1;
if (idx + buttonCount > data.length) throw ProtocolParseException('Button count exceeds buffer', data);
final buttonIds = data.sublist(idx, idx + buttonCount).toList();
final controllerButtons = buttonIds.mapNotNull((id) => BUTTON_NAMES[id]).toList();
return AppInfo(
appId: appId,
appVersion: appVersion,
supportedButtons: controllerButtons,
supportedActions: controllerButtons.mapNotNull((b) => b.action).toList(),
);
}
}
class AppInfo {
final String appId;
final String appVersion;
final List<ControllerButton> supportedButtons;
final List<InGameAction> supportedActions;
AppInfo({
required this.appId,
required this.appVersion,
required this.supportedButtons,
required this.supportedActions,
});
@override
String toString() =>
'AppInfo(appId: $appId, appVersion: $appVersion, supportedButtons: $supportedButtons, supportedActions: $supportedActions)';
}
/// DeviceStatus message representation
class DeviceStatus {
final int? battery; // 0-100, null if 0xFF
final bool connected;
DeviceStatus({required this.battery, required this.connected});
@override
String toString() => 'DeviceStatus(battery: ${battery ?? 'unknown'}, connected: $connected)';
}
class ButtonState {
/// Represents a single button id/state pair.class ButtonState {
final ControllerButton button;
final int state; // 0=released,1=pressed,2-255=analog
const ButtonState(this.button, this.state);
@override
String toString() => formatButtonState(button, state);
String formatButtonState(ControllerButton button, int state) {
final buttonName = button.name;
String stateStr;
if (state == 0) {
stateStr = 'RELEASED';
} else if (state == 1) {
stateStr = 'PRESSED';
} else {
final percentage = ((state - 2) / (255 - 2) * 100).round();
stateStr = 'ANALOG $percentage%';
}
return '$buttonName: $stateStr';
}
}
/// Haptic feedback representation
class HapticFeedbackMessage {
final String pattern;
final int patternByte;
final int duration; // in 10ms units
final int intensity; // 0-255
HapticFeedbackMessage({
required this.pattern,
required this.patternByte,
required this.duration,
required this.intensity,
});
@override
String toString() => 'HapticFeedback(pattern: $pattern, duration: $duration, intensity: $intensity)';
}

View File

@@ -0,0 +1,66 @@
import 'dart:typed_data';
import 'package:bike_control/bluetooth/devices/bluetooth_device.dart';
import 'package:prop/emulators/ftms_emulator.dart';
import 'package:shadcn_flutter/shadcn_flutter.dart';
import 'package:universal_ble/universal_ble.dart';
class ProxyDevice extends BluetoothDevice {
static final List<String> proxyServiceUUIDs = [
'0000180d-0000-1000-8000-00805f9b34fb', // Heart Rate
'00001818-0000-1000-8000-00805f9b34fb', // Cycling Power
'00001826-0000-1000-8000-00805f9b34fb', // Fitness Machine
];
final FtmsEmulator emulator = FtmsEmulator();
ProxyDevice(super.scanResult)
: super(
availableButtons: const [],
isBeta: true,
);
late final List<BleService> services;
@override
Future<void> handleServices(List<BleService> services) async {
emulator.setScanResult(scanResult);
emulator.handleServices(services);
emulator.startServer();
}
@override
Future<void> processCharacteristic(String characteristic, Uint8List bytes) async {
emulator.processCharacteristic(characteristic, bytes);
}
@override
Widget showInformation(BuildContext context) {
return Column(
spacing: 16,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
super.showInformation(context),
if (!isConnected)
Button.primary(
style: ButtonStyle.primary(size: ButtonSize.small),
onPressed: () {
super.connect();
},
child: Text('Proxy'),
),
],
);
}
@override
Future<void> connect() async {}
@override
Future<void> disconnect() {
emulator.stop();
return super.disconnect();
}
}

View File

@@ -1,16 +1,16 @@
import 'dart:typed_data';
import 'package:bike_control/utils/core.dart';
import 'package:bike_control/utils/keymap/buttons.dart';
import 'package:dartx/dartx.dart';
import 'package:flutter/material.dart';
import 'package:swift_control/main.dart';
import 'package:swift_control/utils/keymap/apps/custom_app.dart';
import 'package:swift_control/utils/keymap/buttons.dart';
import 'package:prop/prop.dart';
import 'package:universal_ble/universal_ble.dart';
import '../bluetooth_device.dart';
class ShimanoDi2 extends BluetoothDevice {
ShimanoDi2(super.scanResult) : super(availableButtons: []);
ShimanoDi2(super.scanResult) : super(availableButtons: [], buttonPrefix: 'D-Fly Channel ');
@override
Future<void> handleServices(List<BleService> services) async {
@@ -26,11 +26,15 @@ class ShimanoDi2 extends BluetoothDevice {
await UniversalBle.subscribeIndications(device.deviceId, service.uuid, characteristic.uuid);
}
final _lastButtons = <int, int>{};
final _lastButtons = <int, ({int value, _Di2State type})>{};
bool _isInitialized = false;
@override
Future<void> processCharacteristic(String characteristic, Uint8List bytes) {
String get buttonExplanation => 'Click a D-Fly button to configure them.';
@override
Future<void> processCharacteristic(String characteristic, Uint8List bytes) async {
Logger.info('Received data from $characteristic: ${bytesToReadableHex(bytes)}');
if (characteristic.toLowerCase() == ShimanoDi2Constants.D_FLY_CHANNEL_UUID) {
final channels = bytes.sublist(1);
@@ -38,40 +42,100 @@ class ShimanoDi2 extends BluetoothDevice {
if (!_isInitialized) {
channels.forEachIndexed((int value, int index) {
final readableIndex = index + 1;
_lastButtons[index] = value;
_lastButtons[index] = (value: value, type: _Di2State.released);
actionHandler.supportedApp?.keymap.getOrAddButton(
getOrAddButton(
'D-Fly Channel $readableIndex',
() => ControllerButton('D-Fly Channel $readableIndex'),
() => ControllerButton('D-Fly Channel $readableIndex', sourceDeviceId: device.deviceId),
);
});
_isInitialized = true;
return Future.value();
}
final clickedButtons = <ControllerButton>[];
var actualChange = false;
channels.forEachIndexed((int value, int index) {
final didChange = _lastButtons[index] != value;
_lastButtons[index] = value;
final didChange = _lastButtons[index]?.value != value;
final readableIndex = index + 1;
final button = actionHandler.supportedApp?.keymap.getOrAddButton(
'D-Fly Channel $readableIndex',
() => ControllerButton('D-Fly Channel $readableIndex'),
);
if (didChange && button != null) {
clickedButtons.add(button);
if (didChange) {
if ((value & 0x10) != 0) {
if (_lastButtons[index]?.type == _Di2State.longPress || _lastButtons[index]?.type == _Di2State.keep) {
// short press is triggered after long press, until it's released later on
_lastButtons[index] = (value: value, type: _Di2State.keep);
Logger.info('Button $readableIndex still long pressed');
} else {
_lastButtons[index] = (value: value, type: _Di2State.shortPress);
actualChange = true;
Logger.info('Button $readableIndex short pressed');
}
} else if ((value & 0x20) != 0) {
_lastButtons[index] = (value: value, type: _Di2State.longPress);
actualChange = true;
Logger.info('Button $readableIndex long pressed');
} else if ((value & 0x40) != 0) {
_lastButtons[index] = (value: value, type: _Di2State.doublePress);
actualChange = true;
Logger.info('Button $readableIndex double pressed');
} else {
_lastButtons[index] = (value: value, type: _Di2State.released);
actualChange = true;
Logger.info('Button $readableIndex released');
}
}
});
if (clickedButtons.isNotEmpty) {
handleButtonsClicked(clickedButtons);
handleButtonsClicked([]);
if (actualChange) {
final Map<_Di2State, List<ControllerButton>> mapped = _lastButtons.entries.groupBy((e) => e.value.type).map((
key,
value,
) {
final buttons = value
.map((entry) => availableButtons.firstWhere((button) => button.name == 'D-Fly Channel ${entry.key + 1}'))
.toList();
return MapEntry(key, buttons);
});
final shortPress = [...?mapped[_Di2State.shortPress], ...?mapped[_Di2State.doublePress]];
if (shortPress.isNotEmpty) {
Logger.debug('Short Press Buttons to trigger: ${shortPress.map((b) => b.name).join(', ')}');
handleButtonsClicked(shortPress);
handleButtonsClicked([]);
_resetButtonsForState([_Di2State.shortPress]);
}
final longPress = mapped[_Di2State.longPress] ?? [];
if (longPress.isNotEmpty) {
Logger.debug('Long Press Buttons to trigger: ${longPress.map((b) => b.name).join(', ')}');
handleButtonsClicked(longPress);
}
final released = mapped[_Di2State.released] ?? [];
final keepPress = mapped[_Di2State.longPress] ?? [];
if (released.isNotEmpty && keepPress.isEmpty) {
Logger.debug('Releasing all Buttons');
handleButtonsClicked([]);
}
final doublePress = mapped[_Di2State.doublePress] ?? [];
if (doublePress.isNotEmpty) {
Logger.debug('Buttons to still trigger: ${doublePress.map((b) => b.name).join(', ')}');
handleButtonsClicked(doublePress);
handleButtonsClicked([]);
_resetButtonsForState([_Di2State.doublePress]);
}
}
}
return Future.value();
}
void _resetButtonsForState(List<_Di2State> list) {
_lastButtons.forEach((key, value) {
if (list.contains(value.type)) {
_lastButtons[key] = (value: value.value, type: _Di2State.released);
}
});
}
@override
@@ -80,13 +144,9 @@ class ShimanoDi2 extends BluetoothDevice {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
super.showInformation(context),
Text(
'Make sure to set your Di2 buttons to D-Fly channels in the Shimano E-TUBE app.',
style: TextStyle(fontSize: 12, color: Colors.grey),
),
if (actionHandler.supportedApp is! CustomApp)
if (!core.settings.getShowOnboarding())
Text(
'Use a custom keymap to support ${scanResult.name}',
'Make sure to set your Di2 buttons to D-Fly channels in the Shimano E-TUBE app.',
style: TextStyle(fontSize: 12, color: Colors.grey),
),
],
@@ -96,6 +156,15 @@ class ShimanoDi2 extends BluetoothDevice {
class ShimanoDi2Constants {
static const String SERVICE_UUID = "000018ef-5348-494d-414e-4f5f424c4500";
static const String SERVICE_UUID_ALTERNATIVE = "000018ff-5348-494d-414e-4f5f424c4500";
static const String D_FLY_CHANNEL_UUID = "00002ac2-5348-494d-414e-4f5f424c4500";
}
enum _Di2State {
shortPress,
longPress,
keep,
doublePress,
released,
}

View File

@@ -0,0 +1,179 @@
import 'dart:async';
import 'package:bike_control/bluetooth/messages/notification.dart';
import 'package:bike_control/utils/core.dart';
import 'package:bike_control/utils/keymap/buttons.dart';
import 'package:dartx/dartx.dart';
import 'package:flutter/foundation.dart';
import 'package:prop/prop.dart';
import 'package:shadcn_flutter/shadcn_flutter.dart';
import 'package:universal_ble/universal_ble.dart';
import '../bluetooth_device.dart';
class SramAxs extends BluetoothDevice {
SramAxs(super.scanResult) : super(availableButtons: [], isBeta: true);
Timer? _singleClickTimer;
int _tapCount = 0;
@override
Future<void> disconnect() async {
_singleClickTimer?.cancel();
_singleClickTimer = null;
_tapCount = 0;
await super.disconnect();
}
@override
Future<void> handleServices(List<BleService> services) async {
final service = services.firstOrNullWhere(
(e) => e.uuid.toLowerCase() == SramAxsConstants.SERVICE_UUID_RELEVANT.toLowerCase(),
);
if (service == null) {
actionStreamInternal.add(LogNotification('SramAxs: Relevant service not found: ${SramAxsConstants.SERVICE_UUID_RELEVANT}'));
return;
}
final characteristic = service.characteristics.firstWhere(
(e) => e.uuid.toLowerCase() == SramAxsConstants.TRIGGER_UUID.toLowerCase(),
orElse: () => throw Exception('Characteristic not found: ${SramAxsConstants.TRIGGER_UUID}'),
);
await UniversalBle.subscribeNotifications(device.deviceId, service.uuid, characteristic.uuid);
// add both buttons
_singleClickButton();
_doubleClickButton();
}
ControllerButton _singleClickButton() => getOrAddButton(
'SRAM Tap',
() => ControllerButton('SRAM Tap', action: InGameAction.shiftUp, sourceDeviceId: device.deviceId),
);
ControllerButton _doubleClickButton() => getOrAddButton(
'SRAM Double Tap',
() => ControllerButton('SRAM Double Tap', action: InGameAction.shiftDown, sourceDeviceId: device.deviceId),
);
void _emitClick(ControllerButton button) {
// Use the common pipeline so long-press handling and app action execution stays consistent.
handleButtonsClickedWithoutLongPressSupport([button]);
}
void _registerTap() {
final windowMs = core.settings.getSramAxsDoubleClickWindowMs();
_tapCount++;
// First tap: start a timer. If no second tap arrives in time => single click.
if (_tapCount == 1) {
_singleClickTimer?.cancel();
_singleClickTimer = Timer(Duration(milliseconds: windowMs), () {
if (_tapCount == 1) {
_emitClick(_singleClickButton());
}
_tapCount = 0;
});
return;
}
// Second tap within window: double click.
if (_tapCount == 2) {
_singleClickTimer?.cancel();
_singleClickTimer = null;
_emitClick(_doubleClickButton());
_tapCount = 0;
return;
}
// If we get more than two taps fast, treat as a double click and restart counting.
_singleClickTimer?.cancel();
_singleClickTimer = null;
_emitClick(_doubleClickButton());
_tapCount = 0;
}
@override
Future<void> processCharacteristic(String characteristic, Uint8List bytes) async {
if (kDebugMode) {
debugPrint('SramAxs: Received data on characteristic $characteristic: ${bytesToHex(bytes)}');
}
if (characteristic.toLowerCase() == SramAxsConstants.TRIGGER_UUID.toLowerCase()) {
// At the moment we can only detect "some button pressed". We therefore interpret each
// notification as a tap and provide two logical buttons (single & double click).
_registerTap();
}
return Future.value();
}
@override
Widget showInformation(BuildContext context) {
final windowMs = core.settings.getSramAxsDoubleClickWindowMs();
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 12,
children: [
super.showInformation(context),
Text(
"Don't forget to turn off the function of the button you want to use in the SRAM AXS app!\n"
"Unfortunately, at the moment it's not possible to determine which physical button was pressed on your SRAM AXS device. Let us know if you have a contact at SRAM who can help :)\n\n"
'So the app exposes two logical buttons:\n'
'• SRAM Tap, assigned to Shift Up\n'
'• SRAM Double Tap, assigned to Shift Down\n\n'
'You can assign an action to each in the app settings.',
).xSmall,
Builder(
builder: (context) {
return PrimaryButton(
size: ButtonSize.small,
trailing: Container(
padding: const EdgeInsets.symmetric(horizontal: 4),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primary,
borderRadius: BorderRadius.circular(4),
),
child: Text('${windowMs}ms'),
),
onPressed: () {
final values = [
for (var v = 150; v <= 600; v += 50) v,
];
showDropdown(
context: context,
builder: (b) => DropdownMenu(
children: values
.map(
(v) => MenuButton(
child: Text('${v}ms'),
onPressed: (c) async {
await core.settings.setSramAxsDoubleClickWindowMs(v);
// Force rebuild to show new value.
(context as Element).markNeedsBuild();
},
),
)
.toList(),
),
);
},
child: const Text('Double-click window:'),
);
},
),
],
);
}
}
class SramAxsConstants {
static const String SERVICE_UUID = "0000fe51-0000-1000-8000-00805f9b34fb";
static const String SERVICE_UUID_RELEVANT = "d9050053-90aa-4c7c-b036-1e01fb8eb7ee";
static const String TRIGGER_UUID = "d9050054-90aa-4c7c-b036-1e01fb8eb7ee";
}

View File

@@ -0,0 +1,90 @@
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:bike_control/bluetooth/messages/notification.dart';
import 'package:bike_control/utils/keymap/buttons.dart';
import 'package:universal_ble/universal_ble.dart';
import '../bluetooth_device.dart';
class ThinkRiderVs200 extends BluetoothDevice {
ThinkRiderVs200(super.scanResult)
: super(
availableButtons: ThinkRiderVs200Buttons.values,
isBeta: true,
allowMultiple: true,
);
@override
Future<void> handleServices(List<BleService> services) async {
// Only subscribe to service 0xFEA0
final service = services.firstWhere(
(e) => e.uuid.toLowerCase() == ThinkRiderVs200Constants.SERVICE_UUID.toLowerCase(),
orElse: () => throw Exception('Service not found: ${ThinkRiderVs200Constants.SERVICE_UUID}'),
);
final characteristic = service.characteristics.firstWhere(
(e) => e.uuid.toLowerCase() == ThinkRiderVs200Constants.CHARACTERISTIC_UUID.toLowerCase(),
orElse: () => throw Exception('Characteristic not found: ${ThinkRiderVs200Constants.CHARACTERISTIC_UUID}'),
);
await UniversalBle.subscribeNotifications(device.deviceId, service.uuid, characteristic.uuid);
}
@override
Future<void> processCharacteristic(String characteristic, Uint8List bytes) {
if (characteristic.toLowerCase() == ThinkRiderVs200Constants.CHARACTERISTIC_UUID.toLowerCase()) {
final hexValue = _bytesToHex(bytes).toLowerCase();
// Log all received values while in beta
if (isBeta) {
actionStreamInternal.add(LogNotification('VS200 received: $hexValue'));
}
// Check for specific byte patterns
if (hexValue == ThinkRiderVs200Constants.SHIFT_UP_PATTERN) {
// Plus button pressed
actionStreamInternal.add(LogNotification('Shift Up detected: $hexValue'));
handleButtonsClickedWithoutLongPressSupport([availableButtons[0]]);
} else if (hexValue == ThinkRiderVs200Constants.SHIFT_DOWN_PATTERN) {
// Minus button pressed
actionStreamInternal.add(LogNotification('Shift Down detected: $hexValue'));
handleButtonsClickedWithoutLongPressSupport([availableButtons[1]]);
}
}
return Future.value();
}
String _bytesToHex(List<int> bytes) {
return bytes.map((byte) => byte.toRadixString(16).padLeft(2, '0')).join();
}
}
class ThinkRiderVs200Constants {
// Service and characteristic UUIDs based on the nRF Connect screenshot
static const String SERVICE_UUID = "0000fea0-0000-1000-8000-00805f9b34fb";
static const String CHARACTERISTIC_UUID = "0000fea1-0000-1000-8000-00805f9b34fb";
// Byte patterns for button detection
static const String SHIFT_UP_PATTERN = "f3050301fc";
static const String SHIFT_DOWN_PATTERN = "f3050300fb";
}
class ThinkRiderVs200Buttons {
static const ControllerButton shiftUp = ControllerButton(
'shiftUp',
action: InGameAction.shiftUp,
icon: Icons.add,
);
static const ControllerButton shiftDown = ControllerButton(
'shiftDown',
action: InGameAction.shiftDown,
icon: Icons.remove,
);
static const List<ControllerButton> values = [
shiftUp,
shiftDown,
];
}

View File

@@ -0,0 +1,16 @@
import 'package:bike_control/utils/actions/base_actions.dart';
import 'package:bike_control/utils/keymap/buttons.dart';
import 'package:bike_control/utils/keymap/keymap.dart';
import 'package:flutter/foundation.dart';
abstract class TrainerConnection {
final String title;
List<InGameAction> supportedActions;
final ValueNotifier<bool> isStarted = ValueNotifier(false);
final ValueNotifier<bool> isConnected = ValueNotifier(false);
TrainerConnection({required this.title, required this.supportedActions});
Future<ActionResult> sendAction(KeyPair keyPair, {required bool isKeyDown, required bool isKeyUp});
}

View File

@@ -0,0 +1,10 @@
import 'package:bike_control/bluetooth/devices/zwift/zwift_ride.dart';
import '../zwift/constants.dart';
class WahooKickrBikePro extends ZwiftRide {
WahooKickrBikePro(super.scanResult) : super();
@override
String get customServiceId => ZwiftConstants.ZWIFT_CUSTOM_SERVICE_UUID;
}

View File

@@ -2,7 +2,7 @@ import 'dart:collection';
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:swift_control/utils/keymap/buttons.dart';
import 'package:bike_control/utils/keymap/buttons.dart';
import 'package:universal_ble/universal_ble.dart';
import '../bluetooth_device.dart';

View File

@@ -0,0 +1,154 @@
import 'dart:typed_data';
import 'package:bike_control/utils/actions/base_actions.dart';
import 'package:bike_control/utils/keymap/buttons.dart';
import 'package:bike_control/utils/keymap/keymap.dart';
import 'package:universal_ble/universal_ble.dart';
import '../bluetooth_device.dart';
class WahooKickrHeadwind extends BluetoothDevice {
// Current mode state
HeadwindMode _currentMode = HeadwindMode.unknown;
int _currentSpeed = 0;
WahooKickrHeadwind(super.scanResult)
: super(
availableButtons: const [],
isBeta: true,
);
@override
Future<void> handleServices(List<BleService> services) async {
final service = services.firstWhere(
(e) => e.uuid == WahooKickrHeadwindConstants.SERVICE_UUID.toLowerCase(),
orElse: () => throw Exception('Service not found: ${WahooKickrHeadwindConstants.SERVICE_UUID}'),
);
final characteristic = service.characteristics.firstWhere(
(e) => e.uuid == WahooKickrHeadwindConstants.CHARACTERISTIC_UUID.toLowerCase(),
orElse: () => throw Exception('Characteristic not found: ${WahooKickrHeadwindConstants.CHARACTERISTIC_UUID}'),
);
// Subscribe to notifications for status updates
await UniversalBle.subscribeNotifications(device.deviceId, service.uuid, characteristic.uuid);
}
@override
Future<void> processCharacteristic(String characteristic, Uint8List bytes) {
// Analyze the received bytes to determine current state
if (bytes.length >= 4 && bytes[0] == 0xFD && bytes[1] == 0x01) {
final mode = bytes[3];
final speed = bytes[2];
switch (mode) {
case 0x02:
_currentMode = HeadwindMode.heartRate;
break;
case 0x03:
_currentMode = HeadwindMode.speed;
break;
case 0x01:
_currentMode = HeadwindMode.off;
break;
case 0x04:
_currentMode = HeadwindMode.manual;
_currentSpeed = speed;
break;
}
}
return Future.value();
}
Future<void> setSpeed(int speedPercent) async {
// Validate against the allowed speed values
const allowedSpeeds = [0, 25, 50, 75, 100];
if (!allowedSpeeds.contains(speedPercent)) {
throw ArgumentError('Speed must be one of: ${allowedSpeeds.join(", ")}');
}
final service = WahooKickrHeadwindConstants.SERVICE_UUID.toLowerCase();
final characteristic = WahooKickrHeadwindConstants.CHARACTERISTIC_UUID.toLowerCase();
// Check if manual mode is enabled, if not enable it first
if (_currentMode != HeadwindMode.manual) {
final manualModeData = Uint8List.fromList([0x04, 0x04]);
await UniversalBle.write(
device.deviceId,
service,
characteristic,
manualModeData,
withoutResponse: true,
);
_currentMode = HeadwindMode.manual;
// Small delay to ensure mode change is processed before speed command
await Future.delayed(const Duration(milliseconds: 100));
}
// Command format: [0x02, speed_value]
// Speed value: 0x00 to 0x64 (0-100 in hex)
final data = Uint8List.fromList([0x02, speedPercent]);
await UniversalBle.write(
device.deviceId,
service,
characteristic,
data,
withoutResponse: true,
);
_currentSpeed = speedPercent;
}
Future<void> setHeartRateMode() async {
final service = WahooKickrHeadwindConstants.SERVICE_UUID.toLowerCase();
final characteristic = WahooKickrHeadwindConstants.CHARACTERISTIC_UUID.toLowerCase();
// Command format: [0x04, 0x02] for HR mode
final data = Uint8List.fromList([0x04, 0x02]);
await UniversalBle.write(
device.deviceId,
service,
characteristic,
data,
withoutResponse: true,
);
_currentMode = HeadwindMode.heartRate;
}
Future<ActionResult> handleKeypair(KeyPair keyPair, {required bool isKeyDown}) async {
if (!isKeyDown) {
return NotHandled('');
}
try {
if (keyPair.inGameAction == InGameAction.headwindSpeed) {
final speed = keyPair.inGameActionValue ?? 0;
await setSpeed(speed);
return Success('Headwind speed set to $speed%');
} else if (keyPair.inGameAction == InGameAction.headwindHeartRateMode) {
await setHeartRateMode();
return Success('Headwind set to Heart Rate mode');
}
} catch (e) {
return Error('Failed to control Headwind: $e');
}
return NotHandled('');
}
}
class WahooKickrHeadwindConstants {
// Wahoo KICKR Headwind service and characteristic UUIDs
// These are standard Wahoo fitness equipment UUIDs
static const String SERVICE_UUID = "A026EE0C-0A7D-4AB3-97FA-F1500F9FEB8B";
static const String CHARACTERISTIC_UUID = "A026E038-0A7D-4AB3-97FA-F1500F9FEB8B";
}
enum HeadwindMode {
unknown,
heartRate, // HR mode (0x02)
speed, // Speed mode (0x03)
off, // OFF mode (0x01)
manual, // Manual speed mode (0x04)
}

View File

@@ -1,10 +1,11 @@
import 'dart:typed_data';
import 'package:bike_control/utils/keymap/buttons.dart';
import 'package:flutter/material.dart';
import 'package:swift_control/utils/keymap/buttons.dart';
class ZwiftConstants {
static const ZWIFT_CUSTOM_SERVICE_UUID = "00000001-19CA-4651-86E5-FA29DCDD09D1";
static const ZWIFT_CUSTOM_SERVICE_SHORT_UUID = "0001";
static const ZWIFT_RIDE_CUSTOM_SERVICE_UUID = "0000fc82-0000-1000-8000-00805f9b34fb";
static const ZWIFT_RIDE_CUSTOM_SERVICE_UUID_SHORT = "fc82";
static const ZWIFT_ASYNC_CHARACTERISTIC_UUID = "00000002-19CA-4651-86E5-FA29DCDD09D1";
@@ -59,25 +60,25 @@ class ZwiftButtons {
// left controller
static const ControllerButton navigationUp = ControllerButton(
'navigationUp',
action: InGameAction.toggleUi,
action: InGameAction.up,
icon: Icons.keyboard_arrow_up,
color: Colors.black,
);
static const ControllerButton navigationDown = ControllerButton(
'navigationDown',
action: InGameAction.uturn,
action: InGameAction.down,
icon: Icons.keyboard_arrow_down,
color: Colors.black,
);
static const ControllerButton navigationLeft = ControllerButton(
'navigationLeft',
action: InGameAction.navigateLeft,
action: InGameAction.steerLeft,
icon: Icons.keyboard_arrow_left,
color: Colors.black,
);
static const ControllerButton navigationRight = ControllerButton(
'navigationRight',
action: InGameAction.navigateRight,
action: InGameAction.steerRight,
icon: Icons.keyboard_arrow_right,
color: Colors.black,
);
@@ -99,10 +100,14 @@ class ZwiftButtons {
static const ControllerButton powerUpLeft = ControllerButton('powerUpLeft', action: InGameAction.shiftDown);
// right controller
static const ControllerButton a = ControllerButton('a', action: null, color: Colors.lightGreen);
static const ControllerButton b = ControllerButton('b', action: null, color: Colors.pinkAccent);
static const ControllerButton z = ControllerButton('z', action: null, color: Colors.deepOrangeAccent);
static const ControllerButton y = ControllerButton('y', action: null, color: Colors.lightBlue);
static const ControllerButton a = ControllerButton('a', action: InGameAction.select, color: Colors.lightGreen);
static const ControllerButton b = ControllerButton('b', action: InGameAction.back, color: Colors.pinkAccent);
static const ControllerButton z = ControllerButton(
'z',
action: InGameAction.rideOnBomb,
color: Colors.deepOrangeAccent,
);
static const ControllerButton y = ControllerButton('y', action: InGameAction.menu, color: Colors.lightBlue);
static const ControllerButton onOffRight = ControllerButton('onOffRight', action: InGameAction.toggleUi);
static const ControllerButton sideButtonRight = ControllerButton('sideButtonRight', action: InGameAction.shiftUp);
static const ControllerButton paddleRight = ControllerButton('paddleRight', action: InGameAction.shiftUp);

View File

@@ -0,0 +1,120 @@
import 'package:bike_control/bluetooth/devices/trainer_connection.dart';
import 'package:bike_control/bluetooth/devices/zwift/zwift_ride.dart';
import 'package:bike_control/bluetooth/messages/notification.dart';
import 'package:bike_control/gen/l10n.dart';
import 'package:bike_control/utils/actions/base_actions.dart';
import 'package:bike_control/utils/core.dart';
import 'package:bike_control/utils/keymap/buttons.dart';
import 'package:bike_control/utils/keymap/keymap.dart';
import 'package:flutter/foundation.dart';
import 'package:prop/prop.dart' hide RideButtonMask;
class FtmsMdnsEmulator extends TrainerConnection {
static const String connectionTitle = 'Zwift Network Emulator';
late final ClickEmulator clickEmulator = ClickEmulator();
var lastMessageId = 0;
FtmsMdnsEmulator()
: super(
title: connectionTitle,
supportedActions: [
InGameAction.shiftUp,
InGameAction.shiftDown,
InGameAction.uturn,
InGameAction.steerLeft,
InGameAction.steerRight,
InGameAction.openActionBar,
InGameAction.usePowerUp,
InGameAction.select,
InGameAction.back,
InGameAction.rideOnBomb,
],
) {
clickEmulator.isStarted.addListener(() {
isStarted.value = clickEmulator.isStarted.value;
});
clickEmulator.isConnected.addListener(() {
isConnected.value = clickEmulator.isConnected.value;
if (isConnected.value) {
core.connection.signalNotification(
AlertNotification(LogLevel.LOGLEVEL_INFO, AppLocalizations.current.connected),
);
} else {
core.connection.signalNotification(
AlertNotification(LogLevel.LOGLEVEL_INFO, AppLocalizations.current.disconnected),
);
}
});
}
Future<void> startServer() async {
return clickEmulator.startServer();
}
void stop() {
clickEmulator.stop();
}
@override
Future<ActionResult> sendAction(KeyPair keyPair, {required bool isKeyDown, required bool isKeyUp}) async {
final button = switch (keyPair.inGameAction) {
InGameAction.shiftUp => RideButtonMask.SHFT_UP_R_BTN,
InGameAction.shiftDown => RideButtonMask.SHFT_UP_L_BTN,
InGameAction.uturn => RideButtonMask.DOWN_BTN,
InGameAction.steerLeft => RideButtonMask.LEFT_BTN,
InGameAction.steerRight => RideButtonMask.RIGHT_BTN,
InGameAction.openActionBar => RideButtonMask.UP_BTN,
InGameAction.usePowerUp => RideButtonMask.Y_BTN,
InGameAction.select => RideButtonMask.A_BTN,
InGameAction.back => RideButtonMask.B_BTN,
InGameAction.rideOnBomb => RideButtonMask.Z_BTN,
_ => null,
};
if (button == null) {
return NotHandled('Action ${keyPair.inGameAction!.name} not supported by Zwift Emulator');
}
if (isKeyDown) {
final status = RideKeyPadStatus()
..buttonMap = (~button.mask) & 0xFFFFFFFF
..analogPaddles.clear();
final bytes = status.writeToBuffer();
clickEmulator.writeNotification(bytes);
}
if (isKeyUp) {
clickEmulator.writeNotification(
Uint8List.fromList([0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F]),
);
}
if (kDebugMode) {
print('Sent action up $isKeyUp vs down $isKeyDown ${keyPair.inGameAction!.title} to Zwift Emulator');
}
return Success('Sent action ${isKeyDown ? 'down' : ''} ${isKeyUp ? 'up' : ''}: ${keyPair.inGameAction!.title}');
}
}
class FtmsMdnsConstants {
static const DC_RC_REQUEST_COMPLETED_SUCCESSFULLY = 0; // Request completed successfully
static const DC_RC_UNKNOWN_MESSAGE_TYPE = 1; // Unknown Message Type
static const DC_RC_UNEXPECTED_ERROR = 2; // Unexpected Error
static const DC_RC_SERVICE_NOT_FOUND = 3; // Service Not Found
static const DC_RC_CHARACTERISTIC_NOT_FOUND = 4; // Characteristic Not Found
static const DC_RC_CHARACTERISTIC_OPERATION_NOT_SUPPORTED =
5; // Characteristic Operation Not Supported (See Characteristic Properties)
static const DC_RC_CHARACTERISTIC_WRITE_FAILED_INVALID_SIZE =
6; // Characteristic Write Failed Invalid characteristic data size
static const DC_RC_UNKNOWN_PROTOCOL_VERSION =
7; // Unknown Protocol Version the command contains a protocol version that the device does not recognize
static const DC_MESSAGE_DISCOVER_SERVICES = 0x01; // Discover Services
static const DC_MESSAGE_DISCOVER_CHARACTERISTICS = 0x02; // Discover Characteristics
static const DC_MESSAGE_READ_CHARACTERISTIC = 0x03; // Read Characteristic
static const DC_MESSAGE_WRITE_CHARACTERISTIC = 0x04; // Write Characteristic
static const DC_MESSAGE_ENABLE_CHARACTERISTIC_NOTIFICATIONS = 0x05; // Enable Characteristic Notifications
static const DC_MESSAGE_CHARACTERISTIC_NOTIFICATION = 0x06; // Characteristic Notification
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,14 +0,0 @@
//
// Generated code. Do not modify.
// source: zp.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides, camel_case_types, comment_references
// ignore_for_file: constant_identifier_names
// ignore_for_file: deprecated_member_use_from_same_package, library_prefixes
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import
export 'zp.pb.dart';

View File

@@ -1,896 +0,0 @@
//
// Generated code. Do not modify.
// source: zp_vendor.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides, camel_case_types, comment_references
// ignore_for_file: constant_identifier_names, library_prefixes
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import
import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
import 'zp_vendor.pbenum.dart';
export 'zp_vendor.pbenum.dart';
class ControllerSync extends $pb.GeneratedMessage {
factory ControllerSync({
ControllerSyncStatus? status,
$core.int? timeStamp,
}) {
final $result = create();
if (status != null) {
$result.status = status;
}
if (timeStamp != null) {
$result.timeStamp = timeStamp;
}
return $result;
}
ControllerSync._() : super();
factory ControllerSync.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory ControllerSync.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'ControllerSync', package: const $pb.PackageName(_omitMessageNames ? '' : 'com.zwift.protobuf'), createEmptyInstance: create)
..e<ControllerSyncStatus>(1, _omitFieldNames ? '' : 'status', $pb.PbFieldType.OE, defaultOrMaker: ControllerSyncStatus.NOT_CONNECTED, valueOf: ControllerSyncStatus.valueOf, enumValues: ControllerSyncStatus.values)
..a<$core.int>(2, _omitFieldNames ? '' : 'timeStamp', $pb.PbFieldType.O3, protoName: 'timeStamp')
..hasRequiredFields = false
;
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
ControllerSync clone() => ControllerSync()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
ControllerSync copyWith(void Function(ControllerSync) updates) => super.copyWith((message) => updates(message as ControllerSync)) as ControllerSync;
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static ControllerSync create() => ControllerSync._();
ControllerSync createEmptyInstance() => create();
static $pb.PbList<ControllerSync> createRepeated() => $pb.PbList<ControllerSync>();
@$core.pragma('dart2js:noInline')
static ControllerSync getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<ControllerSync>(create);
static ControllerSync? _defaultInstance;
/// optional in code; proto3 treats as present when non-zero
@$pb.TagNumber(1)
ControllerSyncStatus get status => $_getN(0);
@$pb.TagNumber(1)
set status(ControllerSyncStatus v) { setField(1, v); }
@$pb.TagNumber(1)
$core.bool hasStatus() => $_has(0);
@$pb.TagNumber(1)
void clearStatus() => clearField(1);
@$pb.TagNumber(2)
$core.int get timeStamp => $_getIZ(1);
@$pb.TagNumber(2)
set timeStamp($core.int v) { $_setSignedInt32(1, v); }
@$pb.TagNumber(2)
$core.bool hasTimeStamp() => $_has(1);
@$pb.TagNumber(2)
void clearTimeStamp() => clearField(2);
}
class EnableTestMode extends $pb.GeneratedMessage {
factory EnableTestMode({
$core.bool? enable,
}) {
final $result = create();
if (enable != null) {
$result.enable = enable;
}
return $result;
}
EnableTestMode._() : super();
factory EnableTestMode.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory EnableTestMode.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'EnableTestMode', package: const $pb.PackageName(_omitMessageNames ? '' : 'com.zwift.protobuf'), createEmptyInstance: create)
..aOB(1, _omitFieldNames ? '' : 'enable')
..hasRequiredFields = false
;
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
EnableTestMode clone() => EnableTestMode()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
EnableTestMode copyWith(void Function(EnableTestMode) updates) => super.copyWith((message) => updates(message as EnableTestMode)) as EnableTestMode;
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static EnableTestMode create() => EnableTestMode._();
EnableTestMode createEmptyInstance() => create();
static $pb.PbList<EnableTestMode> createRepeated() => $pb.PbList<EnableTestMode>();
@$core.pragma('dart2js:noInline')
static EnableTestMode getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<EnableTestMode>(create);
static EnableTestMode? _defaultInstance;
@$pb.TagNumber(1)
$core.bool get enable => $_getBF(0);
@$pb.TagNumber(1)
set enable($core.bool v) { $_setBool(0, v); }
@$pb.TagNumber(1)
$core.bool hasEnable() => $_has(0);
@$pb.TagNumber(1)
void clearEnable() => clearField(1);
}
class PairDevices extends $pb.GeneratedMessage {
factory PairDevices({
$core.bool? pair,
PairDeviceType? type,
$core.List<$core.int>? deviceId,
}) {
final $result = create();
if (pair != null) {
$result.pair = pair;
}
if (type != null) {
$result.type = type;
}
if (deviceId != null) {
$result.deviceId = deviceId;
}
return $result;
}
PairDevices._() : super();
factory PairDevices.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory PairDevices.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'PairDevices', package: const $pb.PackageName(_omitMessageNames ? '' : 'com.zwift.protobuf'), createEmptyInstance: create)
..aOB(1, _omitFieldNames ? '' : 'pair')
..e<PairDeviceType>(2, _omitFieldNames ? '' : 'type', $pb.PbFieldType.OE, defaultOrMaker: PairDeviceType.BLE, valueOf: PairDeviceType.valueOf, enumValues: PairDeviceType.values)
..a<$core.List<$core.int>>(3, _omitFieldNames ? '' : 'deviceId', $pb.PbFieldType.OY, protoName: 'deviceId')
..hasRequiredFields = false
;
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
PairDevices clone() => PairDevices()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
PairDevices copyWith(void Function(PairDevices) updates) => super.copyWith((message) => updates(message as PairDevices)) as PairDevices;
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static PairDevices create() => PairDevices._();
PairDevices createEmptyInstance() => create();
static $pb.PbList<PairDevices> createRepeated() => $pb.PbList<PairDevices>();
@$core.pragma('dart2js:noInline')
static PairDevices getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<PairDevices>(create);
static PairDevices? _defaultInstance;
@$pb.TagNumber(1)
$core.bool get pair => $_getBF(0);
@$pb.TagNumber(1)
set pair($core.bool v) { $_setBool(0, v); }
@$pb.TagNumber(1)
$core.bool hasPair() => $_has(0);
@$pb.TagNumber(1)
void clearPair() => clearField(1);
@$pb.TagNumber(2)
PairDeviceType get type => $_getN(1);
@$pb.TagNumber(2)
set type(PairDeviceType v) { setField(2, v); }
@$pb.TagNumber(2)
$core.bool hasType() => $_has(1);
@$pb.TagNumber(2)
void clearType() => clearField(2);
@$pb.TagNumber(3)
$core.List<$core.int> get deviceId => $_getN(2);
@$pb.TagNumber(3)
set deviceId($core.List<$core.int> v) { $_setBytes(2, v); }
@$pb.TagNumber(3)
$core.bool hasDeviceId() => $_has(2);
@$pb.TagNumber(3)
void clearDeviceId() => clearField(3);
}
class DevicePairingDataPage_PairedDevice extends $pb.GeneratedMessage {
factory DevicePairingDataPage_PairedDevice({
$core.List<$core.int>? device,
}) {
final $result = create();
if (device != null) {
$result.device = device;
}
return $result;
}
DevicePairingDataPage_PairedDevice._() : super();
factory DevicePairingDataPage_PairedDevice.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory DevicePairingDataPage_PairedDevice.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'DevicePairingDataPage.PairedDevice', package: const $pb.PackageName(_omitMessageNames ? '' : 'com.zwift.protobuf'), createEmptyInstance: create)
..a<$core.List<$core.int>>(1, _omitFieldNames ? '' : 'device', $pb.PbFieldType.OY)
..hasRequiredFields = false
;
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
DevicePairingDataPage_PairedDevice clone() => DevicePairingDataPage_PairedDevice()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
DevicePairingDataPage_PairedDevice copyWith(void Function(DevicePairingDataPage_PairedDevice) updates) => super.copyWith((message) => updates(message as DevicePairingDataPage_PairedDevice)) as DevicePairingDataPage_PairedDevice;
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static DevicePairingDataPage_PairedDevice create() => DevicePairingDataPage_PairedDevice._();
DevicePairingDataPage_PairedDevice createEmptyInstance() => create();
static $pb.PbList<DevicePairingDataPage_PairedDevice> createRepeated() => $pb.PbList<DevicePairingDataPage_PairedDevice>();
@$core.pragma('dart2js:noInline')
static DevicePairingDataPage_PairedDevice getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<DevicePairingDataPage_PairedDevice>(create);
static DevicePairingDataPage_PairedDevice? _defaultInstance;
@$pb.TagNumber(1)
$core.List<$core.int> get device => $_getN(0);
@$pb.TagNumber(1)
set device($core.List<$core.int> v) { $_setBytes(0, v); }
@$pb.TagNumber(1)
$core.bool hasDevice() => $_has(0);
@$pb.TagNumber(1)
void clearDevice() => clearField(1);
}
class DevicePairingDataPage extends $pb.GeneratedMessage {
factory DevicePairingDataPage({
$core.int? devicesCount,
$core.int? pairingStatus,
$core.Iterable<DevicePairingDataPage_PairedDevice>? pairingDevList,
}) {
final $result = create();
if (devicesCount != null) {
$result.devicesCount = devicesCount;
}
if (pairingStatus != null) {
$result.pairingStatus = pairingStatus;
}
if (pairingDevList != null) {
$result.pairingDevList.addAll(pairingDevList);
}
return $result;
}
DevicePairingDataPage._() : super();
factory DevicePairingDataPage.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory DevicePairingDataPage.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'DevicePairingDataPage', package: const $pb.PackageName(_omitMessageNames ? '' : 'com.zwift.protobuf'), createEmptyInstance: create)
..a<$core.int>(1, _omitFieldNames ? '' : 'devicesCount', $pb.PbFieldType.O3, protoName: 'devicesCount')
..a<$core.int>(2, _omitFieldNames ? '' : 'pairingStatus', $pb.PbFieldType.O3, protoName: 'pairingStatus')
..pc<DevicePairingDataPage_PairedDevice>(3, _omitFieldNames ? '' : 'pairingDevList', $pb.PbFieldType.PM, protoName: 'pairingDevList', subBuilder: DevicePairingDataPage_PairedDevice.create)
..hasRequiredFields = false
;
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
DevicePairingDataPage clone() => DevicePairingDataPage()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
DevicePairingDataPage copyWith(void Function(DevicePairingDataPage) updates) => super.copyWith((message) => updates(message as DevicePairingDataPage)) as DevicePairingDataPage;
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static DevicePairingDataPage create() => DevicePairingDataPage._();
DevicePairingDataPage createEmptyInstance() => create();
static $pb.PbList<DevicePairingDataPage> createRepeated() => $pb.PbList<DevicePairingDataPage>();
@$core.pragma('dart2js:noInline')
static DevicePairingDataPage getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<DevicePairingDataPage>(create);
static DevicePairingDataPage? _defaultInstance;
@$pb.TagNumber(1)
$core.int get devicesCount => $_getIZ(0);
@$pb.TagNumber(1)
set devicesCount($core.int v) { $_setSignedInt32(0, v); }
@$pb.TagNumber(1)
$core.bool hasDevicesCount() => $_has(0);
@$pb.TagNumber(1)
void clearDevicesCount() => clearField(1);
@$pb.TagNumber(2)
$core.int get pairingStatus => $_getIZ(1);
@$pb.TagNumber(2)
set pairingStatus($core.int v) { $_setSignedInt32(1, v); }
@$pb.TagNumber(2)
$core.bool hasPairingStatus() => $_has(1);
@$pb.TagNumber(2)
void clearPairingStatus() => clearField(2);
@$pb.TagNumber(3)
$core.List<DevicePairingDataPage_PairedDevice> get pairingDevList => $_getList(2);
}
enum SetDfuTest_TestCase {
failedEnterDfu,
failedStartAdvertising,
crcFailure,
notSet
}
class SetDfuTest extends $pb.GeneratedMessage {
factory SetDfuTest({
$core.bool? failedEnterDfu,
$core.bool? failedStartAdvertising,
$core.int? crcFailure,
}) {
final $result = create();
if (failedEnterDfu != null) {
$result.failedEnterDfu = failedEnterDfu;
}
if (failedStartAdvertising != null) {
$result.failedStartAdvertising = failedStartAdvertising;
}
if (crcFailure != null) {
$result.crcFailure = crcFailure;
}
return $result;
}
SetDfuTest._() : super();
factory SetDfuTest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory SetDfuTest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
static const $core.Map<$core.int, SetDfuTest_TestCase> _SetDfuTest_TestCaseByTag = {
1 : SetDfuTest_TestCase.failedEnterDfu,
2 : SetDfuTest_TestCase.failedStartAdvertising,
3 : SetDfuTest_TestCase.crcFailure,
0 : SetDfuTest_TestCase.notSet
};
static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'SetDfuTest', package: const $pb.PackageName(_omitMessageNames ? '' : 'com.zwift.protobuf'), createEmptyInstance: create)
..oo(0, [1, 2, 3])
..aOB(1, _omitFieldNames ? '' : 'failedEnterDfu', protoName: 'failedEnterDfu')
..aOB(2, _omitFieldNames ? '' : 'failedStartAdvertising', protoName: 'failedStartAdvertising')
..a<$core.int>(3, _omitFieldNames ? '' : 'crcFailure', $pb.PbFieldType.O3, protoName: 'crcFailure')
..hasRequiredFields = false
;
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
SetDfuTest clone() => SetDfuTest()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
SetDfuTest copyWith(void Function(SetDfuTest) updates) => super.copyWith((message) => updates(message as SetDfuTest)) as SetDfuTest;
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static SetDfuTest create() => SetDfuTest._();
SetDfuTest createEmptyInstance() => create();
static $pb.PbList<SetDfuTest> createRepeated() => $pb.PbList<SetDfuTest>();
@$core.pragma('dart2js:noInline')
static SetDfuTest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<SetDfuTest>(create);
static SetDfuTest? _defaultInstance;
SetDfuTest_TestCase whichTestCase() => _SetDfuTest_TestCaseByTag[$_whichOneof(0)]!;
void clearTestCase() => clearField($_whichOneof(0));
@$pb.TagNumber(1)
$core.bool get failedEnterDfu => $_getBF(0);
@$pb.TagNumber(1)
set failedEnterDfu($core.bool v) { $_setBool(0, v); }
@$pb.TagNumber(1)
$core.bool hasFailedEnterDfu() => $_has(0);
@$pb.TagNumber(1)
void clearFailedEnterDfu() => clearField(1);
@$pb.TagNumber(2)
$core.bool get failedStartAdvertising => $_getBF(1);
@$pb.TagNumber(2)
set failedStartAdvertising($core.bool v) { $_setBool(1, v); }
@$pb.TagNumber(2)
$core.bool hasFailedStartAdvertising() => $_has(1);
@$pb.TagNumber(2)
void clearFailedStartAdvertising() => clearField(2);
@$pb.TagNumber(3)
$core.int get crcFailure => $_getIZ(2);
@$pb.TagNumber(3)
set crcFailure($core.int v) { $_setSignedInt32(2, v); }
@$pb.TagNumber(3)
$core.bool hasCrcFailure() => $_has(2);
@$pb.TagNumber(3)
void clearCrcFailure() => clearField(3);
}
class SetGearTestData extends $pb.GeneratedMessage {
factory SetGearTestData({
$core.int? frontGearIdx,
$core.int? rearGearIdx,
}) {
final $result = create();
if (frontGearIdx != null) {
$result.frontGearIdx = frontGearIdx;
}
if (rearGearIdx != null) {
$result.rearGearIdx = rearGearIdx;
}
return $result;
}
SetGearTestData._() : super();
factory SetGearTestData.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory SetGearTestData.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'SetGearTestData', package: const $pb.PackageName(_omitMessageNames ? '' : 'com.zwift.protobuf'), createEmptyInstance: create)
..a<$core.int>(1, _omitFieldNames ? '' : 'frontGearIdx', $pb.PbFieldType.O3, protoName: 'frontGearIdx')
..a<$core.int>(2, _omitFieldNames ? '' : 'rearGearIdx', $pb.PbFieldType.O3, protoName: 'rearGearIdx')
..hasRequiredFields = false
;
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
SetGearTestData clone() => SetGearTestData()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
SetGearTestData copyWith(void Function(SetGearTestData) updates) => super.copyWith((message) => updates(message as SetGearTestData)) as SetGearTestData;
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static SetGearTestData create() => SetGearTestData._();
SetGearTestData createEmptyInstance() => create();
static $pb.PbList<SetGearTestData> createRepeated() => $pb.PbList<SetGearTestData>();
@$core.pragma('dart2js:noInline')
static SetGearTestData getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<SetGearTestData>(create);
static SetGearTestData? _defaultInstance;
@$pb.TagNumber(1)
$core.int get frontGearIdx => $_getIZ(0);
@$pb.TagNumber(1)
set frontGearIdx($core.int v) { $_setSignedInt32(0, v); }
@$pb.TagNumber(1)
$core.bool hasFrontGearIdx() => $_has(0);
@$pb.TagNumber(1)
void clearFrontGearIdx() => clearField(1);
@$pb.TagNumber(2)
$core.int get rearGearIdx => $_getIZ(1);
@$pb.TagNumber(2)
set rearGearIdx($core.int v) { $_setSignedInt32(1, v); }
@$pb.TagNumber(2)
$core.bool hasRearGearIdx() => $_has(1);
@$pb.TagNumber(2)
void clearRearGearIdx() => clearField(2);
}
class SetHrmTestData extends $pb.GeneratedMessage {
factory SetHrmTestData({
$core.bool? hrmPresent,
$core.int? heartRate,
}) {
final $result = create();
if (hrmPresent != null) {
$result.hrmPresent = hrmPresent;
}
if (heartRate != null) {
$result.heartRate = heartRate;
}
return $result;
}
SetHrmTestData._() : super();
factory SetHrmTestData.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory SetHrmTestData.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'SetHrmTestData', package: const $pb.PackageName(_omitMessageNames ? '' : 'com.zwift.protobuf'), createEmptyInstance: create)
..aOB(1, _omitFieldNames ? '' : 'hrmPresent', protoName: 'hrmPresent')
..a<$core.int>(2, _omitFieldNames ? '' : 'heartRate', $pb.PbFieldType.O3, protoName: 'heartRate')
..hasRequiredFields = false
;
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
SetHrmTestData clone() => SetHrmTestData()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
SetHrmTestData copyWith(void Function(SetHrmTestData) updates) => super.copyWith((message) => updates(message as SetHrmTestData)) as SetHrmTestData;
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static SetHrmTestData create() => SetHrmTestData._();
SetHrmTestData createEmptyInstance() => create();
static $pb.PbList<SetHrmTestData> createRepeated() => $pb.PbList<SetHrmTestData>();
@$core.pragma('dart2js:noInline')
static SetHrmTestData getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<SetHrmTestData>(create);
static SetHrmTestData? _defaultInstance;
@$pb.TagNumber(1)
$core.bool get hrmPresent => $_getBF(0);
@$pb.TagNumber(1)
set hrmPresent($core.bool v) { $_setBool(0, v); }
@$pb.TagNumber(1)
$core.bool hasHrmPresent() => $_has(0);
@$pb.TagNumber(1)
void clearHrmPresent() => clearField(1);
@$pb.TagNumber(2)
$core.int get heartRate => $_getIZ(1);
@$pb.TagNumber(2)
set heartRate($core.int v) { $_setSignedInt32(1, v); }
@$pb.TagNumber(2)
$core.bool hasHeartRate() => $_has(1);
@$pb.TagNumber(2)
void clearHeartRate() => clearField(2);
}
class SetInputDeviceTestData_ControllerAnalogEvent extends $pb.GeneratedMessage {
factory SetInputDeviceTestData_ControllerAnalogEvent({
$core.int? sensorId,
$core.int? value,
}) {
final $result = create();
if (sensorId != null) {
$result.sensorId = sensorId;
}
if (value != null) {
$result.value = value;
}
return $result;
}
SetInputDeviceTestData_ControllerAnalogEvent._() : super();
factory SetInputDeviceTestData_ControllerAnalogEvent.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory SetInputDeviceTestData_ControllerAnalogEvent.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'SetInputDeviceTestData.ControllerAnalogEvent', package: const $pb.PackageName(_omitMessageNames ? '' : 'com.zwift.protobuf'), createEmptyInstance: create)
..a<$core.int>(1, _omitFieldNames ? '' : 'sensorId', $pb.PbFieldType.O3, protoName: 'sensorId')
..a<$core.int>(2, _omitFieldNames ? '' : 'value', $pb.PbFieldType.O3)
..hasRequiredFields = false
;
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
SetInputDeviceTestData_ControllerAnalogEvent clone() => SetInputDeviceTestData_ControllerAnalogEvent()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
SetInputDeviceTestData_ControllerAnalogEvent copyWith(void Function(SetInputDeviceTestData_ControllerAnalogEvent) updates) => super.copyWith((message) => updates(message as SetInputDeviceTestData_ControllerAnalogEvent)) as SetInputDeviceTestData_ControllerAnalogEvent;
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static SetInputDeviceTestData_ControllerAnalogEvent create() => SetInputDeviceTestData_ControllerAnalogEvent._();
SetInputDeviceTestData_ControllerAnalogEvent createEmptyInstance() => create();
static $pb.PbList<SetInputDeviceTestData_ControllerAnalogEvent> createRepeated() => $pb.PbList<SetInputDeviceTestData_ControllerAnalogEvent>();
@$core.pragma('dart2js:noInline')
static SetInputDeviceTestData_ControllerAnalogEvent getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<SetInputDeviceTestData_ControllerAnalogEvent>(create);
static SetInputDeviceTestData_ControllerAnalogEvent? _defaultInstance;
@$pb.TagNumber(1)
$core.int get sensorId => $_getIZ(0);
@$pb.TagNumber(1)
set sensorId($core.int v) { $_setSignedInt32(0, v); }
@$pb.TagNumber(1)
$core.bool hasSensorId() => $_has(0);
@$pb.TagNumber(1)
void clearSensorId() => clearField(1);
@$pb.TagNumber(2)
$core.int get value => $_getIZ(1);
@$pb.TagNumber(2)
set value($core.int v) { $_setSignedInt32(1, v); }
@$pb.TagNumber(2)
$core.bool hasValue() => $_has(1);
@$pb.TagNumber(2)
void clearValue() => clearField(2);
}
class SetInputDeviceTestData extends $pb.GeneratedMessage {
factory SetInputDeviceTestData({
$core.int? duration,
$core.int? buttonEvent,
$core.Iterable<SetInputDeviceTestData_ControllerAnalogEvent>? analogEventList,
}) {
final $result = create();
if (duration != null) {
$result.duration = duration;
}
if (buttonEvent != null) {
$result.buttonEvent = buttonEvent;
}
if (analogEventList != null) {
$result.analogEventList.addAll(analogEventList);
}
return $result;
}
SetInputDeviceTestData._() : super();
factory SetInputDeviceTestData.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory SetInputDeviceTestData.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'SetInputDeviceTestData', package: const $pb.PackageName(_omitMessageNames ? '' : 'com.zwift.protobuf'), createEmptyInstance: create)
..a<$core.int>(1, _omitFieldNames ? '' : 'duration', $pb.PbFieldType.O3)
..a<$core.int>(2, _omitFieldNames ? '' : 'buttonEvent', $pb.PbFieldType.O3, protoName: 'buttonEvent')
..pc<SetInputDeviceTestData_ControllerAnalogEvent>(3, _omitFieldNames ? '' : 'analogEventList', $pb.PbFieldType.PM, protoName: 'analogEventList', subBuilder: SetInputDeviceTestData_ControllerAnalogEvent.create)
..hasRequiredFields = false
;
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
SetInputDeviceTestData clone() => SetInputDeviceTestData()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
SetInputDeviceTestData copyWith(void Function(SetInputDeviceTestData) updates) => super.copyWith((message) => updates(message as SetInputDeviceTestData)) as SetInputDeviceTestData;
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static SetInputDeviceTestData create() => SetInputDeviceTestData._();
SetInputDeviceTestData createEmptyInstance() => create();
static $pb.PbList<SetInputDeviceTestData> createRepeated() => $pb.PbList<SetInputDeviceTestData>();
@$core.pragma('dart2js:noInline')
static SetInputDeviceTestData getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<SetInputDeviceTestData>(create);
static SetInputDeviceTestData? _defaultInstance;
@$pb.TagNumber(1)
$core.int get duration => $_getIZ(0);
@$pb.TagNumber(1)
set duration($core.int v) { $_setSignedInt32(0, v); }
@$pb.TagNumber(1)
$core.bool hasDuration() => $_has(0);
@$pb.TagNumber(1)
void clearDuration() => clearField(1);
@$pb.TagNumber(2)
$core.int get buttonEvent => $_getIZ(1);
@$pb.TagNumber(2)
set buttonEvent($core.int v) { $_setSignedInt32(1, v); }
@$pb.TagNumber(2)
$core.bool hasButtonEvent() => $_has(1);
@$pb.TagNumber(2)
void clearButtonEvent() => clearField(2);
@$pb.TagNumber(3)
$core.List<SetInputDeviceTestData_ControllerAnalogEvent> get analogEventList => $_getList(2);
}
class SetTrainerTestData extends $pb.GeneratedMessage {
factory SetTrainerTestData({
$core.int? dataMode,
$core.int? interfaces,
TestTrainerData? testTrainerData,
}) {
final $result = create();
if (dataMode != null) {
$result.dataMode = dataMode;
}
if (interfaces != null) {
$result.interfaces = interfaces;
}
if (testTrainerData != null) {
$result.testTrainerData = testTrainerData;
}
return $result;
}
SetTrainerTestData._() : super();
factory SetTrainerTestData.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory SetTrainerTestData.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'SetTrainerTestData', package: const $pb.PackageName(_omitMessageNames ? '' : 'com.zwift.protobuf'), createEmptyInstance: create)
..a<$core.int>(1, _omitFieldNames ? '' : 'dataMode', $pb.PbFieldType.O3, protoName: 'dataMode')
..a<$core.int>(2, _omitFieldNames ? '' : 'interfaces', $pb.PbFieldType.O3)
..aOM<TestTrainerData>(3, _omitFieldNames ? '' : 'testTrainerData', protoName: 'testTrainerData', subBuilder: TestTrainerData.create)
..hasRequiredFields = false
;
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
SetTrainerTestData clone() => SetTrainerTestData()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
SetTrainerTestData copyWith(void Function(SetTrainerTestData) updates) => super.copyWith((message) => updates(message as SetTrainerTestData)) as SetTrainerTestData;
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static SetTrainerTestData create() => SetTrainerTestData._();
SetTrainerTestData createEmptyInstance() => create();
static $pb.PbList<SetTrainerTestData> createRepeated() => $pb.PbList<SetTrainerTestData>();
@$core.pragma('dart2js:noInline')
static SetTrainerTestData getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<SetTrainerTestData>(create);
static SetTrainerTestData? _defaultInstance;
@$pb.TagNumber(1)
$core.int get dataMode => $_getIZ(0);
@$pb.TagNumber(1)
set dataMode($core.int v) { $_setSignedInt32(0, v); }
@$pb.TagNumber(1)
$core.bool hasDataMode() => $_has(0);
@$pb.TagNumber(1)
void clearDataMode() => clearField(1);
@$pb.TagNumber(2)
$core.int get interfaces => $_getIZ(1);
@$pb.TagNumber(2)
set interfaces($core.int v) { $_setSignedInt32(1, v); }
@$pb.TagNumber(2)
$core.bool hasInterfaces() => $_has(1);
@$pb.TagNumber(2)
void clearInterfaces() => clearField(2);
@$pb.TagNumber(3)
TestTrainerData get testTrainerData => $_getN(2);
@$pb.TagNumber(3)
set testTrainerData(TestTrainerData v) { setField(3, v); }
@$pb.TagNumber(3)
$core.bool hasTestTrainerData() => $_has(2);
@$pb.TagNumber(3)
void clearTestTrainerData() => clearField(3);
@$pb.TagNumber(3)
TestTrainerData ensureTestTrainerData() => $_ensure(2);
}
class TestTrainerData extends $pb.GeneratedMessage {
factory TestTrainerData({
$core.int? power,
$core.int? cadence,
$core.int? bikeSpeed,
$core.int? averagedPower,
$core.int? wheelSpeed,
$core.int? calculatedRealGearRatio,
}) {
final $result = create();
if (power != null) {
$result.power = power;
}
if (cadence != null) {
$result.cadence = cadence;
}
if (bikeSpeed != null) {
$result.bikeSpeed = bikeSpeed;
}
if (averagedPower != null) {
$result.averagedPower = averagedPower;
}
if (wheelSpeed != null) {
$result.wheelSpeed = wheelSpeed;
}
if (calculatedRealGearRatio != null) {
$result.calculatedRealGearRatio = calculatedRealGearRatio;
}
return $result;
}
TestTrainerData._() : super();
factory TestTrainerData.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory TestTrainerData.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'TestTrainerData', package: const $pb.PackageName(_omitMessageNames ? '' : 'com.zwift.protobuf'), createEmptyInstance: create)
..a<$core.int>(1, _omitFieldNames ? '' : 'power', $pb.PbFieldType.O3)
..a<$core.int>(2, _omitFieldNames ? '' : 'cadence', $pb.PbFieldType.O3)
..a<$core.int>(3, _omitFieldNames ? '' : 'bikeSpeed', $pb.PbFieldType.O3, protoName: 'bikeSpeed')
..a<$core.int>(4, _omitFieldNames ? '' : 'averagedPower', $pb.PbFieldType.O3, protoName: 'averagedPower')
..a<$core.int>(5, _omitFieldNames ? '' : 'wheelSpeed', $pb.PbFieldType.O3, protoName: 'wheelSpeed')
..a<$core.int>(6, _omitFieldNames ? '' : 'calculatedRealGearRatio', $pb.PbFieldType.O3, protoName: 'calculatedRealGearRatio')
..hasRequiredFields = false
;
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
TestTrainerData clone() => TestTrainerData()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
TestTrainerData copyWith(void Function(TestTrainerData) updates) => super.copyWith((message) => updates(message as TestTrainerData)) as TestTrainerData;
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static TestTrainerData create() => TestTrainerData._();
TestTrainerData createEmptyInstance() => create();
static $pb.PbList<TestTrainerData> createRepeated() => $pb.PbList<TestTrainerData>();
@$core.pragma('dart2js:noInline')
static TestTrainerData getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<TestTrainerData>(create);
static TestTrainerData? _defaultInstance;
@$pb.TagNumber(1)
$core.int get power => $_getIZ(0);
@$pb.TagNumber(1)
set power($core.int v) { $_setSignedInt32(0, v); }
@$pb.TagNumber(1)
$core.bool hasPower() => $_has(0);
@$pb.TagNumber(1)
void clearPower() => clearField(1);
@$pb.TagNumber(2)
$core.int get cadence => $_getIZ(1);
@$pb.TagNumber(2)
set cadence($core.int v) { $_setSignedInt32(1, v); }
@$pb.TagNumber(2)
$core.bool hasCadence() => $_has(1);
@$pb.TagNumber(2)
void clearCadence() => clearField(2);
@$pb.TagNumber(3)
$core.int get bikeSpeed => $_getIZ(2);
@$pb.TagNumber(3)
set bikeSpeed($core.int v) { $_setSignedInt32(2, v); }
@$pb.TagNumber(3)
$core.bool hasBikeSpeed() => $_has(2);
@$pb.TagNumber(3)
void clearBikeSpeed() => clearField(3);
@$pb.TagNumber(4)
$core.int get averagedPower => $_getIZ(3);
@$pb.TagNumber(4)
set averagedPower($core.int v) { $_setSignedInt32(3, v); }
@$pb.TagNumber(4)
$core.bool hasAveragedPower() => $_has(3);
@$pb.TagNumber(4)
void clearAveragedPower() => clearField(4);
@$pb.TagNumber(5)
$core.int get wheelSpeed => $_getIZ(4);
@$pb.TagNumber(5)
set wheelSpeed($core.int v) { $_setSignedInt32(4, v); }
@$pb.TagNumber(5)
$core.bool hasWheelSpeed() => $_has(4);
@$pb.TagNumber(5)
void clearWheelSpeed() => clearField(5);
@$pb.TagNumber(6)
$core.int get calculatedRealGearRatio => $_getIZ(5);
@$pb.TagNumber(6)
set calculatedRealGearRatio($core.int v) { $_setSignedInt32(5, v); }
@$pb.TagNumber(6)
$core.bool hasCalculatedRealGearRatio() => $_has(5);
@$pb.TagNumber(6)
void clearCalculatedRealGearRatio() => clearField(6);
}
const _omitFieldNames = $core.bool.fromEnvironment('protobuf.omit_field_names');
const _omitMessageNames = $core.bool.fromEnvironment('protobuf.omit_message_names');

View File

@@ -1,101 +0,0 @@
//
// Generated code. Do not modify.
// source: zp_vendor.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides, camel_case_types, comment_references
// ignore_for_file: constant_identifier_names, library_prefixes
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import
import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
class VendorOpcode extends $pb.ProtobufEnum {
static const VendorOpcode UNDEFINED = VendorOpcode._(0, _omitEnumNames ? '' : 'UNDEFINED');
static const VendorOpcode CONTROLLER_SYNC = VendorOpcode._(1, _omitEnumNames ? '' : 'CONTROLLER_SYNC');
static const VendorOpcode PAIR_DEVICES = VendorOpcode._(2, _omitEnumNames ? '' : 'PAIR_DEVICES');
static const VendorOpcode ENABLE_TEST_MODE = VendorOpcode._(65280, _omitEnumNames ? '' : 'ENABLE_TEST_MODE');
static const VendorOpcode SET_DFU_TEST = VendorOpcode._(65281, _omitEnumNames ? '' : 'SET_DFU_TEST');
static const VendorOpcode SET_TRAINER_TEST_DATA = VendorOpcode._(65282, _omitEnumNames ? '' : 'SET_TRAINER_TEST_DATA');
static const VendorOpcode SET_INPUT_DEVICE_TEST_DATA = VendorOpcode._(65283, _omitEnumNames ? '' : 'SET_INPUT_DEVICE_TEST_DATA');
static const VendorOpcode SET_GEAR_TEST_DATA = VendorOpcode._(65284, _omitEnumNames ? '' : 'SET_GEAR_TEST_DATA');
static const VendorOpcode SET_HRM_TEST_DATA = VendorOpcode._(65285, _omitEnumNames ? '' : 'SET_HRM_TEST_DATA');
static const VendorOpcode SET_TEST_DATA = VendorOpcode._(65286, _omitEnumNames ? '' : 'SET_TEST_DATA');
static const $core.List<VendorOpcode> values = <VendorOpcode> [
UNDEFINED,
CONTROLLER_SYNC,
PAIR_DEVICES,
ENABLE_TEST_MODE,
SET_DFU_TEST,
SET_TRAINER_TEST_DATA,
SET_INPUT_DEVICE_TEST_DATA,
SET_GEAR_TEST_DATA,
SET_HRM_TEST_DATA,
SET_TEST_DATA,
];
static final $core.Map<$core.int, VendorOpcode> _byValue = $pb.ProtobufEnum.initByValue(values);
static VendorOpcode? valueOf($core.int value) => _byValue[value];
const VendorOpcode._($core.int v, $core.String n) : super(v, n);
}
class PairDeviceType extends $pb.ProtobufEnum {
static const PairDeviceType BLE = PairDeviceType._(0, _omitEnumNames ? '' : 'BLE');
static const PairDeviceType ANT = PairDeviceType._(1, _omitEnumNames ? '' : 'ANT');
static const $core.List<PairDeviceType> values = <PairDeviceType> [
BLE,
ANT,
];
static final $core.Map<$core.int, PairDeviceType> _byValue = $pb.ProtobufEnum.initByValue(values);
static PairDeviceType? valueOf($core.int value) => _byValue[value];
const PairDeviceType._($core.int v, $core.String n) : super(v, n);
}
/// Status used by ControllerSync
class ControllerSyncStatus extends $pb.ProtobufEnum {
static const ControllerSyncStatus NOT_CONNECTED = ControllerSyncStatus._(0, _omitEnumNames ? '' : 'NOT_CONNECTED');
static const ControllerSyncStatus CONNECTED = ControllerSyncStatus._(1, _omitEnumNames ? '' : 'CONNECTED');
static const $core.List<ControllerSyncStatus> values = <ControllerSyncStatus> [
NOT_CONNECTED,
CONNECTED,
];
static final $core.Map<$core.int, ControllerSyncStatus> _byValue = $pb.ProtobufEnum.initByValue(values);
static ControllerSyncStatus? valueOf($core.int value) => _byValue[value];
const ControllerSyncStatus._($core.int v, $core.String n) : super(v, n);
}
/// Looks like “data object / page” IDs used with pairing pages
class VendorDO extends $pb.ProtobufEnum {
static const VendorDO NO_CLUE = VendorDO._(0, _omitEnumNames ? '' : 'NO_CLUE');
static const VendorDO PAGE_DEVICE_PAIRING = VendorDO._(61440, _omitEnumNames ? '' : 'PAGE_DEVICE_PAIRING');
static const VendorDO DEVICE_COUNT = VendorDO._(61441, _omitEnumNames ? '' : 'DEVICE_COUNT');
static const VendorDO PAIRING_STATUS = VendorDO._(61442, _omitEnumNames ? '' : 'PAIRING_STATUS');
static const VendorDO PAIRED_DEVICE = VendorDO._(61443, _omitEnumNames ? '' : 'PAIRED_DEVICE');
static const $core.List<VendorDO> values = <VendorDO> [
NO_CLUE,
PAGE_DEVICE_PAIRING,
DEVICE_COUNT,
PAIRING_STATUS,
PAIRED_DEVICE,
];
static final $core.Map<$core.int, VendorDO> _byValue = $pb.ProtobufEnum.initByValue(values);
static VendorDO? valueOf($core.int value) => _byValue[value];
const VendorDO._($core.int v, $core.String n) : super(v, n);
}
const _omitEnumNames = $core.bool.fromEnvironment('protobuf.omit_enum_names');

Some files were not shown because too many files have changed in this diff Show More