abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Pointers.java
AgeCommit message (Collapse)AuthorFilesLines
2025-03-29Restore previous swipe sensibilityJules Aguillon1-4/+12
The distance at which a swipe was considered successful was reduced in 188c682 to allow making circle gestures on a key that also had a slider. It was also useful in reducing accidental sliding. This is impractical for normal typing so it is reverted. The reduced range continues to be used for sliders.
2025-01-25Slightly less permissive swipe detectionJules Aguillon1-2/+3
This allows starting an anticircle gesture on a key with sliders on two opposite sides.
2025-01-18Vibrate when a circle gesture endsJules Aguillon1-0/+1
This is especially useful when discovering the circle gestures and to feel when a gesture has been entered by accident.
2025-01-11Allow sliders in every directionsJules Aguillon1-16/+27
Sliders are no longer limited to the x dimension and can be placed in corners or purely on the y dimension.
2025-01-11Remove the 'slider="true"' attributeJules Aguillon1-1/+1
Whether a key behaves as a slider is now purely defined by the key values present on it.
2025-01-11Refactor: Restrict sliders to new 'Slider' key kindJules Aguillon1-45/+17
Setting 'slider="true"' on a key is no longer enough to make a slider, the key must also be of kind 'Slider'. Only the KeyValue that started sliding is now considered, they can be generated with negative values. This allows keys that don't have the complementary cursor movement key on the opposite direction. This will help implement other kind of sliders as well as up/down sliders.
2025-01-11More precise 1-position movement with space bar sliderJules Aguillon1-9/+24
Moving the cursor by 1 position is hard because the finger has to travel far enough to activate the slider but then becomes very sensitive. With this change, swiping on the space bar slider will immediately move the cursor by 1 position but the slider will activate only if the finger travel an other swiping distance.
2024-12-31Don't double tap for capslock after automatic capitalisationJules Aguillon1-1/+2
Allow to more easily disable automatic capitalisation when it's unwanted.
2024-12-31Refactor: Simplify double tap for capslockJules Aguillon1-12/+20
This doesn't fix a bug but remove some tricky code. The shift key is no longer different when the "double tap for capslock" option is on. The handling of the option is moved to Pointer instead and becomes simpler.
2024-11-17Automatic Shift should be disabled when pressing CtrlJules Aguillon1-1/+1
This was caused by a programming error.
2024-06-30Option to disable key repeatJules Aguillon1-34/+32
Internally "key repeat" is reword into "long press" when the same mechanism was used for both features. The constraint that 'timeoutWhat' must be set to '-1' when no message is expected has been lifted to simplify the code.
2024-06-22Don't stop keyrepeat after a circle gestureJules Aguillon1-1/+0
This was inconsistent with the anticircle and roundtrip gestures.
2024-05-29Configure anticircle gesture per-key (#644)Jules Aguillon1-1/+1
This adds the new 'anticircle' attribute to layouts '<key>' elements that configure the key to send when doing a anti-clockwise circle gesture on it. Labels are drawn the same way as indication. Updated docs.
2024-05-25Circle and round trip gestures (#640)Jules Aguillon1-34/+110
This implements clockwise/anticlockwise circle and round trip gestures inspired by Messagease. The circle gestures start after a small threshold to avoid making the regular swipe too hard to aim. The gestures do: - circle: The center symbol with Shift applied, with a fallback on Fn - round trip: Same as the circle gesture but applied to a side symbol - anticlockwise circle: Nothing currently. It is intended to be made configurable per-layout in the future. The new Gesture class keeps track of what the pointer is doing while it moves on a key. It replaces the 'selected_direction' integer.
2024-05-02More precise and faster spacebar slider (#593)Jules Aguillon1-36/+97
* Make slider speed independent from swipe distance Swipe distances other than the default resulted in a slider that were not easy to control. * refactor: Add class Pointers.Sliding It holds the states and the code needed to make the slider work. 'Pointer.sliding' is set to [null] when sliding is not in progress. The implementation is changed not to depend on [downX] and [dx] but instead use the pointer's [x] coordinate directly. * Move the cursor further for faster slides In sliding mode, compute the speed of the pointer and use it to increase at which the cursor moves. * refactor: Separate kind for cursor movement keys This allows to define a key that moves the cursor more than one position at a time. This will be used to avoid lag during fast slider movements. * Reduce lag when sliding quickly on the spacebar Avoid sending key events in a loop while sliding quickly in a cursor movement key. Key of kind Cursor_move are "multiplied", meaning a single key event represents a movement of more than one position, reducing the number of key events sent. This is only for cursor move keys.
2024-03-18refactor: Implement Compose without global stateJules Aguillon1-1/+14
Thanks to the previous commit, a modifier key can now be more complex than just a KeyValue.Modifier. This allows a more elegant implementation of the compose key, that could be taken as a base for other features (eg. unicode hex entry, hangul) The COMPOSE_PENDING modifier is removed as keys of kind Compose_pending can act as a modifier. This has the advantage of highlighting the key that was last pressed in the sequence. Rules are added to Pointers: Non-special but latchable keys must clear latches and cannot be locked with a long press. These rules were not needed before but were intended.
2024-03-18refactor: Allow modifier of other key kindsJules Aguillon1-15/+25
Allow keys of a kind other than Modifier to be a modifier. This requires writing a compareTo function for KeyValue. Fields are compared in this order: Kind, value, flags, symbol.
2024-03-11refactor: Pointers: Flag for sliding stateJules Aguillon1-7/+5
2024-03-11refactor: Add latched flag to PointersJules Aguillon1-8/+14
2024-03-11refactor: Use internal flags in PointersJules Aguillon1-36/+39
'FLAG_LOCKED' and 'FLAG_FAKE_PTR' are only used within Pointers. Define new flags in Pointers and remove these from KeyValue. Also allows to define new flags.
2024-03-03Fix auto-capitalisation disabling locked shiftJules Aguillon1-9/+33
Shift locked via the "caps lock" key use the "fake pointer" mechanism that is also used by auto-capitalisation. Make sure that unlatching a fake pointer do not disabled a locked modifier. The implementation is moved into the Pointers class for a safer API and easier implementation.
2024-02-17compose: Grey out keys that are not in sequenceJules Aguillon1-1/+1
Keys that are not in the pending compose sequence are greyed out with the new 'FLAG_GREYED' flag.
2024-01-26Send down event for modifiers on timeJules Aguillon1-1/+65
This allows to use modifiers in combination with other inputs like a mouse click, for example under termux-x11. The key down event and notification about modifiers changing are sent down to KeyEventHandler. A mutable state remember for which modifier down events have been sent. When pressing down a modifier with one finger and typing with the other, it might appear that the modifier is released after the first time an other key is pressed and then pressed and released for the following keys. This prevents unintentionally type two modified keys instead of one when the second key is pressed while the other is not yet released.
2023-08-26Disable automatically Shift when pressing CtrlJules Aguillon1-5/+6
Automatic capitalisation might interferes with keyboard shortcuts.
2023-06-03Per-layout shift modmapJules Aguillon1-0/+4
Specify the behavior of shift for a layout. This is intended for locales that use the same alphabet but have different capital letters (eg. Bengali). The modmap is defined like this: <keyboard> <modmap> <shift a="a" b="A"/> </modmap> </keyboard>
2023-04-10Do not lock modifiers if sliding a keydoak1-0/+1
This unconditionally removes all pointers (touches) pressing modifiers which are not already locked, avoiding that the (currently) latched modifier will be locked aventually. This can be verfified while sliding the space bar to move the cursor left or right. Closes #319.
2023-03-13Correct pointer directionJules Aguillon1-3/+5
The previous algorithm did not cut the circle into 16 equal parts. The division by 2pi yielded numbers smaller than 16, which no longer made sense after the cast to int.
2023-03-05Refactor: Remove KeyboardData.CornerJules Aguillon1-15/+6
The Corner class is removed. The "localized" flag for all the corners is held in a bitfield.
2023-03-03Allow 8 symbols per keyJules Aguillon1-40/+43
'Keyboard.Key' now contains an array of size 9, giving each keyvalue an index. The algorithm for finding the nearest key during a swipe now needs 16 segments, which are now calculated as an angle. The algorithm does one more interation instead of 2 more, slightly reducing the sensitivity of corner values. The 'getAtDirection' function is moved into the Pointers class to clearly separate the two systems. The 'edgekey' attribute is now obsolete but is kept for compatibility. The flag is removed internally, key index are simply translated. Similarly, the 'slider' attribute now act on keys at index 5 and 6 instead of 2 and 3.
2023-03-02Fix caps lock stopped by auto-capitalisationJules Aguillon1-3/+11
Auto-capitalisation triggers when the backspace key is used. Make sure to not remove a locked shift pointer.
2023-02-12Modify keys after a long pressJules Aguillon1-3/+14
2023-02-08Fix arrow keys not repeatingJules Aguillon1-2/+0
The special handling of arrow keys have been removed in 854eff2. Key repeat was not starting when the key0 was empty.
2023-01-29Don't send event at end of slidingJules Aguillon1-0/+13
A sliding pointer going up must not cause a key event to be sent. This caused an extra cursor movement and cleared the latched modifiers.
2023-01-22Move cursor by sliding on the space barJules Aguillon1-3/+62
Send key events for the left or right arrow as the finger slides on the space bar. Can be used to select text by holding shift. Works under Termux. Events are sent linearly as the finger travels. The distance between each events is defined from the swiping distance divided by 4. 'slider="true"' can be set on a key that have 'edgekeys="true"'. 'key2' and 'key3' represent the right and left keys.
2023-01-22Remove the modulated repeatJules Aguillon1-56/+3
It allowed to modulate the repeat speed of some keys (arrow, backspace, delete) by move the finger farther or closer to the key. In practice, this wasn't pratical and doesn't seem popular. It is removed in favor of a better mechanism for moving the cursor.
2022-12-04Correctly handle pointer cancel eventsJules Aguillon1-6/+4
The cancel event ends the motion, it doesn't apply to a single pointer like it was previously expected.
2022-11-26Make fake pointers not lockableJules Aguillon1-3/+3
Especially annoying now that modifiers are not locked by a double tap.
2022-11-06Fix adding two pointers for the same keyJules Aguillon1-1/+2
2022-10-23Add the capslock keyJules Aguillon1-5/+6
The key enable caps lock immediately. It does nothing if caps lock is already enabled. It is not present on the keyboard by default but a place is defined on every layout, top-right of the shift key. It can be enabled in the settings. The icon is from materialdesignicons.com.
2022-07-30Fix auto-capitalisation interfering with caps lockJules Aguillon1-2/+2
Add a flag to recognize fake pointers and avoid clearing the intentionally locked shift key.
2022-07-24Hold any modifier to lockJules Aguillon1-25/+50
Modifiers can be locked with a long press. The key repeat mechanism is re-used and the press timeout is the same. Every modifiers can be locked that way, not only the "lockable" ones. The previous behavior can be enabled in the settings (for shift only) but the default is changed.
2022-07-24Automatic capitalisation at beginning of sentencesJules Aguillon1-2/+23
Keep track of end-of-sentence characters while typing and automatically enable shift when appropriate. The last few characters just before the cursor need to be queried in some cases: Begin of input, cursor has moved or text is deleted. This might have a performance cost. This normally only enable shift but it also needs to disable shift when the cursor moves.
2022-07-03Compatibility with API level < 24Jules Aguillon1-1/+1
The Math.floorMod method was added on API level 24.
2022-06-24Fix localized key not in predefined positionJules Aguillon1-2/+9
The "loc " prefix for predefining a place for an "extra key" was broken since 31d6a70. The FLAG_LOCALIZED flag cannot be used anymore, as adding it to any key would turn it into a different key that wouldn't be recognized by parts of the code comparing the keys (placing the extra keys). Add an other layer in KeyboardData to store such informations.
2022-06-06Refactor: Remove KeyValue.nameJules Aguillon1-6/+3
This makes KeyValue objects smaller. 'equals' and 'hashCode' are now implemented too. Key names are still used to recognise keys with special meaning, but not for comparing keys anymore.
2022-06-05Refactor: Separate Events and Keyevents and use enumsJules Aguillon1-20/+22
Negative values for internal events are preventing further refactoring. Add a new kind of key and split internal events (now Event) and Android's key events (now Keyevent). Use enums events and modifiers outside of the KeyValue class. Internally, they are converted to and from integer.
2022-06-05Refactor: Merge KeyValue.char and code fieldsJules Aguillon1-1/+1
These two fields couldn't have an interesting value at the same time. As we can no longer rely on a special value to distinguish between what's the kind, the kind of the key is explicitly encoded in the two most significative bits of the _flags field. Extra nice thing: This removes the special values 'EVENT_NONE' and 'CHAR_NONE'.
2022-06-05Refactor: Abstract KeyValue fieldsJules Aguillon1-7/+8
The meaning of the public fields of KeyValue was quite complicated and not handled consistently accross the app. Make these fields private and add a more abstract API on top. The meaning of these fields changed recently and it wasn't an easy change. I plan on making more changes in the future.
2022-06-05Stop using flags for modifiersJules Aguillon1-26/+80
There was no free bits left to add new modifiers. Instead of increasing the width of the 'flags' field, refactor the way modifiers are represented and used. Modifers are now represented as independent values and stored in the 'code' field. A flag is added to distinguish between modifiers and keys with a key event. The most notable change is that modifiers can no longer be or-ed into a single value but have to be represented as an array.
2022-05-08Find closest key furtherJules Aguillon1-1/+1
The previous limit was checking d-1 and d+1, the new limit also tries d-2 and d+2.