Compare commits

...

198 Commits

Author SHA1 Message Date
Jonas Bark
2eab9c581c update readme 2025-10-22 09:43:28 +02:00
Jonas Bark
1284499c25 MyWhoosh Link implementation #2 2025-10-22 09:35:41 +02:00
Jonas Bark
a74471b9f8 MyWhoosh Link implementation #1 2025-10-21 22:43:02 +02:00
Jonas Bark
81f61a5b87 Merge remote-tracking branch 'origin/main' 2025-10-21 10:45:39 +02:00
Jonas Bark
7b2446b6e0 CI cleanup 2025-10-21 10:45:30 +02:00
jonasbark
60898f7536 Update Windows Store version to 3.1.1 2025-10-21 10:25:26 +02:00
Jonas Bark
b2fa7870b6 CI cleanup 2025-10-21 10:21:44 +02:00
Jonas Bark
6ef2ff711a misc fixes 2025-10-21 10:18:12 +02:00
Jonas Bark
9f58dca10e restructure UI to make target selection easier to understand as well as how to get help 2025-10-21 10:10:40 +02:00
Jonas Bark
35e499720b CI patch update 2025-10-20 19:26:22 +02:00
Jonas Bark
7820a80241 Merge remote-tracking branch 'origin/main' 2025-10-20 19:11:08 +02:00
Jonas Bark
ffc6409488 CI patch update 2025-10-20 19:10:57 +02:00
jonasbark
8eaa411a80 Update CHANGELOG for version 3.1.0 enhancements 2025-10-20 19:09:40 +02:00
Jonas Bark
e4bbb8b279 windows store preparation 2025-10-20 12:19:25 +02:00
Jonas Bark
a13e2aa494 windows store preparation 2025-10-20 11:59:01 +02:00
Jonas Bark
b8383a2280 windows store preparation 2025-10-20 11:36:36 +02:00
Jonas Bark
2cb5ef03ce windows store preparation 2025-10-20 11:35:21 +02:00
Jonas Bark
5203c3a576 windows store preparation 2025-10-20 11:31:11 +02:00
Jonas Bark
36dfb2dc0b windows store preparation 2025-10-20 11:29:18 +02:00
jonasbark
3f6434b5a3 Revise download links and compatibility information
Updated download links for iPhone, macOS, and Windows in the README.
2025-10-20 11:28:15 +02:00
Jonas Bark
d9595a3485 windows store preparation 2025-10-20 11:25:20 +02:00
Jonas Bark
b3352d0c1c restart scanning when bluetooth turned on, cleanup when turned off 2025-10-19 12:55:13 +02:00
Jonas Bark
7e15df1f15 restart scanning when bluetooth turned on, cleanup when turned off
remove Sterzo from Readme until confirmed working
2025-10-19 12:44:44 +02:00
Jonas Bark
b7e086c326 resolve issue #123 2025-10-19 11:15:36 +02:00
Jonas Bark
659e7b0585 resolve #122 2025-10-19 11:09:11 +02:00
Jonas Bark
501ab48da5 Merge branch 'copilot/support-elite-sterzo-smart' 2025-10-19 09:56:50 +02:00
Jonas Bark
3b9ceea64b web CORS proxy workaround for fetching file 2025-10-19 09:56:39 +02:00
Jonas Bark
f3c7bbbcbf Revert "Use file storage instead of SharedPreferences for challenge codes"
This reverts commit a744242c70.
2025-10-19 09:48:51 +02:00
Jonas Bark
9b21a2775e Zwift devices: add firmware update available information 2025-10-19 09:11:51 +02:00
Jonas Bark
b669d4c5ea Android: fix touches for very old Android versions 2025-10-19 08:55:15 +02:00
copilot-swe-agent[bot]
a744242c70 Use file storage instead of SharedPreferences for challenge codes
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-10-19 06:36:11 +00:00
copilot-swe-agent[bot]
7f963f71f8 Load Elite Sterzo challenge codes from HTTP with caching
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-10-19 06:28:13 +00:00
Jonas Bark
9f0ab53e1f add troubleshooting entry for Redmi devices 2025-10-18 12:27:11 +02:00
Jonas Bark
5fc16e9fb7 version++ 2025-10-18 10:06:41 +02:00
Jonas Bark
4329afba1c version++ 2025-10-18 09:58:46 +02:00
Jonas Bark
01f87beef5 resolve issue #116 2025-10-18 09:56:04 +02:00
Jonas Bark
45fecfb4f6 more robust parsing of settings (issue #115) 2025-10-18 09:29:26 +02:00
copilot-swe-agent[bot]
9b020e09ae Fix Elite Sterzo Smart implementation with correct UUIDs and protocol
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-10-17 19:23:58 +00:00
Jonas Bark
3b1c05aba4 version++ 2025-10-17 20:51:17 +02:00
Jonas Bark
90a111944a fix issue #114 by adding missing entitlement 2025-10-17 20:42:26 +02:00
copilot-swe-agent[bot]
ceb029afb0 Add Elite Sterzo Smart support for virtual steering
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-10-17 17:40:12 +00:00
copilot-swe-agent[bot]
dc769ce6a0 Initial plan 2025-10-17 17:33:56 +00:00
Jonas Bark
66b7e74f84 CI change 2025-10-17 13:13:49 +02:00
Jonas Bark
29ef0dfaf4 CI change 2025-10-17 11:21:50 +02:00
Jonas Bark
90144948f4 CI change 2025-10-17 10:35:36 +02:00
Jonas Bark
bda384953e CI change 2025-10-17 10:12:39 +02:00
Jonas Bark
b0fd2a8413 fix logo 2025-10-17 10:10:13 +02:00
Jonas Bark
2403971063 update CI to exclude github build until App Store versions are available - avoid confusion 2025-10-17 10:09:34 +02:00
Jonas Bark
22a0379202 revise restart mechanism, fix Android 'Exit' notification button issue 2025-10-17 09:41:33 +02:00
Jonas Bark
c06a426490 allow macOS and Windows to act as remote 2025-10-17 09:26:31 +02:00
Jonas Bark
908e144e1b macos + ios icon changes 2025-10-17 09:19:21 +02:00
Jonas Bark
0189019e54 Merge branch 'icon_new' 2025-10-17 09:01:48 +02:00
Jonas Bark
5995835d03 more cleanup, refactoring 2025-10-17 08:59:01 +02:00
Jonas Bark
16e637b256 more cleanup, refactoring 2025-10-17 08:52:15 +02:00
Jonas Bark
ac2522e860 remove encryption as it's no longer used, cleanup 2025-10-17 08:15:49 +02:00
Jonas Bark
fdb3ad0efc missing files 2025-10-16 23:56:04 +02:00
Jonas Bark
f7a01f3c32 new icon, cleanup 2025-10-16 23:46:32 +02:00
Jonas Bark
94fd2c7eff Merge remote-tracking branch 'origin/main' 2025-10-16 20:52:46 +02:00
Jonas Bark
f917dfbbb2 elite square: more logging 2025-10-16 20:52:31 +02:00
jonasbark
40bfad6810 Add troubleshooting section for SwiftControl crashes
Added troubleshooting tip for SwiftControl crashes on Windows.
2025-10-16 12:31:09 +02:00
Jonas Bark
fefde66b7b Merge remote-tracking branch 'origin/main' 2025-10-16 12:19:57 +02:00
Jonas Bark
6869adcc09 fix macOS code signing 2025-10-16 12:19:50 +02:00
jonasbark
f5abaec551 Update compatibility matrix in README.md 2025-10-16 12:10:34 +02:00
Jonas Bark
52fbf693b5 fix restart behavior 2025-10-16 11:13:40 +02:00
Jonas Bark
bf3995496e CI 2025-10-15 19:20:51 +02:00
Jonas Bark
f7470a032a CI 2025-10-15 18:56:46 +02:00
Jonas Bark
64c9fe5f03 CI 2025-10-15 18:56:33 +02:00
Jonas Bark
febfbc3cc8 - improve iOS reactivity by delaying button events for a few milliseconds
- use correct icon for shift down buttons
- add more troubleshooting for iOS devices
2025-10-15 16:32:13 +02:00
Jonas Bark
5ea848b62e work on #104 2025-10-15 09:25:52 +02:00
Jonas Bark
96118a98b1 conditional builds, throw error for failed in app updates 2025-10-14 13:25:58 +02:00
Jonas Bark
d25f3a2d4e more work on #42 2025-10-14 09:18:11 +02:00
Jonas Bark
c0600746b6 fix issue #101 2025-10-14 09:15:37 +02:00
Jonas Bark
24cb34408b fix CI 2025-10-13 16:34:23 +02:00
Jonas Bark
f90ae87017 fix CI 2025-10-13 16:33:49 +02:00
Jonas Bark
273a71e759 fix CI 2025-10-13 15:51:13 +02:00
Jonas Bark
d5c6a8f7f1 fix CI 2025-10-13 15:32:08 +02:00
Jonas Bark
b6bb2c37a1 adjust touch placements on Android and macOS 2025-10-13 15:26:59 +02:00
Jonas Bark
3ea1184bab prevent wrong changelog dialog 2025-10-13 14:51:08 +02:00
Jonas Bark
a45e5c4874 Merge branch 'main' of github.com:jonasbark/swiftcontrol 2025-10-13 14:48:33 +02:00
jonasbark
d5926f1d5c Merge pull request #98 from jmoro/main
Fix drag-and-drop in keymap editor
2025-10-13 14:48:15 +02:00
Javier Moro Sotelo
c08ac5468a Fix drag-and-drop in keymap editor
Replaced velocity-based drag detection with distance-based threshold to ensure button positions update correctly even when dragging over other buttons, which can cause velocity to drop to zero.

Fixes #97

Signed-off-by: Javier Moro Sotelo <810976+jmoro@users.noreply.github.com>
2025-10-13 14:42:12 +02:00
Jonas Bark
32ad152079 update supported devices 2025-10-13 13:26:10 +02:00
jonasbark
94372918ac Merge pull request #96 from bin101/patch-1
fix: change key mappings from 'A' and 'D' to arrow keys
2025-10-13 12:24:11 +02:00
jonasbark
3ce364a5be Merge branch 'main' into patch-1 2025-10-13 12:23:57 +02:00
Jonas Bark
e4105ea248 Merge branch 'wahoo_kickr_bike_shift' 2025-10-13 12:22:46 +02:00
Jonas Bark
604a8b6bd6 CI changes 2025-10-13 12:22:35 +02:00
Jonas Bark
fc82a62af3 initial support for wahoo kickr bike shifting 2025-10-13 12:13:45 +02:00
Jens van Almsick
67aeb3e257 fix: change key mappings from 'A' and 'D' to arrow keys
see https://mywhooshinfo.com/blog/mywhoosh-keyboard-shortcuts
2025-10-13 12:04:41 +02:00
Jonas Bark
d371ec6d6e add initial support for Elite Square 2025-10-13 11:42:38 +02:00
Jonas Bark
01509eaae9 refactor device handling to support more devices #2 2025-10-13 11:09:18 +02:00
Jonas Bark
b0df25241a refactor device handling to support more devices #1 2025-10-13 10:59:12 +02:00
Jonas Bark
56447743b2 revise update mechanism 2025-10-13 10:09:58 +02:00
Jonas Bark
301dc39648 Merge branch 'main' of github.com:jonasbark/swiftcontrol 2025-10-13 09:11:30 +02:00
jonasbark
3195568399 Clean up Windows section in README
Removed redundant text from the Windows section.
2025-10-13 09:08:54 +02:00
jonasbark
200b13c97f Add download links to README
Added download links for Google Play and App Store.
2025-10-13 09:02:29 +02:00
jonasbark
47173f6dbd Enhance README with compatibility matrix and links
Added compatibility matrix and download links for platforms.
2025-10-13 09:02:16 +02:00
Jonas Bark
83bf1fe047 cleanup 2025-10-13 00:14:51 +02:00
jonasbark
aa8310905d Update README with app support and web demo details 2025-10-13 00:12:44 +02:00
Jonas Bark
a67a82d638 Merge branch 'main' of github.com:jonasbark/swiftcontrol 2025-10-13 00:10:28 +02:00
jonasbark
65b0807903 Revise README with app and platform updates
Updated supported apps and platforms, added details for iOS and Android usage, and improved troubleshooting section.
2025-10-13 00:10:01 +02:00
Jonas Bark
ca4702a684 github actions patch pipeline 2025-10-12 13:08:55 +02:00
Jonas Bark
a89ffc7ffd integrate shorebird 2025-10-12 12:12:46 +02:00
Jonas Bark
4e75270e49 Merge branch 'ios' 2025-10-12 11:33:57 +02:00
Jonas Bark
e08a1dc183 version++ 2025-10-12 11:33:51 +02:00
Jonas Bark
8fa31968c0 integrate shorebird 2025-10-12 11:13:54 +02:00
Jonas Bark
27e25978f2 integrate shorebird 2025-10-12 11:06:24 +02:00
Jonas Bark
5a0761ef1a integrate shorebird 2025-10-12 11:05:13 +02:00
Jonas Bark
52c40e6f5c fix a few issues in button customization screen 2025-10-12 10:16:36 +02:00
Jonas Bark
be7a18384c fix desktop actions when device pixel ratio is not 1 2025-10-11 10:44:35 +02:00
Jonas Bark
b4693229d2 github actions change 2025-10-10 21:28:13 +02:00
Jonas Bark
dc28be0657 screenshot mode 2025-10-10 15:20:58 +02:00
Jonas Bark
ce6f33522f version++ 2025-10-10 15:03:37 +02:00
Jonas Bark
200ac9d81e Merge branch 'copilot/fix-2d2954be-782f-43b7-b654-d4aa8263083d' into ios 2025-10-10 15:02:40 +02:00
Jonas Bark
078398daba make the UI look nicer 2025-10-10 14:58:30 +02:00
Jonas Bark
9ac73ec6fc make the UI look nicer 2025-10-10 14:23:14 +02:00
Jonas Bark
a469134d2f UI changes and fixes 2025-10-10 12:26:20 +02:00
Jonas Bark
57690808dd UI changes and fixes 2025-10-10 11:10:12 +02:00
Jonas Bark
4edc8ef10c UI changes and fixes 2025-10-10 11:06:16 +02:00
Jonas Bark
576e66c60c fix merge 2025-10-10 09:42:15 +02:00
Jonas Bark
0e53f225d0 Merge branch 'ios' into copilot/fix-2d2954be-782f-43b7-b654-d4aa8263083d
# Conflicts:
#	lib/pages/touch_area.dart
2025-10-10 09:41:16 +02:00
Jonas Bark
5d656913a8 fix when setting full screen takes long time 2025-10-09 23:14:23 +02:00
Jonas Bark
49cea5f45d fix UI 2025-10-09 23:08:54 +02:00
Jonas Bark
255435e419 fix coordinates 2025-10-09 22:48:09 +02:00
Jonas Bark
1657338640 Merge branch 'ios' into copilot/fix-2d2954be-782f-43b7-b654-d4aa8263083d 2025-10-09 22:41:33 +02:00
Jonas Bark
eb66731784 dev fix 2025-10-09 22:41:26 +02:00
Jonas Bark
07c9abc87b fix simulate button 2025-10-09 22:41:15 +02:00
Jonas Bark
f5e8bad1ae initial fixes 2025-10-09 22:37:07 +02:00
Jonas Bark
38e9533bfa Merge branch 'ios' into copilot/fix-2d2954be-782f-43b7-b654-d4aa8263083d 2025-10-09 22:17:28 +02:00
copilot-swe-agent[bot]
2cd0273382 Remove screenSize parameter from encode/decode methods
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-10-09 20:06:11 +00:00
copilot-swe-agent[bot]
d62d572387 Implement full migration to percentage-based keymap coordinates
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-10-09 19:46:16 +00:00
copilot-swe-agent[bot]
b65fe57c68 Add comprehensive tests for import/export and percentage-based keymaps
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-10-09 19:33:56 +00:00
copilot-swe-agent[bot]
0e5f6ef2dd Add import/export functionality for keymap profiles
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-10-09 19:32:46 +00:00
copilot-swe-agent[bot]
45112ccfcf Implement percentage-based keymap storage for better device compatibility
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-10-09 19:30:34 +00:00
copilot-swe-agent[bot]
d26e937066 Remove documentation file and refactor to use Settings methods instead of exposing prefs
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-10-09 19:26:22 +00:00
Jonas Bark
bb1bb42214 build Android for Play Store 2025-10-09 21:21:51 +02:00
Jonas Bark
07c16dcbe2 build Android for Play Store 2025-10-09 20:46:18 +02:00
Jonas Bark
1b4f5613ac build Android for Play Store 2025-10-09 20:43:07 +02:00
jonasbark
3315bcd73e Revise download section in README.md
iOS + Mac App Store links
2025-10-09 16:05:55 +02:00
Jonas Bark
87f33b9a15 rebuild 2025-10-09 15:55:15 +02:00
Jonas Bark
c06d364344 rebuild 2025-10-09 15:28:01 +02:00
Jonas Bark
cbab56c17b rebuild 2025-10-09 15:10:57 +02:00
Jonas Bark
585c78c232 rebuild 2025-10-09 15:06:38 +02:00
Jonas Bark
e569b20b9f zommable customize keymap screen 2025-10-09 14:53:54 +02:00
Jonas Bark
590e18ee43 rebuild 2025-10-09 14:20:06 +02:00
Jonas Bark
a8edd09eae rebuild 2025-10-09 14:10:40 +02:00
Jonas Bark
f3dae6fb48 rebuild 2025-10-09 13:52:18 +02:00
Jonas Bark
b4672c7f39 rebuild 2025-10-09 13:39:28 +02:00
Jonas Bark
e60a7b61a8 rebuild 2025-10-09 13:39:05 +02:00
Jonas Bark
e443e5ab0d rebuild 2025-10-09 13:34:58 +02:00
Jonas Bark
29f773d212 rebuild 2025-10-09 13:30:25 +02:00
Jonas Bark
86d09450b0 rebuild 2025-10-09 13:25:28 +02:00
jonasbark
c081da9545 Merge pull request #91 from jmoro/main
feature: add analog paddle support for Zwift Ride
2025-10-09 12:53:20 +02:00
Jonas Bark
4d0f447b25 rebuild 2025-10-09 12:52:28 +02:00
Jonas Bark
9cc7c1b123 rebuild 2025-10-09 12:46:33 +02:00
Jonas Bark
354742a545 rebuild 2025-10-09 12:44:42 +02:00
Jonas Bark
b64fbfb6e4 rebuild 2025-10-09 12:40:12 +02:00
Jonas Bark
3a2ff5c8d2 rebuild 2025-10-09 12:31:57 +02:00
Jonas Bark
a5a4d9e0c2 rebuild 2025-10-09 12:19:35 +02:00
Jonas Bark
cfeef1621a rebuild 2025-10-09 12:18:48 +02:00
Jonas Bark
2e25b09bdf rebuild 2025-10-09 12:15:22 +02:00
Jonas Bark
5ba70376e6 rebuild 2025-10-09 12:05:26 +02:00
Jonas Bark
7c07d6ecf8 rebuild 2025-10-09 12:02:42 +02:00
Jonas Bark
2788ecc32e rebuild 2025-10-09 11:56:18 +02:00
Jonas Bark
26dc9e93b3 rebuild 2025-10-09 11:52:58 +02:00
Jonas Bark
14bf6c9ac3 rebuild 2025-10-09 11:25:39 +02:00
Jonas Bark
1db9669ed2 rebuild 2025-10-09 10:53:37 +02:00
Jonas Bark
c466e6dfa3 rebuild 2025-10-09 10:51:59 +02:00
Jonas Bark
1c00921ee1 - keep iOS app alive when in background
- keep app active on iOS to keep the remote control happy
- reconnect when this was ignored
2025-10-09 10:45:02 +02:00
Jonas Bark
df432542b5 - keep iOS app alive when in background
- keep app active on iOS to keep the remote control happy
- reconnect when this was ignored
2025-10-09 09:51:47 +02:00
Jonas Bark
fe989750e7 app store compliance 2025-10-08 20:56:40 +02:00
Jonas Bark
e008dea61e fix BT connection issues 2025-10-08 13:08:40 +02:00
Jonas Bark
7a8c7c963b add troubleshooting guide 2025-10-08 12:04:57 +02:00
Jonas Bark
0ecf285a95 adjust readme, changelog 2025-10-08 11:26:17 +02:00
Jonas Bark
b14500351f android works okish 2025-10-08 11:10:26 +02:00
Jonas Bark
97693e25b8 zwift ride does not need encryption 2025-10-08 11:02:02 +02:00
Jonas Bark
12d573bc55 refactoring to allow remote handling on non iOS devices 2025-10-08 10:34:53 +02:00
Javier Moro Sotelo
68562aaec9 fixup! fixup! feature: add analog paddle support for Zwift Ride 2025-10-08 09:56:49 +02:00
Javier Moro Sotelo
2c7e714856 fixup! feature: add analog paddle support for Zwift Ride 2025-10-08 09:34:40 +02:00
Jonas Bark
a7183cc519 remove donate button from iOS 2025-10-08 09:24:43 +02:00
Jonas Bark
bfffb2856d try it on Android #1 2025-10-08 09:18:53 +02:00
Javier Moro Sotelo
d2be747fc1 feature: add analog paddle support for Zwift Ride
Implement analog paddle detection for Zwift Ride with Protocol Buffer parsing.
Paddles (Location 0=left, 1=right) trigger when pressure exceeds threshold and
are user-configurable via keymap settings.

Includes comprehensive test suite and reusable Protocol Buffer parser utilities
for handling non-standard embedded analog data.

Fixes #21

Signed-off-by: Javier Moro Sotelo <810976+jmoro@users.noreply.github.com>
2025-10-08 08:13:40 +02:00
Jonas Bark
7fb44d2782 use relative coordinates on iOS touch targets 2025-10-07 21:52:41 +02:00
Jonas Bark
d7b46205fa make macOS work #7 2025-10-07 20:42:12 +02:00
Jonas Bark
0e0835c2f7 make macOS work #7 2025-10-07 20:08:46 +02:00
Jonas Bark
e81d6cb86f make it work #7 2025-10-07 19:22:38 +02:00
Jonas Bark
8eef01437c make it work #6 2025-10-07 18:33:00 +02:00
Jonas Bark
0d446ee293 make it work #5 2025-10-07 17:47:05 +02:00
Jonas Bark
c0afe1792e make it work #4 2025-10-07 16:53:19 +02:00
Jonas Bark
11fdcad57d make it work #3 2025-10-07 16:41:53 +02:00
Jonas Bark
2ac94907e8 make it work #2 2025-10-06 22:43:36 +02:00
Jonas Bark
f7669b2bbc make it work 2025-10-06 21:41:37 +02:00
Jonas Bark
89d200243b Revert "try flutter_ble_peripheral"
This reverts commit 013b078a44.
2025-10-06 19:28:43 +02:00
Jonas Bark
013b078a44 try flutter_ble_peripheral 2025-10-06 19:27:52 +02:00
Jonas Bark
06aefdedc2 try bluetooth_low_energy 2025-10-06 18:46:46 +02:00
copilot-swe-agent[bot]
4071a12c11 Add documentation for custom profiles feature
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-10-05 10:28:38 +00:00
copilot-swe-agent[bot]
83cdb6efd7 Add comprehensive tests for custom profile functionality
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-10-05 10:26:52 +00:00
copilot-swe-agent[bot]
040c0d3027 Implement multiple custom mapping profiles feature
Co-authored-by: jonasbark <1151304+jonasbark@users.noreply.github.com>
2025-10-05 10:26:20 +00:00
copilot-swe-agent[bot]
a44d4d62d0 Initial plan 2025-10-05 10:19:54 +00:00
210 changed files with 6161 additions and 2896 deletions

View File

@@ -1,15 +1,42 @@
name: "Build"
on:
push:
branches:
- main
paths:
- '.github/workflows/**'
- 'lib/**'
- 'accessibility/**'
- 'keypress_simulator/**'
- 'pubspec.yaml'
workflow_dispatch:
inputs:
build_mac:
description: 'Build for macOS'
required: false
default: true
type: boolean
build_github:
description: 'Build for GitHub'
required: false
default: true
type: boolean
build_windows:
description: 'Build for Windows'
required: false
default: true
type: boolean
build_android:
description: 'Build for Android'
required: false
default: true
type: boolean
build_ios:
description: 'Build for iOS'
required: false
default: true
type: boolean
build_web:
description: 'Build for Web'
required: false
default: true
type: boolean
env:
SHOREBIRD_TOKEN: ${{ secrets.SHOREBIRD_TOKEN }}
FLUTTER_VERSION: 3.35.5
jobs:
build:
@@ -27,17 +54,30 @@ jobs:
uses: actions/checkout@v3
- name: Install certificates
if: inputs.build_mac || inputs.build_ios
env:
DEVELOPER_ID_APPLICATION_P12_BASE64_MAC: ${{ secrets.DEVELOPER_ID_APPLICATION_P12_BASE64_MAC }}
DEVELOPER_ID_INSTALLER_P12_BASE64_MAC: ${{ secrets.DEVELOPER_ID_INSTALLER_P12_BASE64_MAC }}
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
APPSTORE_PROFILE_IOS_BASE64: ${{ secrets.APPSTORE_PROFILE_IOS_BASE64 }}
APPSTORE_PROFILE_MACOS_BASE64: ${{ secrets.APPSTORE_PROFILE_MACOS_BASE64 }}
APPSTORE_PROFILE_DEV_IOS_BASE64: ${{ secrets.APPSTORE_PROFILE_DEV_IOS_BASE64 }}
run: |
# create variables
DEVELOPER_ID_APPLICATION_CERTIFICATE_PATH=$RUNNER_TEMP/build_developerID_application_certificate.p12
DEVELOPER_ID_INSTALLER_CERTIFICATE_PATH=$RUNNER_TEMP/build_developerID_installer_certificate.p12
PP_PATH_IOS=$RUNNER_TEMP/build_pp_ios.mobileprovision
PP_PATH_IOS_DEV=$RUNNER_TEMP/build_pp_ios_dev.mobileprovision
PP_PATH_MACOS=$RUNNER_TEMP/build_pp_macos.provisionprofile
KEYCHAIN_PATH=$RUNNER_TEMP/pg-signing.keychain-db
# import certificate and provisioning profile from secrets
echo -n "$DEVELOPER_ID_APPLICATION_P12_BASE64_MAC" | base64 --decode --output $DEVELOPER_ID_APPLICATION_CERTIFICATE_PATH
echo -n "$DEVELOPER_ID_INSTALLER_P12_BASE64_MAC" | base64 --decode --output $DEVELOPER_ID_INSTALLER_CERTIFICATE_PATH
echo -n "$APPSTORE_PROFILE_IOS_BASE64" | base64 --decode -o $PP_PATH_IOS
echo -n "$APPSTORE_PROFILE_DEV_IOS_BASE64" | base64 --decode -o $PP_PATH_IOS_DEV
echo -n "$APPSTORE_PROFILE_MACOS_BASE64" | base64 --decode -o $PP_PATH_MACOS
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
@@ -47,108 +87,62 @@ jobs:
# import certificate to keychain
security import $DEVELOPER_ID_APPLICATION_CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security import $DEVELOPER_ID_INSTALLER_CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH_IOS ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH_IOS_DEV ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH_MACOS ~/Library/MobileDevice/Provisioning\ Profiles
#2 Setup Java
- name: Set Up Java
uses: actions/setup-java@v3.12.0
- name: 🐦 Setup Shorebird
if: inputs.build_mac || inputs.build_android || inputs.build_ios || inputs.build_web
uses: shorebirdtech/setup-shorebird@v1
with:
distribution: 'oracle'
java-version: '17'
cache: true
#3 Setup Flutter
- name: Set Up Flutter
uses: subosito/flutter-action@v2
- name: 🚀 Shorebird Release macOS
if: inputs.build_mac
uses: shorebirdtech/shorebird-release@v1
with:
channel: 'stable'
#4 Install Dependencies
- name: Install Dependencies
run: flutter pub get
#8 Build app ( macos Build )
- name: Build App
run: flutter build macos --release
- name: Code Signing
run: /usr/bin/codesign --deep --force -s "$DEVELOPER_ID_APPLICATION_SIGNING_IDENTITY" --options runtime SwiftControl.app -v
working-directory: build/macos/Build/Products/Release
env:
DEVELOPER_ID_APPLICATION_SIGNING_IDENTITY: ${{ secrets.DEVELOPER_ID_APPLICATION_SIGNING_IDENTITY }}
flutter-version: ${{ env.FLUTTER_VERSION }}
platform: macos
- name: Decode Keystore
if: inputs.build_android
run: |
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 --decode > android/android.keystore;
echo "${{ secrets.KEYSTORE_PROPERTIES }}" > android/keystore.properties;
- name: Build APK
run: flutter build apk --release
- name: 🚀 Shorebird Release Android
if: inputs.build_android
uses: shorebirdtech/shorebird-release@v1
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
platform: android
args: "--artifact=apk"
- name: Build Bundle
run: flutter build appbundle --release
- 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: Handle archives
run: |
cp build/app/outputs/flutter-apk/app-release.apk build/app/outputs/flutter-apk/SwiftControl.android.apk
cd build/macos/Build/Products/Release/
zip -r SwiftControl.macos.zip SwiftControl.app/
#9 Upload Artifacts
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: Releases
path: |
build/app/outputs/flutter-apk/SwiftControl.android.apk
build/macos/Build/Products/Release/SwiftControl.macos.zip
#10 Extract Version
- name: Extract version from pubspec.yaml
id: extract_version
run: |
version=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2 | tr -d '\r')
echo "VERSION=$version" >> $GITHUB_ENV
#11 Check if Tag Exists
- name: Check if Tag Exists
id: check_tag
run: |
if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then
echo "TAG_EXISTS=true" >> $GITHUB_ENV
else
echo "TAG_EXISTS=false" >> $GITHUB_ENV
fi
#12 Modify Tag if it Exists
- name: Modify Tag
if: env.TAG_EXISTS == 'true'
id: modify_tag
run: |
new_version="${{ env.VERSION }}-build-${{ github.run_number }}"
echo "VERSION=$new_version" >> $GITHUB_ENV
#13 Create Release
- name: Create Release
uses: ncipollo/release-action@v1
with:
artifacts: "build/app/outputs/flutter-apk/SwiftControl.android.apk,build/macos/Build/Products/Release/SwiftControl.macos.zip"
allowUpdates: true
prerelease: ${{ endsWith(env.VERSION, '1337') }}
body: "You can also download the Android version from the Play Store: https://play.google.com/store/apps/details?id=de.jonasbark.swiftcontrol"
tag: v${{ env.VERSION }}
token: ${{ secrets.TOKEN }}
- 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
- name: Extract latest changelog
@@ -156,11 +150,27 @@ jobs:
run: |
chmod +x scripts/get_latest_changelog.sh
mkdir -p whatsnew
./scripts/get_latest_changelog.sh > whatsnew/whatsnew-en-US
./scripts/get_latest_changelog.sh | head -c 500 > whatsnew/whatsnew-en-US
- 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"
- name: Prepare App Store authentication key
if: inputs.build_ios || inputs.build_mac
env:
API_KEY_BASE64: ${{ secrets.APPSTORE_API_KEY_FILE_BASE64 }}
APPSTORE_API_KEY: ${{ secrets.APPSTORE_API_KEY }}
run: |
mkdir -p ./private_keys;
printf %s "$API_KEY_BASE64" | base64 -D > "./private_keys/AuthKey_${APPSTORE_API_KEY}.p8";
- name: Upload to Play Store
# only upload when env.VERSION does not end with 1337, which is our indicator for beta releases
if: "!endsWith(env.VERSION, '1337')"
if: inputs.build_android
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
@@ -169,8 +179,82 @@ jobs:
track: production
whatsNewDirectory: whatsnew
- name: Upload to macOS App Store
if: inputs.build_mac
env:
APPSTORE_API_KEY: ${{ secrets.APPSTORE_API_KEY }}
APPSTORE_API_ISSUER_ID: ${{ secrets.APPSTORE_API_ISSUER_ID }}
run: |
productbuild --component "build/macos/Build/Products/Release/SwiftControl.app" /Applications "SwiftControl.pkg" --sign "3rd Party Mac Developer Installer: JONAS TASSILO BARK (UZRHKPVWN9)";
xcrun altool --upload-app -f SwiftControl.pkg -t osx --apiKey "$APPSTORE_API_KEY" --apiIssuer "$APPSTORE_API_ISSUER_ID";
- name: Upload to iOS App Store
if: inputs.build_ios
env:
APPSTORE_API_KEY: ${{ secrets.APPSTORE_API_KEY }}
APPSTORE_API_ISSUER_ID: ${{ secrets.APPSTORE_API_ISSUER_ID }}
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/SwiftControl.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 SwiftControl.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 SwiftControl.macos.zip SwiftControl.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/SwiftControl.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/SwiftControl.macos.zip
#10 Extract Version
- name: Extract version from pubspec.yaml
if: inputs.build_github
id: extract_version
run: |
version=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2 | tr -d '\r')
echo "VERSION=$version" >> $GITHUB_ENV
#13 Create Release
- name: Create Release
if: inputs.build_github
uses: ncipollo/release-action@v1
with:
artifacts: "build/app/outputs/flutter-apk/SwiftControl.android.apk,build/macos/Build/Products/Release/SwiftControl.macos.zip"
allowUpdates: true
prerelease: true
bodyFile: scripts/RELEASE_NOTES.md
tag: v${{ env.VERSION }}
token: ${{ secrets.TOKEN }}
windows:
needs: build
if: inputs.build_windows
name: Build & Release on Windows
runs-on: windows-latest
@@ -179,25 +263,16 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v3
#2 Setup Java
- name: Set Up Java
uses: actions/setup-java@v3.12.0
- name: 🐦 Setup Shorebird
uses: shorebirdtech/setup-shorebird@v1
with:
distribution: 'oracle'
java-version: '17'
cache: true
#3 Setup Flutter
- name: Set Up Flutter
uses: subosito/flutter-action@v2
- name: 🚀 Shorebird Release Windows
uses: shorebirdtech/shorebird-release@v1
with:
channel: 'stable'
#4 Install Dependencies
- name: Install Dependencies
run: flutter pub get
- name: Build App
run: flutter build windows
flutter-version: ${{ env.FLUTTER_VERSION }}
platform: windows
- name: Zip directory (Windows)
shell: pwsh
@@ -223,7 +298,31 @@ jobs:
}
Compress-Archive -Path "build/windows/x64/runner/Release/*" -DestinationPath "build/windows/x64/runner/Release/SwiftControl.windows.zip"
#9 Upload Artifacts
- uses: microsoft/setup-msstore-cli@v1
if: false
- name: Configure the Microsoft Store CLI
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
- name: Publish MSIX to the Microsoft Store
if: false
run: msstore publish -v "build/windows/x64/runner/Release/"
- name: Rename swift_control.msix to SwiftControl.windows.msix
shell: pwsh
run: |
Rename-Item -Path "build/windows/x64/runner/Release/swift_control.msix" -NewName "SwiftControl.windows.msix"
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
@@ -231,8 +330,8 @@ jobs:
name: Releases
path: |
build/windows/x64/runner/Release/SwiftControl.windows.zip
build/windows/x64/runner/Release/SwiftControl.windows.msix
#10 Extract Version
- name: Extract version from pubspec.yaml (Windows)
shell: pwsh
run: |
@@ -241,12 +340,13 @@ jobs:
}
echo "VERSION=$version" >> $env:GITHUB_ENV
# add artifact to release
- name: Create Release
- name: Update Release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: "build/windows/x64/runner/Release/SwiftControl.windows.zip"
artifacts: "build/windows/x64/runner/Release/SwiftControl.windows.zip,build/windows/x64/runner/Release/SwiftControl.windows.msix"
bodyFile: scripts/RELEASE_NOTES.md
prerelease: true
tag: v${{ env.VERSION }}
token: ${{ secrets.TOKEN }}

