// File: /workspace/github_c_makefile_star2_O0/OnionIoT[P]lv_example/lvgl/src/lv_core/lv_indev.c
// Function: indev_keypad_proc
static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
{
#if LV_USE_GROUP
    if(data->state == LV_INDEV_STATE_PR && i->proc.wait_until_release) return;

    if(i->proc.wait_until_release) {
        i->proc.wait_until_release      = 0;
        i->proc.pr_timestamp            = 0;
        i->proc.long_pr_sent            = 0;
        i->proc.types.keypad.last_state = LV_INDEV_STATE_REL; /*To skip the processing of release*/
    }

    lv_group_t * g = i->group;
    if(g == NULL) return;

    indev_obj_act = lv_group_get_focused(g);
    if(indev_obj_act == NULL) return;

    /*Save the last key to compare it with the current latter on RELEASE*/
    uint32_t prev_key = i->proc.types.keypad.last_key;

    /* Save the last key.
     * It must be done here else `lv_indev_get_key` will return the last key in events and signals*/
    i->proc.types.keypad.last_key = data->key;

    /* Save the previous state so we can detect state changes below and also set the last state now
     * so if any signal/event handler on the way returns `LV_RES_INV` the last state is remembered
     * for the next time*/
    uint32_t prev_state             = i->proc.types.keypad.last_state;
    i->proc.types.keypad.last_state = data->state;

    /*Key press happened*/
    if(data->state == LV_INDEV_STATE_PR && prev_state == LV_INDEV_STATE_REL) {
        i->proc.pr_timestamp = lv_tick_get();

        /*Simulate a press on the object if ENTER was pressed*/
        if(data->key == LV_KEY_ENTER) {
            /*Send the ENTER as a normal KEY*/
            lv_group_send_data(g, LV_KEY_ENTER);

            indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_PRESSED, NULL);
            if(indev_reset_check(&i->proc)) return;
            lv_event_send(indev_obj_act, LV_EVENT_PRESSED, NULL);
            if(indev_reset_check(&i->proc)) return;
        } else if(data->key == LV_KEY_ESC) {
            /*Send the ESC as a normal KEY*/
            lv_group_send_data(g, LV_KEY_ESC);

            lv_event_send(indev_obj_act, LV_EVENT_CANCEL, NULL);
            if(indev_reset_check(&i->proc)) return;
        }
        /*Move the focus on NEXT*/
        else if(data->key == LV_KEY_NEXT) {
            lv_group_set_editing(g, false); /*Editing is not used by KEYPAD is be sure it is disabled*/
            lv_group_focus_next(g);
            if(indev_reset_check(&i->proc)) return;
        }
        /*Move the focus on PREV*/
        else if(data->key == LV_KEY_PREV) {
            lv_group_set_editing(g, false); /*Editing is not used by KEYPAD is be sure it is disabled*/
            lv_group_focus_prev(g);
            if(indev_reset_check(&i->proc)) return;
        }
        /*Just send other keys to the object (e.g. 'A' or `LV_GROUP_KEY_RIGHT`)*/
        else {
            lv_group_send_data(g, data->key);
        }
    }
    /*Pressing*/
    else if(data->state == LV_INDEV_STATE_PR && prev_state == LV_INDEV_STATE_PR) {
        /*Long press time has elapsed?*/
        if(i->proc.long_pr_sent == 0 && lv_tick_elaps(i->proc.pr_timestamp) > i->driver.long_press_time) {
            i->proc.long_pr_sent = 1;
            if(data->key == LV_KEY_ENTER) {
                i->proc.longpr_rep_timestamp = lv_tick_get();
                indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_LONG_PRESS, NULL);
                if(indev_reset_check(&i->proc)) return;
                lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED, NULL);
                if(indev_reset_check(&i->proc)) return;
            }
        }
        /*Long press repeated time has elapsed?*/
        else if(i->proc.long_pr_sent != 0 &&
                lv_tick_elaps(i->proc.longpr_rep_timestamp) > i->driver.long_press_rep_time) {

            i->proc.longpr_rep_timestamp = lv_tick_get();

            /*Send LONG_PRESS_REP on ENTER*/
            if(data->key == LV_KEY_ENTER) {
                indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_LONG_PRESS_REP, NULL);
                if(indev_reset_check(&i->proc)) return;
                lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED_REPEAT, NULL);
                if(indev_reset_check(&i->proc)) return;
            }
            /*Move the focus on NEXT again*/
            else if(data->key == LV_KEY_NEXT) {
                lv_group_set_editing(g, false); /*Editing is not used by KEYPAD is be sure it is disabled*/
                lv_group_focus_next(g);
                if(indev_reset_check(&i->proc)) return;
            }
            /*Move the focus on PREV again*/
            else if(data->key == LV_KEY_PREV) {
                lv_group_set_editing(g, false); /*Editing is not used by KEYPAD is be sure it is disabled*/
                lv_group_focus_prev(g);
                if(indev_reset_check(&i->proc)) return;
            }
            /*Just send other keys again to the object (e.g. 'A' or `LV_GORUP_KEY_RIGHT)*/
            else {
                lv_group_send_data(g, data->key);
                if(indev_reset_check(&i->proc)) return;
            }
        }
    }
    /*Release happened*/
    else if(data->state == LV_INDEV_STATE_REL && prev_state == LV_INDEV_STATE_PR) {
        /*The user might clear the key when it was released. Always release the pressed key*/
        data->key = prev_key;
        if(data->key == LV_KEY_ENTER) {

            indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_RELEASED, NULL);
            if(indev_reset_check(&i->proc)) return;

            if(i->proc.long_pr_sent == 0) {
                lv_event_send(indev_obj_act, LV_EVENT_SHORT_CLICKED, NULL);
                if(indev_reset_check(&i->proc)) return;
            }

            lv_event_send(indev_obj_act, LV_EVENT_CLICKED, NULL);
            if(indev_reset_check(&i->proc)) return;

            lv_event_send(indev_obj_act, LV_EVENT_RELEASED, NULL);
            if(indev_reset_check(&i->proc)) return;
        }
        i->proc.pr_timestamp = 0;
        i->proc.long_pr_sent = 0;
    }
    indev_obj_act = NULL;
