// File: /workspace/github_c_makefile_star2_O2/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_kb.c
// Function: lv_kb_create
lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy)
{
    LV_LOG_TRACE("keyboard create started");

    /*Create the ancestor of keyboard*/
    lv_obj_t * new_kb = lv_btnm_create(par, copy);
    LV_ASSERT_MEM(new_kb);
    if(new_kb == NULL) return NULL;

    if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_kb);

    /*Allocate the keyboard type specific extended data*/
    lv_kb_ext_t * ext = lv_obj_allocate_ext_attr(new_kb, sizeof(lv_kb_ext_t));
    LV_ASSERT_MEM(ext);
    if(ext == NULL) return NULL;

    /*Initialize the allocated 'ext' */

    ext->ta         = NULL;
    ext->mode       = LV_KB_MODE_TEXT;
    ext->cursor_mng = 0;

    /*The signal and design functions are not copied so set them here*/
    lv_obj_set_signal_cb(new_kb, lv_kb_signal);

    /*Init the new keyboard keyboard*/
    if(copy == NULL) {
        /* Set a size which fits into the parent.
         * Don't use `par` directly because if the window is created on a page it is moved to the
         * scrollable so the parent has changed */
        lv_obj_set_size(new_kb, lv_obj_get_width_fit(lv_obj_get_parent(new_kb)),
                        lv_obj_get_height_fit(lv_obj_get_parent(new_kb)) / 2);

        lv_obj_align(new_kb, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
        lv_obj_set_event_cb(new_kb, lv_kb_def_event_cb);
        lv_btnm_set_map(new_kb, kb_map_lc);
        lv_btnm_set_ctrl_map(new_kb, kb_ctrl_lc_map);
        lv_obj_set_base_dir(new_kb, LV_BIDI_DIR_LTR);

        /*Set the default styles*/
        lv_theme_t * th = lv_theme_get_current();
        if(th) {
            lv_kb_set_style(new_kb, LV_KB_STYLE_BG, th->style.kb.bg);
            lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_REL, th->style.kb.btn.rel);
            lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_PR, th->style.kb.btn.pr);
            lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_TGL_REL, th->style.kb.btn.tgl_rel);
            lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_TGL_PR, th->style.kb.btn.tgl_pr);
            lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_INA, th->style.kb.btn.ina);
        } else {
            /*Let the button matrix's styles*/
        }
    }
    /*Copy an existing keyboard*/
    else {
        lv_kb_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
        ext->ta                = NULL;
        ext->ta                = copy_ext->ta;
        ext->mode              = copy_ext->mode;
        ext->cursor_mng        = copy_ext->cursor_mng;

        /*Refresh the style with new signal function*/
        lv_obj_refresh_style(new_kb);
    }

    LV_LOG_INFO("keyboard created");

    return new_kb;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
callq 0x1f420
movq %rax, %rbx
movq %rax, %rdi
callq 0x7994
testb %al, %al
je 0xbefa
testq %rbx, %rbx
je 0xbf0b
cmpq $0x0, 0x5247d(%rip)     # 0x5e2e8
jne 0xbe7c
movq %rbx, %rdi
callq 0x66db
movq %rax, 0x5246c(%rip)     # 0x5e2e8
pushq $0x58
popq %rsi
movq %rbx, %rdi
callq 0x6146
movq %rax, %r15
movq %rax, %rdi
callq 0x7994
testb %al, %al
je 0xbf1b
testq %r15, %r15
je 0xbf0b
andq $0x0, 0x48(%r15)
movb $0x0, 0x50(%r15)
andb $-0x2, 0x51(%r15)
leaq 0x17a(%rip), %rsi       # 0xc02f
movq %rbx, %rdi
callq 0x60e6
testq %r14, %r14
je 0xbf2c
movq %r14, %rdi
callq 0x6747
andq $0x0, 0x48(%r15)
movq 0x48(%rax), %rcx
movq %rcx, 0x48(%r15)
movb 0x50(%rax), %cl
movb %cl, 0x50(%r15)
movb 0x51(%rax), %al
andb $0x1, %al
movb 0x51(%r15), %cl
andb $-0x2, %cl
orb %al, %cl
movb %cl, 0x51(%r15)
movq %rbx, %rdi
callq 0x5ae7
jmp 0xbf0d
leaq 0x2f13f(%rip), %rdi     # 0x3b040
movq %rbx, %rsi
callq 0x7b01
jmp 0xbf09
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2f11e(%rip), %rdi     # 0x3b040
movq %r15, %rsi
callq 0x7b01
jmp 0xbf2a
movq %rbx, %rdi
callq 0x47bc
movq %rax, %rdi
callq 0x63d0
movl %eax, %ebp
movq %rbx, %rdi
callq 0x47bc
movq %rax, %rdi
callq 0x6418
cwtd
movw $0x2, %cx
idivw %cx
movswl %ax, %edx
movswl %bp, %esi
movq %rbx, %rdi
callq 0x520e
pushq $0x5
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x5424
leaq 0x160(%rip), %rsi       # 0xc0de
movq %rbx, %rdi
callq 0x5fce
leaq 0x45123(%rip), %rsi     # 0x510b0
movq %rbx, %rdi
callq 0x1fe53
leaq 0x2f3f4(%rip), %rsi     # 0x3b390
movq %rbx, %rdi
callq 0x203e1
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5e3f
callq 0x2be75
testq %rax, %rax
je 0xbf0d
movq %rax, %r14
movq 0x1b8(%rax), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xc425
movq 0x1c0(%r14), %rdx
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xc425
movq 0x1c8(%r14), %rdx
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0xc425
movq 0x1d0(%r14), %rdx
pushq $0x3
popq %rsi
movq %rbx, %rdi
callq 0xc425
movq 0x1d8(%r14), %rdx
pushq $0x4
popq %rsi
movq %rbx, %rdi
callq 0xc425
movq 0x1e0(%r14), %rdx
pushq $0x5
popq %rsi
movq %rbx, %rdi
callq 0xc425
jmp 0xbf0d