flipperzero-firmware icon indicating copy to clipboard operation
flipperzero-firmware copied to clipboard

event.input.sequence returns the same wrong value on remote control

Open vad7 opened this issue 1 year ago • 7 comments

qFlipper ver. 1.2.1 Code:

typedef enum { EventTypeTick, EventTypeKey, } EventType; typedef struct { EventType type; InputEvent input; } PluginEvent; FuriMessageQueue* event_queue; PluginEvent event; FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100); if(event_status == FuriStatusOk && event.type == EventTypeKey) {

here always >>> event.input.sequence == 536921112

}

vad7 avatar Nov 26 '22 08:11 vad7

Looks like it belongs to flipperzero-firmware.

gsurkov avatar Dec 14 '22 13:12 gsurkov

Yep, external events doesn't hame valid sequence number. Can I see use your case of it?

skotopes avatar Dec 14 '22 13:12 skotopes

switch(event.input.key) { case InputKeyOk: if(event.input.type == InputTypeLong) { ...func#1 key_press_seq_ok = event.input.sequence; } else if(event.input.type == InputTypeRelease && key_press_seq_ok != event.input.sequence) { // short press ...func#2 }

vad7 avatar Dec 14 '22 13:12 vad7

ViewPort and View are ensuring that input sequence is always complimentary. Using event.input.sequence here looks like overkill. There are some really special edge cases where you may want to use it, but I don't see any in your code.

Anyway, I'll update code to add sequence number for rpc input events.

skotopes avatar Dec 14 '22 14:12 skotopes

I need to handle long keypress and single keypress. how to do it?

vad7 avatar Dec 14 '22 14:12 vad7

if(event.input.type == InputTypeShort) {
    // Short
} else if(event.input.type == InputTypeLong) {
    // Long
}

Something like that is not enough?

skotopes avatar Dec 14 '22 14:12 skotopes

Thanks, it's ok. I used InputTypePress instead of InputTypeShort.

vad7 avatar Dec 14 '22 14:12 vad7

Couple releases ago I've implemented proper sequence number for external events. So your original issue should be solved.

skotopes avatar Jun 06 '23 06:06 skotopes