// File: /workspace/github_c_makefile_star2_O1/OnionIoT[P]lv_example/lvgl/src/lv_core/lv_indev.c
// Function: indev_proc_press
static void indev_proc_press(lv_indev_proc_t * proc)
{
    indev_obj_act = proc->types.pointer.act_obj;

    if(proc->wait_until_release != 0) return;

    lv_disp_t * disp = indev_act->driver.disp;
    bool new_obj_searched = false;

    /*If there is no last object then search*/
    if(indev_obj_act == NULL) {
        indev_obj_act = indev_search_obj(proc, lv_disp_get_layer_sys(disp));
        if(indev_obj_act == NULL) indev_obj_act = indev_search_obj(proc, lv_disp_get_layer_top(disp));
        if(indev_obj_act == NULL) indev_obj_act = indev_search_obj(proc, lv_disp_get_scr_act(disp));
        new_obj_searched = true;
    }
    /*If there is last object but it is not dragged and not protected also search*/
    else if(proc->types.pointer.drag_in_prog == 0 &&
            lv_obj_is_protected(indev_obj_act, LV_PROTECT_PRESS_LOST) == false) {
        indev_obj_act = indev_search_obj(proc, lv_disp_get_layer_sys(disp));
        if(indev_obj_act == NULL) indev_obj_act = indev_search_obj(proc, lv_disp_get_layer_top(disp));
        if(indev_obj_act == NULL) indev_obj_act = indev_search_obj(proc, lv_disp_get_scr_act(disp));
        new_obj_searched = true;
    }
    /*If a dragable or a protected object was the last then keep it*/
    else {
    }

    /*The last object might have drag throw. Stop it manually*/
    if(new_obj_searched && proc->types.pointer.last_obj) {
        proc->types.pointer.drag_throw_vect.x = 0;
        proc->types.pointer.drag_throw_vect.y = 0;
        indev_drag_throw(proc);
    }

    /*If a new object was found reset some variables and send a pressed signal*/
    if(indev_obj_act != proc->types.pointer.act_obj) {
        proc->types.pointer.last_point.x = proc->types.pointer.act_point.x;
        proc->types.pointer.last_point.y = proc->types.pointer.act_point.y;

        /*If a new object found the previous was lost, so send a signal*/
        if(proc->types.pointer.act_obj != NULL) {
            /*Save the obj because in special cases `act_obj` can change in the signal function*/
            lv_obj_t * last_obj = proc->types.pointer.act_obj;

            last_obj->signal_cb(last_obj, LV_SIGNAL_PRESS_LOST, indev_act);
            if(indev_reset_check(proc)) return;
            lv_event_send(last_obj, LV_EVENT_PRESS_LOST, NULL);
            if(indev_reset_check(proc)) return;

        }

        proc->types.pointer.act_obj  = indev_obj_act; /*Save the pressed object*/
        proc->types.pointer.last_obj = indev_obj_act;

        if(indev_obj_act != NULL) {
            /* Save the time when the obj pressed.
             * It is necessary to count the long press time.*/
            proc->pr_timestamp                 = lv_tick_get();
            proc->long_pr_sent                 = 0;
            proc->types.pointer.drag_limit_out = 0;
            proc->types.pointer.drag_in_prog   = 0;
            proc->types.pointer.drag_sum.x     = 0;
            proc->types.pointer.drag_sum.y     = 0;
            proc->types.pointer.vect.x         = 0;
            proc->types.pointer.vect.y         = 0;

            /*Search for 'top' attribute*/
            lv_obj_t * i        = indev_obj_act;
            lv_obj_t * last_top = NULL;
            while(i != NULL) {
                if(i->top) last_top = i;
                i = lv_obj_get_parent(i);
            }

            if(last_top != NULL) {
                /*Move the last_top object to the foreground*/
                lv_obj_move_foreground(last_top);
            }

            /*Send a signal about the press*/
            indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_PRESSED, indev_act);
            if(indev_reset_check(proc)) return;

            lv_event_send(indev_obj_act, LV_EVENT_PRESSED, NULL);
            if(indev_reset_check(proc)) return;
        }
    }

    /*Calculate the types.pointer.vector*/
    proc->types.pointer.vect.x = proc->types.pointer.act_point.x - proc->types.pointer.last_point.x;
    proc->types.pointer.vect.y = proc->types.pointer.act_point.y - proc->types.pointer.last_point.y;

    proc->types.pointer.drag_throw_vect.x = (proc->types.pointer.drag_throw_vect.x * 5) >> 3;
    proc->types.pointer.drag_throw_vect.y = (proc->types.pointer.drag_throw_vect.y * 5) >> 3;

    if(proc->types.pointer.drag_throw_vect.x < 0)
        proc->types.pointer.drag_throw_vect.x++;
    else if(proc->types.pointer.drag_throw_vect.x > 0)
        proc->types.pointer.drag_throw_vect.x--;

    if(proc->types.pointer.drag_throw_vect.y < 0)
        proc->types.pointer.drag_throw_vect.y++;
    else if(proc->types.pointer.drag_throw_vect.y > 0)
        proc->types.pointer.drag_throw_vect.y--;

    proc->types.pointer.drag_throw_vect.x += (proc->types.pointer.vect.x * 4) >> 3;
    proc->types.pointer.drag_throw_vect.y += (proc->types.pointer.vect.y * 4) >> 3;

    /*If there is active object and it can be dragged run the drag*/
    if(indev_obj_act != NULL) {
        indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_PRESSING, indev_act);
        if(indev_reset_check(proc)) return;
        lv_event_send(indev_obj_act, LV_EVENT_PRESSING, NULL);
        if(indev_reset_check(proc)) return;

        indev_drag(proc);
        if(indev_reset_check(proc)) return;

        /*If there is no drag then check for long press time*/
        if(proc->types.pointer.drag_in_prog == 0 && proc->long_pr_sent == 0) {
            /*Send a signal about the long press if enough time elapsed*/
            if(lv_tick_elaps(proc->pr_timestamp) > indev_act->driver.long_press_time) {
                indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_LONG_PRESS, indev_act);
                if(indev_reset_check(proc)) return;
                lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED, NULL);
                if(indev_reset_check(proc)) return;

                /*Mark the signal sending to do not send it again*/
                proc->long_pr_sent = 1;

                /*Save the long press time stamp for the long press repeat handler*/
                proc->longpr_rep_timestamp = lv_tick_get();
            }
        }
        /*Send long press repeated signal*/
        if(proc->types.pointer.drag_in_prog == 0 && proc->long_pr_sent == 1) {
            /*Send a signal about the long press repeat if enough time elapsed*/
            if(lv_tick_elaps(proc->longpr_rep_timestamp) > indev_act->driver.long_press_rep_time) {
                indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_LONG_PRESS_REP, indev_act);
                if(indev_reset_check(proc)) return;
                lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED_REPEAT, NULL);
                if(indev_reset_check(proc)) return;
                proc->longpr_rep_timestamp = lv_tick_get();
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x20(%rdi), %rdi
movq %rdi, 0x5c5c3(%rip)     # 0x5fea0
testb $0x8, 0x48(%rbx)
jne 0x3e58
movq 0x5c5aa(%rip), %rax     # 0x5fe98
movq 0x18(%rax), %r14
testq %rdi, %rdi
je 0x390f
testb $0x2, 0x38(%rbx)
jne 0x3982
movl $0x10, %esi
callq 0x6a3c
testb %al, %al
jne 0x3982
movq %r14, %rdi
callq 0x4420
movq %rbx, %rdi
movq %rax, %rsi
callq 0x410d
movq %rax, 0x5c577(%rip)     # 0x5fea0
testq %rax, %rax
jne 0x3948
movq %r14, %rdi
callq 0x4403
movq %rbx, %rdi
movq %rax, %rsi
callq 0x410d
movq %rax, 0x5c558(%rip)     # 0x5fea0
cmpq $0x0, 0x5c550(%rip)     # 0x5fea0
jne 0x396c
movq %r14, %rdi
callq 0x43d0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x410d
movq %rax, 0x5c534(%rip)     # 0x5fea0
cmpq $0x0, 0x28(%rbx)
je 0x3982
movl $0x0, 0x18(%rbx)
movq %rbx, %rdi
callq 0x41b9
movq 0x20(%rbx), %r14
cmpq %r14, 0x5c513(%rip)     # 0x5fea0
je 0x3a6f
movl 0x8(%rbx), %eax
movl %eax, 0xc(%rbx)
testq %r14, %r14
je 0x39d4
movq 0x5c4f3(%rip), %rdx     # 0x5fe98
movq %r14, %rdi
movl $0xa, %esi
callq *0x30(%r14)
testb $0x2, 0x48(%rbx)
jne 0x3e4d
movq %r14, %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x4fea
testb $0x2, 0x48(%rbx)
jne 0x3e4d
movq 0x5c4c5(%rip), %rax     # 0x5fea0
movq %rax, 0x20(%rbx)
movq %rax, 0x28(%rbx)
testq %rax, %rax
je 0x3a6f
callq 0x883e
movl %eax, 0x40(%rbx)
andb $-0x2, 0x48(%rbx)
andb $-0x4, 0x38(%rbx)
movq $0x0, 0x10(%rbx)
movq 0x5c495(%rip), %rax     # 0x5fea0
xorl %r14d, %r14d
testq %rax, %rax
je 0x3a28
movzwl 0x58(%rax), %ecx
testb $0x20, %cl
cmovneq %rax, %r14
movq %rax, %rdi
callq 0x4abf
jmp 0x3a0e
testq %r14, %r14
je 0x3a35
movq %r14, %rdi
callq 0x5334
movq 0x5c464(%rip), %rdi     # 0x5fea0
movq 0x5c455(%rip), %rdx     # 0x5fe98
movl $0x8, %esi
callq *0x30(%rdi)
testb $0x2, 0x48(%rbx)
jne 0x3e4d
movq 0x5c444(%rip), %rdi     # 0x5fea0
xorl %esi, %esi
xorl %edx, %edx
callq 0x4fea
testb $0x2, 0x48(%rbx)
jne 0x3e4d
movzwl 0x8(%rbx), %ecx
movzwl 0xa(%rbx), %eax
subw 0xc(%rbx), %cx
movw %cx, 0x10(%rbx)
subw 0xe(%rbx), %ax
movw %ax, 0x12(%rbx)
movswl 0x18(%rbx), %edx
leal (%rdx,%rdx,4), %esi
shrl $0x3, %esi
movw %si, 0x18(%rbx)
movswl 0x1a(%rbx), %edx
leal (%rdx,%rdx,4), %edx
shrl $0x3, %edx
movw %dx, 0x1a(%rbx)
testw %si, %si
js 0x3ab0
movw $0xffff, %di            # imm = 0xFFFF
jne 0x3ab4
jmp 0x3abd
movw $0x1, %di
movswl %di, %edi
addl %esi, %edi
movw %di, 0x18(%rbx)
testw %dx, %dx
js 0x3aca
movw $0xffff, %si            # imm = 0xFFFF
jne 0x3ace
jmp 0x3ad7
movw $0x1, %si
movswl %si, %esi
addl %edx, %esi
movw %si, 0x1a(%rbx)
movswl %cx, %ecx
shrl %ecx
addw %cx, 0x18(%rbx)
cwtl
shrl %eax
addw %ax, 0x1a(%rbx)
movq 0x5c3b2(%rip), %rdi     # 0x5fea0
testq %rdi, %rdi
je 0x3e58
movq 0x5c39a(%rip), %rdx     # 0x5fe98
movl $0x9, %esi
callq *0x30(%rdi)
testb $0x2, 0x48(%rbx)
jne 0x3e4d
movq 0x5c389(%rip), %rdi     # 0x5fea0
movl $0x1, %esi
xorl %edx, %edx
callq 0x4fea
testb $0x2, 0x48(%rbx)
jne 0x3e4d
movq 0x20(%rbx), %r14
movq %r14, %rdi
callq 0x6975
xorb $0x1, %al
testq %r14, %r14
sete %cl
orb %al, %cl
jne 0x3b61
movq %r14, %rdi
callq 0x4abf
movq %rax, %r14
movq %rax, %rdi
callq 0x6975
testb %al, %al
je 0x3b61
testq %r14, %r14
jne 0x3b45
testq %r14, %r14
je 0x3d84
movq %r14, %rdi
callq 0x6901
testb %al, %al
je 0x3d84
movq %r14, %rdi
callq 0x6928
movl %eax, %r13d
movzwl 0x10(%rbx), %eax
movzwl 0x12(%rbx), %ecx
movzwl 0x14(%rbx), %edi
addw %ax, %di
movw %di, 0x14(%rbx)
movzwl 0x16(%rbx), %esi
addw %cx, %si
movw %si, 0x16(%rbx)
movb 0x38(%rbx), %dl
testb $0x1, %dl
jne 0x3bed
testb $0x1, %r13b
je 0x3bce
movl %edi, %r8d
negw %r8w
cmovsw %di, %r8w
movq 0x5c2d4(%rip), %rdi     # 0x5fe98
movzbl 0x28(%rdi), %edi
cmpw %di, %r8w
jae 0x3bf2
testb $0x2, %r13b
je 0x3bed
movl %esi, %edi
negw %di
cmovsw %si, %di
movq 0x5c2b4(%rip), %rsi     # 0x5fe98
movzbl 0x28(%rsi), %esi
cmpw %si, %di
jae 0x3bf2
xorl %r12d, %r12d
jmp 0x3bfb
orb $0x1, %dl
movb %dl, 0x38(%rbx)
movb $0x1, %r12b
testb $0x1, 0x38(%rbx)
je 0x3d84
orw %cx, %ax
je 0x3d84
movq 0x5c283(%rip), %rax     # 0x5fe98
movq 0x18(%rax), %rdi
callq 0x8665
movl %eax, 0x14(%rsp)
movzwl 0x20(%r14), %r15d
movzwl 0x22(%r14), %eax
movw %ax, 0x12(%rsp)
movq %r14, %rdi
callq 0x4abf
movq %rax, %rdi
callq 0x5651
movw %ax, 0x10(%rsp)
movq %r14, %rdi
callq 0x4abf
movq %rax, %rdi
callq 0x567b
movw %ax, 0xe(%rsp)
movq %r14, %rdi
callq 0x4bc6
movl %eax, %ebp
movq %r14, %rdi
callq 0x4bfe
cmpb $0x3, %r13b
jne 0x3c98
testb %r12b, %r12b
je 0x3c80
addw 0x14(%rbx), %bp
addw 0x16(%rbx), %ax
addw 0x10(%rbx), %bp
addw 0x12(%rbx), %ax
movswl %bp, %esi
movswl %ax, %edx
movq %r14, %rdi
callq 0x4ae2
jmp 0x3cd6
testb $0x1, %r13b
jne 0x3cbe
testb $0x2, %r13b
je 0x3cd6
testb %r12b, %r12b
je 0x3cad
addw 0x16(%rbx), %ax
addw 0x12(%rbx), %ax
movswl %ax, %esi
movq %r14, %rdi
callq 0x5501
jmp 0x3cd6
testb %r12b, %r12b
je 0x3cc7
addw 0x14(%rbx), %bp
addw 0x10(%rbx), %bp
movswl %bp, %esi
movq %r14, %rdi
callq 0x54c3
cmpw %r15w, 0x20(%r14)
jne 0x3d42
movzwl 0x12(%rsp), %eax
cmpw %ax, 0x22(%r14)
jne 0x3d42
movq %r14, %rdi
callq 0x4abf
movq %rax, %rdi
callq 0x5651
movl %eax, %ebp
movq %r14, %rdi
callq 0x4abf
movq %rax, %rdi
callq 0x567b
cmpw 0x10(%rsp), %bp
jne 0x3d84
cmpw 0xe(%rsp), %ax
jne 0x3d84
movq 0x5c178(%rip), %rax     # 0x5fe98
movq 0x18(%rax), %rdi
callq 0x8665
movq 0x5c168(%rip), %rcx     # 0x5fe98
movq 0x18(%rcx), %rdi
subl 0x14(%rsp), %eax
movzwl %ax, %esi
callq 0x8672
jmp 0x3d84
orb $0x2, 0x38(%rbx)
testb %r12b, %r12b
je 0x3d84
movq 0x5c146(%rip), %rdx     # 0x5fe98
movq %r14, %rdi
movl $0xe, %esi
callq *0x30(%r14)
testb $0x2, 0x48(%rbx)
jne 0x3d79
movq %r14, %rdi
movl $0x8, %esi
xorl %edx, %edx
callq 0x4fea
testb $0x2, 0x48(%rbx)
je 0x3d84
movq $0x0, 0x5c11c(%rip) # 0x5fea0
movb 0x48(%rbx), %al
testb $0x2, %al
jne 0x3e4d
movb 0x38(%rbx), %cl
andb $0x2, %cl
andb $0x1, %al
orb %cl, %al
jne 0x3df2
movl 0x40(%rbx), %edi
callq 0x8855
movq 0x5c0ee(%rip), %rdx     # 0x5fe98
movzwl 0x2a(%rdx), %ecx
cmpl %ecx, %eax
jbe 0x3df2
movq 0x5c0e7(%rip), %rdi     # 0x5fea0
movl $0xc, %esi
callq *0x30(%rdi)
testb $0x2, 0x48(%rbx)
jne 0x3e4d
movq 0x5c0ce(%rip), %rdi     # 0x5fea0
movl $0x4, %esi
xorl %edx, %edx
callq 0x4fea
movb 0x48(%rbx), %al
testb $0x2, %al
jne 0x3e4d
orb $0x1, %al
movb %al, 0x48(%rbx)
callq 0x883e
movl %eax, 0x44(%rbx)
testb $0x2, 0x38(%rbx)
jne 0x3e58
testb $0x1, 0x48(%rbx)
je 0x3e58
movl 0x44(%rbx), %edi
callq 0x8855
movq 0x5c08b(%rip), %rdx     # 0x5fe98
movzwl 0x2c(%rdx), %ecx
cmpl %ecx, %eax
jbe 0x3e58
movq 0x5c084(%rip), %rdi     # 0x5fea0
movl $0xd, %esi
callq *0x30(%rdi)
testb $0x2, 0x48(%rbx)
jne 0x3e4d
movq 0x5c06f(%rip), %rdi     # 0x5fea0
movl $0x5, %esi
xorl %edx, %edx
callq 0x4fea
testb $0x2, 0x48(%rbx)
jne 0x3e4d
callq 0x883e
movl %eax, 0x44(%rbx)
jmp 0x3e58
movq $0x0, 0x5c048(%rip) # 0x5fea0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq