Refactoring of regex and key debugging code.
This commit is contained in:
parent
1b1edeea1a
commit
1f26194218
69
midizap.c
69
midizap.c
|
@ -190,31 +190,9 @@ void reload_callback(void)
|
|||
have_window = 0;
|
||||
}
|
||||
|
||||
static char *note_names[] = { "C", "C#", "D", "Eb", "E", "F", "F#", "G", "G#", "A", "Bb", "B" };
|
||||
|
||||
void
|
||||
send_strokes(translation *tr, uint8_t portno, int status, int chan, int data,
|
||||
int index, int dir)
|
||||
static void debug_section(translation *tr)
|
||||
{
|
||||
int nkeys = 0;
|
||||
stroke *s = fetch_stroke(tr, portno, status, chan, data, index, dir);
|
||||
|
||||
if (!s && enable_jack_output) {
|
||||
// fall back to default MIDI translation
|
||||
tr = default_midi_translation[portno];
|
||||
s = fetch_stroke(tr, portno, status, chan, data, index, dir);
|
||||
// Ignore all MIDI input on the second port if no translation was found in
|
||||
// the [MIDI2] section (or the section is missing altogether).
|
||||
if (portno && !s) return;
|
||||
}
|
||||
|
||||
if (!s) {
|
||||
// fall back to the default translation
|
||||
tr = default_translation;
|
||||
s = fetch_stroke(tr, portno, status, chan, data, index, dir);
|
||||
}
|
||||
|
||||
if (s && debug_regex && (!have_window || tr != last_translation)) {
|
||||
if (tr && debug_regex && (!have_window || tr != last_translation)) {
|
||||
last_translation = tr;
|
||||
have_window = 1;
|
||||
if (tr != NULL) {
|
||||
|
@ -225,9 +203,14 @@ send_strokes(translation *tr, uint8_t portno, int status, int chan, int data,
|
|||
last_window_name, last_window_class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (debug_keys && s) {
|
||||
char name[100] = "??", *suffix = "";
|
||||
static char *debug_key(translation *tr, char *name,
|
||||
int status, int chan, int data, int dir)
|
||||
{
|
||||
static char *note_names[] = { "C", "C#", "D", "Eb", "E", "F", "F#", "G", "G#", "A", "Bb", "B" };
|
||||
char *suffix = "";
|
||||
strcpy(name, "??");
|
||||
switch (status) {
|
||||
case 0x90:
|
||||
sprintf(name, "%s%d-%d", note_names[data % 12],
|
||||
|
@ -265,7 +248,39 @@ send_strokes(translation *tr, uint8_t portno, int status, int chan, int data,
|
|||
default: // this can't happen
|
||||
break;
|
||||
}
|
||||
print_stroke_sequence(name, dir?"":index?"U":"D", s);
|
||||
return name;
|
||||
}
|
||||
|
||||
void
|
||||
send_strokes(translation *tr, uint8_t portno, int status, int chan, int data,
|
||||
int index, int dir)
|
||||
{
|
||||
int nkeys = 0;
|
||||
stroke *s = fetch_stroke(tr, portno, status, chan, data, index, dir);
|
||||
|
||||
if (!s && enable_jack_output) {
|
||||
// fall back to default MIDI translation
|
||||
tr = default_midi_translation[portno];
|
||||
s = fetch_stroke(tr, portno, status, chan, data, index, dir);
|
||||
// Ignore all MIDI input on the second port if no translation was found in
|
||||
// the [MIDI2] section (or the section is missing altogether).
|
||||
if (portno && !s) return;
|
||||
}
|
||||
|
||||
if (!s) {
|
||||
// fall back to the default translation
|
||||
tr = default_translation;
|
||||
s = fetch_stroke(tr, portno, status, chan, data, index, dir);
|
||||
}
|
||||
|
||||
if (tr && debug_regex) {
|
||||
debug_section(tr);
|
||||
}
|
||||
|
||||
if (s && debug_keys) {
|
||||
char name[100];
|
||||
print_stroke_sequence(debug_key(tr, name, status, chan, data, dir),
|
||||
dir?"":index?"U":"D", s);
|
||||
}
|
||||
while (s) {
|
||||
if (s->keysym) {
|
||||
|
|
Loading…
Reference in New Issue