// File: tkaczenko[P]asteroids-clone/src/App.cpp
// Function: App::inputs()
void App::inputs()
{
    while (SDL_PollEvent(&event)) {
        if (event.type == SDL_QUIT) {
            this->exit();
        } else if (event.type == SDL_WINDOWEVENT) {
            if (event.window.event == SDL_WINDOWEVENT_FOCUS_LOST) {
                SDL_Event focus;
                focus.type = SDL_WINDOWEVENT;
                focus.window.event = SDL_WINDOWEVENT_FOCUS_GAINED;
                SDL_WaitEvent(&focus);
            }
        }
        if (event.type == SDL_KEYDOWN) {
            if (event.key.keysym.scancode == SDL_SCANCODE_UP ||
                event.key.keysym.scancode == SDL_SCANCODE_W) {
                game.actionShip(GameEngine::UP, true);
            }
            if (event.key.keysym.scancode == SDL_SCANCODE_LEFT ||
                event.key.keysym.scancode == SDL_SCANCODE_A) {
                game.actionShip(GameEngine::LEFT, true);
            } else if (event.key.keysym.scancode == SDL_SCANCODE_RIGHT ||
                        event.key.keysym.scancode == SDL_SCANCODE_D) {
                game.actionShip(GameEngine::RIGHT, true);
            }
            if (event.key.keysym.scancode == SDL_SCANCODE_SPACE) {
                game.actionShip(GameEngine::FIRE, true);
            }
        }
        if (event.type == SDL_KEYUP) {
            if (event.key.keysym.scancode == SDL_SCANCODE_UP ||
                event.key.keysym.scancode == SDL_SCANCODE_W) {
                game.actionShip(GameEngine::UP, false);
            }
            if (event.key.keysym.scancode == SDL_SCANCODE_LEFT ||
                event.key.keysym.scancode == SDL_SCANCODE_RIGHT ||
                event.key.keysym.scancode == SDL_SCANCODE_A ||
                event.key.keysym.scancode == SDL_SCANCODE_D) {
                game.actionShip(GameEngine::LEFT, false);
            }
            if (event.key.keysym.scancode == SDL_SCANCODE_R) {
                game.actionShip(GameEngine::ALIVE, false);
            }
            if (event.key.keysym.scancode == SDL_SCANCODE_SPACE) {
                game.actionShip(GameEngine::FIRE, false);
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
addq $0xe0, %rdi
callq 0x3190
cmpl $0x0, %eax
je 0x3dc4
movq -0x68(%rbp), %rax
cmpl $0x100, 0xe0(%rax)      # imm = 0x100
jne 0x3bb8
movq -0x68(%rbp), %rdi
callq 0x3f20
jmp 0x3bf0
movq -0x68(%rbp), %rax
cmpl $0x200, 0xe0(%rax)      # imm = 0x200
jne 0x3bee
movq -0x68(%rbp), %rax
movzbl 0xec(%rax), %eax
cmpl $0xd, %eax
jne 0x3bec
movl $0x200, -0x40(%rbp)     # imm = 0x200
movb $0xc, -0x34(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3380
jmp 0x3bee
jmp 0x3bf0
movq -0x68(%rbp), %rax
cmpl $0x300, 0xe0(%rax)      # imm = 0x300
jne 0x3cd9
movq -0x68(%rbp), %rax
cmpl $0x52, 0xf0(%rax)
je 0x3c1e
movq -0x68(%rbp), %rax
cmpl $0x1a, 0xf0(%rax)
jne 0x3c3b
movq -0x68(%rbp), %rdi
addq $0x10, %rdi
movl $0x0, -0x44(%rbp)
leaq -0x44(%rbp), %rsi
movl $0x1, %edx
callq 0x4820
movq -0x68(%rbp), %rax
cmpl $0x50, 0xf0(%rax)
je 0x3c55
movq -0x68(%rbp), %rax
cmpl $0x4, 0xf0(%rax)
jne 0x3c74
movq -0x68(%rbp), %rdi
addq $0x10, %rdi
movl $0x1, -0x48(%rbp)
leaq -0x48(%rbp), %rsi
movl $0x1, %edx
callq 0x4820
jmp 0x3cad
movq -0x68(%rbp), %rax
cmpl $0x4f, 0xf0(%rax)
je 0x3c8e
movq -0x68(%rbp), %rax
cmpl $0x7, 0xf0(%rax)
jne 0x3cab
movq -0x68(%rbp), %rdi
addq $0x10, %rdi
movl $0x2, -0x4c(%rbp)
leaq -0x4c(%rbp), %rsi
movl $0x1, %edx
callq 0x4820
jmp 0x3cad
movq -0x68(%rbp), %rax
cmpl $0x2c, 0xf0(%rax)
jne 0x3cd7
movq -0x68(%rbp), %rdi
addq $0x10, %rdi
movl $0x3, -0x50(%rbp)
leaq -0x50(%rbp), %rsi
movl $0x1, %edx
callq 0x4820
jmp 0x3cd9
movq -0x68(%rbp), %rax
cmpl $0x301, 0xe0(%rax)      # imm = 0x301
jne 0x3dbf
movq -0x68(%rbp), %rax
cmpl $0x52, 0xf0(%rax)
je 0x3d07
movq -0x68(%rbp), %rax
cmpl $0x1a, 0xf0(%rax)
jne 0x3d21
movq -0x68(%rbp), %rdi
addq $0x10, %rdi
movl $0x0, -0x54(%rbp)
leaq -0x54(%rbp), %rsi
xorl %edx, %edx
callq 0x4820
movq -0x68(%rbp), %rax
cmpl $0x50, 0xf0(%rax)
je 0x3d55
movq -0x68(%rbp), %rax
cmpl $0x4f, 0xf0(%rax)
je 0x3d55
movq -0x68(%rbp), %rax
cmpl $0x4, 0xf0(%rax)
je 0x3d55
movq -0x68(%rbp), %rax
cmpl $0x7, 0xf0(%rax)
jne 0x3d6f
movq -0x68(%rbp), %rdi
addq $0x10, %rdi
movl $0x1, -0x58(%rbp)
leaq -0x58(%rbp), %rsi
xorl %edx, %edx
callq 0x4820
movq -0x68(%rbp), %rax
cmpl $0x15, 0xf0(%rax)
jne 0x3d96
movq -0x68(%rbp), %rdi
addq $0x10, %rdi
movl $0x4, -0x5c(%rbp)
leaq -0x5c(%rbp), %rsi
xorl %edx, %edx
callq 0x4820
movq -0x68(%rbp), %rax
cmpl $0x2c, 0xf0(%rax)
jne 0x3dbd
movq -0x68(%rbp), %rdi
addq $0x10, %rdi
movl $0x3, -0x60(%rbp)
leaq -0x60(%rbp), %rsi
xorl %edx, %edx
callq 0x4820
jmp 0x3dbf
jmp 0x3b84
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)