Skip to content

Conversation

Msprg
Copy link

@Msprg Msprg commented Apr 2, 2025

The code seems to be working, but it might need some adjustments as I honestly don't know what I'm doing lol.

Also, localization still needs to be added as the strings are hardcoded right now.
Settings version is now bumped to 6, so I changed how the comparison works a little to make it somewhat backwards compatible. Let's consider this a temporary fix? (but we all know how that usually ends, right?)

It might not be perfect, but dang does it work...

@@ -1157,14 +1163,23 @@ class ChameleonCommunicator {
aLongPress = getButtonConfigType(resp[4]),
bLongPress = getButtonConfigType(resp[5]);

// Default long press threshold is 1000ms
int longPressThreshold = 1000;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return null if not possible to fetch

}

Future<bool> setLongPressThreshold(int threshold) async {
try {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not catch exceptions in bridge code, you should catch them inside app code

Future<bool> setLongPressThreshold(int threshold) async {
try {
// Enforce minimum value of 200ms
if (threshold < 200) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same there, should be capped on the app code, not library
And well, not silently change variables

Btw
https://github.com/RfidResearchGroup/ChameleonUltra/pull/246/files#diff-a77a6e56d4afc8a8478326a1c55a4e58cefc7da3ce95f1db32056846b9803298R310-R312

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's enforced by the firmware, but the user should get some feedback, not just set it to 50 only for it to either magically turn into 200 or stay the same.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Msprg "should be capped on the app code" means, that it should be capped on the app code, not that it shouldnt be capped. Have a slider or smthng and make the UI (app) code limit it. allows you to also give more descriptive error messages


await sendCmd(ChameleonCommand.setLongPressThreshold,
data: Uint8List.fromList(u16ToBytes(threshold)));
return true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't check real return, should return Future<void>

}

Future<void> _updateLongPressThreshold() async {
if (!mounted) return;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just no, there is FutureBuilder that fetches all info. Idk what prompt are you used, but output is just trash

if (!appState.connector!.connected || appState.communicator == null) return;

try {
int threshold = await appState.communicator!.getLongPressThreshold();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And well, getDeviceSettings returns threshold...

@@ -291,6 +332,113 @@ class ChameleonSettingsState extends State<ChameleonSettings> {
appState.changesMade();
}),
const SizedBox(height: 10),
Text("Buttons Long Press Threshold:",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create localization

return Row(
children: [
Expanded(
child: TextFormField(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slider should be better there, I doubt someone intentionally want to set threshold to exactly 5032 ms

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dislike the slider as it offers either low precision and / or low range. I like to fine tune my values, and while I agree 5032ms is just stupid, values such as 210, 215, 225, 250, will be difficult to set. It could be supplemented by a slider, but not replaced. It's also good for accessibility.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Msprg have the classic arrangement of a slider next to a small textbox. best of both worlds. Maybe have the slider snap to some reasonable values (default value in the middle), i think that should be possible.

builder: (BuildContext context) => AlertDialog(
title: const Text("Long Press Threshold"),
content: const Text(
"Sets the time in milliseconds for how long a button needs to be pressed to be considered a 'long press'.\n\nDefault: 1000ms (1 second)"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Long press threshold" is self explanatory

@GameTec-live GameTec-live added stalled This is stalled due to a 3rd party enhancement New feature or request labels Apr 5, 2025
@GameTec-live
Copy link
Owner

(stalled) Waiting on RfidResearchGroup/ChameleonUltra#246

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stalled This is stalled due to a 3rd party
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

3 participants