abouttreesummaryrefslogcommitdiff
diff options
context:
space:
mode:
authorJules Aguillon2023-08-26 23:37:22 +0200
committerJules Aguillon2023-08-26 23:37:22 +0200
commitf4c11d99ed589c53229bf70d31ff71b8ac3e3ef1 (patch)
tree27b9652df20b3e55e5c0168495ba1070402ee3f7
parentcf761185486db4856c911acc41aa479323b28f97 (diff)
downloadunexpected-keyboard-f4c11d99ed589c53229bf70d31ff71b8ac3e3ef1.tar.gz
unexpected-keyboard-f4c11d99ed589c53229bf70d31ff71b8ac3e3ef1.zip
Disable automatically Shift when pressing Ctrl
Automatic capitalisation might interferes with keyboard shortcuts.
-rw-r--r--srcs/juloo.keyboard2/Autocapitalisation.java7
-rw-r--r--srcs/juloo.keyboard2/Config.java1
-rw-r--r--srcs/juloo.keyboard2/KeyEventHandler.java23
-rw-r--r--srcs/juloo.keyboard2/Keyboard2View.java5
-rw-r--r--srcs/juloo.keyboard2/Pointers.java11
5 files changed, 40 insertions, 7 deletions
diff --git a/srcs/juloo.keyboard2/Autocapitalisation.java b/srcs/juloo.keyboard2/Autocapitalisation.java
index 35f5ad0..3dcdefc 100644
--- a/srcs/juloo.keyboard2/Autocapitalisation.java
+++ b/srcs/juloo.keyboard2/Autocapitalisation.java
@@ -77,6 +77,13 @@ final class Autocapitalisation
callback(true);
}
+ public void stop()
+ {
+ _should_enable_shift = false;
+ _should_update_caps_mode = false;
+ callback(true);
+ }
+
public static interface Callback
{
public void update_shift_state(boolean should_enable, boolean should_disable);
diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java
index 05a7632..b40a41c 100644
--- a/srcs/juloo.keyboard2/Config.java
+++ b/srcs/juloo.keyboard2/Config.java
@@ -359,6 +359,7 @@ final class Config
public static interface IKeyEventHandler
{
+ public void key_down(KeyValue value, boolean is_swipe);
public void key_up(KeyValue value, Pointers.Modifiers flags);
}
diff --git a/srcs/juloo.keyboard2/KeyEventHandler.java b/srcs/juloo.keyboard2/KeyEventHandler.java
index 97a6cd0..c1f0a89 100644
--- a/srcs/juloo.keyboard2/KeyEventHandler.java
+++ b/srcs/juloo.keyboard2/KeyEventHandler.java
@@ -31,6 +31,29 @@ class KeyEventHandler implements Config.IKeyEventHandler
_autocap.selection_updated(oldSelStart, newSelStart);
}
+ /** A key is being pressed. There will not necessarily be a corresponding
+ [key_up] event. */
+ public void key_down(KeyValue key, boolean isSwipe)
+ {
+ if (key == null)
+ return;
+ switch (key.getKind())
+ {
+ case Modifier:
+ // Stop auto capitalisation when activating a system modifier
+ switch (key.getModifier())
+ {
+ case CTRL:
+ case ALT:
+ case META:
+ _autocap.stop();
+ break;
+ }
+ break;
+ default: break;
+ }
+ }
+
/** A key has been released. */
public void key_up(KeyValue key, Pointers.Modifiers mods)
{
diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java
index 3f4a895..949cdab 100644
--- a/srcs/juloo.keyboard2/Keyboard2View.java
+++ b/srcs/juloo.keyboard2/Keyboard2View.java
@@ -113,7 +113,7 @@ public class Keyboard2View extends View
}
else
{
- if ((flags & KeyValue.FLAG_FAKE_PTR) != 0)
+ if ((flags & KeyValue.FLAG_FAKE_PTR) == 0)
return; // Don't remove locked pointers
_pointers.remove_fake_pointer(_shift_kv, _shift_key);
}
@@ -134,8 +134,9 @@ public class Keyboard2View extends View
return KeyModifier.modify(k, mods);
}
- public void onPointerDown(boolean isSwipe)
+ public void onPointerDown(KeyValue k, boolean isSwipe)
{
+ _config.handler.key_down(k, isSwipe);
invalidate();
vibrate();
}
diff --git a/srcs/juloo.keyboard2/Pointers.java b/srcs/juloo.keyboard2/Pointers.java
index bcab202..00a2e3b 100644
--- a/srcs/juloo.keyboard2/Pointers.java
+++ b/srcs/juloo.keyboard2/Pointers.java
@@ -172,7 +172,7 @@ public final class Pointers implements Handler.Callback
Pointer ptr = new Pointer(pointerId, key, value, x, y, mods);
_ptrs.add(ptr);
startKeyRepeat(ptr);
- _handler.onPointerDown(false);
+ _handler.onPointerDown(value, false);
}
static final int[] DIRECTION_TO_INDEX = new int[]{
@@ -263,7 +263,7 @@ public final class Pointers implements Handler.Callback
{
startSliding(ptr, dy);
}
- _handler.onPointerDown(true);
+ _handler.onPointerDown(newValue, true);
}
}
}
@@ -383,7 +383,7 @@ public final class Pointers implements Handler.Callback
{
ptr.value = kv;
ptr.flags = kv.getFlags();
- _handler.onPointerDown(true);
+ _handler.onPointerDown(kv, true);
return true;
}
// Stop repeating: Special keys
@@ -522,8 +522,9 @@ public final class Pointers implements Handler.Callback
public KeyValue modifyKey(KeyValue k, Modifiers flags);
/** A key is pressed. [getModifiers()] is uptodate. Might be called after a
- press or a swipe to a different value. */
- public void onPointerDown(boolean isSwipe);
+ press or a swipe to a different value. Down events are not paired with
+ up events. */
+ public void onPointerDown(KeyValue k, boolean isSwipe);
/** Key is released. [k] is the key that was returned by
[modifySelectedKey] or [modifySelectedKey]. */