163
.github/workflows/patch.yml vendored Normal file
View File

@@ -0,0 +1,163 @@
name: "Patch"
on:
workflow_dispatch:
env:
SHOREBIRD_TOKEN: ${{ secrets.SHOREBIRD_TOKEN }}
FLUTTER_VERSION: 3.35.5
jobs:
build:
name: Patch iOS, Android & macOS
runs-on: macos-latest
permissions:
id-token: write
pages: write
contents: write
steps:
#1 Checkout Repository
- name: Checkout Repository
uses: actions/checkout@v3
- name: 🐦 Setup Shorebird
uses: shorebirdtech/setup-shorebird@v1
with:
cache: true
- name: Install certificates
env:
DEVELOPER_ID_APPLICATION_P12_BASE64_MAC: ${{ secrets.DEVELOPER_ID_APPLICATION_P12_BASE64_MAC }}
DEVELOPER_ID_INSTALLER_P12_BASE64_MAC: ${{ secrets.DEVELOPER_ID_INSTALLER_P12_BASE64_MAC }}
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
APPSTORE_PROFILE_IOS_BASE64: ${{ secrets.APPSTORE_PROFILE_IOS_BASE64 }}
APPSTORE_PROFILE_MACOS_BASE64: ${{ secrets.APPSTORE_PROFILE_MACOS_BASE64 }}
APPSTORE_PROFILE_DEV_IOS_BASE64: ${{ secrets.APPSTORE_PROFILE_DEV_IOS_BASE64 }}
run: |
# create variables
DEVELOPER_ID_APPLICATION_CERTIFICATE_PATH=$RUNNER_TEMP/build_developerID_application_certificate.p12
DEVELOPER_ID_INSTALLER_CERTIFICATE_PATH=$RUNNER_TEMP/build_developerID_installer_certificate.p12
PP_PATH_IOS=$RUNNER_TEMP/build_pp_ios.mobileprovision
PP_PATH_IOS_DEV=$RUNNER_TEMP/build_pp_ios_dev.mobileprovision
PP_PATH_MACOS=$RUNNER_TEMP/build_pp_macos.provisionprofile
KEYCHAIN_PATH=$RUNNER_TEMP/pg-signing.keychain-db
# import certificate and provisioning profile from secrets
echo -n "$DEVELOPER_ID_APPLICATION_P12_BASE64_MAC" | base64 --decode --output $DEVELOPER_ID_APPLICATION_CERTIFICATE_PATH
echo -n "$DEVELOPER_ID_INSTALLER_P12_BASE64_MAC" | base64 --decode --output $DEVELOPER_ID_INSTALLER_CERTIFICATE_PATH
echo -n "$APPSTORE_PROFILE_IOS_BASE64" | base64 --decode -o $PP_PATH_IOS
echo -n "$APPSTORE_PROFILE_DEV_IOS_BASE64" | base64 --decode -o $PP_PATH_IOS_DEV
echo -n "$APPSTORE_PROFILE_MACOS_BASE64" | base64 --decode -o $PP_PATH_MACOS
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# security default-keychain -s $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $DEVELOPER_ID_APPLICATION_CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security import $DEVELOPER_ID_INSTALLER_CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH_IOS ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH_IOS_DEV ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH_MACOS ~/Library/MobileDevice/Provisioning\ Profiles
- name: Decode Keystore
run: |
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 --decode > android/android.keystore;
echo "${{ secrets.KEYSTORE_PROPERTIES }}" > android/keystore.properties;
- name: 🚀 Shorebird Patch macOS
uses: shorebirdtech/shorebird-patch@v1
with:
platform: macos
release-version: latest
args: '--allow-asset-diffs --allow-native-diffs'
- name: 🚀 Shorebird Patch Android
uses: shorebirdtech/shorebird-patch@v1
with:
platform: android
release-version: latest
args: '--allow-asset-diffs --allow-native-diffs'
- 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
run: flutter build macos --release;
- name: Sign macOS build
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 SwiftControl.app -v;
zip -r SwiftControl.macos.zip SwiftControl.app/;
#9 Upload Artifacts
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
overwrite: true
name: Releases
path: |
build/macos/Build/Products/Release/SwiftControl.macos.zip
# add artifact to release
- name: Create Release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: "build/macos/Build/Products/Release/SwiftControl.macos.zip"
bodyFile: scripts/RELEASE_NOTES.md
tag: v${{ env.VERSION }}
token: ${{ secrets.TOKEN }}
windows:
name: Patch Windows
runs-on: windows-latest
steps:
#1 Checkout Repository
- name: Checkout Repository
uses: actions/checkout@v3
#2 Setup Java
- name: Set Up Java
uses: actions/setup-java@v3.12.0
with:
distribution: 'oracle'
java-version: '17'
- name: 🐦 Setup Shorebird
uses: shorebirdtech/setup-shorebird@v1
with:
cache: true
- name: 🚀 Shorebird Patch Windows
uses: shorebirdtech/shorebird-patch@v1
with:
platform: windows
release-version: latest
args: '--allow-asset-diffs --allow-native-diffs'

