| Author | DaveJarvis <email> |
|---|---|
| Date | 2020-08-03 18:22:23 GMT-0700 |
| Commit | 86a0b56f566211fea3c07d37d1898ce18a9a317a |
| Parent | 099d678 |
| private final AutofitLabel[] mLabels = new AutofitLabel[ LabelConfig.size() ]; | ||
| private final Map<HardwareSwitch, ResetTimer> mTimers = new HashMap<>(); | ||
| + private final Deque<HardwareSwitch> mMouseActions = new LinkedList<>(); | ||
| + private final ConsecutiveEventCounter<String> mKeyCounter; | ||
| public EventHandler( | ||
| final HardwareImages hardwareImages, final Settings userSettings ) { | ||
| mHardwareImages = hardwareImages; | ||
| + mKeyCounter = new ConsecutiveEventCounter<>( userSettings.getKeyCount() ); | ||
| final var keyColour = KEY_COLOURS.get( SWITCH_PRESSED ); | ||
| ); | ||
| } | ||
| - | ||
| - private final Deque<HardwareSwitch> mMouseActions = new LinkedList<>(); | ||
| /** | ||
| updateMouseStatus( switchState ); | ||
| + // There are no "stop scrolling" events, so clear the scroll indicator | ||
| + // after a few moments of inactivity. | ||
| if( hwSwitch.isScroll() ) { | ||
| timer.addActionListener( | ||
| ( action ) -> { | ||
| - final var sauce = e.getSource(); | ||
| + final var source = e.getSource(); | ||
| final var name = e.getPropertyName(); | ||
| final var event = new PropertyChangeEvent( | ||
| - sauce, name, true, false ); | ||
| + source, name, true, false ); | ||
| update( event ); | ||
| getHardwareComponent( switchState ).setState( switchState ); | ||
| } | ||
| - | ||
| - private final ConsecutiveEventCounter<String> mKeyCounter = | ||
| - new ConsecutiveEventCounter<>( 9 ); | ||
| /** | ||
| } | ||
| - private boolean isPrefix( final String key ) { | ||
| - return name().startsWith( key ); | ||
| - } | ||
| - | ||
| /** | ||
| * Looks up the key that matches the given name, case-insensitively. | ||
| public String toString() { | ||
| return mName; | ||
| + } | ||
| + | ||
| + private boolean isPrefix( final String key ) { | ||
| + return name().startsWith( key ); | ||
| } | ||
| } | ||
| LABEL_REGULAR_NUM_SUPERSCRIPT( TOP, LEFT ), | ||
| LABEL_REGULAR_COUNTER( TOP, RIGHT ), | ||
| - LABEL_MOUSE_OTHER( MOUSE_EXTRA ); | ||
| + LABEL_MOUSE_EXTRA( MOUSE_EXTRA ); | ||
| /** |
| description = | ||
| "Application height (${DEFAULT-VALUE} pixels)", | ||
| - paramLabel = "height", | ||
| + paramLabel = "pixels", | ||
| defaultValue = "100" | ||
| ) | ||
| description = | ||
| "Regular key release delay (${DEFAULT-VALUE} milliseconds)", | ||
| - paramLabel = "delay", | ||
| + paramLabel = "ms", | ||
| defaultValue = "250" | ||
| ) | ||
| description = | ||
| "Modifier key release delay (${DEFAULT-VALUE} milliseconds)", | ||
| - paramLabel = "delay", | ||
| + paramLabel = "ms", | ||
| defaultValue = "150" | ||
| ) | ||
| description = | ||
| "Mouse button release delay (${DEFAULT-VALUE} milliseconds)", | ||
| - paramLabel = "delay", | ||
| + paramLabel = "ms", | ||
| defaultValue = "100" | ||
| ) | ||
| private int mDelayMouseButton = 100; | ||
| + | ||
| + /** | ||
| + * Milliseconds to wait before releasing (clearing) a mouse scroll event. | ||
| + */ | ||
| + @CommandLine.Option( | ||
| + names = {"-c", "--key-counter"}, | ||
| + description = | ||
| + "Count repeated key presses (${DEFAULT-VALUE} times)", | ||
| + paramLabel = "number", | ||
| + defaultValue = "9" | ||
| + ) | ||
| + private int mKeyCount = 9; | ||
| /** | ||
| * Milliseconds to wait before releasing (clearing) a mouse scroll event. | ||
| */ | ||
| @CommandLine.Option( | ||
| names = {"-s", "--delay-scroll"}, | ||
| description = | ||
| "Mouse scroll release delay (${DEFAULT-VALUE} milliseconds)", | ||
| - paramLabel = "delay", | ||
| + paramLabel = "ms", | ||
| defaultValue = "300" | ||
| ) | ||
| public int getDelayMouseScroll() { | ||
| return mDelayMouseScroll; | ||
| + } | ||
| + | ||
| + public int getKeyCount() { | ||
| + return mKeyCount < 2 ? 2 : mKeyCount; | ||
| } | ||
| Delta | 33 lines added, 17 lines removed, 16-line increase |
|---|