Ticket #29: custom_key_layout.patch

File custom_key_layout.patch, 3.6 KB (added by Matthias Bartsch, 4 years ago)
  • src/ui/root.cc

     
    144144    m_bindings['A']           = sigc::bind(sigc::mem_fun(*this, &Root::adjust_down_throttle), 1); 
    145145    m_bindings[':']           = sigc::bind(sigc::mem_fun(*this, &Root::adjust_down_throttle), -1); 
    146146 
    147   } else { 
     147  } else if (strncasecmp(keyLayout.c_str(), "custom", 6) != 0){ 
    148148    m_bindings['a']           = sigc::bind(sigc::mem_fun(*this, &Root::adjust_up_throttle), 1); 
    149149    m_bindings['z']           = sigc::bind(sigc::mem_fun(*this, &Root::adjust_up_throttle), -1); 
    150150    m_bindings['A']           = sigc::bind(sigc::mem_fun(*this, &Root::adjust_down_throttle), 1); 
    151151    m_bindings['Z']           = sigc::bind(sigc::mem_fun(*this, &Root::adjust_down_throttle), -1); 
     152 
    152153  } 
    153154 
    154   if (strcasecmp(keyLayout.c_str(), "dvorak") != 0) { 
     155  if (strncasecmp(keyLayout.c_str(), "custom", 6) != 0){ 
    155156    m_bindings['s']           = sigc::bind(sigc::mem_fun(*this, &Root::adjust_up_throttle), 5); 
    156157    m_bindings['x']           = sigc::bind(sigc::mem_fun(*this, &Root::adjust_up_throttle), -5); 
    157158    m_bindings['S']           = sigc::bind(sigc::mem_fun(*this, &Root::adjust_down_throttle), 5); 
     
    162163    m_bindings['D']           = sigc::bind(sigc::mem_fun(*this, &Root::adjust_down_throttle), 50); 
    163164    m_bindings['C']           = sigc::bind(sigc::mem_fun(*this, &Root::adjust_down_throttle), -50); 
    164165 
    165   } else { 
     166  } else if (strcasecmp(keyLayout.c_str(), "dvorak") == 0) { 
    166167    m_bindings['o']           = sigc::bind(sigc::mem_fun(*this, &Root::adjust_up_throttle), 5); 
    167168    m_bindings['q']           = sigc::bind(sigc::mem_fun(*this, &Root::adjust_up_throttle), -5); 
    168169    m_bindings['O']           = sigc::bind(sigc::mem_fun(*this, &Root::adjust_down_throttle), 5); 
     
    172173    m_bindings['j']           = sigc::bind(sigc::mem_fun(*this, &Root::adjust_up_throttle), -50); 
    173174    m_bindings['E']           = sigc::bind(sigc::mem_fun(*this, &Root::adjust_down_throttle), 50); 
    174175    m_bindings['J']           = sigc::bind(sigc::mem_fun(*this, &Root::adjust_down_throttle), -50); 
     176 
    175177  } 
    176178 
     179  if (strncasecmp(keyLayout.c_str(), "custom", 6) == 0 && keyLayout.length() >= 19){ 
     180    m_bindings[keyLayout[7]]  = sigc::bind(sigc::mem_fun(*this, &Root::adjust_up_throttle), 1); 
     181    m_bindings[keyLayout[8]]  = sigc::bind(sigc::mem_fun(*this, &Root::adjust_up_throttle), -1); 
     182    m_bindings[keyLayout[9]]  = sigc::bind(sigc::mem_fun(*this, &Root::adjust_down_throttle), 1); 
     183    m_bindings[keyLayout[10]]  = sigc::bind(sigc::mem_fun(*this, &Root::adjust_down_throttle), -1); 
     184 
     185    m_bindings[keyLayout[11]] = sigc::bind(sigc::mem_fun(*this, &Root::adjust_up_throttle), 5); 
     186    m_bindings[keyLayout[12]] = sigc::bind(sigc::mem_fun(*this, &Root::adjust_up_throttle), -5); 
     187    m_bindings[keyLayout[13]] = sigc::bind(sigc::mem_fun(*this, &Root::adjust_down_throttle), 5); 
     188    m_bindings[keyLayout[14]] = sigc::bind(sigc::mem_fun(*this, &Root::adjust_down_throttle), -5); 
     189 
     190    m_bindings[keyLayout[15]] = sigc::bind(sigc::mem_fun(*this, &Root::adjust_up_throttle), 50); 
     191    m_bindings[keyLayout[16]] = sigc::bind(sigc::mem_fun(*this, &Root::adjust_up_throttle), -50); 
     192    m_bindings[keyLayout[17]] = sigc::bind(sigc::mem_fun(*this, &Root::adjust_down_throttle), 50); 
     193    m_bindings[keyLayout[18]] = sigc::bind(sigc::mem_fun(*this, &Root::adjust_down_throttle), -50); 
     194 
     195  } 
     196 
    177197  m_bindings['\x0C']        = sigc::mem_fun(m_control->display(), &display::Manager::force_redraw); // ^L 
    178198  m_bindings['\x11']        = sigc::mem_fun(m_control, &Control::receive_normal_shutdown); // ^Q 
    179199}