#else
    (void)data; /*Unused*/
    (void)i;    /*Unused*/
#endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movzbl 0xe(%rax), %eax
cmpl $0x1, %eax
jne 0x3e66
movq -0x8(%rbp), %rax
movb 0x78(%rax), %al
shrb $0x3, %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x3e66
jmp 0x43ea
movq -0x8(%rbp), %rax
movb 0x78(%rax), %al
shrb $0x3, %al
andb $0x1, %al
cmpb $0x0, %al
je 0x3ea9
movq -0x8(%rbp), %rax
movb 0x78(%rax), %cl
andb $-0x9, %cl
orb $0x0, %cl
movb %cl, 0x78(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x70(%rax)
movq -0x8(%rbp), %rax
movb 0x78(%rax), %cl
andb $-0x2, %cl
orb $0x0, %cl
movb %cl, 0x78(%rax)
movq -0x8(%rbp), %rax
movb $0x0, 0x38(%rax)
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x3ec4
jmp 0x43ea
movq -0x18(%rbp), %rdi
callq 0x3010
movq %rax, 0x8509c(%rip)     # 0x88f70
cmpq $0x0, 0x85094(%rip)     # 0x88f70
jne 0x3ee3
jmp 0x43ea
movq -0x8(%rbp), %rax
movl 0x3c(%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x3c(%rax)
movq -0x8(%rbp), %rax
movzbl 0x38(%rax), %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movb 0xe(%rax), %cl
movq -0x8(%rbp), %rax
movb %cl, 0x38(%rax)
movq -0x10(%rbp), %rax
movzbl 0xe(%rax), %eax
cmpl $0x1, %eax
jne 0x408e
cmpl $0x0, -0x20(%rbp)
jne 0x408e
callq 0xdfe0
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x70(%rax)
movq -0x10(%rbp), %rax
cmpl $0xa, 0x4(%rax)
jne 0x3fb9
movq -0x18(%rbp), %rdi
movl $0xa, %esi
callq 0x2f80
movq 0x85014(%rip), %rax     # 0x88f70
movq 0x30(%rax), %rax
movq 0x85009(%rip), %rdi     # 0x88f70
movl $0x8, %esi
xorl %ecx, %ecx
movl %ecx, %edx
callq *%rax
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x3f85
jmp 0x3f8a
jmp 0x43ea
movq 0x84fdf(%rip), %rdi     # 0x88f70
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7990
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x3faf
jmp 0x3fb4
jmp 0x43ea
jmp 0x4089
movq -0x10(%rbp), %rax
cmpl $0x1b, 0x4(%rax)
jne 0x4003
movq -0x18(%rbp), %rdi
movl $0x1b, %esi
callq 0x2f80
movq 0x84f98(%rip), %rdi     # 0x88f70
movl $0x12, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7990
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x3ff9
jmp 0x3ffe
jmp 0x43ea
jmp 0x4087
movq -0x10(%rbp), %rax
cmpl $0x9, 0x4(%rax)
jne 0x403b
movq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0x2b70
movq -0x18(%rbp), %rdi
callq 0x2cb0
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x4034
jmp 0x4039
jmp 0x43ea
jmp 0x4085
movq -0x10(%rbp), %rax
cmpl $0xb, 0x4(%rax)
jne 0x4073
movq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0x2b70
movq -0x18(%rbp), %rdi
callq 0x2f00
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x406c
jmp 0x4071
jmp 0x43ea
jmp 0x4083
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x2f80
jmp 0x4085
jmp 0x4087
jmp 0x4089
jmp 0x43df
movq -0x10(%rbp), %rax
movzbl 0xe(%rax), %eax
cmpl $0x1, %eax
jne 0x42c2
cmpl $0x1, -0x20(%rbp)
jne 0x42c2
movq -0x8(%rbp), %rax
movb 0x78(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x416b
movq -0x8(%rbp), %rax
movl 0x70(%rax), %edi
callq 0xe010
movq -0x8(%rbp), %rcx
movzwl 0x2a(%rcx), %ecx
cmpl %ecx, %eax
jbe 0x416b
movq -0x8(%rbp), %rax
movb 0x78(%rax), %cl
andb $-0x2, %cl
orb $0x1, %cl
movb %cl, 0x78(%rax)
movq -0x10(%rbp), %rax
cmpl $0xa, 0x4(%rax)
jne 0x4166
callq 0xdfe0
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x74(%rax)
movq 0x84e67(%rip), %rax     # 0x88f70
movq 0x30(%rax), %rax
movq 0x84e5c(%rip), %rdi     # 0x88f70
movl $0xc, %esi
xorl %ecx, %ecx
movl %ecx, %edx
callq *%rax
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x4132
jmp 0x4137
jmp 0x43ea
movq 0x84e32(%rip), %rdi     # 0x88f70
movl $0x4, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7990
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x415f
jmp 0x4164
jmp 0x43ea
jmp 0x4166
jmp 0x42bd
movq -0x8(%rbp), %rax
movb 0x78(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x42bb
movq -0x8(%rbp), %rax
movl 0x74(%rax), %edi
callq 0xe010
movq -0x8(%rbp), %rcx
movzwl 0x2c(%rcx), %ecx
cmpl %ecx, %eax
jbe 0x42bb
callq 0xdfe0
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x74(%rax)
movq -0x10(%rbp), %rax
cmpl $0xa, 0x4(%rax)
jne 0x421b
movq 0x84db5(%rip), %rax     # 0x88f70
movq 0x30(%rax), %rax
movq 0x84daa(%rip), %rdi     # 0x88f70
movl $0xd, %esi
xorl %ecx, %ecx
movl %ecx, %edx
callq *%rax
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x41e4
jmp 0x41e9
jmp 0x43ea
movq 0x84d80(%rip), %rdi     # 0x88f70
movl $0x5, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7990
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x4211
jmp 0x4216
jmp 0x43ea
jmp 0x42b9
movq -0x10(%rbp), %rax
cmpl $0x9, 0x4(%rax)
jne 0x4253
movq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0x2b70
movq -0x18(%rbp), %rdi
callq 0x2cb0
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x424c
jmp 0x4251
jmp 0x43ea
jmp 0x42b7
movq -0x10(%rbp), %rax
cmpl $0xb, 0x4(%rax)
jne 0x428b
movq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0x2b70
movq -0x18(%rbp), %rdi
callq 0x2f00
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x4284
jmp 0x4289
jmp 0x43ea
jmp 0x42b5
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x2f80
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x42ae
jmp 0x42b3
jmp 0x43ea
jmp 0x42b5
jmp 0x42b7
jmp 0x42b9
jmp 0x42bb
jmp 0x42bd
jmp 0x43dd
movq -0x10(%rbp), %rax
movzbl 0xe(%rax), %eax
cmpl $0x0, %eax
jne 0x43db
cmpl $0x1, -0x20(%rbp)
jne 0x43db
movl -0x1c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
cmpl $0xa, 0x4(%rax)
jne 0x43c0
movq 0x84c74(%rip), %rax     # 0x88f70
movq 0x30(%rax), %rax
movq 0x84c69(%rip), %rdi     # 0x88f70
movl $0xb, %esi
xorl %ecx, %ecx
movl %ecx, %edx
callq *%rax
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x4325
jmp 0x432a
jmp 0x43ea
movq -0x8(%rbp), %rax
movb 0x78(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x436a
movq 0x84c2e(%rip), %rdi     # 0x88f70
movl $0x3, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7990
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x4363
jmp 0x4368
jmp 0x43ea
jmp 0x436a
movq 0x84bff(%rip), %rdi     # 0x88f70
movl $0x6, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7990
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x4392
jmp 0x4394
jmp 0x43ea
movq 0x84bd5(%rip), %rdi     # 0x88f70
movl $0x7, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7990
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x43bc
jmp 0x43be
jmp 0x43ea
jmp 0x43c0
movq -0x8(%rbp), %rax
movl $0x0, 0x70(%rax)
movq -0x8(%rbp), %rax
movb 0x78(%rax), %cl
andb $-0x2, %cl
orb $0x0, %cl
movb %cl, 0x78(%rax)
jmp 0x43dd
jmp 0x43df
movq $0x0, 0x84b86(%rip) # 0x88f70
addq $0x20, %rsp
popq %rbp
retq