// File: /workspace/github_c_makefile_star2_O2/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, 0x5a796(%rip)     # 0x5dea0
testb $0x8, 0x48(%rbx)
jne 0x3c32
movq 0x5a77d(%rip), %rax     # 0x5de98
movq 0x18(%rax), %r14
testq %rdi, %rdi
je 0x3736
testb $0x2, 0x38(%rbx)
jne 0x37a1
pushq $0x10
popq %rsi
callq 0x66ab
testb %al, %al
jne 0x37a1
movq %r14, %rdi
callq 0x4190
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3ed7
movq %rax, 0x5a750(%rip)     # 0x5dea0
testq %rax, %rax
jne 0x378e
movq %r14, %rdi
callq 0x4173
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3ed7
movq %rax, 0x5a731(%rip)     # 0x5dea0
testq %rax, %rax
jne 0x378e
movq %r14, %rdi
callq 0x4140
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3ed7
movq %rax, 0x5a712(%rip)     # 0x5dea0
cmpq $0x0, 0x28(%rbx)
je 0x37a1
andl $0x0, 0x18(%rbx)
movq %rbx, %rdi
callq 0x3f6a
movq 0x5a6f8(%rip), %rax     # 0x5dea0
movq 0x20(%rbx), %r14
cmpq %r14, %rax
je 0x3884
movl 0x8(%rbx), %ecx
movl %ecx, 0xc(%rbx)
testq %r14, %r14
je 0x37f9
movq 0x5a6d1(%rip), %rdx     # 0x5de98
pushq $0xa
popq %rsi
movq %r14, %rdi
callq *0x30(%r14)
testb $0x2, 0x48(%rbx)
jne 0x3c2a
pushq $0x2
popq %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x4caf
testb $0x2, 0x48(%rbx)
jne 0x3c2a
movq 0x5a6a7(%rip), %rax     # 0x5dea0
movq %rax, 0x20(%rbx)
movq %rax, 0x28(%rbx)
testq %rax, %rax
je 0x3884
callq 0x801a
movl %eax, 0x40(%rbx)
andb $-0x2, 0x48(%rbx)
andb $-0x4, 0x38(%rbx)
andq $0x0, 0x10(%rbx)
xorl %r14d, %r14d
movq 0x5a67b(%rip), %rax     # 0x5dea0
testq %rax, %rax
je 0x383f
movzwl 0x58(%rax), %ecx
testb $0x20, %cl
cmovneq %rax, %r14
movq %rax, %rdi
callq 0x47bc
jmp 0x3825
testq %r14, %r14
je 0x384c
movq %r14, %rdi
callq 0x4feb
movq 0x5a64d(%rip), %rdi     # 0x5dea0
movq 0x5a63e(%rip), %rdx     # 0x5de98
pushq $0x8
popq %rsi
callq *0x30(%rdi)
testb $0x2, 0x48(%rbx)
jne 0x3c2a
movq 0x5a62f(%rip), %rdi     # 0x5dea0
xorl %esi, %esi
xorl %edx, %edx
callq 0x4caf
testb $0x2, 0x48(%rbx)
jne 0x3c2a
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 0x37788(%rip), %xmm1    # 0x3b060
pand %xmm2, %xmm4
pandn %xmm1, %xmm2
por %xmm4, %xmm2
psraw $0x1, %xmm0
paddw %xmm2, %xmm0
movd %xmm0, 0x18(%rbx)
movq 0x5a5a7(%rip), %rdi     # 0x5dea0
testq %rdi, %rdi
je 0x3c32
movq 0x5a58f(%rip), %rdx     # 0x5de98
pushq $0x9
popq %rsi
callq *0x30(%rdi)
testb $0x2, 0x48(%rbx)
jne 0x3c2a
movq 0x5a580(%rip), %rdi     # 0x5dea0
pushq $0x1
popq %rsi
xorl %edx, %edx
callq 0x4caf
testb $0x2, 0x48(%rbx)
jne 0x3c2a
movq 0x20(%rbx), %r14
movq %r14, %rdi
callq 0x65f2
testb %al, %al
je 0x3956
testq %r14, %r14
je 0x3956
movq %r14, %rdi
callq 0x47bc
movq %rax, %r14
jmp 0x3938
testq %r14, %r14
je 0x3b6d
movq %r14, %rdi
callq 0x657e
testb %al, %al
je 0x3b6d
movq %r14, %rdi
callq 0x65a5
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 0x39f1
testb $0x1, %r13b
je 0x39c1
movl %esi, %edi
negw %di
cmovsw %si, %di
movq 0x5a4e0(%rip), %rsi     # 0x5de98
movzbl 0x28(%rsi), %esi
cmpw %si, %di
jae 0x39e8
testb $0x2, %r13b
je 0x3b6d
movl %edx, %esi
negw %si
cmovsw %dx, %si
movq 0x5a4bd(%rip), %rdx     # 0x5de98
movzbl 0x28(%rdx), %edx
cmpw %dx, %si
jb 0x3b6d
movl %r12d, %edx
orb $0x1, %dl
movb %dl, 0x38(%rbx)
orw %cx, %ax
je 0x3b6d
movq 0x5a497(%rip), %rax     # 0x5de98
movq 0x18(%rax), %rdi
callq 0x7e4a
movl %eax, 0x14(%rsp)
movzwl 0x20(%r14), %r15d
movzwl 0x22(%r14), %eax
movw %ax, 0x12(%rsp)
movq %r14, %rdi
callq 0x47bc
movq %rax, %rdi
callq 0x5308
movw %ax, 0x10(%rsp)
movq %r14, %rdi
callq 0x47bc
movq %rax, %rdi
callq 0x5332
movw %ax, 0xe(%rsp)
movq %r14, %rdi
callq 0x48ca
movl %eax, %ebp
movq %r14, %rdi
callq 0x4902
cmpb $0x3, %r13b
jne 0x3a85
testb $0x1, %r12b
jne 0x3a6d
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 0x47df
jmp 0x3ac5
testb $0x1, %r13b
jne 0x3aac
testb $0x2, %r13b
je 0x3ac5
testb $0x1, %r12b
jne 0x3a9b
addw 0x16(%rbx), %ax
addw 0x12(%rbx), %ax
movswl %ax, %esi
movq %r14, %rdi
callq 0x51d0
jmp 0x3ac5
testb $0x1, %r12b
jne 0x3ab6
addw 0x14(%rbx), %bp
addw 0x10(%rbx), %bp
movswl %bp, %esi
movq %r14, %rdi
callq 0x5192
cmpw %r15w, 0x20(%r14)
jne 0x3b31
movzwl 0x12(%rsp), %eax
cmpw %ax, 0x22(%r14)
jne 0x3b31
movq %r14, %rdi
callq 0x47bc
movq %rax, %rdi
callq 0x5308
movl %eax, %ebp
movq %r14, %rdi
callq 0x47bc
movq %rax, %rdi
callq 0x5332
cmpw 0x10(%rsp), %bp
jne 0x3b6d
cmpw 0xe(%rsp), %ax
jne 0x3b6d
movq 0x5a389(%rip), %rax     # 0x5de98
movq 0x18(%rax), %rdi
callq 0x7e4a
movq 0x5a379(%rip), %rcx     # 0x5de98
movq 0x18(%rcx), %rdi
subl 0x14(%rsp), %eax
movzwl %ax, %esi
callq 0x7e57
jmp 0x3b6d
orb $0x2, 0x38(%rbx)
testb $0x1, %r12b
jne 0x3b6d
movq 0x5a356(%rip), %rdx     # 0x5de98
pushq $0xe
popq %rsi
movq %r14, %rdi
callq *0x30(%r14)
testb $0x2, 0x48(%rbx)
jne 0x3b65
pushq $0x8
popq %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x4caf
testb $0x2, 0x48(%rbx)
je 0x3b6d
andq $0x0, 0x5a333(%rip)     # 0x5dea0
movb 0x48(%rbx), %al
testb $0x2, %al
jne 0x3c2a
movb 0x38(%rbx), %cl
andb $0x2, %cl
andb $0x1, %al
orb %cl, %al
jne 0x3bd3
movl 0x40(%rbx), %edi
callq 0x8031
movq 0x5a305(%rip), %rdx     # 0x5de98
movzwl 0x2a(%rdx), %ecx
cmpl %ecx, %eax
jbe 0x3bd3
movq 0x5a2fe(%rip), %rdi     # 0x5dea0
pushq $0xc
popq %rsi
callq *0x30(%rdi)
testb $0x2, 0x48(%rbx)
jne 0x3c2a
movq 0x5a2eb(%rip), %rdi     # 0x5dea0
pushq $0x4
popq %rsi
xorl %edx, %edx
callq 0x4caf
movb 0x48(%rbx), %al
testb $0x2, %al
jne 0x3c2a
orb $0x1, %al
movb %al, 0x48(%rbx)
callq 0x801a
movl %eax, 0x44(%rbx)
testb $0x2, 0x38(%rbx)
jne 0x3c32
testb $0x1, 0x48(%rbx)
je 0x3c32
movl 0x44(%rbx), %edi
callq 0x8031
movq 0x5a2aa(%rip), %rdx     # 0x5de98
movzwl 0x2c(%rdx), %ecx
cmpl %ecx, %eax
jbe 0x3c32
movq 0x5a2a3(%rip), %rdi     # 0x5dea0
pushq $0xd
popq %rsi
callq *0x30(%rdi)
testb $0x2, 0x48(%rbx)
jne 0x3c2a
movq 0x5a290(%rip), %rdi     # 0x5dea0
pushq $0x5
popq %rsi
xorl %edx, %edx
callq 0x4caf
testb $0x2, 0x48(%rbx)
jne 0x3c2a
callq 0x801a
movl %eax, 0x44(%rbx)
jmp 0x3c32
andq $0x0, 0x5a26e(%rip)     # 0x5dea0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq