// File: /workspace/github_cpp_makefile_star2_O3/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 0xc975
cmpl $-0x1, %r14d
je 0xcd8c
cmpl $0x1b, %r14d
jne 0xc9ed
movq 0x10(%rbx), %rdi
callq 0x6240
movl %eax, %r15d
cmpl $-0x1, %eax
je 0xc9ed
cmpl $0x4f, %r15d
jne 0xcab8
movq 0x10(%rbx), %rdi
callq 0x6240
movl %eax, %r15d
cmpl $-0x1, %eax
je 0xc9ed
movl %r15d, %ebp
negl %ebp
cmovsl %r15d, %ebp
movl $0x1, %r14d
cmpl $0xa, %ebp
jb 0xcec7
movl $0x4, %r14d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %ebp, %ecx
cmpl $0x63, %ecx
jbe 0xcebe
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xcec4
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xcec7
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r14d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xc933
addl $-0x3, %r14d
jmp 0xcec7
cmpl $0x19a, %r14d           # imm = 0x19A
je 0xca54
cmpl $0x199, %r14d           # imm = 0x199
jne 0xc9ed
leaq 0x8(%rsp), %rdi
callq 0x69c0
testl %eax, %eax
jne 0xcd8c
movl 0x10(%rsp), %edx
movl 0x18(%rsp), %eax
movl 0xc(%rbx), %ecx
decl %ecx
cmpl %ecx, %edx
jne 0xcb25
testb $0x2, %al
jne 0xcdbf
movl $0x1, %esi
btl $0x10, %eax
jb 0xc9d4
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
btl $0x15, %eax
jae 0xcd8c
addl 0x130(%rbx), %esi
movl %esi, 0x130(%rbx)
movq %rbx, %rdi
callq 0xc6e2
jmp 0xcd8c
movl %r14d, %ebp
negl %ebp
cmovsl %r14d, %ebp
movl $0x1, %r15d
cmpl $0xa, %ebp
jb 0xcb5a
movl $0x4, %r15d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %ebp, %ecx
cmpl $0x63, %ecx
jbe 0xcb1f
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xcb57
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xcb5a
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r15d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xca12
addl $-0x3, %r15d
jmp 0xcb5a
movq 0xb545(%rip), %rax      # 0x17fa0
movq (%rax), %rax
testq %rax, %rax
je 0xca75
movswl 0x4(%rax), %esi
leal 0x1(%rsi), %ecx
movl %ecx, 0xc(%rbx)
movswl 0x6(%rax), %edx
incl %edx
jmp 0xca86
movl $0xffffffff, 0xc(%rbx)  # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
movl %edx, 0x8(%rbx)
movq 0x10(%rbx), %rdi
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 0xcd8c
movl %r15d, %ebp
negl %ebp
cmovsl %r15d, %ebp
movl $0x1, %r14d
cmpl $0xa, %ebp
jb 0xce27
movl $0x4, %r14d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %ebp, %ecx
cmpl $0x63, %ecx
jbe 0xce1e
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xce24
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xce27
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r14d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xcadd
addl $-0x3, %r14d
jmp 0xce27
addl $-0x2, %r15d
jmp 0xcb5a
movl $0x1, %ecx
testb $0x2, %al
jne 0xcb42
movl $0x4, %ecx
btl $0x10, %eax
jb 0xcb42
shrl $0x15, %eax
andl $0x1, %eax
leal (%rax,%rax,4), %ecx
movq 0x138(%rbx), %rdi
movl 0xc(%rsp), %esi
callq 0xe8a4
jmp 0xcd8c
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 0xaba1
leaq 0x5cfd(%rip), %rsi      # 0x12893
leaq 0x48(%rsp), %rdi
movq %r14, %rdx
callq 0xd392
movq 0x48(%rsp), %r14
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x5cc8(%rip), %rsi      # 0x12880
leaq 0x5cc8(%rip), %rdx      # 0x12887
leaq 0x28(%rsp), %rdi
callq 0x73f0
leaq 0xbbd0(%rip), %rsi      # 0x187a0
leaq 0x68(%rsp), %rdi
leaq 0x28(%rsp), %rcx
movq %r14, %rdx
callq 0xa416
leaq 0x88(%rsp), %rdi
leaq 0x68(%rsp), %r14
movq %r14, %rsi
callq 0x6710
movq (%r14), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0xcc11
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x65c0
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0xcc28
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x65c0
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xcc43
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x65c0
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0xcc5a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x65c0
movq 0x88(%rsp), %r14
leaq 0x5c17(%rip), %rdi      # 0x12880
movq %r14, %rsi
callq 0x67f0
testl %eax, %eax
je 0xcd8c
leaq 0x5c1c(%rip), %rdi      # 0x1289c
movq %r14, %rsi
callq 0x67f0
testl %eax, %eax
je 0xcd5e
leaq 0x5c0a(%rip), %rdi      # 0x128a1
movq %r14, %rsi
callq 0x67f0
testl %eax, %eax
je 0xcd6c
leaq 0x5bfc(%rip), %rdi      # 0x128aa
movq %r14, %rsi
callq 0x67f0
testl %eax, %eax
je 0xcd73
leaq 0x5bee(%rip), %rdi      # 0x128b3
movq %r14, %rsi
callq 0x67f0
testl %eax, %eax
je 0xcdbb
leaq 0x5be4(%rip), %rdi      # 0x128c0
movq %r14, %rsi
callq 0x67f0
testl %eax, %eax
je 0xcdfd
leaq 0x5bdb(%rip), %rdi      # 0x128ce
movq %r14, %rsi
callq 0x67f0
testl %eax, %eax
je 0xce14
leaq 0x5bcf(%rip), %rdi      # 0x128d9
movq %r14, %rsi
callq 0x67f0
testl %eax, %eax
je 0xceb4
leaq 0x5bc2(%rip), %rdi      # 0x128e3
movq %r14, %rsi
callq 0x67f0
testl %eax, %eax
je 0xcf54
leaq 0x4316(%rip), %rdi      # 0x1104e
movq %r14, %rsi
callq 0x67f0
testl %eax, %eax
je 0xcf5e
movq 0x138(%rbx), %rdi
leaq 0x8(%rsp), %rsi
movq %r14, (%rsi)
callq 0xe130
jmp 0xcd8c
callq 0x66c0
movb $0x0, 0x104(%rbx)
jmp 0xcd8c
movl $0x1, %esi
jmp 0xcd78
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
addl 0x130(%rbx), %esi
movl %esi, 0x130(%rbx)
movq %rbx, %rdi
callq 0xc6e2
movq 0x88(%rsp), %rdi
cmpq %r12, %rdi
je 0xcda9
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 0xcd84
xorl %r14d, %r14d
movl 0xc(%rsp), %ebp
xorl %r15d, %r15d
movq 0x108(%rbx,%r14,8), %rdi
callq 0x62b0
cmpl %r15d, %ebp
setge %cl
leal (%r15,%rax), %edx
cmpl %edx, %ebp
setl %dl
andb %cl, %dl
cmpb $0x1, %dl
je 0xce04
addl %eax, %r15d
incl %r15d
incq %r14
cmpq $0x5, %r14
jne 0xcdc9
jmp 0xcd8c
movl $0x1, %esi
jmp 0xcd84
movq %rbx, %rdi
movl %r14d, %esi
callq 0xc6e2
jmp 0xcd8c
movl $0x2, %esi
jmp 0xcd84
addl $-0x2, %r14d
jmp 0xce27
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 0xaba1
leaq 0x5a10(%rip), %rsi      # 0x12873
leaq 0x48(%rsp), %rdi
movq %r15, %rdx
callq 0xd392
movq 0x48(%rsp), %r14
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x59fb(%rip), %rsi      # 0x12880
leaq 0x59fb(%rip), %rdx      # 0x12887
leaq 0x28(%rsp), %rdi
callq 0x73f0
leaq 0xb903(%rip), %rsi      # 0x187a0
leaq 0x68(%rsp), %rdi
leaq 0x28(%rsp), %rcx
movq %r14, %rdx
callq 0xa416
jmp 0xcbe2
movl $0x3, %esi
jmp 0xcd84
addl $-0x2, %r14d
jmp 0xcec7
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 0xaba1
leaq 0x5985(%rip), %rsi      # 0x12888
leaq 0x48(%rsp), %rdi
movq %r15, %rdx
callq 0xd392
movq 0x48(%rsp), %r14
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x595b(%rip), %rsi      # 0x12880
leaq 0x595b(%rip), %rdx      # 0x12887
leaq 0x28(%rsp), %rdi
callq 0x73f0
leaq 0xb863(%rip), %rsi      # 0x187a0
leaq 0x68(%rsp), %rdi
leaq 0x28(%rsp), %rcx
movq %r14, %rdx
callq 0xa416
jmp 0xcbe2
movl $0x4, %esi
jmp 0xcd84
callq 0xd014
jmp 0xcd8c
jmp 0xcfda
jmp 0xcfda
jmp 0xcfda
jmp 0xcf80
jmp 0xcf9c
jmp 0xcfbc
jmp 0xcfda
jmp 0xcf80
jmp 0xcf9c
jmp 0xcfbc
jmp 0xcfda
jmp 0xcfda
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0xcf9f
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x65c0
jmp 0xcf9f
movq %rax, %rbx
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xcfbf
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x65c0
jmp 0xcfbf
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0xcfdd
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x65c0
jmp 0xcfdd
jmp 0xcfda
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r12, %rdi
je 0xcffa
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x65c0
movq %rbx, %rdi
callq 0x6a80