# data file for the Fltk User Interface Designer (fluid)
version 1.0109 
do_not_include_H_from_C 
header_name {.hpp} 
code_name {.cpp}
decl {\#include "gui.hpp"} {selected private local
} 

decl {\#ifdef WIN32} {private local
} 

decl {\#define WIN32_LEAN_AND_MEAN 1} {private local
} 

decl {\#include <windows.h>} {private local
} 

decl {\#endif} {private local
} 

decl {\#include <cmath>} {private local
} 

class Ep128EmuGUI_KbdDefineWindow {open : {public Fl_Double_Window}
} {
  decl {int keyCode_;} {public local
  }
  Function {Ep128EmuGUI_KbdDefineWindow(int xx, int yy, int ww, int hh, const char *lbl_ = (char *) 0) : Fl_Double_Window(xx, yy, ww, hh, lbl_)} {open
  } {
    code {{
  keyCode_ = -1;
}} {}
  }
  Function {Ep128EmuGUI_KbdDefineWindow(int ww, int hh, const char *lbl_ = (char *) 0) : Fl_Double_Window(ww, hh, lbl_)} {open
  } {
    code {{
  keyCode_ = -1;
}} {}
  }
  Function {~Ep128EmuGUI_KbdDefineWindow()} {open return_type virtual
  } {
    code {{
}} {}
  }
  Function {handle(int evt_)} {open return_type {virtual int}
  } {
    code {{
  switch (evt_) {
  case FL_FOCUS:
  case FL_UNFOCUS:
    return 1;
  case FL_KEYUP:
    return 1;
  case FL_KEYDOWN:
    keyCode_ = Fl::event_key();
\#ifdef WIN32
    if (keyCode_ == FL_Shift_L || keyCode_ == FL_Shift_R) {
      // work around FLTK bug
      if (GetKeyState(VK_RSHIFT) < 0)
        keyCode_ = FL_Shift_R;
      else
        keyCode_ = FL_Shift_L;
    }
\#endif
    return 1;
  }
  return 0;
}} {}
  }
} 

