javelin-script.javelin-script
Pinchord · pinchord.git · Tickets · Changelog
Branches > v28.0 > 469edff > files / javelin-script.javelin-script
const true = 1;
const false = 0;
// Toggles this script and the normal Javelin lookup
const SCRIPT_ENABLED = true;
// The full mask of keys pressed in the last stroke
// Reset after the stroke ends
var pressed_keys;
// The current mask of keys pressed down
var current_keys;
// TODO The script I saw had some things masked out, I'm not really sure why?
// Gemini codes to key indices
const key_masks = [[
01 01 02 03 04 05 06 07 // S1 - RL
08 09 0a 0a 0a 0a 0b 0c // A - U
0d 0e 0f 10 11 12 13 14 // FR - SR
15 16 00 00 00 00 00 00 // DR - NUM6
00 00 00 00 00 00 00 ff // NUM7 - X1
ff ff ff ff ff ff ff ff // X2 - X9
ff ff ff ff ff ff ff ff // X10 - X17
ff ff ff ff ff ff ff ff // X18 - X25
ff // X26
]];
// Key is an index, I guess from gemini?
func on_key_press_(key) {
var mask = 1 << key_masks[key];
pressed_keys |= mask;
current_keys |= mask;
}
func on_key_press(key) {
if (SCRIPT_ENABLED) {
on_key_press_(key);
} else {
// Fall back to the default behavior
pressStenoKey(key);
}
}
func on_key_release_(key) {
var mask = 1 << key_masks[key];
current_keys &= ~mask;
// No keys are pressed down
if (current_keys == 0) {
printValue("key_mask", pressed_keys);
var text = "???";
// If it's an invalid stroke, I think just send it to Javelin to look up?
sendText(text);
// I could just have a 'simulate_steno_stroke(mask)' that sends 'pressStenoKey' and 'releaseStenoKey' over and over lol.
pressed_keys = 0;
}
}
func on_key_release(key) {
if (SCRIPT_ENABLED) {
on_key_release_(key);
} else {
// Fall back to the default behavior
releaseStenoKey(key);
}
}