Add IL and IR bindings for incremental movements of the shuttle, so that the shuttle can be treated like a secondary jog wheel.

pull/5/head
Albert Graef 2018-08-03 20:43:13 +02:00
rodzic 5591d62460
commit 18fb538d33
3 zmienionych plików z 34 dodań i 4 usunięć

Wyświetl plik

@ -12,6 +12,7 @@
[name] regex [name] regex
K<1..15> output K<1..15> output
S<-7..7> output S<-7..7> output
I<LR> output
J<LR> output J<LR> output
When focus is on a window whose title matches regex, the following When focus is on a window whose title matches regex, the following
@ -24,7 +25,7 @@
translations for the named translation class. The name is only used translations for the named translation class. The name is only used
for debugging output, and needn't be unique. The following lines for debugging output, and needn't be unique. The following lines
with K, S, and J labels indicate what output should be produced for with K, S, and J labels indicate what output should be produced for
the given keypress, shuttle position, or jog direction. the given keypress, shuttle position, shuttle direction, or jog direction.
output is a sequence of one or more key codes with optional up/down output is a sequence of one or more key codes with optional up/down
indicators, or strings of printable characters enclosed in double indicators, or strings of printable characters enclosed in double
@ -193,6 +194,9 @@ new_translation_section(char *name, char *regex)
for (i=0; i<NUM_SHUTTLES; i++) { for (i=0; i<NUM_SHUTTLES; i++) {
ret->shuttle[i] = NULL; ret->shuttle[i] = NULL;
} }
for (i=0; i<NUM_SHUTTLE_INCRS; i++) {
ret->shuttle_incr[i] = NULL;
}
for (i=0; i<NUM_JOGS; i++) { for (i=0; i<NUM_JOGS; i++) {
ret->jog[i] = NULL; ret->jog[i] = NULL;
} }
@ -234,6 +238,9 @@ free_translation_section(translation *tr)
for (i=0; i<NUM_SHUTTLES; i++) { for (i=0; i<NUM_SHUTTLES; i++) {
free_strokes(tr->shuttle[i]); free_strokes(tr->shuttle[i]);
} }
for (i=0; i<NUM_SHUTTLE_INCRS; i++) {
free_strokes(tr->shuttle_incr[i]);
}
for (i=0; i<NUM_JOGS; i++) { for (i=0; i<NUM_JOGS; i++) {
free_strokes(tr->jog[i]); free_strokes(tr->jog[i]);
} }
@ -503,12 +510,18 @@ start_translation(translation *tr, char *which_key)
first_release_stroke = 0; first_release_stroke = 0;
regular_key_down = 0; regular_key_down = 0;
modifier_count = 0; modifier_count = 0;
// JL, JR
if (tolower(which_key[0]) == 'j' && if (tolower(which_key[0]) == 'j' &&
(tolower(which_key[1]) == 'l' || tolower(which_key[1]) == 'r') && (tolower(which_key[1]) == 'l' || tolower(which_key[1]) == 'r') &&
which_key[2] == '\0') { which_key[2] == '\0') {
// JL, JR
k = tolower(which_key[1]) == 'l' ? 0 : 1; k = tolower(which_key[1]) == 'l' ? 0 : 1;
first_stroke = &(tr->jog[k]); first_stroke = &(tr->jog[k]);
} else if (tolower(which_key[0]) == 'i' &&
(tolower(which_key[1]) == 'l' || tolower(which_key[1]) == 'r') &&
which_key[2] == '\0') {
// IL, IR
k = tolower(which_key[1]) == 'l' ? 0 : 1;
first_stroke = &(tr->shuttle_incr[k]);
} else { } else {
n = 0; n = 0;
sscanf(which_key, "%c%d%n", &c, &k, &n); sscanf(which_key, "%c%d%n", &c, &k, &n);

Wyświetl plik

@ -67,6 +67,7 @@
#define NUM_KEYS 15 #define NUM_KEYS 15
#define NUM_SHUTTLES 15 #define NUM_SHUTTLES 15
#define NUM_SHUTTLE_INCRS 2
#define NUM_JOGS 2 #define NUM_JOGS 2
typedef struct _stroke { typedef struct _stroke {
@ -78,7 +79,8 @@ typedef struct _stroke {
#define KJS_KEY_DOWN 1 #define KJS_KEY_DOWN 1
#define KJS_KEY_UP 2 #define KJS_KEY_UP 2
#define KJS_SHUTTLE 3 #define KJS_SHUTTLE 3
#define KJS_JOG 4 #define KJS_SHUTTLE_INCR 4
#define KJS_JOG 5
typedef struct _translation { typedef struct _translation {
struct _translation *next; struct _translation *next;
@ -88,6 +90,7 @@ typedef struct _translation {
stroke *key_down[NUM_KEYS]; stroke *key_down[NUM_KEYS];
stroke *key_up[NUM_KEYS]; stroke *key_up[NUM_KEYS];
stroke *shuttle[NUM_SHUTTLES]; stroke *shuttle[NUM_SHUTTLES];
stroke *shuttle_incr[NUM_SHUTTLE_INCRS];
stroke *jog[NUM_JOGS]; stroke *jog[NUM_JOGS];
} translation; } translation;

Wyświetl plik

@ -70,6 +70,8 @@ fetch_stroke(translation *tr, int kjs, int index)
switch (kjs) { switch (kjs) {
case KJS_SHUTTLE: case KJS_SHUTTLE:
return tr->shuttle[index]; return tr->shuttle[index];
case KJS_SHUTTLE_INCR:
return tr->shuttle_incr[index];
case KJS_JOG: case KJS_JOG:
return tr->jog[index]; return tr->jog[index];
case KJS_KEY_UP: case KJS_KEY_UP:
@ -120,8 +122,20 @@ shuttle(int value, translation *tr)
gettimeofday(&last_shuttle, 0); gettimeofday(&last_shuttle, 0);
need_synthetic_shuttle = value != 0; need_synthetic_shuttle = value != 0;
if( value != shuttlevalue ) { if( value != shuttlevalue ) {
shuttlevalue = value; if (shuttlevalue < -7 || shuttlevalue > 7) {
// not yet initialized, assume 0
shuttlevalue = 0;
}
int direction = (value < shuttlevalue) ? -1 : 1;
int index = direction > 0 ? 1 : 0;
send_stroke_sequence(tr, KJS_SHUTTLE, value+7); send_stroke_sequence(tr, KJS_SHUTTLE, value+7);
if (fetch_stroke(tr, KJS_SHUTTLE_INCR, index)) {
while (shuttlevalue != value) {
send_stroke_sequence(tr, KJS_SHUTTLE_INCR, index);
shuttlevalue += direction;
}
} else
shuttlevalue = value;
} }
} }
} }