Add Dvorak layout support.

Submitted by:		Michael Watts <zwy648rct at gmail.com>


git-svn-id: svn://svn.code.sf.net/p/jack-keyboard/code/trunk@10 1fa2bf75-7d80-4145-9e94-f9b4e25a1cb2
This commit is contained in:
trasz 2009-08-29 19:42:01 +00:00
parent fdf976ab39
commit d8c58677de
2 changed files with 55 additions and 2 deletions

View File

@ -1691,7 +1691,7 @@ usage(void)
fprintf(stderr, " where <channel> is MIDI channel to use for output, from 1 to 16,\n"); fprintf(stderr, " where <channel> is MIDI channel to use for output, from 1 to 16,\n");
fprintf(stderr, " <bank> is MIDI bank to use, from 0 to 16383,\n"); fprintf(stderr, " <bank> is MIDI bank to use, from 0 to 16383,\n");
fprintf(stderr, " <program> is MIDI program to use, from 0 to 127,\n"); fprintf(stderr, " <program> is MIDI program to use, from 0 to 127,\n");
fprintf(stderr, " and <layout> is either QWERTY, QWERTZ or AZERTY.\n"); fprintf(stderr, " and <layout> is QWERTY, QWERTZ, AZERTY or DVORAK.\n");
fprintf(stderr, "See manual page for details.\n"); fprintf(stderr, "See manual page for details.\n");
exit(EX_USAGE); exit(EX_USAGE);
@ -1829,7 +1829,7 @@ main(int argc, char *argv[])
int ret = piano_keyboard_set_keyboard_layout(keyboard, keyboard_layout); int ret = piano_keyboard_set_keyboard_layout(keyboard, keyboard_layout);
if (ret) { if (ret) {
g_critical("Invalid layout, proper choices are QWERTY, QWERTZ and AZERTY."); g_critical("Invalid layout, proper choices are QWERTY, QWERTZ, AZERTY and DVORAK.");
exit(EX_USAGE); exit(EX_USAGE);
} }
} }

View File

@ -328,6 +328,56 @@ bind_keys_azerty(PianoKeyboard *pk)
bind_key(pk, "p", 40); bind_key(pk, "p", 40);
} }
static void
bind_keys_dvorak(PianoKeyboard *pk)
{
clear_notes(pk);
/* Lower keyboard row - ";qjkxbm". */
bind_key(pk, "semicolon", 12); /* C0 */
bind_key(pk, "o", 13);
bind_key(pk, "q", 14);
bind_key(pk, "e", 15);
bind_key(pk, "j", 16);
bind_key(pk, "k", 17);
bind_key(pk, "i", 18);
bind_key(pk, "x", 19);
bind_key(pk, "d", 20);
bind_key(pk, "b", 21);
bind_key(pk, "h", 22);
bind_key(pk, "m", 23);
bind_key(pk, "w", 24); /* overlaps with upper row */
bind_key(pk, "n", 25);
bind_key(pk, "v", 26);
bind_key(pk, "s", 27);
bind_key(pk, "z", 28);
/* Upper keyboard row, first octave - "',.pyfg". */
bind_key(pk, "apostrophe", 24);
bind_key(pk, "2", 25);
bind_key(pk, "comma", 26);
bind_key(pk, "3", 27);
bind_key(pk, "period", 28);
bind_key(pk, "p", 29);
bind_key(pk, "5", 30);
bind_key(pk, "y", 31);
bind_key(pk, "6", 32);
bind_key(pk, "f", 33);
bind_key(pk, "7", 34);
bind_key(pk, "g", 35);
/* Upper keyboard row, the rest - "crl". */
bind_key(pk, "c", 36);
bind_key(pk, "9", 37);
bind_key(pk, "r", 38);
bind_key(pk, "0", 39);
bind_key(pk, "l", 40);
bind_key(pk, "slash", 41); /* extra F */
bind_key(pk, "bracketright", 42);
bind_key(pk, "equal", 43);
}
static gint static gint
keyboard_event_handler(GtkWidget *mk, GdkEventKey *event, gpointer notused) keyboard_event_handler(GtkWidget *mk, GdkEventKey *event, gpointer notused)
{ {
@ -683,6 +733,9 @@ piano_keyboard_set_keyboard_layout(PianoKeyboard *pk, const char *layout)
} else if (!strcasecmp(layout, "AZERTY")) { } else if (!strcasecmp(layout, "AZERTY")) {
bind_keys_azerty(pk); bind_keys_azerty(pk);
} else if (!strcasecmp(layout, "DVORAK")) {
bind_keys_dvorak(pk);
} else { } else {
/* Unknown layout name. */ /* Unknown layout name. */
return (TRUE); return (TRUE);