// File: /workspace/github_cpp_makefile_star2_O2/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 %rbx
subq $0xa8, %rsp
movq %rdi, %rbx
xorl %edi, %edi
callq 0x6660
xorl %edi, %edi
callq 0x6970
movl $0x210002, %edi         # imm = 0x210002
xorl %esi, %esi
callq 0x6400
movq 0x10(%rbx), %rdi
callq 0x6230
leaq 0x78(%rsp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
cmpl $-0x1, %eax
je 0xc103
movl %eax, %ebp
cmpl $0x1b, %eax
je 0xbd4e
cmpl $0x19a, %ebp            # imm = 0x19A
je 0xbf66
cmpl $0x199, %ebp            # imm = 0x199
jne 0xbdce
leaq 0x8(%rsp), %rdi
callq 0x69f0
testl %eax, %eax
jne 0xc103
movl 0x10(%rsp), %edx
movl 0x18(%rsp), %eax
movl 0xc(%rbx), %ecx
decl %ecx
cmpl %ecx, %edx
jne 0xc034
testb $0x2, %al
jne 0xc06b
btl $0x10, %eax
jb 0xc0b5
btl $0x15, %eax
jae 0xc103
pushq $-0x1
jmp 0xc0b7
movq 0x10(%rbx), %rdi
callq 0x6230
cmpl $-0x1, %eax
je 0xbdce
cmpl $0x4f, %eax
jne 0xbfd2
movq 0x10(%rbx), %rdi
callq 0x6230
cmpl $-0x1, %eax
je 0xbdce
leaq 0x8(%rsp), %rdi
movl %eax, %esi
callq 0xa255
leaq 0x5b42(%rip), %rsi      # 0x118c8
leaq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0xc533
movq 0x48(%rsp), %r14
leaq 0x5b1f(%rip), %rsi      # 0x118c0
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0xa1f6
leaq 0xca19(%rip), %rsi      # 0x187d0
leaq 0x88(%rsp), %rdi
leaq 0x28(%rsp), %rcx
movq %r14, %rdx
callq 0x9eb6
jmp 0xbe27
leaq 0x8(%rsp), %rdi
movl %ebp, %esi
callq 0xa255
leaq 0x5af2(%rip), %rsi      # 0x118d3
leaq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0xc533
movq 0x48(%rsp), %r14
leaq 0x5ac4(%rip), %rsi      # 0x118c0
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0xa1f6
leaq 0xc9be(%rip), %rsi      # 0x187d0
leaq 0x88(%rsp), %rdi
leaq 0x28(%rsp), %rcx
movq %r14, %rdx
callq 0x9eb6
leaq 0x68(%rsp), %rdi
leaq 0x88(%rsp), %r14
movq %r14, %rsi
callq 0x6720
movq %r14, %rdi
callq 0x62b0
leaq 0x28(%rsp), %rdi
callq 0x62b0
leaq 0x48(%rsp), %rdi
callq 0x62b0
leaq 0x8(%rsp), %rdi
callq 0x62b0
movq 0x68(%rsp), %r14
leaq 0x5a52(%rip), %rdi      # 0x118c0
movq %r14, %rsi
callq 0x6830
testl %eax, %eax
je 0xc103
leaq 0x5a57(%rip), %rdi      # 0x118dc
movq %r14, %rsi
callq 0x6830
testl %eax, %eax
je 0xbf87
leaq 0x5a45(%rip), %rdi      # 0x118e1
movq %r14, %rsi
callq 0x6830
testl %eax, %eax
je 0xc030
leaq 0x5a37(%rip), %rdi      # 0x118ea
movq %r14, %rsi
callq 0x6830
testl %eax, %eax
je 0xc050
leaq 0x5a29(%rip), %rdi      # 0x118f3
movq %r14, %rsi
callq 0x6830
testl %eax, %eax
je 0xc064
leaq 0x5a1f(%rip), %rdi      # 0x11900
movq %r14, %rsi
callq 0x6830
testl %eax, %eax
je 0xc0b1
leaq 0x5a16(%rip), %rdi      # 0x1190e
movq %r14, %rsi
callq 0x6830
testl %eax, %eax
je 0xc0f0
leaq 0x5a0a(%rip), %rdi      # 0x11919
movq %r14, %rsi
callq 0x6830
testl %eax, %eax
je 0xc0f4
leaq 0x59fd(%rip), %rdi      # 0x11923
movq %r14, %rsi
callq 0x6830
testl %eax, %eax
je 0xc0f8
leaq 0x413d(%rip), %rdi      # 0x1007a
movq %r14, %rsi
callq 0x6830
testl %eax, %eax
je 0xc11b
movq 0x138(%rbx), %rdi
leaq 0x8(%rsp), %rsi
movq %r14, (%rsi)
callq 0xd032
jmp 0xc103
movq 0xc023(%rip), %rax      # 0x17f90
movq (%rax), %rax
testq %rax, %rax
je 0xbf98
movswl 0x4(%rax), %esi
leal 0x1(%rsi), %ecx
movl %ecx, 0xc(%rbx)
movswl 0x6(%rax), %edx
incl %edx
jmp 0xbfa2
callq 0x66d0
movb $0x0, 0x104(%rbx)
jmp 0xc103
orl $-0x1, 0xc(%rbx)
pushq $-0x1
popq %rdx
pushq $-0x2
popq %rsi
movl %edx, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x63b0
movq 0x18(%rbx), %rdi
movl 0xc(%rbx), %esi
decl %esi
xorl %edx, %edx
callq 0x6290
movq 0x18(%rbx), %rdi
movl 0x8(%rbx), %edx
pushq $0x1
popq %rsi
callq 0x63b0
jmp 0xc103
leaq 0x8(%rsp), %rdi
movl %eax, %esi
callq 0xa255
leaq 0x58ce(%rip), %rsi      # 0x118b3
leaq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0xc533
movq 0x48(%rsp), %r14
leaq 0x58c0(%rip), %rsi      # 0x118c0
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0xa1f6
leaq 0xc7ba(%rip), %rsi      # 0x187d0
leaq 0x88(%rsp), %rdi
leaq 0x28(%rsp), %rcx
movq %r14, %rdx
callq 0x9eb6
jmp 0xbe27
pushq $0x1
jmp 0xc052
testb $0x2, %al
jne 0xc0ad
btl $0x10, %eax
jb 0xc0ce
shrl $0x15, %eax
andl $0x1, %eax
leal (%rax,%rax,4), %ecx
jmp 0xc0d1
pushq $-0x1
popq %rsi
addl 0x130(%rbx), %esi
movl %esi, 0x130(%rbx)
jmp 0xc0fb
xorl %esi, %esi
jmp 0xc0fb
xorl %r14d, %r14d
movl 0xc(%rsp), %ebp
xorl %r15d, %r15d
cmpq $0x5, %r14
je 0xc103
movq 0x108(%rbx,%r14,8), %rdi
callq 0x62a0
cmpl %r15d, %ebp
setge %cl
leal (%r15,%rax), %edx
cmpl %edx, %ebp
setl %dl
andb %cl, %dl
cmpb $0x1, %dl
je 0xc0e3
addl %eax, %r15d
incl %r15d
incq %r14
jmp 0xc075
pushq $0x1
jmp 0xc0d0
pushq $0x1
jmp 0xc0fa
pushq $0x1
popq %rsi
addl 0x130(%rbx), %esi
movl %esi, 0x130(%rbx)
movq %rbx, %rdi
callq 0xbb2a
jmp 0xc103
pushq $0x4
popq %rcx
movq 0x138(%rbx), %rdi
movl 0xc(%rsp), %esi
callq 0xd6ca
jmp 0xc103
movq %rbx, %rdi
movl %r14d, %esi
callq 0xbb2a
jmp 0xc103
pushq $0x2
jmp 0xc0fa
pushq $0x3
jmp 0xc0fa
pushq $0x4
popq %rsi
movq %rbx, %rdi
callq 0xbb2a
leaq 0x68(%rsp), %rdi
callq 0x62b0
addq $0xa8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0xc190
jmp 0xc103
jmp 0xc169
jmp 0xc169
jmp 0xc169
jmp 0xc13a
jmp 0xc149
jmp 0xc158
jmp 0xc169
jmp 0xc13a
jmp 0xc149
jmp 0xc158
jmp 0xc169
jmp 0xc169
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x62b0
jmp 0xc14c
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x62b0
jmp 0xc15b
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x62b0
jmp 0xc16c
jmp 0xc169
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x62b0
movq %rbx, %rdi
callq 0x6ac0