// File: /workspace/github_cpp_makefile_star2_O1/fulhax[P]ncpamixer/src/ui/ui.cpp
// Function: Ui::handleInput()
void Ui::handleInput()
{
    set_escdelay(0);

#ifdef KEY_MOUSE
    mouseinterval(0);
#if NCURSES_MOUSE_VERSION > 1
    mousemask(BUTTON1_PRESSED | BUTTON4_PRESSED | BUTTON5_PRESSED, NULL);
#else
    mousemask(BUTTON1_PRESSED, NULL);
#endif
#endif

    int input = wgetch(window);
    std::string event{};

    if (input == ERR) {
        return;
    }

    switch (input) {
#ifdef KEY_MOUSE
        case KEY_MOUSE: {
            MEVENT mevent;
            int ok;

            ok = getmouse(&mevent);
            if (ok != OK) {
                return;
            }
            if (mevent.y == height - 1) {
                if (mevent.bstate & BUTTON1_PRESSED) {
                    int x = 0;
                    for (int i = 0; i < NUM_TABS; i++) {
                        int len = strlen(tabs[i]);
                        if (mevent.x >= x && mevent.x < x + len) {
                            switchTab(i);
                            return;
                        }
                        x += len + 1;
                    }
#if NCURSES_MOUSE_VERSION > 1
                } else if (mevent.bstate & BUTTON4_PRESSED) {
                    switchTab(++tab_index);
                    return;
                } else if (mevent.bstate & BUTTON5_PRESSED) {
                    switchTab(--tab_index);
                    return;
#endif
                }
            } else {
                int button = 0;
                if (mevent.bstate & BUTTON1_PRESSED) {
                    button = 1;
                }
#if NCURSES_MOUSE_VERSION > 1
                else if (mevent.bstate & BUTTON4_PRESSED) {
                    button = 4;
                } else if (mevent.bstate & BUTTON5_PRESSED) {
                    button = 5;
                }
#endif

                current_tab->handleMouse(mevent.x, mevent.y, button);
            }

            return;
        }
#endif
        case KEY_RESIZE:
            getmaxyx(stdscr, height, width);
            wresize(window, height - 1, width);

            mvwin(statusbar, height - 1, 0);
            wresize(statusbar, 1, width);

            return;

        case 27: { // Fix for alt/escape (also f-keys on some terminals)
            input = wgetch(window);

            if (input != -1 && input != 79) {
                std::string key = std::to_string(input);

                event = config.getString(
                            ("keycode.alt." +  key).c_str(),
                            "unbound"
                        );

                break;
            }

            if (input == 79) {
                input = wgetch(window);

                if (input != -1) {
                    std::string key = std::to_string(input);

                    event = config.getString(
                            ("keycode.f." +  key).c_str(),
                            "unbound"
                            );

                    break;
                }
            }

            input = 27;
        }

        default:
            std::string key = std::to_string(input);
            event = config.getString(
                        ("keycode." +  key).c_str(),
                        "unbound"
                    );

            break;
    }

    if (!strcmp("unbound", event.c_str())) {
        return;
    }

    if (!strcmp("quit", event.c_str())) {
        kill();
    } else if (!strcmp("tab_next", event.c_str())) {
        switchTab(++tab_index);
    } else if (!strcmp("tab_prev", event.c_str())) {
        switchTab(--tab_index);
    } else if (!strcmp("tab_playback", event.c_str())) {
        switchTab(TAB_PLAYBACK);
    } else if (!strcmp("tab_recording", event.c_str())) {
        switchTab(TAB_RECORDING);
    } else if (!strcmp("tab_output", event.c_str())) {
        switchTab(TAB_OUTPUT);
    } else if (!strcmp("tab_input", event.c_str())) {
        switchTab(TAB_INPUT);
    } else if (!strcmp("tab_config", event.c_str())) {
        switchTab(TAB_CONFIGURATION);
    } else if (!strcmp("help", event.c_str())) {
        show_help();
    } else {
        current_tab->handleEvents(event.c_str());
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %rbx
xorl %edi, %edi
callq 0x6640
xorl %edi, %edi
callq 0x6950
movl $0x210002, %edi         # imm = 0x210002
xorl %esi, %esi
callq 0x63f0
movq 0x10(%rbx), %rdi
callq 0x6240
movl %eax, %r14d
leaq 0x98(%rsp), %r12
movq %r12, -0x10(%r12)
movq $0x0, -0x8(%r12)
movb $0x0, (%r12)
cmpl $0x198, %eax            # imm = 0x198
jg 0xc9e5
cmpl $-0x1, %r14d
je 0xcdf9
cmpl $0x1b, %r14d
jne 0xca5d
movq 0x10(%rbx), %rdi
callq 0x6240
movl %eax, %r15d
movl $0x1b, %r14d
cmpl $-0x1, %eax
je 0xca5d
cmpl $0x4f, %r15d
jne 0xcb25
movq 0x10(%rbx), %rdi
callq 0x6240
movl %eax, %r15d
cmpl $-0x1, %eax
je 0xca5d
movl %r15d, %ebp
negl %ebp
cmovsl %r15d, %ebp
movl $0x1, %r14d
cmpl $0xa, %ebp
jb 0xcf41
movl $0x4, %r14d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %ebp, %ecx
cmpl $0x63, %ecx
jbe 0xcf38
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xcf3e
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xcf41
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r14d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xc9a3
addl $-0x3, %r14d
jmp 0xcf41
cmpl $0x19a, %r14d           # imm = 0x19A
je 0xcac4
cmpl $0x199, %r14d           # imm = 0x199
jne 0xca5d
leaq 0x8(%rsp), %rdi
callq 0x69c0
testl %eax, %eax
jne 0xcdf9
movl 0x10(%rsp), %edx
movl 0x18(%rsp), %eax
movl 0xc(%rbx), %ecx
decl %ecx
cmpl %ecx, %edx
jne 0xcb92
testb $0x2, %al
jne 0xce2c
movl $0x1, %esi
btl $0x10, %eax
jb 0xca44
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
btl $0x15, %eax
jae 0xcdf9
addl 0x130(%rbx), %esi
movl %esi, 0x130(%rbx)
movq %rbx, %rdi
callq 0xc73a
jmp 0xcdf9
movl %r14d, %ebp
negl %ebp
cmovsl %r14d, %ebp
movl $0x1, %r15d
cmpl $0xa, %ebp
jb 0xcbc7
movl $0x4, %r15d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %ebp, %ecx
cmpl $0x63, %ecx
jbe 0xcb8c
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xcbc4
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xcbc7
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r15d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xca82
addl $-0x3, %r15d
jmp 0xcbc7
movq 0xb4d5(%rip), %rax      # 0x17fa0
movq (%rax), %rax
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0xcae3
movswl 0x4(%rax), %esi
incl %esi
movl %esi, 0xc(%rbx)
testq %rax, %rax
je 0xcaf1
movswl 0x6(%rax), %edx
incl %edx
movl %edx, 0x8(%rbx)
movq 0x10(%rbx), %rdi
decl %esi
callq 0x63a0
movq 0x18(%rbx), %rdi
movl 0xc(%rbx), %esi
decl %esi
xorl %edx, %edx
callq 0x62a0
movq 0x18(%rbx), %rdi
movl 0x8(%rbx), %edx
movl $0x1, %esi
callq 0x63a0
jmp 0xcdf9
movl %r15d, %ebp
negl %ebp
cmovsl %r15d, %ebp
movl $0x1, %r14d
cmpl $0xa, %ebp
jb 0xcea1
movl $0x4, %r14d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %ebp, %ecx
cmpl $0x63, %ecx
jbe 0xce98
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xce9e
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xcea1
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r14d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xcb4a
addl $-0x3, %r14d
jmp 0xcea1
addl $-0x2, %r15d
jmp 0xcbc7
movl $0x1, %ecx
testb $0x2, %al
jne 0xcbaf
movl $0x4, %ecx
btl $0x10, %eax
jb 0xcbaf
shrl $0x15, %eax
andl $0x1, %eax
leal (%rax,%rax,4), %ecx
movq 0x138(%rbx), %rdi
movl 0xc(%rsp), %esi
callq 0xe964
jmp 0xcdf9
decl %r15d
shrl $0x1f, %r14d
leal (%r15,%r14), %esi
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x8(%rsp), %rdi
movl $0x2d, %edx
callq 0x66b0
movl %r14d, %edi
leaq 0x8(%rsp), %r14
addq (%r14), %rdi
movl %r15d, %esi
movl %ebp, %edx
callq 0xac05
leaq 0x5c90(%rip), %rsi      # 0x12893
leaq 0x48(%rsp), %rdi
movq %r14, %rdx
callq 0xd41a
movq 0x48(%rsp), %r14
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x5c5b(%rip), %rsi      # 0x12880
leaq 0x5c5b(%rip), %rdx      # 0x12887
leaq 0x28(%rsp), %rdi
callq 0x73f0
leaq 0xbb63(%rip), %rsi      # 0x187a0
leaq 0x68(%rsp), %rdi
leaq 0x28(%rsp), %rcx
movq %r14, %rdx
callq 0xa47a
leaq 0x88(%rsp), %rdi
leaq 0x68(%rsp), %r14
movq %r14, %rsi
callq 0x6710
movq (%r14), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0xcc7e
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x65c0
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0xcc95
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x65c0
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xccb0
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x65c0
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0xccc7
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x65c0
movq 0x88(%rsp), %r14
leaq 0x5baa(%rip), %rdi      # 0x12880
movq %r14, %rsi
callq 0x67f0
testl %eax, %eax
je 0xcdf9
leaq 0x5baf(%rip), %rdi      # 0x1289c
movq %r14, %rsi
callq 0x67f0
testl %eax, %eax
je 0xcdcb
leaq 0x5b9d(%rip), %rdi      # 0x128a1
movq %r14, %rsi
callq 0x67f0
testl %eax, %eax
je 0xcdd9
leaq 0x5b8f(%rip), %rdi      # 0x128aa
movq %r14, %rsi
callq 0x67f0
testl %eax, %eax
je 0xcde0
leaq 0x5b81(%rip), %rdi      # 0x128b3
movq %r14, %rsi
callq 0x67f0
testl %eax, %eax
je 0xce28
leaq 0x5b77(%rip), %rdi      # 0x128c0
movq %r14, %rsi
callq 0x67f0
testl %eax, %eax
je 0xce84
leaq 0x5b6e(%rip), %rdi      # 0x128ce
movq %r14, %rsi
callq 0x67f0
testl %eax, %eax
je 0xce8e
leaq 0x5b62(%rip), %rdi      # 0x128d9
movq %r14, %rsi
callq 0x67f0
testl %eax, %eax
je 0xcf2e
leaq 0x5b55(%rip), %rdi      # 0x128e3
movq %r14, %rsi
callq 0x67f0
testl %eax, %eax
je 0xcfce
leaq 0x42a9(%rip), %rdi      # 0x1104e
movq %r14, %rsi
callq 0x67f0
testl %eax, %eax
je 0xcfd8
movq 0x138(%rbx), %rdi
leaq 0x8(%rsp), %rsi
movq %r14, (%rsi)
callq 0xe1e4
jmp 0xcdf9
callq 0x66c0
movb $0x0, 0x104(%rbx)
jmp 0xcdf9
movl $0x1, %esi
jmp 0xcde5
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
addl 0x130(%rbx), %esi
movl %esi, 0x130(%rbx)
movq %rbx, %rdi
callq 0xc73a
movq 0x88(%rsp), %rdi
cmpq %r12, %rdi
je 0xce16
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x65c0
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %esi, %esi
jmp 0xcdf1
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x108(%rbx,%r14,8), %rdi
callq 0x62b0
movl 0xc(%rsp), %ecx
cmpl %r15d, %ecx
setge %dl
leal (%r15,%rax), %esi
cmpl %esi, %ecx
setl %bpl
andb %dl, %bpl
cmpb $0x1, %bpl
jne 0xce69
movq %rbx, %rdi
movl %r14d, %esi
callq 0xc73a
jmp 0xce6f
addl %eax, %r15d
incl %r15d
cmpq $0x4, %r14
leaq 0x1(%r14), %r14
sete %al
orb %al, %bpl
je 0xce32
jmp 0xcdf9
movl $0x1, %esi
jmp 0xcdf1
movl $0x2, %esi
jmp 0xcdf1
addl $-0x2, %r14d
jmp 0xcea1
decl %r14d
shrl $0x1f, %r15d
leal (%r14,%r15), %esi
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x8(%rsp), %rdi
movl $0x2d, %edx
callq 0x66b0
movl %r15d, %edi
leaq 0x8(%rsp), %r15
addq (%r15), %rdi
movl %r14d, %esi
movl %ebp, %edx
callq 0xac05
leaq 0x5996(%rip), %rsi      # 0x12873
leaq 0x48(%rsp), %rdi
movq %r15, %rdx
callq 0xd41a
movq 0x48(%rsp), %r14
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x5981(%rip), %rsi      # 0x12880
leaq 0x5981(%rip), %rdx      # 0x12887
leaq 0x28(%rsp), %rdi
callq 0x73f0
leaq 0xb889(%rip), %rsi      # 0x187a0
leaq 0x68(%rsp), %rdi
leaq 0x28(%rsp), %rcx
movq %r14, %rdx
callq 0xa47a
jmp 0xcc4f
movl $0x3, %esi
jmp 0xcdf1
addl $-0x2, %r14d
jmp 0xcf41
decl %r14d
shrl $0x1f, %r15d
leal (%r14,%r15), %esi
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x8(%rsp), %rdi
movl $0x2d, %edx
callq 0x66b0
movl %r15d, %edi
leaq 0x8(%rsp), %r15
addq (%r15), %rdi
movl %r14d, %esi
movl %ebp, %edx
callq 0xac05
leaq 0x590b(%rip), %rsi      # 0x12888
leaq 0x48(%rsp), %rdi
movq %r15, %rdx
callq 0xd41a
movq 0x48(%rsp), %r14
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x58e1(%rip), %rsi      # 0x12880
leaq 0x58e1(%rip), %rdx      # 0x12887
leaq 0x28(%rsp), %rdi
callq 0x73f0
leaq 0xb7e9(%rip), %rsi      # 0x187a0
leaq 0x68(%rsp), %rdi
leaq 0x28(%rsp), %rcx
movq %r14, %rdx
callq 0xa47a
jmp 0xcc4f
movl $0x4, %esi
jmp 0xcdf1
callq 0xd08e
jmp 0xcdf9
jmp 0xd054
jmp 0xd054
jmp 0xcff8
jmp 0xd014
jmp 0xd034
jmp 0xd054
jmp 0xcff8
jmp 0xd014
jmp 0xd034
jmp 0xd054
jmp 0xd054
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0xd017
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x65c0
jmp 0xd017
movq %rax, %rbx
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xd037
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x65c0
jmp 0xd037
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0xd057
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x65c0
jmp 0xd057
jmp 0xd054
jmp 0xd054
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r12, %rdi
je 0xd074
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x65c0
movq %rbx, %rdi
callq 0x6a80