Restored pattern editor functionality.
[epichord.git] / src / keyboard.cpp
blob4ff356b021ec061dd52936eb0df45467ac4b91c1
1 /*
2 Epichord - a midi sequencer
3 Copyright (C) 2008 Evan Rinehart
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to
18 The Free Software Foundation, Inc.
19 51 Franklin Street, Fifth Floor
20 Boston, MA 02110-1301, USA
23 #include <unistd.h>
24 #include <string.h>
25 #include <stdio.h>
27 #include <iostream>
28 #include <fstream>
30 #include <fltk/Group.h>
31 #include <fltk/Widget.h>
32 #include <fltk/events.h>
34 #include "ui.h"
36 #include "backend.h"
38 #include "uihelper.h"
40 #include "util.h"
44 extern UI* ui;
46 using namespace std;
47 using namespace fltk;
49 extern struct conf config;
51 Keyboard::Keyboard(int x, int y, int w, int h, const char* label = 0) : fltk::Widget(x, y, w, h, label) {
52 sustain = 0;
53 cur_note = -1;
54 fltk::add_event_handler(keyboard_handler);
56 for(int i=0; i<128; i++){
57 ons[i]=0;
58 helds[i]=0;
61 cur_port = 0;
62 cur_chan = 0;
64 octave = 4;
70 int keyboard_handler(int e, fltk::Window* w){
71 combo E = combo(event_key(),event_state());
72 switch(e){
73 case fltk::SHORTCUT:
74 if(fltk::event_key_repeated()){
75 return 0;
77 if(E==combo(fltk::SpaceKey,0)){
78 ui->keyboard->set_sustain(1);
80 else if(ui->kg_od->cmp(E)){
81 ui->keyboard->octave_down();
83 else if(ui->kg_ou->cmp(E)){
84 ui->keyboard->octave_up();
86 else if(ui->kg_l0->cmp(E))
87 ui->keyboard->kb_play_note(0);
88 else if(ui->kg_l1->cmp(E))
89 ui->keyboard->kb_play_note(1);
90 else if(ui->kg_l2->cmp(E))
91 ui->keyboard->kb_play_note(2);
92 else if(ui->kg_l3->cmp(E))
93 ui->keyboard->kb_play_note(3);
94 else if(ui->kg_l4->cmp(E))
95 ui->keyboard->kb_play_note(4);
96 else if(ui->kg_l5->cmp(E))
97 ui->keyboard->kb_play_note(5);
98 else if(ui->kg_l6->cmp(E))
99 ui->keyboard->kb_play_note(6);
100 else if(ui->kg_l7->cmp(E))
101 ui->keyboard->kb_play_note(7);
102 else if(ui->kg_l8->cmp(E))
103 ui->keyboard->kb_play_note(8);
104 else if(ui->kg_l9->cmp(E))
105 ui->keyboard->kb_play_note(9);
106 else if(ui->kg_l10->cmp(E))
107 ui->keyboard->kb_play_note(10);
108 else if(ui->kg_l11->cmp(E))
109 ui->keyboard->kb_play_note(11);
110 else if(ui->kg_l12->cmp(E))
111 ui->keyboard->kb_play_note(12);
112 else if(ui->kg_l13->cmp(E))
113 ui->keyboard->kb_play_note(13);
114 else if(ui->kg_l14->cmp(E))
115 ui->keyboard->kb_play_note(14);
116 else if(ui->kg_l15->cmp(E))
117 ui->keyboard->kb_play_note(15);
118 else if(ui->kg_l16->cmp(E))
119 ui->keyboard->kb_play_note(16);
120 else if(ui->kg_u0->cmp(E))
121 ui->keyboard->kb_play_note(12);
122 else if(ui->kg_u1->cmp(E))
123 ui->keyboard->kb_play_note(13);
124 else if(ui->kg_u2->cmp(E))
125 ui->keyboard->kb_play_note(14);
126 else if(ui->kg_u3->cmp(E))
127 ui->keyboard->kb_play_note(15);
128 else if(ui->kg_u4->cmp(E))
129 ui->keyboard->kb_play_note(16);
130 else if(ui->kg_u5->cmp(E))
131 ui->keyboard->kb_play_note(17);
132 else if(ui->kg_u6->cmp(E))
133 ui->keyboard->kb_play_note(18);
134 else if(ui->kg_u7->cmp(E))
135 ui->keyboard->kb_play_note(19);
136 else if(ui->kg_u8->cmp(E))
137 ui->keyboard->kb_play_note(20);
138 else if(ui->kg_u9->cmp(E))
139 ui->keyboard->kb_play_note(21);
140 else if(ui->kg_u10->cmp(E))
141 ui->keyboard->kb_play_note(22);
142 else if(ui->kg_u11->cmp(E))
143 ui->keyboard->kb_play_note(23);
144 else if(ui->kg_u12->cmp(E))
145 ui->keyboard->kb_play_note(24);
146 else if(ui->kg_u13->cmp(E))
147 ui->keyboard->kb_play_note(25);
148 else if(ui->kg_u14->cmp(E))
149 ui->keyboard->kb_play_note(26);
150 else if(ui->kg_u15->cmp(E))
151 ui->keyboard->kb_play_note(27);
152 else if(ui->kg_u16->cmp(E))
153 ui->keyboard->kb_play_note(28);
154 else if(ui->kg_u17->cmp(E))
155 ui->keyboard->kb_play_note(29);
156 else if(ui->kg_u18->cmp(E))
157 ui->keyboard->kb_play_note(30);
158 else if(ui->kg_u19->cmp(E))
159 ui->keyboard->kb_play_note(31);
160 else if(ui->kg_u20->cmp(E))
161 ui->keyboard->kb_play_note(32);
164 return 1;
165 case fltk::KEYUP:
166 if(E==combo(fltk::SpaceKey,0)){
167 ui->keyboard->set_sustain(0);
169 else if(ui->kg_l0->cmp(E))
170 ui->keyboard->kb_release_note(0);
171 else if(ui->kg_l1->cmp(E))
172 ui->keyboard->kb_release_note(1);
173 else if(ui->kg_l2->cmp(E))
174 ui->keyboard->kb_release_note(2);
175 else if(ui->kg_l3->cmp(E))
176 ui->keyboard->kb_release_note(3);
177 else if(ui->kg_l4->cmp(E))
178 ui->keyboard->kb_release_note(4);
179 else if(ui->kg_l5->cmp(E))
180 ui->keyboard->kb_release_note(5);
181 else if(ui->kg_l6->cmp(E))
182 ui->keyboard->kb_release_note(6);
183 else if(ui->kg_l7->cmp(E))
184 ui->keyboard->kb_release_note(7);
185 else if(ui->kg_l8->cmp(E))
186 ui->keyboard->kb_release_note(8);
187 else if(ui->kg_l9->cmp(E))
188 ui->keyboard->kb_release_note(9);
189 else if(ui->kg_l10->cmp(E))
190 ui->keyboard->kb_release_note(10);
191 else if(ui->kg_l11->cmp(E))
192 ui->keyboard->kb_release_note(11);
193 else if(ui->kg_l12->cmp(E))
194 ui->keyboard->kb_release_note(12);
195 else if(ui->kg_l13->cmp(E))
196 ui->keyboard->kb_release_note(13);
197 else if(ui->kg_l14->cmp(E))
198 ui->keyboard->kb_release_note(14);
199 else if(ui->kg_l15->cmp(E))
200 ui->keyboard->kb_release_note(15);
201 else if(ui->kg_l16->cmp(E))
202 ui->keyboard->kb_release_note(16);
203 else if(ui->kg_u0->cmp(E))
204 ui->keyboard->kb_release_note(12);
205 else if(ui->kg_u1->cmp(E))
206 ui->keyboard->kb_release_note(13);
207 else if(ui->kg_u2->cmp(E))
208 ui->keyboard->kb_release_note(14);
209 else if(ui->kg_u3->cmp(E))
210 ui->keyboard->kb_release_note(15);
211 else if(ui->kg_u4->cmp(E))
212 ui->keyboard->kb_release_note(16);
213 else if(ui->kg_u5->cmp(E))
214 ui->keyboard->kb_release_note(17);
215 else if(ui->kg_u6->cmp(E))
216 ui->keyboard->kb_release_note(18);
217 else if(ui->kg_u7->cmp(E))
218 ui->keyboard->kb_release_note(19);
219 else if(ui->kg_u8->cmp(E))
220 ui->keyboard->kb_release_note(20);
221 else if(ui->kg_u9->cmp(E))
222 ui->keyboard->kb_release_note(21);
223 else if(ui->kg_u10->cmp(E))
224 ui->keyboard->kb_release_note(22);
225 else if(ui->kg_u11->cmp(E))
226 ui->keyboard->kb_release_note(23);
227 else if(ui->kg_u12->cmp(E))
228 ui->keyboard->kb_release_note(24);
229 else if(ui->kg_u13->cmp(E))
230 ui->keyboard->kb_release_note(25);
231 else if(ui->kg_u14->cmp(E))
232 ui->keyboard->kb_release_note(26);
233 else if(ui->kg_u15->cmp(E))
234 ui->keyboard->kb_release_note(27);
235 else if(ui->kg_u16->cmp(E))
236 ui->keyboard->kb_release_note(28);
237 else if(ui->kg_u17->cmp(E))
238 ui->keyboard->kb_release_note(29);
239 else if(ui->kg_u18->cmp(E))
240 ui->keyboard->kb_release_note(30);
241 else if(ui->kg_u19->cmp(E))
242 ui->keyboard->kb_release_note(31);
243 else if(ui->kg_u20->cmp(E))
244 ui->keyboard->kb_release_note(32);
245 return 1;
247 return 0;
251 void note_on(int note, int vel, int channel){
255 void Keyboard::set_sustain(int state){
256 sustain=state;
257 if(state==0){
258 for(int i=0; i<128; i++){
259 if(ons[i]==1 && helds[i]==0){
260 release_note(i,1);
263 redraw();
267 int Keyboard::handle(int event){
268 char buf[16];
269 int note;
270 switch(event){
271 case fltk::FOCUS:
272 return 1;
273 case fltk::PUSH:
274 take_focus();
275 note = ypix2note(event_y()+scroll, event_x() < w()/2 ? 1 : 0);
276 if(note < 0 || note > 127){
277 return 1;
279 cur_note = note;
280 helds[note] = 1;
281 play_note(note,1);
282 return 1;
283 case fltk::RELEASE:
284 if(cur_note!=-1){
285 helds[cur_note]=0;
287 cur_note=-1;
288 if(sustain == 0){
289 cut_notes(1);
290 redraw();
292 return 1;
293 case fltk::DRAG:
294 note = ypix2note(event_y()+scroll, event_x() < w()/2 ? 1 : 0);
295 if(note < 0 || note > 127){
296 return 1;
298 if(cur_note != note){
299 helds[cur_note]=0;
300 cur_note = note;
301 if(sustain == 0){
302 cut_notes(1);
304 helds[note]=1;
305 play_note(note,1);
307 return 1;
309 return 0;
312 void Keyboard::play_note(int note, int rec){
313 if(ons[note]==1){
314 return;
317 char buf[3];
318 buf[0] = 0x90 | cur_chan;
319 buf[1] = note;
320 buf[2] = config.defaultvelocity;
321 send_midi(buf,3,cur_port);
323 ons[note] = 1;
324 helds[note] = 1;
326 if(rec && is_backend_recording()){
327 send_midi_local(buf,3);
330 redraw();
333 void Keyboard::release_note(int note, int rec){
334 if(ons[note]==0){
335 return;
338 helds[note]=0;
340 if(sustain==1){
341 return;
344 char buf[3];
345 buf[0] = 0x80 | cur_chan;
346 buf[1] = note;
347 buf[2] = 0x00;
348 send_midi(buf,3,cur_port);
350 ons[note] = 0;
351 if(rec && is_backend_recording()){
352 send_midi_local(buf,3);
355 redraw();
358 void Keyboard::kb_play_note(int note){
359 int raw = octave*12 + note;
360 if(raw < 128 && raw >= 0){
361 play_note(raw,1);
365 void Keyboard::kb_release_note(int note){
366 int raw = octave*12 + note;
367 if(raw < 128 && raw >= 0){
368 release_note(raw,1);
372 void Keyboard::octave_up(){
373 if(octave < 9){
374 cut_notes(1);
375 octave++;
379 void Keyboard::octave_down(){
380 if(octave > 0){
381 cut_notes(1);
382 octave--;
386 void Keyboard::cut_notes(int rec){
387 for(int i=0; i<128; i++){
388 if(ons[i]){
389 release_note(i,rec);
395 void Keyboard::draw(){
396 fltk::setcolor(fltk::WHITE);
397 fltk::fillrect(0,0,w(),h());
399 fltk::push_clip(0,0,w(),h());
401 //draw held white notes
402 int black;
403 for(int i=0; i<128; i++){
404 if(ons[i]){
405 int Y = note2ypix(i,&black)-scroll;
406 if(!black){
407 fltk::setcolor(fltk::GRAY50);
408 fltk::fillrect(0,Y,w(),12);
413 fltk::setcolor(fltk::BLACK);
414 for(int i=1; i<=75; i++){
415 fltk::fillrect(0,i*12-scroll,w(),1);
418 int j;
419 for(int i=0; i<11; i++){
420 j = 900 - 12 - i*12*7 - scroll;
421 fltk::fillrect(0,j-3,w()/2,7);
422 fltk::fillrect(0,j-12-3,w()/2,7);
424 fltk::fillrect(0,j-12*3-3,w()/2,7);
425 if(i<10){
426 fltk::fillrect(0,j-12*4-3,w()/2,7);
427 fltk::fillrect(0,j-12*5-3,w()/2,7);
431 //draw held black notes
432 for(int i=0; i<128; i++){
433 if(ons[i]){
434 int Y = note2ypix(i,&black)-scroll;
435 if(black){
436 fltk::setcolor(fltk::GRAY70);
437 fltk::fillrect(1,Y+1,w()/2 - 2,5);
442 fltk::pop_clip();
446 KeyGrabber::KeyGrabber(int x, int y, int w, int h, const char* label = 0) : fltk::Widget(x, y, w, h, label) {
447 key = 'a';
448 mod = 0;
449 strncpy(str,get_keystring(key,mod),32);
450 in_flag = 0;
453 int KeyGrabber::handle(int event){
454 int specialok=0;
455 switch(event){
456 case FOCUS:
457 return 1;
458 case PUSH:
459 take_focus();
460 in_flag = 1;
461 set_key(' ',0);
462 redraw();
463 return 1;
464 break;
465 case KEY:
466 if(in_flag){
467 switch(event_key()){
468 case fltk::Keypad:
469 case fltk::KeypadEnter:
470 case fltk::MultiplyKey:
471 case fltk::AddKey:
472 case fltk::SubtractKey:
473 case fltk::DecimalKey:
474 case fltk::DivideKey:
475 case fltk::Keypad0:
476 case fltk::Keypad1:
477 case fltk::Keypad2:
478 case fltk::Keypad3:
479 case fltk::Keypad4:
480 case fltk::Keypad5:
481 case fltk::Keypad6:
482 case fltk::Keypad7:
483 case fltk::Keypad8:
484 case fltk::Keypad9:
485 case fltk::KeypadLast:
486 specialok = 1;
487 break;
489 if(specialok || event_key()<0x80){
490 set_key(event_key(),event_state());
491 in_flag = 0;
492 redraw();
493 return 1;
495 return 0;
497 break;
499 return 0;
502 void KeyGrabber::draw(){
503 draw_box();
504 setfont(fltk::COURIER,10);
505 fltk::push_clip(0,0,w(),h());
507 if(in_flag){
508 fltk::setcolor(fltk::color(128,128,255));
510 else{
511 fltk::setcolor(fltk::WHITE);
513 fillrect(2,2,w()-4,h()-4);
515 fltk::setcolor(fltk::BLACK);
517 drawtext(str,2,12);
518 pop_clip();
521 int KeyGrabber::set_key(int zkey, int zmod){
522 key = zkey;
523 mod = zmod;
524 strncpy(str,get_keystring(key,mod),32);
525 redraw();
528 int KeyGrabber::set_key(combo c){
529 key = c.key;
530 mod = c.mod;
531 strncpy(str,get_keystring(key,mod),32);
532 redraw();
535 int KeyGrabber::cmp(combo c){
536 return (key==c.key && mod==c.mod) ? 1 : 0;
539 void KeyGrabber::save(fstream& f){
540 f << key << " " << mod << endl;
543 void KeyGrabber::load(fstream& f){
544 int k,m;
545 f >> k >> m;
546 set_key(k,m);
550 char keystring[32] = "";
551 char* get_keystring(int key, int mod){
552 keystring[0] = '\0';
553 if(key == ' '){
554 keystring[0] = '\0';
555 return keystring;
558 fltk::SHIFT, fltk::CAPSLOCK, fltk::CTRL, fltk::ALT,
559 fltk::NUMLOCK, fltk::META, fltk::SCROLLLOCK, fltk::BUTTON1,
560 fltk::BUTTON2, fltk::BUTTON3, fltk::ANY_BUTTON, fltk::ACCELERATOR,
561 fltk::COMMAND, fltk::OPTION
565 if(mod&fltk::SHIFT) strcpy(keystring,"shft+");
566 else if(mod&fltk::CTRL) strcpy(keystring,"ctrl+");
567 else if(mod&fltk::ALT) strcpy(keystring,"alt+");
568 else if(mod&fltk::META) strcpy(keystring,"meta+");
569 else if(mod&fltk::OPTION) strcpy(keystring,"opt+");
571 int N = strlen(keystring);
573 fltk::LeftButton, fltk::MiddleButton, fltk::RightButton, fltk::SpaceKey,
574 fltk::BackSpaceKey, fltk::TabKey, fltk::ClearKey, fltk::ReturnKey,
575 fltk::PauseKey, fltk::ScrollLockKey, fltk::EscapeKey, fltk::HomeKey,
576 fltk::LeftKey, fltk::UpKey, fltk::RightKey, fltk::DownKey,
577 fltk::PageUpKey, fltk::PageDownKey, fltk::EndKey, fltk::PrintKey,
578 fltk::InsertKey, fltk::MenuKey, fltk::HelpKey, fltk::NumLockKey,
579 fltk::Keypad, fltk::KeypadEnter, fltk::MultiplyKey, fltk::AddKey,
580 fltk::SubtractKey, fltk::DecimalKey, fltk::DivideKey, fltk::Keypad0,
581 fltk::Keypad1, fltk::Keypad2, fltk::Keypad3, fltk::Keypad4,
582 fltk::Keypad5, fltk::Keypad6, fltk::Keypad7, fltk::Keypad8,
583 fltk::Keypad9, fltk::KeypadLast, fltk::F0Key, fltk::F1Key,
584 fltk::F2Key, fltk::F3Key, fltk::F4Key, fltk::F5Key,
585 fltk::F6Key, fltk::F7Key, fltk::F8Key, fltk::F9Key,
586 fltk::F10Key, fltk::F11Key, fltk::F12Key, fltk::LastFunctionKey,
587 fltk::LeftShiftKey, fltk::RightShiftKey, fltk::LeftCtrlKey, fltk::RightCtrlKey,
588 fltk::CapsLockKey, fltk::LeftMetaKey, fltk::RightMetaKey, fltk::LeftAltKey,
589 fltk::RightAltKey, fltk::DeleteKey, LeftAccKey, RightAccKey,
590 LeftCmdKey, RightCmdKey
592 char k[4];
593 k[0] = key;
594 k[1] = '\0';
595 switch(key){
596 case fltk::Keypad: strcpy(keystring+N,"keypad"); break;
597 case fltk::KeypadEnter: strcpy(keystring+N,"enter"); break;
598 case fltk::MultiplyKey: strcpy(keystring+N,"mult"); break;
599 case fltk::AddKey: strcpy(keystring+N,"plus"); break;
600 case fltk::SubtractKey: strcpy(keystring+N,"minus"); break;
601 case fltk::DecimalKey: strcpy(keystring+N,"dec"); break;
602 case fltk::DivideKey: strcpy(keystring+N,"div"); break;
603 case fltk::Keypad0: strcpy(keystring+N,"0"); break;
604 case fltk::Keypad1: strcpy(keystring+N,"1"); break;
605 case fltk::Keypad2: strcpy(keystring+N,"2"); break;
606 case fltk::Keypad3: strcpy(keystring+N,"3"); break;
607 case fltk::Keypad4: strcpy(keystring+N,"4"); break;
608 case fltk::Keypad5: strcpy(keystring+N,"5"); break;
609 case fltk::Keypad6: strcpy(keystring+N,"6"); break;
610 case fltk::Keypad7: strcpy(keystring+N,"7"); break;
611 case fltk::Keypad8: strcpy(keystring+N,"8"); break;
612 case fltk::Keypad9: strcpy(keystring+N,"9"); break;
613 default: strcpy(keystring+N,k); break;
616 return keystring;
620 void load_keymap(std::fstream& f){
622 unsigned key, mod;
624 ui->kg_l0->load(f);
625 ui->kg_l1->load(f);
626 ui->kg_l2->load(f);
627 ui->kg_l3->load(f);
628 ui->kg_l4->load(f);
629 ui->kg_l5->load(f);
630 ui->kg_l6->load(f);
631 ui->kg_l7->load(f);
632 ui->kg_l8->load(f);
633 ui->kg_l9->load(f);
634 ui->kg_l10->load(f);
635 ui->kg_l11->load(f);
636 ui->kg_l12->load(f);
637 ui->kg_l13->load(f);
638 ui->kg_l14->load(f);
639 ui->kg_l15->load(f);
640 ui->kg_l16->load(f);
642 ui->kg_u0->load(f);
643 ui->kg_u1->load(f);
644 ui->kg_u2->load(f);
645 ui->kg_u3->load(f);
646 ui->kg_u4->load(f);
647 ui->kg_u5->load(f);
648 ui->kg_u6->load(f);
649 ui->kg_u7->load(f);
650 ui->kg_u8->load(f);
651 ui->kg_u9->load(f);
652 ui->kg_u10->load(f);
653 ui->kg_u11->load(f);
654 ui->kg_u12->load(f);
655 ui->kg_u13->load(f);
656 ui->kg_u14->load(f);
657 ui->kg_u15->load(f);
658 ui->kg_u16->load(f);
659 ui->kg_u17->load(f);
660 ui->kg_u18->load(f);
661 ui->kg_u19->load(f);
662 ui->kg_u20->load(f);
664 ui->kg_zi->load(f);
665 ui->kg_zo->load(f);
666 ui->kg_ou->load(f);
667 ui->kg_od->load(f);
671 void save_keymap(fstream& f){
672 f << "keymap" << endl;
673 ui->kg_l0->save(f);
674 ui->kg_l1->save(f);
675 ui->kg_l2->save(f);
676 ui->kg_l3->save(f);
677 ui->kg_l4->save(f);
678 ui->kg_l5->save(f);
679 ui->kg_l6->save(f);
680 ui->kg_l7->save(f);
681 ui->kg_l8->save(f);
682 ui->kg_l9->save(f);
683 ui->kg_l10->save(f);
684 ui->kg_l11->save(f);
685 ui->kg_l12->save(f);
686 ui->kg_l13->save(f);
687 ui->kg_l14->save(f);
688 ui->kg_l15->save(f);
689 ui->kg_l16->save(f);
691 ui->kg_u0->save(f);
692 ui->kg_u1->save(f);
693 ui->kg_u2->save(f);
694 ui->kg_u3->save(f);
695 ui->kg_u4->save(f);
696 ui->kg_u5->save(f);
697 ui->kg_u6->save(f);
698 ui->kg_u7->save(f);
699 ui->kg_u8->save(f);
700 ui->kg_u9->save(f);
701 ui->kg_u10->save(f);
702 ui->kg_u11->save(f);
703 ui->kg_u12->save(f);
704 ui->kg_u13->save(f);
705 ui->kg_u14->save(f);
706 ui->kg_u15->save(f);
707 ui->kg_u16->save(f);
708 ui->kg_u17->save(f);
709 ui->kg_u18->save(f);
710 ui->kg_u19->save(f);
711 ui->kg_u20->save(f);
713 ui->kg_zi->save(f);
714 ui->kg_zo->save(f);
715 ui->kg_ou->save(f);
716 ui->kg_od->save(f);
718 f << endl;
721 void load_default_keymap(){
722 ui->kg_l0->set_key('z',0);
723 ui->kg_l1->set_key('s',0);
724 ui->kg_l2->set_key('x',0);
725 ui->kg_l3->set_key('d',0);
726 ui->kg_l4->set_key('c',0);
727 ui->kg_l5->set_key('v',0);
728 ui->kg_l6->set_key('g',0);
729 ui->kg_l7->set_key('b',0);
730 ui->kg_l8->set_key('h',0);
731 ui->kg_l9->set_key('n',0);
732 ui->kg_l10->set_key('j',0);
733 ui->kg_l11->set_key('m',0);
734 ui->kg_l12->set_key(',',0);
735 ui->kg_l13->set_key('l',0);
736 ui->kg_l14->set_key('.',0);
737 ui->kg_l15->set_key(';',0);
738 ui->kg_l16->set_key('/',0);
740 ui->kg_u0->set_key('q',0);
741 ui->kg_u1->set_key('2',0);
742 ui->kg_u2->set_key('w',0);
743 ui->kg_u3->set_key('3',0);
744 ui->kg_u4->set_key('e',0);
745 ui->kg_u5->set_key('r',0);
746 ui->kg_u6->set_key('5',0);
747 ui->kg_u7->set_key('t',0);
748 ui->kg_u8->set_key('6',0);
749 ui->kg_u9->set_key('y',0);
750 ui->kg_u10->set_key('7',0);
751 ui->kg_u11->set_key('u',0);
752 ui->kg_u12->set_key('i',0);
753 ui->kg_u13->set_key('9',0);
754 ui->kg_u14->set_key('o',0);
755 ui->kg_u15->set_key('0',0);
756 ui->kg_u16->set_key('p',0);
757 ui->kg_u17->set_key('[',0);
758 ui->kg_u18->set_key('=',0);
759 ui->kg_u19->set_key(']',0);
760 ui->kg_u20->set_key('\\',0);
762 ui->kg_ou->set_key(']',fltk::SHIFT);
763 ui->kg_od->set_key('[',fltk::SHIFT);
764 ui->kg_zi->set_key('=',fltk::SHIFT);
765 ui->kg_zo->set_key('-',fltk::SHIFT);
771 int zoom_out_key(unsigned key,unsigned mod){
772 if(ui->kg_zo->cmp(combo(key,mod))){return 1;}
773 return 0;
776 int zoom_in_key(unsigned key,unsigned mod){
777 if(ui->kg_zi->cmp(combo(key,mod))){return 1;}
778 return 0;