class Ep128EmuGUI_KbdConfigWindow {open
} {
  decl {Ep128EmuGUI& gui;} {private local
  }
  Function {Ep128EmuGUI_KbdConfigWindow(Ep128EmuGUI& gui_) : gui(gui_)} {open
  } {
    Fl_Window window {
      label {Configure keyboard map}
      callback {{
  try {
    gui.applyEmulatorConfiguration();
  }
  catch (std::exception& e) {
    gui.errorMessage(e.what());
  }
  window->hide();
}} open
      xywh {135 144 570 390} type Double color 48 visible
    } {
      Fl_Group {} {open
        xywh {10 10 550 195} box THIN_UP_BOX
      } {
        Fl_Button {} {
          label F1
          callback {{
  defineKey(0x27, "F1");
}}
          xywh {45 20 45 25} color 216 selection_color 176 labelfont 4 labelcolor 55 align 20
        }
        Fl_Button {} {
          label F2
          callback {{
  defineKey(0x26, "F2");
}}
          xywh {95 20 45 25} color 216 selection_color 176 labelfont 4 labelcolor 55 align 20
        }
        Fl_Button {} {
          label F3
          callback {{
  defineKey(0x22, "F3");
}}
          xywh {145 20 45 25} color 216 selection_color 176 labelfont 4 labelcolor 55 align 20
        }
        Fl_Button {} {
          label F4
          callback {{
  defineKey(0x20, "F4");
}}
          xywh {195 20 45 25} color 216 selection_color 176 labelfont 4 labelcolor 55 align 20
        }
        Fl_Button {} {
          label F5
          callback {{
  defineKey(0x24, "F5");
}}
          xywh {245 20 45 25} color 216 selection_color 176 labelfont 4 labelcolor 55 align 20
        }
        Fl_Button {} {
          label F6
          callback {{
  defineKey(0x23, "F6");
}}
          xywh {295 20 45 25} color 216 selection_color 176 labelfont 4 labelcolor 55 align 20
        }
        Fl_Button {} {
          label F7
          callback {{
  defineKey(0x25, "F7");
}}
          xywh {345 20 45 25} color 216 selection_color 176 labelfont 4 labelcolor 55 align 20
        }
        Fl_Button {} {
          label F8
          callback {{
  defineKey(0x21, "F8");
}}
          xywh {395 20 45 25} color 216 selection_color 176 labelfont 4 labelcolor 55 align 20
        }
        Fl_Button {} {
          label Pau
          callback {{
  defineKey(0x3C, "Pause");
}}
          xywh {465 20 25 25} color 61 selection_color 60 labelsize 11 labelcolor 55 align 20
        }
        Fl_Button {} {
          label Stop
          callback {{
  defineKey(0x38, "Stop");
}}
          xywh {495 20 40 25} color 88 selection_color 80 labelfont 4 labelsize 11 labelcolor 55 align 20
        }
        Fl_Button {} {
          label Esc
          callback {{
  defineKey(0x1F, "Esc");
}}
          xywh {30 50 25 25} color 61 selection_color 60 labelsize 11 labelcolor 55 align 20
        }
        Fl_Button {} {
          label 1
          callback {{
  defineKey(0x19, "1");
}}
          xywh {60 50 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label 2
          callback {{
  defineKey(0x1E, "2");
}}
          xywh {90 50 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label 3
          callback {{
  defineKey(0x1D, "3");
}}
          xywh {120 50 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label 4
          callback {{
  defineKey(0x1B, "4");
}}
          xywh {150 50 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label 5
          callback {{
  defineKey(0x1C, "5");
}}
          xywh {180 50 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label 6
          callback {{
  defineKey(0x1A, "6");
}}
          xywh {210 50 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label 7
          callback {{
  defineKey(0x18, "7");
}}
          xywh {240 50 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label 8
          callback {{
  defineKey(0x28, "8");
}}
          xywh {270 50 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label 9
          callback {{
  defineKey(0x2A, "9");
}}
          xywh {300 50 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label 0
          callback {{
  defineKey(0x2C, "0");
}}
          xywh {330 50 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label {-}
          callback {{
  defineKey(0x2B, "-");
}}
          xywh {360 50 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label {^}
          callback {{
  defineKey(0x2D, "^");
}}
          xywh {390 50 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label Erase
          callback {{
  defineKey(0x2E, "Erase");
}}
          xywh {420 50 40 25} color 61 selection_color 60 labelfont 4 labelsize 11 labelcolor 55 align 20
        }
        Fl_Button {} {
          label Del
          callback {{
  defineKey(0x41, "Del");
}}
          xywh {465 50 40 25} color 61 selection_color 60 labelfont 4 labelsize 11 labelcolor 55 align 20
        }
        Fl_Button {} {
          label Ins
          callback {{
  defineKey(0x47, "Ins");
}}
          xywh {510 50 25 25} color 61 selection_color 60 labelsize 11 labelcolor 55 align 20
        }
        Fl_Button {} {
          label Tab
          callback {{
  defineKey(0x17, "Tab");
}}
          xywh {30 80 40 25} color 61 selection_color 60 labelfont 4 labelsize 11 labelcolor 55 align 20
        }
        Fl_Button {} {
          label Q
          callback {{
  defineKey(0x11, "Q");
}}
          xywh {75 80 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label W
          callback {{
  defineKey(0x16, "W");
}}
          xywh {105 80 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label E
          callback {{
  defineKey(0x15, "E");
}}
          xywh {135 80 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label R
          callback {{
  defineKey(0x13, "R");
}}
          xywh {165 80 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label T
          callback {{
  defineKey(0x14, "T");
}}
          xywh {195 80 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label Y
          callback {{
  defineKey(0x12, "Y");
}}
          xywh {225 80 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label U
          callback {{
  defineKey(0x10, "U");
}}
          xywh {255 80 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label I
          callback {{
  defineKey(0x48, "I");
}}
          xywh {285 80 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label O
          callback {{
  defineKey(0x4A, "O");
}}
          xywh {315 80 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label P
          callback {{
  defineKey(0x4C, "P");
}}
          xywh {345 80 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label {@@}
          callback {{
  defineKey(0x4B, "@@");
}}
          xywh {375 80 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label {[}
          callback {{
  defineKey(0x4D, "[");
}}
          xywh {405 80 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label Ent
          callback {{
  defineKey(0x3E, "Enter");
}}
          xywh {440 80 25 55} color 61 selection_color 60 labelsize 11 labelcolor 55 align 20
        }
        Fl_Button {} {
          label Ctl
          callback {{
  defineKey(0x0F, "Ctrl");
}}
          xywh {20 110 25 25} color 61 selection_color 60 labelsize 11 labelcolor 55 align 20
        }
        Fl_Button {} {
          label Lck
          callback {{
  defineKey(0x09, "Lock");
}}
          xywh {50 110 25 25} color 61 selection_color 60 labelsize 11 labelcolor 55 align 20
        }
        Fl_Button {} {
          label A
          callback {{
  defineKey(0x0E, "A");
}}
          xywh {80 110 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label S
          callback {{
  defineKey(0x0D, "S");
}}
          xywh {110 110 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label D
          callback {{
  defineKey(0x0B, "D");
}}
          xywh {140 110 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label F
          callback {{
  defineKey(0x0C, "F");
}}
          xywh {170 110 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label G
          callback {{
  defineKey(0x0A, "G");
}}
          xywh {200 110 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label H
          callback {{
  defineKey(0x08, "H");
}}
          xywh {230 110 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label J
          callback {{
  defineKey(0x30, "J");
}}
          xywh {260 110 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label K
          callback {{
  defineKey(0x32, "K");
}}
          xywh {290 110 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label L
          callback {{
  defineKey(0x34, "L");
}}
          xywh {320 110 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label {;}
          callback {{
  defineKey(0x33, ";");
}}
          xywh {350 110 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label {:}
          callback {{
  defineKey(0x35, ":");
}}
          xywh {380 110 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label {]}
          callback {{
  defineKey(0x36, "]");
}}
          xywh {410 110 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label Shift
          callback {{
  defineKey(0x07, "Left shift");
}}
          xywh {20 140 40 25} color 61 selection_color 60 labelfont 4 labelsize 11 labelcolor 55 align 20
        }
        Fl_Button {} {
          label {\\}
          callback {{
  defineKey(0x01, "\\\\");
}}
          xywh {65 140 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label Z
          callback {{
  defineKey(0x06, "Z");
}}
          xywh {95 140 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label X
          callback {{
  defineKey(0x05, "X");
}}
          xywh {125 140 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label C
          callback {{
  defineKey(0x03, "C");
}}
          xywh {155 140 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label V
          callback {{
  defineKey(0x04, "V");
}}
          xywh {185 140 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label B
          callback {{
  defineKey(0x02, "B");
}}
          xywh {215 140 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label N
          callback {{
  defineKey(0x00, "N");
}}
          xywh {245 140 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label M
          callback {{
  defineKey(0x40, "M");
}}
          xywh {275 140 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label {,}
          callback {{
  defineKey(0x42, ",");
}}
          xywh {305 140 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label {.}
          callback {{
  defineKey(0x44, ".");
}}
          xywh {335 140 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label {/}
          callback {{
  defineKey(0x43, "/");
}}
          xywh {365 140 25 25} selection_color 48 labelfont 4 align 20
        }
        Fl_Button {} {
          label Shift
          callback {{
  defineKey(0x45, "Right shift");
}}
          xywh {395 140 40 25} color 61 selection_color 60 labelfont 4 labelsize 11 labelcolor 55 align 20
        }
        Fl_Button {} {
          label Alt
          callback {{
  defineKey(0x3F, "Alt");
}}
          xywh {440 140 25 25} color 61 selection_color 60 labelsize 11 labelcolor 55 align 20
        }
        Fl_Button {} {
          label Space
          callback {{
  defineKey(0x46, "Space");
}}
          xywh {135 170 235 25} selection_color 48 labelfont 4 align 16
        }
        Fl_Group {} {open
          xywh {480 100 70 70} box OVAL_FRAME color 56
        } {
          Fl_Box {} {
            xywh {505 125 20 20} box OVAL_FRAME color 56
          }
          Fl_Button {} {
            label {@>}
            callback {{
  defineKey(0x3A, "Right");
}}
            xywh {530 128 15 15} box ROUND_UP_BOX color 50 selection_color 51 labelsize 11
          }
          Fl_Button {} {
            label {@8>}
            callback {{
  defineKey(0x3B, "Up");
}}
            xywh {508 105 15 15} box ROUND_UP_BOX color 50 selection_color 51 labelsize 11
          }
          Fl_Button {} {
            label {@4>}
            callback {{
  defineKey(0x3D, "Left");
}}
            xywh {485 128 15 15} box ROUND_UP_BOX color 50 selection_color 51 labelsize 11
          }
          Fl_Button {} {
            label {@2>}
            callback {{
  defineKey(0x39, "Down");
}}
            xywh {508 150 15 15} box ROUND_UP_BOX color 50 selection_color 51 labelsize 11
          }
        }
        Fl_Dial mouseSensitivityXValuator {
          label {Mouse sensitivity X}
          callback {{
  gui.config.mouse.sensitivityX =
      std::pow(2.0, o->value() / 3.0);
  gui.config.mouseSettingsChanged = true;
}}
          xywh {481 172 25 25} box GTK_ROUND_UP_BOX color 50 selection_color 55 labelsize 10 align 4 minimum -3 maximum 3 step 1
        }
        Fl_Dial mouseSensitivityYValuator {
          label Y
          callback {{
  gui.config.mouse.sensitivityY =
      std::pow(2.0, o->value() / 3.0);
  gui.config.mouseSettingsChanged = true;
}}
          xywh {525 172 25 25} box GTK_ROUND_UP_BOX color 50 selection_color 55 labelsize 10 align 4 minimum -3 maximum 3 step 1
        }
      }
      Fl_Group {} {open
        xywh {10 215 320 130} box THIN_UP_BOX
      } {
        Fl_Light_Button joystickEnableValuator {
          label {Enable joystick}
          callback {{
  gui.config.joystick.enableJoystick = (o->value() != 0);
  gui.config.joystickSettingsChanged = true;
}}
          tooltip {Check to enable use of external joysticks and gamepads} xywh {20 225 115 20} color 50 selection_color 3 labelsize 12
        }
        Fl_Value_Slider joystickThresholdValuator {
          label Threshold
          callback {{
  gui.config.joystick.axisThreshold = o->value();
  gui.config.joystickSettingsChanged = true;
}}
          tooltip {Joystick threshold (controls sensitivity)} xywh {200 225 120 20} type Horizontal color 47 selection_color 52 labelsize 11 align 4 minimum 0.01 maximum 0.99 value 0.5
        }
        Fl_Light_Button joystickEnablePWMValuator {
          label {Enable PWM}
          callback {{
  gui.config.joystick.enablePWM = (o->value() != 0);
  gui.config.joystickSettingsChanged = true;
}}
          tooltip {Emulate analogue joystick by pulse width modulation} xywh {20 255 115 20} color 50 selection_color 3 labelsize 12
        }
        Fl_Value_Slider joystickPWMFrequencyValuator {
          label Frequency
          callback {{
  gui.config.joystick.pwmFrequency = o->value();
  gui.config.joystickSettingsChanged = true;
}}
          tooltip {Pulse width modulation frequency in Hz} xywh {200 255 120 20} type Horizontal color 47 selection_color 52 labelsize 11 align 4 minimum 1 maximum 100 step 0.5 value 17.5
        }
        Fl_Light_Button joystickEnableAutoFireValuator {
          label {Enable auto fire}
          callback {{
  gui.config.joystick.enableAutoFire = (o->value() != 0);
  gui.config.joystickSettingsChanged = true;
}}
          xywh {20 285 115 20} color 50 selection_color 3 labelsize 12
        }
        Fl_Value_Slider joystickAutoFireFreqValuator {
          label Frequency
          callback {{
  gui.config.joystick.autoFireFrequency = o->value();
  gui.config.joystickSettingsChanged = true;
}}
          tooltip {Auto fire frequency in Hz} xywh {200 285 120 20} type Horizontal color 47 selection_color 52 labelsize 11 align 4 minimum 0.5 maximum 50 step 0.5 value 8
        }
        Fl_Value_Slider joystickAutoFirePWValuator {
          label {Pulse width}
          callback {{
  gui.config.joystick.autoFirePulseWidth = o->value();
  gui.config.joystickSettingsChanged = true;
}}
          tooltip {Auto fire pulse width} xywh {200 315 120 20} type Horizontal color 47 selection_color 52 labelsize 11 align 4 minimum 0.01 maximum 0.99 value 0.5
        }
      }
      Fl_Group {} {
        label {Joystick 1} open
        xywh {340 215 105 130} box THIN_UP_BOX align 17
      } {
        Fl_Box {} {
          xywh {345 240 95 95} box OVAL_FRAME color 56
        }
        Fl_Button {} {
          label {@>}
          callback {{
  defineKey(0x70, "Joy 1 right");
}}
          xywh {410 278 20 20} box ROUND_UP_BOX color 50 labelsize 12
        }
        Fl_Button {} {
          label {@8>}
          callback {{
  defineKey(0x73, "Joy 1 up");
}}
          xywh {383 250 20 20} box ROUND_UP_BOX color 50 labelsize 12
        }
        Fl_Button {} {
          label {@4>}
          callback {{
  defineKey(0x71, "Joy 1 left");
}}
          xywh {355 278 20 20} box ROUND_UP_BOX color 50 labelsize 12
        }
        Fl_Button {} {
          label {@2>}
          callback {{
  defineKey(0x72, "Joy 1 down");
}}
          xywh {383 305 20 20} box ROUND_UP_BOX color 50 labelsize 12
        }
        Fl_Button {} {
          label Fire
          callback {{
  defineKey(0x74, "Joy 1 fire");
}}
          xywh {380 275 25 25} box ROUND_UP_BOX color 80 selection_color 88 labelsize 11 labelcolor 55
        }
        Fl_Button {} {
          label F2
          callback {{
  defineKey(0x75, "Joy 1 fire 2");
}}
          xywh {425 320 20 20} box ROUND_UP_BOX color 80 selection_color 88 labelsize 11 labelcolor 55
        }
        Fl_Button {} {
          label F3
          callback {{
  defineKey(0x76, "Joy 1 fire 3");
}}
          xywh {425 235 20 20} box ROUND_UP_BOX color 80 selection_color 88 labelsize 11 labelcolor 55
        }
      }
      Fl_Group {} {
        label {Joystick 2} open
        xywh {455 215 105 130} box THIN_UP_BOX align 17
      } {
        Fl_Box {} {
          xywh {460 240 95 95} box OVAL_FRAME color 56
        }
        Fl_Button {} {
          label {@>}
          callback {{
  defineKey(0x78, "Joy 2 right");
}}
          xywh {525 278 20 20} box ROUND_UP_BOX color 50 labelsize 12
        }
        Fl_Button {} {
          label {@8>}
          callback {{
  defineKey(0x7B, "Joy 2 up");
}}
          xywh {498 250 20 20} box ROUND_UP_BOX color 50 labelsize 12
        }
        Fl_Button {} {
          label {@4>}
          callback {{
  defineKey(0x79, "Joy 2 left");
}}
          xywh {470 278 20 20} box ROUND_UP_BOX color 50 labelsize 12
        }
        Fl_Button {} {
          label {@2>}
          callback {{
  defineKey(0x7A, "Joy 2 down");
}}
          xywh {498 305 20 20} box ROUND_UP_BOX color 50 labelsize 12
        }
        Fl_Button {} {
          label Fire
          callback {{
  defineKey(0x7C, "Joy 2 fire");
}}
          xywh {495 275 25 25} box ROUND_UP_BOX color 80 selection_color 88 labelsize 11 labelcolor 55
        }
        Fl_Button {} {
          label F2
          callback {{
  defineKey(0x7D, "Joy 2 fire 2");
}}
          xywh {540 320 20 20} box ROUND_UP_BOX color 80 selection_color 88 labelsize 11 labelcolor 55
        }
        Fl_Button {} {
          label F3
          callback {{
  defineKey(0x7E, "Joy 2 fire 3");
}}
          xywh {540 235 20 20} box ROUND_UP_BOX color 80 selection_color 88 labelsize 11 labelcolor 55
        }
      }
      Fl_Button {} {
        label Apply
        callback {{
  try {
    gui.applyEmulatorConfiguration();
  }
  catch (std::exception& e) {
    gui.errorMessage(e.what());
  }
}}
        xywh {425 355 60 25} selection_color 50
      }
      Fl_Button {} {
        label OK
        callback {{
  try {
    gui.applyEmulatorConfiguration();
  }
  catch (std::exception& e) {
    gui.errorMessage(e.what());
  }
  window->hide();
}}
        xywh {495 355 60 25} selection_color 50
      }
      Fl_Button {} {
        label Save
        callback {{
  try {
    std::string tmp;
    if (gui.browseFile(tmp, gui.configDirectory,
                       "Configuration files\\t*.cfg",
                       Fl_Native_File_Chooser::BROWSE_SAVE_FILE,
                       "Save keyboard configuration as ASCII text file")) {
      Ep128Emu::addFileNameExtension(tmp, "cfg");
      Ep128Emu::ConfigurationDB tmpCfg;
      char    cvName[16];
      for (int i = 0; i < 256; i++) {
        std::sprintf(&(cvName[0]), "keyboard.%02X.%d",
                     (unsigned int) (i >> 1), int(i & 1));
        tmpCfg.createKey(&(cvName[0]), gui.config.keyboard[i >> 1][i & 1]);
      }
      gui.config.joystick.registerConfigurationVariables(tmpCfg);
      tmpCfg.saveState(tmp.c_str(), false);
    }
  }
  catch (std::exception& e) {
    gui.errorMessage(e.what());
  }
}}
        xywh {195 355 60 25} selection_color 50
      }
      Fl_Button {} {
        label Load
        callback {{
  gui.menuCallback_File_LoadConfig(o, (void *) &gui);
}}
        xywh {265 355 60 25} selection_color 50
      }
      Fl_Button {} {
        label {Clear all}
        callback {{
  for (int i = 0; i < 256; i++)
    setKeyMap(i, -1);
}}
        xywh {15 355 80 25} selection_color 50
      }
    }
    Fl_Window defineKeyWindow {
      label {Define key} open
      xywh {182 585 220 120} type Double color 48
      class Ep128EmuGUI_KbdDefineWindow visible
    } {
      Fl_Box {} {
        xywh {10 10 200 100} box THIN_UP_BOX
      }
      Fl_Box defineKeyWindowText {
        xywh {15 15 190 90} align 144
      }
    }
  }
  Function {~Ep128EmuGUI_KbdConfigWindow()} {open
  } {
    code {{
  if (defineKeyWindow->shown() || window->shown()) {
    if (defineKeyWindow->shown())
      defineKeyWindow->hide();
    if (window->shown())
      window->hide();
    Fl::wait(0.0);
  }
  gui.joystickInput.unlock();
  delete defineKeyWindow;
  delete window;
}} {}
  }
  Function {show()} {open return_type void
  } {
    code {{
  if (!window->shown())
    updateWindow();
  window->show();
}} {}
  }
  Function {shown()} {open return_type bool
  } {
    code {{
  return bool(window->shown());
}} {}
  }
  Function {hide()} {open return_type void
  } {
    code {{
  if (defineKeyWindow->shown())
    defineKeyWindow->hide();
  if (window->shown())
    window->hide();
  gui.joystickInput.unlock();
}} {}
  }
  Function {setKeyMap(int n, int keyCode)} {open private return_type void
  } {
    code {{
  int   oldKey = gui.config.keyboard[n >> 1][n & 1];
  if (keyCode >= 0) {
    keyCode = keyCode & 0xFFFF;
    for (int i = 0; i < 256; i++) {
      if (gui.config.keyboard[i >> 1][i & 1] == keyCode && i != n)
        gui.config.keyboard[i >> 1][i & 1] = -1;
    }
    gui.config.keyboard[n >> 1][n & 1] = keyCode;
  }
  else
    gui.config.keyboard[n >> 1][n & 1] = -1;
  if (gui.config.keyboard[n >> 1][n & 1] != oldKey)
    gui.config.keyboardMapChanged = true;
}} {}
  }
  Function {defineKey(int n, const char *keyName)} {open private return_type void
  } {
    code {{
  char    buf[256];
  std::sprintf(&(buf[0]), "Press key for '%s', F9 for no key, F10 or F11 to keep "
                          "the original key, or F12 to close this window", keyName);
  defineKeyWindowText->copy_label(&(buf[0]));
  defineKeyWindow->set_modal();
  defineKeyWindow->show();
  defineKeyWindow->keyCode_ = -1;
  gui.joystickInput.lock();
  gui.joystickInput.flushEvents();
  do {
    Fl::wait(0.05);
    int   tmp = gui.joystickInput.getEvent(true, false);
    if (tmp > 0)
      defineKeyWindow->keyCode_ = tmp;
  } while (defineKeyWindow->keyCode_ < 0 && defineKeyWindow->shown());
  gui.joystickInput.unlock();
  defineKeyWindowText->label("");
  if (!defineKeyWindow->shown())
    return;
  if (defineKeyWindow->keyCode_ == (FL_F + 12)) {
    defineKeyWindow->hide();
    return;
  }
  if (defineKeyWindow->keyCode_ == (FL_F + 9))
    setKeyMap(n << 1, -1);
  else if (!(defineKeyWindow->keyCode_ == (FL_F + 10) ||
             defineKeyWindow->keyCode_ == (FL_F + 11)))
    setKeyMap(n << 1, defineKeyWindow->keyCode_);
  std::sprintf(&(buf[0]),
               "Press alternate key for '%s', F9 for no key, F10 or "
               "F11 to keep the original key, or F12 to close this window", keyName);
  defineKeyWindowText->copy_label(&(buf[0]));
  defineKeyWindow->keyCode_ = -1;
  gui.joystickInput.lock();
  gui.joystickInput.flushEvents();
  do {
    Fl::wait(0.05);
    int   tmp = gui.joystickInput.getEvent(true, false);
    if (tmp > 0)
      defineKeyWindow->keyCode_ = tmp;
  } while (defineKeyWindow->keyCode_ < 0 && defineKeyWindow->shown());
  gui.joystickInput.unlock();
  defineKeyWindowText->label("");
  if (!defineKeyWindow->shown())
    return;
  if (defineKeyWindow->keyCode_ == (FL_F + 12)) {
    defineKeyWindow->hide();
    return;
  }
  if (defineKeyWindow->keyCode_ == (FL_F + 9))
    setKeyMap((n << 1) + 1, -1);
  else if (!(defineKeyWindow->keyCode_ == (FL_F + 10) ||
             defineKeyWindow->keyCode_ == (FL_F + 11)))
    setKeyMap((n << 1) + 1, defineKeyWindow->keyCode_);
  defineKeyWindow->hide();
}} {}
  }
  Function {updateWindow()} {open return_type void
  } {
    code {{
  mouseSensitivityXValuator->value(
      double(int(3.0 * std::log(gui.config.mouse.sensitivityX)
                 / std::log(2.0) + 3.5) - 3));
  mouseSensitivityYValuator->value(
      double(int(3.0 * std::log(gui.config.mouse.sensitivityY)
                 / std::log(2.0) + 3.5) - 3));
  joystickEnableValuator->value(gui.config.joystick.enableJoystick ? 1 : 0);
  joystickThresholdValuator->value(gui.config.joystick.axisThreshold);
  joystickEnablePWMValuator->value(gui.config.joystick.enablePWM ? 1 : 0);
  joystickPWMFrequencyValuator->value(gui.config.joystick.pwmFrequency);
  joystickEnableAutoFireValuator->value(gui.config.joystick.enableAutoFire ? 1 : 0);
  joystickAutoFireFreqValuator->value(gui.config.joystick.autoFireFrequency);
  joystickAutoFirePWValuator->value(gui.config.joystick.autoFirePulseWidth);
}} {}
  }
} 
