feat: support for xiaomi smart pen#1132
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1132 +/- ##
=======================================
Coverage 37.31% 37.31%
=======================================
Files 108 108
Lines 8498 8524 +26
=======================================
+ Hits 3171 3181 +10
- Misses 5327 5343 +16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Do you think this could be backported for Redmi Smart Pen? The buttons do the same actions (pageup, pagedown) but don't do anything while in Saber. |
I haven't looked at this code for a long time and still using the app I compiled while I last worked on this. If it is pageup/down then it should work without any change on other pens too. |
| onFocusGained: () { | ||
| // Key bindings won't work until keyboard is shown at least once for some reason. | ||
| // This is a workaround to fix that. It should be unnoticable to the user. | ||
| if (Platform.isAndroid) { | ||
| SystemChannels.textInput.invokeMethod('TextInput.show'); | ||
| SystemChannels.textInput.invokeMethod('TextInput.hide'); | ||
| } | ||
| }, |
There was a problem hiding this comment.
This solution seems a bit hacky.
I'm willing to accept it, but to reduce the impact of any potential side effects, please limit this to Xiaomi devices.
There was a problem hiding this comment.
This solution seems a bit hacky. I'm willing to accept it, but to reduce the impact of any potential side effects, please limit this to Xiaomi devices.
And Redmi (if it makes a difference), please.
| showColorOptions.value = !showColorOptions.value; | ||
| } | ||
|
|
||
| void togglePrimarySecondaryColor() { |
There was a problem hiding this comment.
The primary/secondary color switching is out-of-scope for this PR. Additional stylus button functionalities are something we'd need to properly design in the future.
For now, please just make either button switch to the eraser like with other styluses.
First of all I would like to thank you for this amazing project. Its perfect for my purpose. My only concern was that my Pen for Xiaomi Pad 6 wasn't supported. I took a look around the code base to implement support for the pen. Seems like you already have support for keyboard and since Xiaomi pen keys works as Page Up and Down, I have updated a few things to support the pen.
Changes made:
PageUpto toggle colors andPageDownto toggle eraser.About the workaround:
For some reason, keybinds only works after virtual keyboard is opened at least once. I am currently fixing this by doing this:
To be fair I am not too experienced in flutter but I tried various ways but none seemed to work. You might know better way to handle this. Let me know what to change to fix that if you have ideas. But this workaround has been perfectly working for me and keyboard doesn't even show up since show and hide happen one after another.