// File: /workspace/github_c_makefile_star2_O3/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, 0x5c5bd(%rip)     # 0x5fea0
testb $0x8, 0x48(%rbx)
jne 0x3e4c
movq 0x5c5a4(%rip), %rax     # 0x5fe98
movq 0x18(%rax), %r14
testq %rdi, %rdi
je 0x3911
testb $0x2, 0x38(%rbx)
jne 0x397f
movl $0x10, %esi
callq 0x6a5b
testb %al, %al
jne 0x397f
movq %r14, %rdi
callq 0x4410
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4105
movq %rax, 0x5c575(%rip)     # 0x5fea0
testq %rax, %rax
jne 0x3969
movq %r14, %rdi
callq 0x43f3
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4105
movq %rax, 0x5c556(%rip)     # 0x5fea0
testq %rax, %rax
jne 0x3969
movq %r14, %rdi
callq 0x43c0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4105
movq %rax, 0x5c537(%rip)     # 0x5fea0
cmpq $0x0, 0x28(%rbx)
je 0x397f
movl $0x0, 0x18(%rbx)
movq %rbx, %rdi
callq 0x41a6
movq 0x5c51a(%rip), %rax     # 0x5fea0
movq 0x20(%rbx), %r14
cmpq %r14, %rax
je 0x3a72
movl 0x8(%rbx), %ecx
movl %ecx, 0xc(%rbx)
testq %r14, %r14
je 0x39db
movq 0x5c4f3(%rip), %rdx     # 0x5fe98
movq %r14, %rdi
movl $0xa, %esi
callq *0x30(%r14)
testb $0x2, 0x48(%rbx)
jne 0x3e41
movq %r14, %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x5018
testb $0x2, 0x48(%rbx)
jne 0x3e41
movq 0x5c4c5(%rip), %rax     # 0x5fea0
movq %rax, 0x20(%rbx)
movq %rax, 0x28(%rbx)
testq %rax, %rax
je 0x3a72
callq 0x87b6
movl %eax, 0x40(%rbx)
andb $-0x2, 0x48(%rbx)
andb $-0x4, 0x38(%rbx)
movq $0x0, 0x10(%rbx)
movq 0x5c495(%rip), %rax     # 0x5fea0
testq %rax, %rax
je 0x3a38
xorl %r14d, %r14d
movzwl 0x58(%rax), %ecx
testb $0x20, %cl
cmovneq %rax, %r14
movq %rax, %rdi
callq 0x4ab5
testq %rax, %rax
jne 0x3a13
testq %r14, %r14
je 0x3a38
movq %r14, %rdi
callq 0x5338
movq 0x5c461(%rip), %rdi     # 0x5fea0
movq 0x5c452(%rip), %rdx     # 0x5fe98
movl $0x8, %esi
callq *0x30(%rdi)
testb $0x2, 0x48(%rbx)
jne 0x3e41
movq 0x5c441(%rip), %rdi     # 0x5fea0
xorl %esi, %esi
xorl %edx, %edx
callq 0x5018
testb $0x2, 0x48(%rbx)
jne 0x3e41
movq 0x8(%rbx), %xmm0
movd 0xc(%rbx), %xmm1
psubw %xmm1, %xmm0
movd %xmm0, 0x10(%rbx)
movq 0x18(%rbx), %xmm1
punpcklwd %xmm1, %xmm1    # xmm1 = xmm1[0,0,1,1,2,2,3,3]
psrad $0x10, %xmm1
movdqa %xmm1, %xmm2
pslld $0x2, %xmm2
paddd %xmm1, %xmm2
psrld $0x3, %xmm2
pshuflw $0xe8, %xmm2, %xmm1     # xmm1 = xmm2[0,2,2,3,4,5,6,7]
pxor %xmm2, %xmm2
pcmpgtw %xmm1, %xmm2
pcmpeqd %xmm3, %xmm3
movdqa %xmm1, %xmm4
psubw %xmm3, %xmm4
psubusw 0x3b62a(%rip), %xmm1    # 0x3f0f0
pand %xmm2, %xmm4
pandn %xmm1, %xmm2
por %xmm4, %xmm2
psraw $0x1, %xmm0
paddw %xmm2, %xmm0
movd %xmm0, 0x18(%rbx)
movq 0x5c3b9(%rip), %rdi     # 0x5fea0
testq %rdi, %rdi
je 0x3e4c
movq 0x5c3a1(%rip), %rdx     # 0x5fe98
movl $0x9, %esi
callq *0x30(%rdi)
testb $0x2, 0x48(%rbx)
jne 0x3e41
movq 0x5c390(%rip), %rdi     # 0x5fea0
movl $0x1, %esi
xorl %edx, %edx
callq 0x5018
testb $0x2, 0x48(%rbx)
jne 0x3e41
movq 0x20(%rbx), %r14
movq %r14, %rdi
callq 0x6994
xorb $0x1, %al
testq %r14, %r14
sete %cl
orb %al, %cl
jne 0x3b5a
movq %r14, %rdi
callq 0x4ab5
movq %rax, %r14
movq %rax, %rdi
callq 0x6994
testb %al, %al
je 0x3b5a
testq %r14, %r14
jne 0x3b3e
testq %r14, %r14
je 0x3d78
movq %r14, %rdi
callq 0x6920
testb %al, %al
je 0x3d78
movq %r14, %rdi
callq 0x6947
movl %eax, %r13d
movzwl 0x10(%rbx), %eax
movzwl 0x12(%rbx), %ecx
movzwl 0x14(%rbx), %esi
addw %ax, %si
movw %si, 0x14(%rbx)
movzwl 0x16(%rbx), %edx
addw %cx, %dx
movw %dx, 0x16(%rbx)
movb 0x38(%rbx), %r12b
testb $0x1, %r12b
jne 0x3bf5
testb $0x1, %r13b
je 0x3bc5
movl %esi, %edi
negw %di
cmovsw %si, %di
movq 0x5c2dc(%rip), %rsi     # 0x5fe98
movzbl 0x28(%rsi), %esi
cmpw %si, %di
jae 0x3bec
testb $0x2, %r13b
je 0x3d78
movl %edx, %esi
negw %si
cmovsw %dx, %si
movq 0x5c2b9(%rip), %rdx     # 0x5fe98
movzbl 0x28(%rdx), %edx
cmpw %dx, %si
jb 0x3d78
movl %r12d, %edx
orb $0x1, %dl
movb %dl, 0x38(%rbx)
orw %cx, %ax
je 0x3d78
movq 0x5c293(%rip), %rax     # 0x5fe98
movq 0x18(%rax), %rdi
callq 0x85dd
movl %eax, 0x14(%rsp)
movzwl 0x20(%r14), %r15d
movzwl 0x22(%r14), %eax
movw %ax, 0x12(%rsp)
movq %r14, %rdi
callq 0x4ab5
movq %rax, %rdi
callq 0x566d
movw %ax, 0x10(%rsp)
movq %r14, %rdi
callq 0x4ab5
movq %rax, %rdi
callq 0x5697
movw %ax, 0xe(%rsp)
movq %r14, %rdi
callq 0x4bdd
movl %eax, %ebp
movq %r14, %rdi
callq 0x4c15
cmpb $0x3, %r13b
jne 0x3c89
testb $0x1, %r12b
jne 0x3c71
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 0x4ad8
jmp 0x3cc9
testb $0x1, %r13b
jne 0x3cb0
testb $0x2, %r13b
je 0x3cc9
testb $0x1, %r12b
jne 0x3c9f
addw 0x16(%rbx), %ax
addw 0x12(%rbx), %ax
movswl %ax, %esi
movq %r14, %rdi
callq 0x5519
jmp 0x3cc9
testb $0x1, %r12b
jne 0x3cba
addw 0x14(%rbx), %bp
addw 0x10(%rbx), %bp
movswl %bp, %esi
movq %r14, %rdi
callq 0x54db
cmpw %r15w, 0x20(%r14)
jne 0x3d35
movzwl 0x12(%rsp), %eax
cmpw %ax, 0x22(%r14)
jne 0x3d35
movq %r14, %rdi
callq 0x4ab5
movq %rax, %rdi
callq 0x566d
movl %eax, %ebp
movq %r14, %rdi
callq 0x4ab5
movq %rax, %rdi
callq 0x5697
cmpw 0x10(%rsp), %bp
jne 0x3d78
cmpw 0xe(%rsp), %ax
jne 0x3d78
movq 0x5c185(%rip), %rax     # 0x5fe98
movq 0x18(%rax), %rdi
callq 0x85dd
movq 0x5c175(%rip), %rcx     # 0x5fe98
movq 0x18(%rcx), %rdi
subl 0x14(%rsp), %eax
movzwl %ax, %esi
callq 0x85ea
jmp 0x3d78
orb $0x2, 0x38(%rbx)
testb $0x1, %r12b
jne 0x3d78
movq 0x5c152(%rip), %rdx     # 0x5fe98
movq %r14, %rdi
movl $0xe, %esi
callq *0x30(%r14)
testb $0x2, 0x48(%rbx)
jne 0x3d6d
movq %r14, %rdi
movl $0x8, %esi
xorl %edx, %edx
callq 0x5018
testb $0x2, 0x48(%rbx)
je 0x3d78
movq $0x0, 0x5c128(%rip) # 0x5fea0
movb 0x48(%rbx), %al
testb $0x2, %al
jne 0x3e41
movb 0x38(%rbx), %cl
andb $0x2, %cl
andb $0x1, %al
orb %cl, %al
jne 0x3de6
movl 0x40(%rbx), %edi
callq 0x87cd
movq 0x5c0fa(%rip), %rdx     # 0x5fe98
movzwl 0x2a(%rdx), %ecx
cmpl %ecx, %eax
jbe 0x3de6
movq 0x5c0f3(%rip), %rdi     # 0x5fea0
movl $0xc, %esi
callq *0x30(%rdi)
testb $0x2, 0x48(%rbx)
jne 0x3e41
movq 0x5c0da(%rip), %rdi     # 0x5fea0
movl $0x4, %esi
xorl %edx, %edx
callq 0x5018
movb 0x48(%rbx), %al
testb $0x2, %al
jne 0x3e41
orb $0x1, %al
movb %al, 0x48(%rbx)
callq 0x87b6
movl %eax, 0x44(%rbx)
testb $0x2, 0x38(%rbx)
jne 0x3e4c
testb $0x1, 0x48(%rbx)
je 0x3e4c
movl 0x44(%rbx), %edi
callq 0x87cd
movq 0x5c097(%rip), %rdx     # 0x5fe98
movzwl 0x2c(%rdx), %ecx
cmpl %ecx, %eax
jbe 0x3e4c
movq 0x5c090(%rip), %rdi     # 0x5fea0
movl $0xd, %esi
callq *0x30(%rdi)
testb $0x2, 0x48(%rbx)
jne 0x3e41
movq 0x5c07b(%rip), %rdi     # 0x5fea0
movl $0x5, %esi
xorl %edx, %edx
callq 0x5018
testb $0x2, 0x48(%rbx)
jne 0x3e41
callq 0x87b6
movl %eax, 0x44(%rbx)
jmp 0x3e4c
movq $0x0, 0x5c054(%rip) # 0x5fea0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq