Skip to content

Commit 0076f04

Browse files
Greek accent/dead key support (#1240)
Greek accent/dead key support: simplify by making every combining accent key a dead key --------- Co-authored-by: Helium314 <[email protected]>
1 parent 4638709 commit 0076f04

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

Diff for: app/src/main/assets/layouts/greek.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
{ "label": "η" },
2424
{ "label": "ξ" },
2525
{ "label": "κ" },
26-
{ "label": "λ" }
26+
{ "label": "λ" },
27+
{ "$": "shift_state_selector",
28+
"shiftedManual": { "code": 776, "label": "¨" },
29+
"default": { "code": 769, "label": "´" }
30+
}
2731
],
2832
[
2933
{ "label": "ζ" },

Diff for: app/src/main/java/helium314/keyboard/event/Event.kt

+8-1
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,19 @@ class Event private constructor(
146146
}
147147

148148
// This creates an input event for a dead character. @see {@link #FLAG_DEAD}
149-
fun createDeadEvent(codePoint: Int, keyCode: Int, metaState: Int, next: Event?): Event { // TODO: add an argument or something if we ever create a software layout with dead keys.
149+
fun createDeadEvent(codePoint: Int, keyCode: Int, metaState: Int, next: Event?): Event {
150150
return Event(EVENT_TYPE_INPUT_KEYPRESS, null, codePoint, keyCode, metaState,
151151
Constants.EXTERNAL_KEYBOARD_COORDINATE, Constants.EXTERNAL_KEYBOARD_COORDINATE,
152152
null, FLAG_DEAD, next)
153153
}
154154

155+
// This creates an input event for a dead character. @see {@link #FLAG_DEAD}
156+
@JvmStatic
157+
fun createSoftwareDeadEvent(codePoint: Int, keyCode: Int, metaState: Int, x: Int, y: Int, next: Event?): Event {
158+
return Event(EVENT_TYPE_INPUT_KEYPRESS, null, codePoint, keyCode, metaState, x, y,
159+
null, FLAG_DEAD, next)
160+
}
161+
155162
/**
156163
* Create an input event with nothing but a code point. This is the most basic possible input
157164
* event; it contains no information on many things the IME requires to function correctly,

Diff for: app/src/main/java/helium314/keyboard/latin/LatinIME.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -1496,7 +1496,15 @@ public void onCodeInput(final int codePoint, final int metaState, final int x, f
14961496
// this transformation, it should be done already before calling onEvent.
14971497
final int keyX = mainKeyboardView.getKeyX(x);
14981498
final int keyY = mainKeyboardView.getKeyY(y);
1499-
final Event event = createSoftwareKeypressEvent(codePoint, metaState, keyX, keyY, isKeyRepeat);
1499+
final Event event;
1500+
1501+
// checking if the character is a combining accent
1502+
if (0x300 <= codePoint && codePoint <= 0x35b) {
1503+
event = Event.createSoftwareDeadEvent(codePoint, 0, metaState, x, y, null);
1504+
} else {
1505+
event = createSoftwareKeypressEvent(codePoint, metaState, keyX, keyY, isKeyRepeat);
1506+
}
1507+
15001508
onEvent(event);
15011509
}
15021510

0 commit comments

Comments
 (0)