View File

@@ -1,11 +1,13 @@
name: "Build"
name: "Build Web"
on:
push:
branches:
- web
- wahoo_kickr_bike_shift
- main
paths:
- '.github/workflows/**'
- '.github/workflows/web.yml'
- 'lib/**'
- 'accessibility/**'
- 'keypress_simulator/**'
@@ -13,7 +15,7 @@ on:
jobs:
build:
name: Build & Release
name: Build Web
runs-on: macos-latest
permissions:

View File

@@ -1,3 +1,29 @@
### 3.2.0 (2025-10-22)
- a brand-new way of controlling MyWhoosh:
- device pairing no longer required as mouse emulation is no longer needed
- SwiftControl can now stay in the background
- more devices can be controlled
- do more, such as define Emotes, Camera angles and steering
### 3.1.0 (2025-10-17)
- new app icon
- adjusted MyWhoosh keyboard navigation mapping (thanks @bin101)
- support for Wahook Kickr Bike Shift (thanks @MattW2)
- initial support for Elite Square Smart Frame
- reconnects to your device automatically when connection is lost
- SwiftControl now warns you if your device firmware is outdated
- SwiftControl is now available in Microsoft Store: https://apps.microsoft.com/detail/9NP42GS03Z26
### 3.0.3 (2025-10-12)
- SwiftControl now supports iOS!
- Note that you can't run SwiftControl and your trainer app on the same iPhone due to iOS limitations but...:
- You can now use SwiftControl as "remote control" for other devices, such as an iPad. Example scenario:
- your phone (Android/iOS) runs SwiftControl and connects to your Click devices
- your iPad or other tablet runs e.g. MyWhoosh (does not need to have SwiftControl installed)
- after pairing SwiftControl to your iPad / tablet via Bluetooth your phone will send the button presses to your iPad / tablet
- Ride: analog paddles are now supported thanks to contributor @jmoro
- you can now zoom in and out in the Keymap customization screen
### 2.6.3 (2025-10-01)
- fix a few issues with the new touch placement feature
- add a workaround for Zwift Click V2 which resets the device when button events are no longer sent

