// File: tomfunkhouser[P]gaps/apps/confview/confview.cpp
// Function: GLUTSpecial(int, int, int)
void GLUTSpecial(int key, int x, int y)
{
  // Invert y coordinate
  y = GLUTwindow_height - y;

  // Process keyboard button event 
  switch (key) {
  case GLUT_KEY_F1:
    AlignWithAxes();
    ResetViewer();
    break;

  case GLUT_KEY_LEFT:
  case GLUT_KEY_RIGHT:
    // Select next image
    if (configuration.NImages() > 0) {
      snap_image_index += (key == GLUT_KEY_RIGHT) ? 1 : -1;
      if (snap_image_index < 0) snap_image_index = 0;
      if (snap_image_index >= configuration.NImages()) snap_image_index = configuration.NImages()-1;
      RGBDImage *snap_image = configuration.Image(snap_image_index);
      for (int i = 0; i < configuration.NImages(); i++) {
        RGBDImage *image = configuration.Image(i);
        if (image == snap_image) { if (!image->DepthChannel()) image->ReadChannels(); }
        else { if (image->DepthChannel()) image->ReleaseChannels(); }
      }
    }
    break;
  }

  // Remember mouse position 
  GLUTmouse[0] = x;
  GLUTmouse[1] = y;

  // Remember modifiers 
  GLUTmodifiers = glutGetModifiers();

  // Redraw
  glutPostRedisplay();
}

// Assembly:
subq $0x38, %rsp
movl %edi, 0x34(%rsp)
movl %esi, 0x30(%rsp)
movl %edx, 0x2c(%rsp)
movl 0x20a02a(%rip), %eax    # 0x235ae0
movl 0x2c(%rsp), %ecx
subl %ecx, %eax
movl %eax, 0x2c(%rsp)
movl 0x34(%rsp), %eax
movl %eax, 0xc(%rsp)
subl $0x1, %eax
je 0x2bae8
jmp 0x2bacf
movl 0xc(%rsp), %eax
subl $0x64, %eax
je 0x2baf7
jmp 0x2bada
movl 0xc(%rsp), %eax
subl $0x66, %eax
je 0x2baf7
jmp 0x2bc28
callq 0x2bc60
callq 0x2c010
jmp 0x2bc28
leaq 0x2100e2(%rip), %rdi    # 0x23bbe0
callq 0x2ea00
cmpl $0x0, %eax
jle 0x2bc26
movl 0x34(%rsp), %edx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl $0x1, %ecx
cmpl $0x66, %edx
cmovel %ecx, %eax
addl 0x209fc6(%rip), %eax    # 0x235aec
movl %eax, 0x209fc0(%rip)    # 0x235aec
cmpl $0x0, 0x209fb9(%rip)    # 0x235aec
jge 0x2bb3f
movl $0x0, 0x209fad(%rip)    # 0x235aec
movl 0x209fa7(%rip), %eax    # 0x235aec
movl %eax, 0x8(%rsp)
leaq 0x210090(%rip), %rdi    # 0x23bbe0
callq 0x2ea00
movl %eax, %ecx
movl 0x8(%rsp), %eax
cmpl %ecx, %eax
jl 0x2bb74
leaq 0x21007a(%rip), %rdi    # 0x23bbe0
callq 0x2ea00
subl $0x1, %eax
movl %eax, 0x209f78(%rip)    # 0x235aec
movl 0x209f72(%rip), %esi    # 0x235aec
leaq 0x21005f(%rip), %rdi    # 0x23bbe0
callq 0x2ea20
movq %rax, 0x20(%rsp)
movl $0x0, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
movl %eax, 0x4(%rsp)
leaq 0x21003e(%rip), %rdi    # 0x23bbe0
callq 0x2ea00
movl %eax, %ecx
movl 0x4(%rsp), %eax
cmpl %ecx, %eax
jge 0x2bc24
movl 0x1c(%rsp), %esi
leaq 0x210024(%rip), %rdi    # 0x23bbe0
callq 0x2ea20
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
cmpq 0x20(%rsp), %rax
jne 0x2bbf2
movq 0x10(%rsp), %rdi
callq 0x2ea50
cmpq $0x0, %rax
jne 0x2bbf0
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
callq *0xf8(%rax)
jmp 0x2bc12
movq 0x10(%rsp), %rdi
callq 0x2ea50
cmpq $0x0, %rax
je 0x2bc10
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
callq *0x148(%rax)
jmp 0x2bc12
jmp 0x2bc14
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x2bb93
jmp 0x2bc26
jmp 0x2bc28
movl 0x30(%rsp), %eax
movl %eax, 0x2101a2(%rip)    # 0x23bdd4
movl 0x2c(%rsp), %eax
movl %eax, 0x21019c(%rip)    # 0x23bdd8
callq 0x1bad10
movl %eax, 0x210199(%rip)    # 0x23bde0
callq 0x1b2ae0
addq $0x38, %rsp
retq
nopw %cs:(%rax,%rax)