// File: mikeakohn[P]cloudtari/build/../src/TelevisionSDL.cxx
// Function: TelevisionSDL::handle_events()
int TelevisionSDL::handle_events()
{
  SDL_Event event;

  if (SDL_PollEvent(&event))
  {
    switch(event.type)
    {
      case SDL_KEYDOWN:
        if (event.key.keysym.sym == SDLK_ESCAPE) { return KEY_QUIT; }
        if (event.key.keysym.sym == SDLK_TAB) { return KEY_SELECT_DOWN; }
        if (event.key.keysym.sym == SDLK_RETURN) { return KEY_RESET_DOWN; }
        if (event.key.keysym.sym == SDLK_LEFT) { return KEY_LEFT_DOWN; }
        if (event.key.keysym.sym == SDLK_RIGHT) { return KEY_RIGHT_DOWN; }
        if (event.key.keysym.sym == SDLK_UP) { return KEY_UP_DOWN; }
        if (event.key.keysym.sym == SDLK_DOWN) { return KEY_DOWN_DOWN; }
        if (event.key.keysym.sym == SDLK_SPACE) { return KEY_FIRE_DOWN; }
        break;

      case SDL_KEYUP:
        if (event.key.keysym.sym == SDLK_TAB) { return KEY_SELECT_UP; }
        if (event.key.keysym.sym == SDLK_RETURN) { return KEY_RESET_UP; }
        if (event.key.keysym.sym == SDLK_LEFT) { return KEY_LEFT_UP; }
        if (event.key.keysym.sym == SDLK_RIGHT) { return KEY_RIGHT_UP; }
        if (event.key.keysym.sym == SDLK_UP) { return KEY_UP_UP; }
        if (event.key.keysym.sym == SDLK_DOWN) { return KEY_DOWN_UP; }
        if (event.key.keysym.sym == SDLK_SPACE) { return KEY_FIRE_UP; }
        break;

        break;
      case SDL_QUIT:
        return KEY_QUIT;
    }
  }

#if 0
  const Uint8 *keystate = SDL_GetKeyboardState(NULL);

  //if (keystate[SDLK_ESCAPE])
  if (keystate[SDL_SCANCODE_ESCAPE])
  {
    return -1;
  }
#endif

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x41a0
cmpl $0x0, %eax
je 0xed43
movl -0x48(%rbp), %eax
movl %eax, -0x4c(%rbp)
subl $0x100, %eax            # imm = 0x100
je 0xed38
jmp 0xec01
movl -0x4c(%rbp), %eax
subl $0x300, %eax            # imm = 0x300
je 0xec20
jmp 0xec0d
movl -0x4c(%rbp), %eax
subl $0x301, %eax            # imm = 0x301
je 0xecc1
jmp 0xed41
cmpl $0x1b, -0x34(%rbp)
jne 0xec32
movl $0x1, -0x4(%rbp)
jmp 0xed4a
cmpl $0x9, -0x34(%rbp)
jne 0xec44
movl $0x2, -0x4(%rbp)
jmp 0xed4a
cmpl $0xd, -0x34(%rbp)
jne 0xec56
movl $0x4, -0x4(%rbp)
jmp 0xed4a
cmpl $0x40000050, -0x34(%rbp) # imm = 0x40000050
jne 0xec6b
movl $0x6, -0x4(%rbp)
jmp 0xed4a
cmpl $0x4000004f, -0x34(%rbp) # imm = 0x4000004F
jne 0xec80
movl $0x8, -0x4(%rbp)
jmp 0xed4a
cmpl $0x40000052, -0x34(%rbp) # imm = 0x40000052
jne 0xec95
movl $0xa, -0x4(%rbp)
jmp 0xed4a
cmpl $0x40000051, -0x34(%rbp) # imm = 0x40000051
jne 0xecaa
movl $0xc, -0x4(%rbp)
jmp 0xed4a
cmpl $0x20, -0x34(%rbp)
jne 0xecbc
movl $0xe, -0x4(%rbp)
jmp 0xed4a
jmp 0xed41
cmpl $0x9, -0x34(%rbp)
jne 0xecd0
movl $0x3, -0x4(%rbp)
jmp 0xed4a
cmpl $0xd, -0x34(%rbp)
jne 0xecdf
movl $0x5, -0x4(%rbp)
jmp 0xed4a
cmpl $0x40000050, -0x34(%rbp) # imm = 0x40000050
jne 0xecf1
movl $0x7, -0x4(%rbp)
jmp 0xed4a
cmpl $0x4000004f, -0x34(%rbp) # imm = 0x4000004F
jne 0xed03
movl $0x9, -0x4(%rbp)
jmp 0xed4a
cmpl $0x40000052, -0x34(%rbp) # imm = 0x40000052
jne 0xed15
movl $0xb, -0x4(%rbp)
jmp 0xed4a
cmpl $0x40000051, -0x34(%rbp) # imm = 0x40000051
jne 0xed27
movl $0xd, -0x4(%rbp)
jmp 0xed4a
cmpl $0x20, -0x34(%rbp)
jne 0xed36
movl $0xf, -0x4(%rbp)
jmp 0xed4a
jmp 0xed41
movl $0x1, -0x4(%rbp)
jmp 0xed4a
jmp 0xed43
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)