1
INSTRUCTIONS_ANDROID.md Normal file
View File

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

1
INSTRUCTIONS_IOS.md Normal file
View File

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

1
INSTRUCTIONS_MACOS.md Normal file
View File

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

1
INSTRUCTIONS_WINDOWS.md Normal file
View File

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

View File

@@ -1,6 +1,6 @@
# SwiftControl
<img src="logo.jpg" alt="SwiftControl Logo"/>
<img src="logo.png" alt="SwiftControl Logo"/>
## Description
@@ -11,8 +11,6 @@ With SwiftControl you can **control your favorite trainer app** using your Zwift
- control music on your device
- more? If you can do it via keyboard, mouse or touch, you can do it with SwiftControl
**Android AccessibilityService Usage**: On Android, SwiftControl uses the AccessibilityService API to simulate touch gestures on your screen, allowing your Zwift devices to control training apps. This service only monitors which app window is active and performs touch gestures at the locations you configure. No personal data is accessed or collected.
https://github.com/user-attachments/assets/1f81b674-1628-4763-ad66-5f3ed7a3f159
@@ -20,49 +18,69 @@ https://github.com/user-attachments/assets/1f81b674-1628-4763-ad66-5f3ed7a3f159
## Downloads
Check the compatibility matrix below!
<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>
Get the latest version for free for Windows, macOS and Android here: https://github.com/jonasbark/swiftcontrol/releases
<a href="https://apps.apple.com/us/app/swiftcontrol/id6753721284?platform=iphone"><img width="270" alt="App Store" src="https://github.com/user-attachments/assets/c23f977a-48f6-4951-811e-ae530dbfa014" /></a>
<a href="https://apps.apple.com/us/app/swiftcontrol/id6753721284?platform=mac"><img width="270" height="80" alt="Mac App Store" src="https://github.com/user-attachments/assets/b3552436-409c-43b0-ba7d-b6a72ae30ff1" /></a>
<a href="https://apps.microsoft.com/detail/9NP42GS03Z26"><img width="270" alt="Microsoft Store" src="https://github.com/user-attachments/assets/7a8a3cd6-ec26-4678-a850-732eedd27c48" /></a>
## Supported Apps
- MyWhoosh
- indieVelo / Training Peaks
- Biketerra.com
- any other:
- Android: you can customize simulated touch points of all your buttons in the app
- Desktop: you can customize keyboard shortcuts and mouse clicks in the app
- TrainingPeaks Virtual / indieVelo
- Biketerra.com (they do offer native integration already - check it out)
- Rouvy (most Zwift devices are already supported by Rouvy)
- any other! You can add custom mapping and adjust touch points or keyboard shortcuts to your liking
## Supported Devices
- Zwift Click
- Zwift Click v2 (mostly, see #68)
- Zwift Click v2 (mostly, see issue #68)
- Zwift Ride
- Zwift Play
- Wahoo Kickr Bike Shift
- Elite Square Smart Frame (beta)
Support for other devices can be added - check the issues tab here on GithUb.
## Supported Platforms
- Android
- App is losing connection over time? Read about how to [keep the app alive](https://dontkillmyapp.com/).
- macOS
- Windows
- Windows may flag the app as virus. I think it does so because the app does control the mouse and keyboard.
- Bluetooth connection unstable? You may need to use an [external Bluetooth adapter](https://github.com/jonasbark/swiftcontrol/issues/14#issuecomment-3193839509).
- Make sure your Zwift device is not paired with Windows Bluetooth settings: [more information](https://github.com/jonasbark/swiftcontrol/issues/70).
- [Web](https://jonasbark.github.io/swiftcontrol/) (you won't be able to do much)
- NOT SUPPORTED: iOS (iPhone, iPad) as Apple does not provide any way to simulate touches or keyboard events
Follow this compatibility matrix. It all depends on where you want to run your trainer app (e.g. MyWhoosh on):
| Run Trainer app (MyWhoosh, ...) on: | Possible | Link | Information |
|-------------------------------------------------------------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Android | ✅ | <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> | |
| iPad | ✅ | <a href="https://apps.apple.com/us/app/swiftcontrol/id6753721284?platform=iphone"><img width="270" height="80" alt="App Store" src="https://github.com/user-attachments/assets/c23f977a-48f6-4951-811e-ae530dbfa014" /></a> | You will need to use SwiftControl as a "remote" to control the trainer app on your iPad. Typically you would use an iPhone or an Android phone for that. |
| Windows | ✅ | <a href="https://apps.microsoft.com/detail/9NP42GS03Z26"><img width="270" alt="Microsoft Store" src="https://github.com/user-attachments/assets/7a8a3cd6-ec26-4678-a850-732eedd27c48" /></a> | - Windows may flag the app as virus. It likely does so because the app controls the mouse and keyboard.<br>- Bluetooth connection unstable? You may need to use an [external Bluetooth adapter](https://github.com/jonasbark/swiftcontrol/issues/14#issuecomment-3193839509).<br>- Make sure your Zwift device is not paired with Windows Bluetooth settings: [more information](https://github.com/jonasbark/swiftcontrol/issues/70). |
| macOS | ✅ | <a href="https://apps.apple.com/us/app/swiftcontrol/id6753721284?platform=mac"><img width="270" height="80" alt="Mac App Store" src="https://github.com/user-attachments/assets/b3552436-409c-43b0-ba7d-b6a72ae30ff1" /></a> | |
| iPhone | (✅) | <a href="https://apps.apple.com/us/app/swiftcontrol/id6753721284?platform=iphone"><img width="270" height="80" alt="App Store" src="https://github.com/user-attachments/assets/c23f977a-48f6-4951-811e-ae530dbfa014" /></a> | Note that you can't run SwiftControl and your trainer app on the same iPhone due to iOS limitations, but you could use the Link method on another device to control MyWhoosh (and only MyWhoosh) on an iPhone. |
| Apple TV | (✅) | | Unconfirmed: only MyWhoosh using the Link method is supported |
For testing purposes you can also run it on [Web](https://jonasbark.github.io/swiftcontrol/) but this is just a tech demo - you won't be able to control other apps.
## Troubleshooting
- Your Zwift device is found but connection does not work properly? You may need to update the firmware in Zwift Companion app.
Check the troubleshooting guide [here](TROUBLESHOOTING.md).
## How does it work?
The app connects to your Zwift device automatically. It does not connect to your trainer itself.
The app connects to your Controller devices (such as Zwift ones) automatically. It does not connect to your trainer itself.
- When using Android: SwiftControl 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.
- When using macOS or Windows a keyboard or mouse click is used to trigger the action.
- **Android**: SwiftControl 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 SwiftControl as "remote control" for other devices, such as an iPad. Example scenario:
- your phone (Android/iOS) runs SwiftControl and connects to your Controller devices
- your iPad or other tablet runs e.g. MyWhoosh (does not need to have SwiftControl installed)
- if you want to use MyWhoosh you can use the Link method to directly connect to MyWhoosh
- for other trainer apps you need to pair SwiftControl 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
</details>
## Alternatives
- [qdomyos-zwift](https://www.qzfitness.com/) directly controls the trainer (as opposed to controlling the trainer app)
- [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.
## Donate
Please consider donating to support the development of this app :)

50
TROUBLESHOOTING.md Normal file
View File

@@ -0,0 +1,50 @@
## Click device cannot be found
You may need to update the firmware in Zwift Companion app.
## Click 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/jonasbark/swiftcontrol/issues/68) discussion.
To make your Click V2 work best you should connect it in the Zwift app once each day.
If you don't do that SwiftControl 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 SwiftControl
## 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/:
- disable battery optimization for SwiftControl
- enable auto start of SwiftControl
- grant accessibility permission for SwiftControl
- see https://github.com/jonasbark/swiftcontrol/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 SwiftControl
- 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 SwiftControl / restart SwiftControl.
## 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 SwiftControl iOS) > Button 1
switch the setting to None, then back to Single-Tap and it should work again
## SwiftControl crashes on Windows when searching for the device
You're probably running into [this](https://github.com/jonasbark/swiftcontrol/issues/70) issue. Disconnect your controller device (e.g. Zwift Play) from Windows Bluetooth settings.
## Link requirement for MyWhoosh stuck at "Waiting for MyWhoosh"
The same network restrictions apply for SwiftControl 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://www.facebook.com/groups/mywhoosh/posts/1323791068858873/
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

View File

@@ -0,0 +1 @@
3.1.1

View File

@@ -5,6 +5,7 @@ import android.accessibilityservice.GestureDescription
import android.accessibilityservice.GestureDescription.StrokeDescription
import android.graphics.Path
import android.graphics.Rect
import android.os.Build
import android.util.Log
import android.view.ViewConfiguration
import android.view.accessibility.AccessibilityEvent
@@ -56,7 +57,12 @@ class AccessibilityService : AccessibilityService(), Listener {
path.moveTo(x.toFloat(), y.toFloat())
path.lineTo(x.toFloat()+1, y.toFloat())
val stroke = StrokeDescription(path, 0, ViewConfiguration.getTapTimeout().toLong(), isKeyDown && !isKeyUp)
val stroke = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
StrokeDescription(path, 0, ViewConfiguration.getTapTimeout().toLong(), isKeyDown && !isKeyUp)
} else {
// API 2425: no “willContinue” support
StrokeDescription(path, 0L, ViewConfiguration.getTapTimeout().toLong())
}
gestureBuilder.addStroke(stroke)
dispatchGesture(gestureBuilder.build(), null, null)

View File

@@ -23,8 +23,10 @@ linter:
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
- require_trailing_commas
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
formatter:
page_width: 120
trailing_commas: preserve

View File

@@ -1,7 +1,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
<!-- Allow Bluetooth -->
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE"/>
<!-- New Bluetooth permissions in Android 12
https://developer.android.com/about/versions/12/features/bluetooth-permissions -->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
@@ -16,7 +18,7 @@
<!-- legacy for Android 9 or lower -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="28" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="28" tools:replace="android:maxSdkVersion" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<!-- to check if you have the latest version -->

View File

@@ -4,9 +4,9 @@
<item android:drawable="?android:colorBackground" />
<!-- You can insert your own image assets here -->
<!-- <item>
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
android:src="@mipmap/ic_launcher" />
</item>
</layer-list>

View File

@@ -4,9 +4,9 @@
<item android:drawable="@android:color/white" />
<!-- You can insert your own image assets here -->
<!-- <item>
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
android:src="@mipmap/ic_launcher" />
</item>
</layer-list>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@mipmap/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<monochrome android:drawable="@mipmap/ic_launcher_monochrome"/>
</adaptive-icon>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

View File

@@ -1,32 +0,0 @@
# flutter pub run flutter_launcher_icons
flutter_launcher_icons:
image_path: "icon.png"
android: "ic_launcher"
# image_path_android: "assets/icon/icon.png"
min_sdk_android: 24 # android min sdk min:16, default 21
# adaptive_icon_background: "assets/icon/background.png"
# adaptive_icon_foreground: "assets/icon/foreground.png"
# adaptive_icon_monochrome: "assets/icon/monochrome.png"
ios: false
# image_path_ios: "assets/icon/icon.png"
remove_alpha_channel_ios: true
# image_path_ios_dark_transparent: "assets/icon/icon_dark.png"
# image_path_ios_tinted_grayscale: "assets/icon/icon_tinted.png"
# desaturate_tinted_to_grayscale_ios: true
web:
generate: true
image_path: "icon.png"
background_color: "#ffffff"
theme_color: "#ffffff"
windows:
generate: true
image_path: "icon.png"
icon_size: 48 # min:48, max:256, default: 48
macos:
generate: true
image_path: "icon.png"

BIN
icon.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 555 KiB

29
ios/ExportOptions.plist Normal file
View File

@@ -0,0 +1,29 @@
<?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>destination</key>
<string>export</string>
<key>generateAppStoreInformation</key>
<false/>
<key>manageAppVersionAndBuildNumber</key>
<true/>
<key>method</key>
<string>app-store-connect</string>
<key>signingStyle</key>
<string>manual</string>
<key>provisioningProfiles</key>
<dict>
<key>de.jonasbark.swiftcontrol.darwin</key>
<string>ios app store</string>
</dict>
<key>stripSwiftSymbols</key>
<true/>
<key>teamID</key>
<string>UZRHKPVWN9</string>
<key>testFlightInternalTestingOnly</key>
<false/>
<key>uploadSymbols</key>
<true/>
</dict>
</plist>

View File

@@ -1,4 +1,7 @@
PODS:
- bluetooth_low_energy_darwin (0.0.1):
- Flutter
- FlutterMacOS
- device_info_plus (0.0.1):
- Flutter
- Flutter (1.0.0)
@@ -10,6 +13,8 @@ PODS:
- Flutter
- permission_handler_apple (9.3.0):
- Flutter
- restart_app (0.0.1):
- Flutter
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
@@ -18,19 +23,26 @@ PODS:
- FlutterMacOS
- url_launcher_ios (0.0.1):
- Flutter
- wakelock_plus (0.0.1):
- Flutter
DEPENDENCIES:
- 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`)
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- restart_app (from `.symlinks/plugins/restart_app/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`)
EXTERNAL SOURCES:
bluetooth_low_energy_darwin:
:path: ".symlinks/plugins/bluetooth_low_energy_darwin/darwin"
device_info_plus:
:path: ".symlinks/plugins/device_info_plus/ios"
Flutter:
@@ -43,23 +55,30 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/package_info_plus/ios"
permission_handler_apple:
:path: ".symlinks/plugins/permission_handler_apple/ios"
restart_app:
:path: ".symlinks/plugins/restart_app/ios"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
universal_ble:
:path: ".symlinks/plugins/universal_ble/darwin"
url_launcher_ios:
:path: ".symlinks/plugins/url_launcher_ios/ios"
wakelock_plus:
:path: ".symlinks/plugins/wakelock_plus/ios"
SPEC CHECKSUMS:
bluetooth_low_energy_darwin: 764d8d1ae5abefbcdb839e812b4b25c0061fcf8b
device_info_plus: bf2e3232933866d73fe290f2942f2156cdd10342
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
flutter_local_notifications: ff50f8405aaa0ccdc7dcfb9022ca192e8ad9688f
image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1
package_info_plus: c0502532a26c7662a62a356cebe2692ec5fe4ec4
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
restart_app: 806659942bf932f6ce51c5372f91ce5e81c8c14a
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
universal_ble: cf52a7b3fd2e7c14d6d7262e9fdadb72ab6b88a6
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe
wakelock_plus: 76957ab028e12bfa4e66813c99e46637f367fc7e
PODFILE CHECKSUM: 3c63482e143d1b91d2d2560aee9fb04ecc74ac7e

View File

@@ -97,7 +97,6 @@
8AA6D129479129F106E2298A /* Pods-RunnerTests.release.xcconfig */,
EFDECED99A47773C293F8819 /* Pods-RunnerTests.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
@@ -488,16 +487,19 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 7BL8RUV2K6;
DEVELOPMENT_TEAM = UZRHKPVWN9;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = de.jonasbark.swiftPlay;
PRODUCT_BUNDLE_IDENTIFIER = de.jonasbark.swiftcontrol.darwin;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
@@ -558,7 +560,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
@@ -615,7 +617,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
@@ -671,16 +673,19 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 7BL8RUV2K6;
DEVELOPMENT_TEAM = UZRHKPVWN9;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = de.jonasbark.swiftPlay;
PRODUCT_BUNDLE_IDENTIFIER = de.jonasbark.swiftcontrol.darwin;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
@@ -694,16 +699,19 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 7BL8RUV2K6;
DEVELOPMENT_TEAM = UZRHKPVWN9;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = de.jonasbark.swiftPlay;
PRODUCT_BUNDLE_IDENTIFIER = de.jonasbark.swiftcontrol.darwin;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 866 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

View File

@@ -1,122 +1,134 @@
{
"images" : [
"images": [
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-App-20x20@2x.png",
"scale" : "2x"
"filename": "AppIcon@2x.png",
"idiom": "iphone",
"scale": "2x",
"size": "60x60"
},
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-App-20x20@3x.png",
"scale" : "3x"
"filename": "AppIcon@3x.png",
"idiom": "iphone",
"scale": "3x",
"size": "60x60"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@1x.png",
"scale" : "1x"
"filename": "AppIcon~ipad.png",
"idiom": "ipad",
"scale": "1x",
"size": "76x76"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@2x.png",
"scale" : "2x"
"filename": "AppIcon@2x~ipad.png",
"idiom": "ipad",
"scale": "2x",
"size": "76x76"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@3x.png",
"scale" : "3x"
"filename": "AppIcon-83.5@2x~ipad.png",
"idiom": "ipad",
"scale": "2x",
"size": "83.5x83.5"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-App-40x40@2x.png",
"scale" : "2x"
"filename": "AppIcon-40@2x.png",
"idiom": "iphone",
"scale": "2x",
"size": "40x40"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-App-40x40@3x.png",
"scale" : "3x"
"filename": "AppIcon-40@3x.png",
"idiom": "iphone",
"scale": "3x",
"size": "40x40"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-App-60x60@2x.png",
"scale" : "2x"
"filename": "AppIcon-40~ipad.png",
"idiom": "ipad",
"scale": "1x",
"size": "40x40"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-App-60x60@3x.png",
"scale" : "3x"
"filename": "AppIcon-40@2x~ipad.png",
"idiom": "ipad",
"scale": "2x",
"size": "40x40"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-App-20x20@1x.png",
"scale" : "1x"
"filename": "AppIcon-20@2x.png",
"idiom": "iphone",
"scale": "2x",
"size": "20x20"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-App-20x20@2x.png",
"scale" : "2x"
"filename": "AppIcon-20@3x.png",
"idiom": "iphone",
"scale": "3x",
"size": "20x20"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-App-29x29@1x.png",
"scale" : "1x"
"filename": "AppIcon-20~ipad.png",
"idiom": "ipad",
"scale": "1x",
"size": "20x20"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-App-29x29@2x.png",
"scale" : "2x"
"filename": "AppIcon-20@2x~ipad.png",
"idiom": "ipad",
"scale": "2x",
"size": "20x20"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-App-40x40@1x.png",
"scale" : "1x"
"filename": "AppIcon-29.png",
"idiom": "iphone",
"scale": "1x",
"size": "29x29"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-App-40x40@2x.png",
"scale" : "2x"
"filename": "AppIcon-29@2x.png",
"idiom": "iphone",
"scale": "2x",
"size": "29x29"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-App-76x76@1x.png",
"scale" : "1x"
"filename": "AppIcon-29@3x.png",
"idiom": "iphone",
"scale": "3x",
"size": "29x29"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-App-76x76@2x.png",
"scale" : "2x"
"filename": "AppIcon-29~ipad.png",
"idiom": "ipad",
"scale": "1x",
"size": "29x29"
},
{
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "Icon-App-83.5x83.5@2x.png",
"scale" : "2x"
"filename": "AppIcon-29@2x~ipad.png",
"idiom": "ipad",
"scale": "2x",
"size": "29x29"
},
{
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "Icon-App-1024x1024@1x.png",
"scale" : "1x"
"filename": "AppIcon-60@2x~car.png",
"idiom": "car",
"scale": "2x",
"size": "60x60"
},
{
"filename": "AppIcon-60@3x~car.png",
"idiom": "car",
"scale": "3x",
"size": "60x60"
},
{
"filename": "AppIcon~ios-marketing.png",
"idiom": "ios-marketing",
"scale": "1x",
"size": "1024x1024"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"info": {
"author": "iconkitchen",
"version": 1
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 462 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 704 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 586 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 862 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 862 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 762 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

View File

@@ -1,23 +1,23 @@
{
"images" : [
{
"filename" : "AppIcon-min 2.png",
"idiom" : "universal",
"filename" : "LaunchImage.png",
"scale" : "1x"
},
{
"filename" : "AppIcon-min 1.png",
"idiom" : "universal",
"filename" : "LaunchImage@2x.png",
"scale" : "2x"
},
{
"filename" : "AppIcon-min.png",
"idiom" : "universal",
"filename" : "LaunchImage@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 B

View File

@@ -1,5 +0,0 @@
# Launch Screen Assets
You can customize the launch screen with your own desired assets by replacing the image files in this directory.
You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.

View File

@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="23504" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23506"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
@@ -14,9 +16,11 @@
<viewControllerLayoutGuide type="bottom" id="xbc-2k-c8Z"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4">
<rect key="frame" x="111.33333333333333" y="340.66666666666669" width="170.66666666666669" height="170.66666666666669"/>
</imageView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@@ -28,10 +32,10 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
<point key="canvasLocation" x="80.916030534351137" y="264.08450704225356"/>
</scene>
</scenes>
<resources>
<image name="LaunchImage" width="168" height="185"/>
<image name="LaunchImage" width="170.66667175292969" height="170.66667175292969"/>
</resources>
</document>

View File

@@ -2,6 +2,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>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
@@ -24,6 +26,19 @@
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSLocalNetworkUsageDescription</key>
<string>This app connects to your trainer app on your local network.</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>SwiftControl uses Bluetooth to connect to accessories.</string>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UIBackgroundModes</key>
<array>
<string>bluetooth-peripheral</string>
<string>bluetooth-central</string>
</array>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
@@ -41,11 +56,5 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>SwiftControl</string>
</dict>
</plist>

View File

@@ -67,11 +67,11 @@ public class KeypressSimulatorMacosPlugin: NSObject, FlutterPlugin {
let point = CGPoint(x: x, y: y)
// Move mouse to the point
/*let move = CGEvent(mouseEventSource: nil,
let move = CGEvent(mouseEventSource: nil,
mouseType: .mouseMoved,
mouseCursorPosition: point,
mouseButton: .left)
move?.post(tap: .cghidEventTap)*/
move?.post(tap: .cghidEventTap)
if (keyDown) {
// Mouse down

View File

@@ -1,126 +1,8 @@
import 'dart:typed_data';
class BleUuid {
static final DEVICE_INFORMATION_SERVICE_UUID = "0000180a-0000-1000-8000-00805f9b34fb".toLowerCase();
static final DEVICE_INFORMATION_CHARACTERISTIC_FIRMWARE_REVISION =
"00002a26-0000-1000-8000-00805f9b34fb".toLowerCase();
static final DEVICE_INFORMATION_CHARACTERISTIC_FIRMWARE_REVISION = "00002a26-0000-1000-8000-00805f9b34fb"
.toLowerCase();
static final DEVICE_BATTERY_SERVICE_UUID = "0000180f-0000-1000-8000-00805f9b34fb".toLowerCase();
static final DEVICE_INFORMATION_CHARACTERISTIC_BATTERY_LEVEL = "00002a19-0000-1000-8000-00805f9b34fb".toLowerCase();
static final ZWIFT_CUSTOM_SERVICE_UUID = "00000001-19CA-4651-86E5-FA29DCDD09D1".toLowerCase();
static final ZWIFT_RIDE_CUSTOM_SERVICE_UUID = "0000fc82-0000-1000-8000-00805f9b34fb".toLowerCase();
static final ZWIFT_ASYNC_CHARACTERISTIC_UUID = "00000002-19CA-4651-86E5-FA29DCDD09D1".toLowerCase();
static final ZWIFT_SYNC_RX_CHARACTERISTIC_UUID = "00000003-19CA-4651-86E5-FA29DCDD09D1".toLowerCase();
static final ZWIFT_SYNC_TX_CHARACTERISTIC_UUID = "00000004-19CA-4651-86E5-FA29DCDD09D1".toLowerCase();
}
class Constants {
static const ZWIFT_MANUFACTURER_ID = 2378; // Zwift, Inc => 0x094A
// Zwift Play = RC1
static const RC1_LEFT_SIDE = 0x03;
static const RC1_RIGHT_SIDE = 0x02;
// Zwift Ride
static const RIDE_RIGHT_SIDE = 0x07;
static const RIDE_LEFT_SIDE = 0x08;
// Zwift Click = BC1
static const BC1 = 0x09;
// Zwift Click v2 Right (unconfirmed)
static const CLICK_V2_RIGHT_SIDE = 0x0A;
// Zwift Click v2 Right (unconfirmed)
static const CLICK_V2_LEFT_SIDE = 0x0B;
static final RIDE_ON = Uint8List.fromList([0x52, 0x69, 0x64, 0x65, 0x4f, 0x6e]);
static final VIBRATE_PATTERN = Uint8List.fromList([0x12, 0x12, 0x08, 0x0A, 0x06, 0x08, 0x02, 0x10, 0x00, 0x18]);
// these don't actually seem to matter, its just the header has to be 7 bytes RIDEON + 2
static final REQUEST_START = Uint8List.fromList([0, 9]); //byteArrayOf(1, 2)
static final RESPONSE_START_CLICK = Uint8List.fromList([1, 3]); // from device
static final RESPONSE_START_PLAY = Uint8List.fromList([1, 4]); // from device
static final RESPONSE_START_CLICK_V2 = Uint8List.fromList([0x02, 0x03]); // from device
static final RESPONSE_STOPPED_CLICK_V2 = Uint8List.fromList([
0xff,
0x05,
0x00,
0xea,
0x05,
0x19,
0x0a,
0x0c,
0x35,
0x38,
0x44,
0x31,
0x35,
0x41,
0x42,
0x42,
0x34,
0x33,
0x36,
0x33,
0x10,
0x01,
0x18,
0x84,
0x07,
0x20,
0x08,
0x28,
0x09,
0x30,
]); // from device
// Message types received from device
static const CONTROLLER_NOTIFICATION_MESSAGE_TYPE = 07;
static const EMPTY_MESSAGE_TYPE = 21;
static const BATTERY_LEVEL_TYPE = 25;
static const UNKNOWN_CLICKV2_TYPE = 0x3C;
// not figured out the protobuf type this really is, the content is just two varints.
static const int CLICK_NOTIFICATION_MESSAGE_TYPE = 55;
static const int PLAY_NOTIFICATION_MESSAGE_TYPE = 7;
static const int RIDE_NOTIFICATION_MESSAGE_TYPE = 35; // 0x23
// see this if connected to Core then Zwift connects to it. just one byte
static const DISCONNECT_MESSAGE_TYPE = 0xFE;
}
enum DeviceType {
click,
clickV2Right,
clickV2Left,
playLeft,
playRight,
rideRight,
rideLeft;
@override
String toString() {
return super.toString().split('.').last;
}
// add constructor
static DeviceType? fromManufacturerData(int data) {
switch (data) {
case Constants.BC1:
return DeviceType.click;
case Constants.CLICK_V2_RIGHT_SIDE:
return DeviceType.clickV2Right;
case Constants.CLICK_V2_LEFT_SIDE:
return DeviceType.clickV2Left;
case Constants.RC1_LEFT_SIDE:
return DeviceType.playLeft;
case Constants.RC1_RIGHT_SIDE:
return DeviceType.playRight;
case Constants.RIDE_RIGHT_SIDE:
return DeviceType.rideRight;
case Constants.RIDE_LEFT_SIDE:
return DeviceType.rideLeft;
}
return null;
}
}

View File

@@ -9,8 +9,8 @@ import 'package:swift_control/utils/actions/android.dart';
import 'package:swift_control/utils/requirements/android.dart';
import 'package:universal_ble/universal_ble.dart';
import '../bluetooth/ble.dart';
import 'devices/base_device.dart';
import 'devices/zwift/constants.dart';
import 'messages/notification.dart';
class Connection {
@@ -33,6 +33,14 @@ class Connection {
final ValueNotifier<bool> isScanning = ValueNotifier(false);
void initialize() {
UniversalBle.onAvailabilityChange = (available) {
_actionStreams.add(LogNotification('Bluetooth availability changed: $available'));
if (available == AvailabilityState.poweredOn) {
performScanning();
} else if (available == AvailabilityState.poweredOff) {
reset();
}
};
UniversalBle.onScanResult = (result) {
if (_lastScanResult.none((e) => e.deviceId == result.deviceId)) {
_lastScanResult.add(result);
@@ -43,8 +51,9 @@ class Connection {
_addDevices([scanResult]);
} else {
final manufacturerData = result.manufacturerDataList;
final data =
manufacturerData.firstOrNullWhere((e) => e.companyId == Constants.ZWIFT_MANUFACTURER_ID)?.payload;
final data = manufacturerData
.firstOrNullWhere((e) => e.companyId == ZwiftConstants.ZWIFT_MANUFACTURER_ID)
?.payload;
_actionStreams.add(LogNotification('Found unknown device with identifier: ${data?.firstOrNull}'));
}
}
@@ -63,13 +72,16 @@ class Connection {
}
Future<void> performScanning() async {
if (isScanning.value) {
return;
}
isScanning.value = true;
_actionStreams.add(LogNotification('Scanning for devices...'));
// does not work on web, may not work on Windows
if (!kIsWeb && !Platform.isWindows) {
UniversalBle.getSystemDevices(
withServices: [BleUuid.ZWIFT_CUSTOM_SERVICE_UUID, BleUuid.ZWIFT_RIDE_CUSTOM_SERVICE_UUID],
withServices: BaseDevice.servicesToScan,
).then((devices) async {
final baseDevices = devices.mapNotNull(BaseDevice.fromScanResult).toList();
if (baseDevices.isNotEmpty) {
@@ -79,15 +91,9 @@ class Connection {
}
await UniversalBle.startScan(
scanFilter: ScanFilter(withServices: [BleUuid.ZWIFT_CUSTOM_SERVICE_UUID, BleUuid.ZWIFT_RIDE_CUSTOM_SERVICE_UUID]),
platformConfig: PlatformConfig(web: WebOptions(optionalServices: [BleUuid.ZWIFT_CUSTOM_SERVICE_UUID])),
scanFilter: ScanFilter(withServices: BaseDevice.servicesToScan),
platformConfig: PlatformConfig(web: WebOptions(optionalServices: BaseDevice.servicesToScan)),
);
Future.delayed(Duration(seconds: 30)).then((_) {
if (isScanning.value) {
UniversalBle.stopScan();
isScanning.value = false;
}
});
}
void _addDevices(List<BaseDevice> dev) {
@@ -146,9 +152,7 @@ class Connection {
_connectionSubscriptions.remove(bleDevice);
_lastScanResult.clear();
// try reconnect
if (!isScanning.value) {
performScanning();
}
performScanning();
}
});
_connectionSubscriptions[bleDevice] = connectionStateSubscription;
@@ -180,12 +184,17 @@ class Connection {
_connectionSubscriptions[device]?.cancel();
_connectionSubscriptions.remove(device);
UniversalBle.disconnect(device.device.deviceId);
signalChange(device);
}
_lastScanResult.clear();
hasDevices.value = false;
devices.clear();
}
void signalNotification(BaseNotification notification) {
_actionStreams.add(notification);
}
void signalChange(BaseDevice baseDevice) {
_connectionStreams.add(baseDevice);
}

View File

@@ -2,84 +2,118 @@ import 'dart:async';
import 'package:dartx/dartx.dart';
import 'package:flutter/foundation.dart';
import 'package:swift_control/bluetooth/ble.dart';
import 'package:swift_control/bluetooth/devices/zwift_click.dart';
import 'package:swift_control/bluetooth/devices/zwift_clickv2.dart';
import 'package:swift_control/bluetooth/devices/zwift_play.dart';
import 'package:swift_control/bluetooth/devices/zwift_ride.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_play.dart';
import 'package:swift_control/bluetooth/devices/zwift/zwift_ride.dart';
import 'package:swift_control/main.dart';
import 'package:swift_control/utils/actions/desktop.dart';
import 'package:swift_control/utils/crypto/local_key_provider.dart';
import 'package:swift_control/utils/crypto/zap_crypto.dart';
import 'package:swift_control/utils/single_line_exception.dart';
import 'package:universal_ble/universal_ble.dart';
import '../../utils/crypto/encryption_utils.dart';
import '../../utils/keymap/buttons.dart';
import '../messages/notification.dart';
import 'elite/elite_square.dart';
import 'elite/elite_sterzo.dart';
abstract class BaseDevice {
final BleDevice scanResult;
final List<ZwiftButton> availableButtons;
final bool isBeta;
final List<ControllerButton> availableButtons;
BaseDevice(this.scanResult, {required this.availableButtons});
final zapEncryption = ZapCrypto(LocalKeyProvider());
BaseDevice(this.scanResult, {required this.availableButtons, this.isBeta = false});
bool isConnected = false;
bool _isInited = false;
int? batteryLevel;
String? firmwareVersion;
bool supportsEncryption = true;
BleCharacteristic? syncRxCharacteristic;
Timer? _longPressTimer;
Set<ZwiftButton> _previouslyPressedButtons = <ZwiftButton>{};
Set<ControllerButton> _previouslyPressedButtons = <ControllerButton>{};
List<int> get startCommand => Constants.RIDE_ON + Constants.RESPONSE_START_CLICK;
String get customServiceId => BleUuid.ZWIFT_CUSTOM_SERVICE_UUID;
static List<String> servicesToScan = [
ZwiftConstants.ZWIFT_CUSTOM_SERVICE_UUID,
ZwiftConstants.ZWIFT_RIDE_CUSTOM_SERVICE_UUID,
SquareConstants.SERVICE_UUID,
WahooKickrBikeShiftConstants.SERVICE_UUID,
SterzoConstants.SERVICE_UUID,
];
static BaseDevice? fromScanResult(BleDevice scanResult) {
// Use the name first as the "System Devices" and Web (android sometimes Windows) don't have manufacturer data
final device =
kIsWeb
? switch (scanResult.name) {
'Zwift Ride' => ZwiftRide(scanResult),
'Zwift Play' => ZwiftPlay(scanResult),
'Zwift Click' => ZwiftClickV2(scanResult),
_ => null,
}
: switch (scanResult.name) {
//'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 Click' => ZwiftClick(scanResult), special case for Zwift Click v2: we must only connect to the left controller
_ => null,
};
BaseDevice? device;
if (kIsWeb) {
device = switch (scanResult.name) {
'Zwift Ride' => ZwiftRide(scanResult),
'Zwift Play' => ZwiftPlay(scanResult),
'Zwift Click' => ZwiftClickV2(scanResult),
'SQUARE' => EliteSquare(scanResult),
_ => null,
};
if (scanResult.name != null && scanResult.name!.toUpperCase().startsWith('KICKR BIKE SHIFT')) {
device = WahooKickrBikeShift(scanResult);
}
if (scanResult.name != null && scanResult.name!.toUpperCase().startsWith('STERZO')) {
device = EliteSterzo(scanResult);
}
} else {
device = switch (scanResult.name) {
//'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 Click' => ZwiftClick(scanResult), special case for Zwift Click v2: we must only connect to the left controller
_ => null,
};
if (scanResult.name != null && scanResult.name!.toUpperCase().startsWith('STERZO')) {
device = EliteSterzo(scanResult);
}
}
if (device != null) {
return device;
} else {
} else if (scanResult.services.containsAny([
ZwiftConstants.ZWIFT_CUSTOM_SERVICE_UUID,
ZwiftConstants.ZWIFT_RIDE_CUSTOM_SERVICE_UUID,
])) {
// otherwise use the manufacturer data to identify the device
final manufacturerData = scanResult.manufacturerDataList;
final data = manufacturerData.firstOrNullWhere((e) => e.companyId == Constants.ZWIFT_MANUFACTURER_ID)?.payload;
final data = manufacturerData
.firstOrNullWhere((e) => e.companyId == ZwiftConstants.ZWIFT_MANUFACTURER_ID)
?.payload;
if (data == null || data.isEmpty) {
return null;
}
final type = DeviceType.fromManufacturerData(data.first);
final type = ZwiftDeviceType.fromManufacturerData(data.first);
return switch (type) {
DeviceType.click => ZwiftClick(scanResult),
DeviceType.playRight => ZwiftPlay(scanResult),
DeviceType.playLeft => ZwiftPlay(scanResult),
DeviceType.rideLeft => ZwiftRide(scanResult),
ZwiftDeviceType.click => ZwiftClick(scanResult),
ZwiftDeviceType.playRight => ZwiftPlay(scanResult),
ZwiftDeviceType.playLeft => ZwiftPlay(scanResult),
ZwiftDeviceType.rideLeft => ZwiftRide(scanResult),
//DeviceType.rideRight => ZwiftRide(scanResult), // see comment above
DeviceType.clickV2Left => ZwiftClickV2(scanResult),
ZwiftDeviceType.clickV2Left => ZwiftClickV2(scanResult),
//DeviceType.clickV2Right => ZwiftClickV2(scanResult), // see comment above
_ => null,
};
} else if (scanResult.services.contains(SquareConstants.SERVICE_UUID)) {
return EliteSquare(scanResult);
} else if (scanResult.services.contains(SterzoConstants.SERVICE_UUID)) {
return EliteSterzo(scanResult);
} else if (scanResult.services.contains(WahooKickrBikeShiftConstants.SERVICE_UUID)) {
if (scanResult.name != null && !scanResult.name!.toUpperCase().contains('KICKR BIKE SHIFT')) {
return WahooKickrBikeShift(scanResult);
} else if (kIsWeb && scanResult.name == null) {
// some devices don't broadcast the name, so we must rely on the service UUID
return WahooKickrBikeShift(scanResult);
} else {
return null;
}
} else {
return null;
}
}
@@ -113,165 +147,13 @@ abstract class BaseDevice {
}
final services = await UniversalBle.discoverServices(device.deviceId);
await _handleServices(services);
await handleServices(services);
}
Future<void> _handleServices(List<BleService> services) async {
final customService = services.firstOrNullWhere((service) => service.uuid == customServiceId);
Future<void> handleServices(List<BleService> services);
Future<void> processCharacteristic(String characteristic, Uint8List bytes);
if (customService == null) {
throw Exception(
'Custom service $customServiceId not found for device $this ${device.name ?? device.rawName}.\nYou may need to update the firmware in Zwift Companion app.\nWe found: ${services.joinToString(transform: (s) => s.uuid)}',
);
}
final deviceInformationService = services.firstOrNullWhere(
(service) => service.uuid == BleUuid.DEVICE_INFORMATION_SERVICE_UUID,
);
final firmwareCharacteristic = deviceInformationService?.characteristics.firstOrNullWhere(
(c) => c.uuid == BleUuid.DEVICE_INFORMATION_CHARACTERISTIC_FIRMWARE_REVISION,
);
if (firmwareCharacteristic != null) {
final firmwareData = await UniversalBle.read(
device.deviceId,
deviceInformationService!.uuid,
firmwareCharacteristic.uuid,
);
firmwareVersion = String.fromCharCodes(firmwareData);
connection.signalChange(this);
}
final asyncCharacteristic = customService.characteristics.firstOrNullWhere(
(characteristic) => characteristic.uuid == BleUuid.ZWIFT_ASYNC_CHARACTERISTIC_UUID,
);
final syncTxCharacteristic = customService.characteristics.firstOrNullWhere(
(characteristic) => characteristic.uuid == BleUuid.ZWIFT_SYNC_TX_CHARACTERISTIC_UUID,
);
syncRxCharacteristic = customService.characteristics.firstOrNullWhere(
(characteristic) => characteristic.uuid == BleUuid.ZWIFT_SYNC_RX_CHARACTERISTIC_UUID,
);
if (asyncCharacteristic == null || syncTxCharacteristic == null || syncRxCharacteristic == null) {
throw Exception('Characteristics not found');
}
await UniversalBle.subscribeNotifications(device.deviceId, customService.uuid, asyncCharacteristic.uuid);
await UniversalBle.subscribeIndications(device.deviceId, customService.uuid, syncTxCharacteristic.uuid);
await setupHandshake();
}
Future<void> setupHandshake() async {
if (supportsEncryption) {
await UniversalBle.write(
device.deviceId,
customServiceId,
syncRxCharacteristic!.uuid,
Uint8List.fromList([
...Constants.RIDE_ON,
...Constants.REQUEST_START,
...zapEncryption.localKeyProvider.getPublicKeyBytes(),
]),
withoutResponse: true,
);
} else {
await UniversalBle.write(
device.deviceId,
customServiceId,
syncRxCharacteristic!.uuid,
Constants.RIDE_ON,
withoutResponse: true,
);
}
}
Future<void> processCharacteristic(String characteristic, Uint8List bytes) async {
if (kDebugMode && false) {
print(
"${DateTime.now().toString().split(" ").last} Received data on $characteristic: ${bytes.map((e) => e.toRadixString(16).padLeft(2, '0')).join(' ')}",
);
}
if (bytes.isEmpty) {
return;
}
try {
if (bytes.startsWith(startCommand)) {
_processDevicePublicKeyResponse(bytes);
} else if (!supportsEncryption || (bytes.length > Int32List.bytesPerElement + EncryptionUtils.MAC_LENGTH)) {
processData(bytes);
}
} catch (e, stackTrace) {
print("Error processing data: $e");
print("Stack Trace: $stackTrace");
if (e is SingleLineException) {
actionStreamInternal.add(LogNotification(e.message));
} else {
actionStreamInternal.add(LogNotification("$e\n$stackTrace"));
}
}
}
void _processDevicePublicKeyResponse(Uint8List bytes) {
final devicePublicKeyBytes = bytes.sublist(Constants.RIDE_ON.length + Constants.RESPONSE_START_CLICK.length);
if (kDebugMode) {
print("Device Public Key - ${devicePublicKeyBytes.map((e) => e.toRadixString(16).padLeft(2, '0')).join(' ')}");
}
zapEncryption.initialise(devicePublicKeyBytes);
}
Future<void> processData(Uint8List bytes) async {
int type;
Uint8List message;
if (supportsEncryption) {
final counter = bytes.sublist(0, 4); // Int.SIZE_BYTES is 4
final payload = bytes.sublist(4);
if (zapEncryption.encryptionKeyBytes == null) {
actionStreamInternal.add(
LogNotification(
'Encryption not initialized, yet. You may need to update the firmware of your device with the Zwift Companion app.',
),
);
return;
}
final data = zapEncryption.decrypt(counter, payload);
type = data[0];
message = data.sublist(1);
} else {
type = bytes[0];
message = bytes.sublist(1);
}
switch (type) {
case Constants.EMPTY_MESSAGE_TYPE:
//print("Empty Message"); // expected when nothing happening
break;
case Constants.BATTERY_LEVEL_TYPE:
if (batteryLevel != message[1]) {
batteryLevel = message[1];
connection.signalChange(this);
}
break;
case Constants.CLICK_NOTIFICATION_MESSAGE_TYPE:
case Constants.PLAY_NOTIFICATION_MESSAGE_TYPE:
case Constants.RIDE_NOTIFICATION_MESSAGE_TYPE:
processClickNotification(message)
.then((buttonsClicked) async {
return handleButtonsClicked(buttonsClicked);
})
.catchError((e) {
actionStreamInternal.add(LogNotification(e.toString()));
});
break;
}
}
Future<List<ZwiftButton>?> processClickNotification(Uint8List message);
Future<void> handleButtonsClicked(List<ZwiftButton>? buttonsClicked) async {
Future<void> handleButtonsClicked(List<ControllerButton>? buttonsClicked) async {
if (buttonsClicked == null) {
// ignore, no changes
} else if (buttonsClicked.isEmpty) {
@@ -284,17 +166,19 @@ abstract class BaseDevice {
buttonsReleased.singleOrNull != null &&
actionHandler.supportedApp?.keymap.getKeyPair(buttonsReleased.single)?.isLongPress == true;
if (buttonsReleased.isNotEmpty && isLongPress) {
await _performRelease(buttonsReleased);
await performRelease(buttonsReleased);
}
_previouslyPressedButtons.clear();
} else {
actionStreamInternal.add(ButtonNotification(buttonsClicked: buttonsClicked));
// Handle release events for buttons that are no longer pressed
final buttonsReleased = _previouslyPressedButtons.difference(buttonsClicked.toSet()).toList();
final wasLongPress =
buttonsReleased.singleOrNull != null &&
actionHandler.supportedApp?.keymap.getKeyPair(buttonsReleased.single)?.isLongPress == true;
if (buttonsReleased.isNotEmpty && wasLongPress) {
await _performRelease(buttonsReleased);
await performRelease(buttonsReleased);
}
final isLongPress =
@@ -302,30 +186,26 @@ abstract class BaseDevice {
actionHandler.supportedApp?.keymap.getKeyPair(buttonsClicked.single)?.isLongPress == true;
if (!isLongPress &&
!(buttonsClicked.singleOrNull == ZwiftButton.onOffLeft ||
buttonsClicked.singleOrNull == ZwiftButton.onOffRight)) {
!(buttonsClicked.singleOrNull == ControllerButton.onOffLeft ||
buttonsClicked.singleOrNull == ControllerButton.onOffRight)) {
// we don't want to trigger the long press timer for the on/off buttons, also not when it's a long press key
_longPressTimer?.cancel();
_longPressTimer = Timer.periodic(const Duration(milliseconds: 350), (timer) async {
_performClick(buttonsClicked);
performClick(buttonsClicked);
});
}
// Update currently pressed buttons
_previouslyPressedButtons = buttonsClicked.toSet();
if (isLongPress) {
return _performDown(buttonsClicked);
return performDown(buttonsClicked);
} else {
return _performClick(buttonsClicked);
return performClick(buttonsClicked);
}
}
}
Future<void> _performDown(List<ZwiftButton> buttonsClicked) async {
if (buttonsClicked.any(((e) => e.action == InGameAction.shiftDown || e.action == InGameAction.shiftUp)) &&
settings.getVibrationEnabled()) {
await _vibrate();
}
Future<void> performDown(List<ControllerButton> buttonsClicked) async {
for (final action in buttonsClicked) {
// For repeated actions, don't trigger key down/up events (useful for long press)
actionStreamInternal.add(
@@ -334,11 +214,7 @@ abstract class BaseDevice {
}
}
Future<void> _performClick(List<ZwiftButton> buttonsClicked) async {
if (buttonsClicked.any(((e) => e.action == InGameAction.shiftDown || e.action == InGameAction.shiftUp)) &&
settings.getVibrationEnabled()) {
await _vibrate();
}
Future<void> performClick(List<ControllerButton> buttonsClicked) async {
for (final action in buttonsClicked) {
actionStreamInternal.add(
LogNotification(await actionHandler.performAction(action, isKeyDown: true, isKeyUp: true)),
@@ -346,7 +222,7 @@ abstract class BaseDevice {
}
}
Future<void> _performRelease(List<ZwiftButton> buttonsReleased) async {
Future<void> performRelease(List<ControllerButton> buttonsReleased) async {
for (final action in buttonsReleased) {
actionStreamInternal.add(
LogNotification(await actionHandler.performAction(action, isKeyDown: false, isKeyUp: true)),
@@ -354,19 +230,7 @@ abstract class BaseDevice {
}
}
Future<void> _vibrate() async {
final vibrateCommand = Uint8List.fromList([...Constants.VIBRATE_PATTERN, 0x20]);
await UniversalBle.write(
device.deviceId,
customServiceId,
syncRxCharacteristic!.uuid,
supportsEncryption ? zapEncryption.encrypt(vibrateCommand) : vibrateCommand,
withoutResponse: true,
);
}
Future<void> disconnect() async {
_isInited = false;
_longPressTimer?.cancel();
// Release any held keys in long press mode
if (actionHandler is DesktopActions) {

View File

@@ -0,0 +1,107 @@
import 'dart:typed_data';
import 'package:dartx/dartx.dart';
import 'package:swift_control/bluetooth/devices/base_device.dart';
import 'package:swift_control/utils/keymap/buttons.dart';
import 'package:universal_ble/universal_ble.dart';
import '../../messages/notification.dart';
class EliteSquare extends BaseDevice {
EliteSquare(super.scanResult)
: super(
availableButtons: SquareConstants.BUTTON_MAPPING.values.toList(),
isBeta: true,
);
String? _lastValue;
@override
Future<void> handleServices(List<BleService> services) async {
final service = services.firstOrNullWhere((e) => e.uuid == SquareConstants.SERVICE_UUID);
if (service == null) {
throw Exception('Service not found: ${SquareConstants.SERVICE_UUID}');
}
final characteristic = service.characteristics.firstOrNullWhere(
(e) => e.uuid == SquareConstants.CHARACTERISTIC_UUID,
);
if (characteristic == null) {
throw Exception('Characteristic not found: ${SquareConstants.CHARACTERISTIC_UUID}');
}
await UniversalBle.subscribeNotifications(device.deviceId, service.uuid, characteristic.uuid);
}
@override
Future<void> processCharacteristic(String characteristic, Uint8List bytes) async {
if (characteristic == SquareConstants.CHARACTERISTIC_UUID) {
final fullValue = _bytesToHex(bytes);
final currentValue = _extractButtonCode(fullValue);
actionStreamInternal.add(LogNotification('Received $fullValue - vs $currentValue (last: $_lastValue)'));
if (_lastValue != null) {
final currentRelevantPart = fullValue.length >= 19
? fullValue.substring(6, fullValue.length - 13)
: fullValue.substring(6);
final lastRelevantPart = _lastValue!.length >= 19
? _lastValue!.substring(6, _lastValue!.length - 13)
: _lastValue!.substring(6);
if (currentRelevantPart != lastRelevantPart) {
final buttonClicked = SquareConstants.BUTTON_MAPPING[currentValue];
actionStreamInternal.add(LogNotification('Button pressed: $buttonClicked'));
handleButtonsClicked([
if (buttonClicked != null) buttonClicked,
]);
}
}
_lastValue = fullValue;
}
}
String _extractButtonCode(String hexValue) {
if (hexValue.length >= 14) {
final buttonCode = hexValue.substring(6, 14);
if (SquareConstants.BUTTON_MAPPING.containsKey(buttonCode)) {
return buttonCode;
}
}
return hexValue;
}
String _bytesToHex(List<int> bytes) {
return bytes.map((byte) => byte.toRadixString(16).padLeft(2, '0')).join();
}
}
class SquareConstants {
static const String DEVICE_NAME = "SQUARE";
static const String CHARACTERISTIC_UUID = "347b0043-7635-408b-8918-8ff3949ce592";
static const String SERVICE_UUID = "347b0001-7635-408b-8918-8ff3949ce592";
static const int RECONNECT_DELAY = 5; // seconds between reconnection attempts
// Button mapping https://images.bike24.com/i/mb/c7/36/d9/elite-square-smart-frame-indoor-bike-3-1724305.jpg
static const Map<String, ControllerButton> BUTTON_MAPPING = {
"00000200": ControllerButton.navigationUp, //"Up",
"00000100": ControllerButton.navigationLeft, //"Left",
"00000800": ControllerButton.navigationDown, // "Down",
"00000400": ControllerButton.navigationRight, //"Right",
"00002000": ControllerButton.powerUpLeft, //"X",
"00001000": ControllerButton.sideButtonLeft, // "Square",
"00008000": ControllerButton.campagnoloLeft, // "Left Campagnolo",
"00004000": ControllerButton.onOffLeft, //"Left brake",
"00000002": ControllerButton.shiftDownLeft, //"Left shift 1",
"00000001": ControllerButton.paddleLeft, // "Left shift 2",
"02000000": ControllerButton.y, // "Y",
"01000000": ControllerButton.a, //"A",
"08000000": ControllerButton.b, // "B",
"04000000": ControllerButton.z, // "Z",
"20000000": ControllerButton.powerUpRight, // "Circle",
"10000000": ControllerButton.sideButtonRight, //"Triangle",
"80000000": ControllerButton.campagnoloRight, // "Right Campagnolo",
"40000000": ControllerButton.onOffRight, //"Right brake",
"00020000": ControllerButton.sideButtonRight, //"Right shift 1",
"00010000": ControllerButton.paddleRight, //"Right shift 2",
};
}

View File

@@ -0,0 +1,291 @@
import 'dart:convert';
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/base_device.dart';
import 'package:swift_control/utils/keymap/buttons.dart';
import 'package:universal_ble/universal_ble.dart';
import '../../messages/notification.dart';
class EliteSterzo extends BaseDevice {
EliteSterzo(super.scanResult)
: super(
availableButtons: [
ControllerButton.navigationLeft,
ControllerButton.navigationRight,
],
isBeta: true,
);
double _lastAngle = 0.0;
int? _latestChallenge;
String? _serviceUuid;
static Uint8List? _challengeCodesData;
static bool _isLoadingChallenges = false;
@override
Future<void> handleServices(List<BleService> services) async {
final service = services.firstOrNullWhere(
(e) => e.uuid.toLowerCase().startsWith('347b0'),
);
if (service == null) {
throw Exception('Elite Sterzo service not found');
}
_serviceUuid = service.uuid;
// Find characteristics
final challengeChar = service.characteristics.firstOrNullWhere(
(e) => e.uuid == SterzoConstants.CHALLENGE_CODE_CHARACTERISTIC_UUID,
);
final measurementChar = service.characteristics.firstOrNullWhere(
(e) => e.uuid == SterzoConstants.MEASUREMENT_CHARACTERISTIC_UUID,
);
final controlChar = service.characteristics.firstOrNullWhere(
(e) => e.uuid == SterzoConstants.CONTROL_POINT_CHARACTERISTIC_UUID,
);
if (challengeChar == null || measurementChar == null || controlChar == null) {
throw Exception('Required Sterzo characteristics not found');
}
// Subscribe to challenge code indications
await UniversalBle.subscribeNotifications(
device.deviceId,
service.uuid,
challengeChar.uuid,
);
// Subscribe to measurement notifications
await UniversalBle.subscribeNotifications(
device.deviceId,
service.uuid,
measurementChar.uuid,
);
// Request to start challenge
await UniversalBle.write(
device.deviceId,
service.uuid,
controlChar.uuid,
Uint8List.fromList([0x03, 0x10]),
withoutResponse: false,
);
actionStreamInternal.add(LogNotification('Elite Sterzo: Initialization started'));
}
@override
Future<void> processCharacteristic(String characteristic, Uint8List bytes) async {
if (characteristic == SterzoConstants.CHALLENGE_CODE_CHARACTERISTIC_UUID) {
_handleChallengeCode(bytes);
} else if (characteristic == SterzoConstants.MEASUREMENT_CHARACTERISTIC_UUID) {
_handleSteeringMeasurement(bytes);
}
}
Future<void> _handleChallengeCode(Uint8List bytes) async {
if (bytes.length >= 4) {
// Challenge is in bytes 2-3 (big-endian)
final challenge = (bytes[2] << 8) | bytes[3];
_latestChallenge = challenge;
actionStreamInternal.add(LogNotification('Elite Sterzo: Received challenge code: $challenge'));
// Respond to challenge
await _activateSteeringMeasurements();
}
}
Future<void> _activateSteeringMeasurements() async {
if (_latestChallenge == null || _serviceUuid == null) {
return;
}
// Ensure challenge codes are loaded
await _ensureChallengeCodesLoaded();
// Get response codes for the challenge
final challengeCodes = _getChallengeResponse(_latestChallenge!);
// Send challenge response
await UniversalBle.write(
device.deviceId,
_serviceUuid!,
SterzoConstants.CONTROL_POINT_CHARACTERISTIC_UUID,
Uint8List.fromList([0x03, 0x11, challengeCodes[0], challengeCodes[1]]),
withoutResponse: false,
);
await Future.delayed(const Duration(seconds: 1));
// Activate measurements
await UniversalBle.write(
device.deviceId,
_serviceUuid!,
SterzoConstants.CONTROL_POINT_CHARACTERISTIC_UUID,
Uint8List.fromList([0x02, 0x02]),
withoutResponse: false,
);
actionStreamInternal.add(LogNotification('Elite Sterzo: Steering measurements activated'));
}
static Future<void> _ensureChallengeCodesLoaded() async {
if (_challengeCodesData != null) {
return; // Already loaded
}
// Wait if already loading
while (_isLoadingChallenges) {
await Future.delayed(const Duration(milliseconds: 100));
}
// Check again after waiting
if (_challengeCodesData != null) {
return;
}
_isLoadingChallenges = true;
try {
if (kIsWeb) {
// On web, always fetch from HTTP
_challengeCodesData = await _fetchChallengeCodes();
} else {
// On native platforms, try to load from cache first
_challengeCodesData = await _loadCachedChallengeCodes();
if (_challengeCodesData == null) {
// Cache miss - fetch from HTTP and cache it
_challengeCodesData = await _fetchChallengeCodes();
if (_challengeCodesData != null) {
await _cacheChallengeCodes(_challengeCodesData!);
}
}
}
} finally {
_isLoadingChallenges = false;
}
}
static Future<Uint8List?> _fetchChallengeCodes() async {
final url = kIsWeb
? 'https://corsproxy.io/${SterzoConstants.CHALLENGE_CODES_URL}'
: SterzoConstants.CHALLENGE_CODES_URL;
try {
final response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
return response.bodyBytes;
}
} catch (e) {
if (kDebugMode) {
print('Failed to fetch challenge codes for URL $url: $e');
}
}
return null;
}
static Future<Uint8List?> _loadCachedChallengeCodes() async {
try {
final prefs = await SharedPreferences.getInstance();
final cached = prefs.getString(SterzoConstants.CACHE_KEY);
if (cached != null) {
// Decode from base64
return base64Decode(cached);
}
} catch (e) {
if (kDebugMode) {
print('Failed to load cached challenge codes: $e');
}
}
return null;
}
static Future<void> _cacheChallengeCodes(Uint8List data) async {
try {
final prefs = await SharedPreferences.getInstance();
// Encode to base64 for storage
await prefs.setString(SterzoConstants.CACHE_KEY, base64Encode(data));
} catch (e) {
if (kDebugMode) {
print('Failed to cache challenge codes: $e');
}
}
}
void _handleSteeringMeasurement(Uint8List bytes) {
if (bytes.length >= 4) {
// Steering angle is a 32-bit float (little-endian)
final angle = ByteData.sublistView(bytes).getFloat32(0, Endian.little);
actionStreamInternal.add(LogNotification('Steering angle: ${angle.toStringAsFixed(1)}°'));
// Determine steering direction based on angle threshold
final button = _getSteeringButton(angle);
if (button != null) {
handleButtonsClicked([button]);
} else if (_getSteeringButton(_lastAngle) != null) {
// Release button if we were steering but now we're centered
handleButtonsClicked([]);
}
_lastAngle = angle;
}
}
ControllerButton? _getSteeringButton(double angle) {
// Use a threshold to avoid jitter around center
if (angle < -SterzoConstants.STEERING_THRESHOLD) {
return ControllerButton.navigationLeft;
} else if (angle > SterzoConstants.STEERING_THRESHOLD) {
return ControllerButton.navigationRight;
}
return null;
}
List<int> _getChallengeResponse(int challenge) {
if (_challengeCodesData == null) {
// Fallback if data not loaded
return [0x96, 0x96];
}
final index = challenge * 2;
if (index >= 0 && index < _challengeCodesData!.length - 1) {
return [_challengeCodesData![index], _challengeCodesData![index + 1]];
}
// Fallback for out of range challenges
return [0x96, 0x96];
}
}
class SterzoConstants {
static const String DEVICE_NAME = "STERZO";
// Elite Sterzo Smart characteristic UUIDs
static const String MEASUREMENT_CHARACTERISTIC_UUID = "347b0030-7635-408b-8918-8ff3949ce592";
static const String CONTROL_POINT_CHARACTERISTIC_UUID = "347b0031-7635-408b-8918-8ff3949ce592";
static const String CHALLENGE_CODE_CHARACTERISTIC_UUID = "347b0032-7635-408b-8918-8ff3949ce592";
// Service UUID pattern (matches Elite devices)
static const String SERVICE_UUID = "347b0001-7635-408b-8918-8ff3949ce592";
// Steering angle threshold in degrees to trigger steering action
static const double STEERING_THRESHOLD = 5.0;
static const int RECONNECT_DELAY = 5; // seconds between reconnection attempts
// URL to fetch challenge codes
static const String CHALLENGE_CODES_URL =
'https://github.com/zacharyedwardbull/pycycling/raw/refs/heads/master/pycycling/data/sterzo-challenge-codes.dat';
// Cache key for SharedPreferences
static const String CACHE_KEY = 'elite_sterzo_challenge_codes';
}

View File

@@ -0,0 +1,127 @@
import 'dart:collection';
import 'dart:typed_data';
import 'package:swift_control/bluetooth/devices/base_device.dart';
import 'package:swift_control/utils/keymap/buttons.dart';
import 'package:universal_ble/universal_ble.dart';
class WahooKickrBikeShift extends BaseDevice {
WahooKickrBikeShift(super.scanResult)
: super(
availableButtons: WahooKickrBikeShiftConstants.prefixToButton.values.toList(),
);
@override
Future<void> handleServices(List<BleService> services) async {
final service = services.firstWhere(
(e) => e.uuid == WahooKickrBikeShiftConstants.SERVICE_UUID,
orElse: () => throw Exception('Service not found: ${WahooKickrBikeShiftConstants.SERVICE_UUID}'),
);
final characteristic = service.characteristics.firstWhere(
(e) => e.uuid == WahooKickrBikeShiftConstants.CHARACTERISTIC_UUID,
orElse: () => throw Exception('Characteristic not found: ${WahooKickrBikeShiftConstants.CHARACTERISTIC_UUID}'),
);
await UniversalBle.subscribeNotifications(device.deviceId, service.uuid, characteristic.uuid);
}
@override
Future<void> processCharacteristic(String characteristic, Uint8List bytes) {
if (characteristic == WahooKickrBikeShiftConstants.CHARACTERISTIC_UUID) {
final hex = toHex(bytes);
// Short-frame detection (hard-coded families)
final s = parseShortFrame(hex);
if (s != null) {
if (s.pressed) {
handleButtonsClicked([s.button]);
} else {
handleButtonsClicked([]);
}
return Future.value();
}
}
return Future.value();
}
// Deduplicate per (prefix, type) using the 7-bit rolling sequence
final Map<String, int> lastSeqByPrefix = HashMap<String, int>();
String toHex(Uint8List bytes) => bytes.map((b) => b.toRadixString(16).padLeft(2, '0')).join().toUpperCase();
// Parse short frames like "PPQQRR" (e.g., "0001E6", "80005E", "40008F", "010004")
ShortFrame? parseShortFrame(String hex) {
final re = RegExp(r'^[0-9A-F]{6}$', caseSensitive: false);
if (!re.hasMatch(hex)) return null;
final prefix = hex.substring(0, 4); // PPQQ
final rrHex = hex.substring(4, 6); // RR
if (!WahooKickrBikeShiftConstants.prefixToButton.containsKey(prefix)) return null;
final idx = int.parse(rrHex, radix: 16);
final type = (idx & 0x80) != 0 ? true : false; // MSB of RR
final seq = idx & 0x7F; // rolling counter for dedupe
return ShortFrame(
prefix: prefix,
rrHex: rrHex,
idx: idx,
pressed: type,
seq: seq,
button: WahooKickrBikeShiftConstants.prefixToButton[prefix]!,
);
}
bool isLongFrame(String hex) {
final re = RegExp(r'^FF0F01', caseSensitive: false);
return re.hasMatch(hex);
}
// Returns true if this (prefix,type,seq) has not been handled yet
bool shouldHandleOnce(String prefix, String type, int seq) {
final key = '$prefix:$type';
final last = lastSeqByPrefix[key];
if (last == seq) return false;
lastSeqByPrefix[key] = seq;
return true;
}
}
class ShortFrame {
final String prefix; // PPQQ
final String rrHex; // RR
final int idx;
final bool pressed;
final int seq;
final ControllerButton button;
ShortFrame({
required this.prefix,
required this.rrHex,
required this.idx,
required this.pressed,
required this.seq,
required this.button,
});
}
class WahooKickrBikeShiftConstants {
static const String SERVICE_UUID = "a026ee0d-0a7d-4ab3-97fa-f1500f9feb8b";
static const String CHARACTERISTIC_UUID = "a026e03c-0a7d-4ab3-97fa-f1500f9feb8b";
// https://support.wahoofitness.com/hc/en-us/articles/22259367275410-Shifter-and-button-configuration-for-KICKR-BIKE-1-2
static const Map<String, ControllerButton> prefixToButton = {
'0001': ControllerButton.powerUpRight, //'Right Up',
'8000': ControllerButton.sideButtonRight, //'Right Down',
'0008': ControllerButton.navigationRight, //'Right Steer',
'0200': ControllerButton.powerUpLeft, // 'Left Up',
'0400': ControllerButton.sideButtonLeft, //'Left Down',
'2000': ControllerButton.navigationLeft, //'Left Steer',
'0004': ControllerButton.shiftUpRight, // 'Right Shift Up',
'0002': ControllerButton.shiftDownRight, // 'Right Shift Down',
'1000': ControllerButton.shiftUpLeft, //'Left Shift Up',
'0800': ControllerButton.shiftDownLeft, //'Left Shift Down',
'4000': ControllerButton.paddleRight, //'Right Brake',
'0100': ControllerButton.paddleLeft, //'Left Brake',
};
}

View File

@@ -0,0 +1,118 @@
import 'dart:typed_data';
class ZwiftConstants {
static final ZWIFT_CUSTOM_SERVICE_UUID = "00000001-19CA-4651-86E5-FA29DCDD09D1".toLowerCase();
static final ZWIFT_RIDE_CUSTOM_SERVICE_UUID = "0000fc82-0000-1000-8000-00805f9b34fb".toLowerCase();
static final ZWIFT_ASYNC_CHARACTERISTIC_UUID = "00000002-19CA-4651-86E5-FA29DCDD09D1".toLowerCase();
static final ZWIFT_SYNC_RX_CHARACTERISTIC_UUID = "00000003-19CA-4651-86E5-FA29DCDD09D1".toLowerCase();
static final ZWIFT_SYNC_TX_CHARACTERISTIC_UUID = "00000004-19CA-4651-86E5-FA29DCDD09D1".toLowerCase();
static const ZWIFT_MANUFACTURER_ID = 2378; // Zwift, Inc => 0x094A
// Zwift Play = RC1
static const RC1_LEFT_SIDE = 0x03;
static const RC1_RIGHT_SIDE = 0x02;
// Zwift Ride
static const RIDE_RIGHT_SIDE = 0x07;
static const RIDE_LEFT_SIDE = 0x08;
// Zwift Click = BC1
static const BC1 = 0x09;
// Zwift Click v2 Right (unconfirmed)
static const CLICK_V2_RIGHT_SIDE = 0x0A;
// Zwift Click v2 Right (unconfirmed)
static const CLICK_V2_LEFT_SIDE = 0x0B;
static final RIDE_ON = Uint8List.fromList([0x52, 0x69, 0x64, 0x65, 0x4f, 0x6e]);
static final VIBRATE_PATTERN = Uint8List.fromList([0x12, 0x12, 0x08, 0x0A, 0x06, 0x08, 0x02, 0x10, 0x00, 0x18]);
// these don't actually seem to matter, its just the header has to be 7 bytes RIDEON + 2
static final REQUEST_START = Uint8List.fromList([0, 9]); //byteArrayOf(1, 2)
static final RESPONSE_START_CLICK = Uint8List.fromList([1, 3]); // from device
static final RESPONSE_START_PLAY = Uint8List.fromList([1, 4]); // from device
static final RESPONSE_START_CLICK_V2 = Uint8List.fromList([0x02, 0x03]); // from device
static final RESPONSE_STOPPED_CLICK_V2 = Uint8List.fromList([
0xff,
0x05,
0x00,
0xea,
0x05,
0x19,
0x0a,
0x0c,
0x35,
0x38,
0x44,
0x31,
0x35,
0x41,
0x42,
0x42,
0x34,
0x33,
0x36,
0x33,
0x10,
0x01,
0x18,
0x84,
0x07,
0x20,
0x08,
0x28,
0x09,
0x30,
]); // from device
// Message types received from device
static const CONTROLLER_NOTIFICATION_MESSAGE_TYPE = 07;
static const EMPTY_MESSAGE_TYPE = 21;
static const BATTERY_LEVEL_TYPE = 25;
static const UNKNOWN_CLICKV2_TYPE = 0x3C;
// not figured out the protobuf type this really is, the content is just two varints.
static const int CLICK_NOTIFICATION_MESSAGE_TYPE = 55;
static const int PLAY_NOTIFICATION_MESSAGE_TYPE = 7;
static const int RIDE_NOTIFICATION_MESSAGE_TYPE = 35; // 0x23
// see this if connected to Core then Zwift connects to it. just one byte
static const DISCONNECT_MESSAGE_TYPE = 0xFE;
}
enum ZwiftDeviceType {
click,
clickV2Right,
clickV2Left,
playLeft,
playRight,
rideRight,
rideLeft;
@override
String toString() {
return super.toString().split('.').last;
}
// add constructor
static ZwiftDeviceType? fromManufacturerData(int data) {
switch (data) {
case ZwiftConstants.BC1:
return ZwiftDeviceType.click;
case ZwiftConstants.CLICK_V2_RIGHT_SIDE:
return ZwiftDeviceType.clickV2Right;
case ZwiftConstants.CLICK_V2_LEFT_SIDE:
return ZwiftDeviceType.clickV2Left;
case ZwiftConstants.RC1_LEFT_SIDE:
return ZwiftDeviceType.playLeft;
case ZwiftConstants.RC1_RIGHT_SIDE:
return ZwiftDeviceType.playRight;
case ZwiftConstants.RIDE_RIGHT_SIDE:
return ZwiftDeviceType.rideRight;
case ZwiftConstants.RIDE_LEFT_SIDE:
return ZwiftDeviceType.rideLeft;
}
return null;
}
}

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