Skip to content

Commit

Permalink
[vkb] Multi-touch handling for modifier keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Perl committed Sep 20, 2013
1 parent 48f73a7 commit a787276
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
28 changes: 27 additions & 1 deletion qml/Key.qml
Expand Up @@ -28,6 +28,7 @@ Rectangle {
property int currentCode: code
property string currentLabel: keyLabel.text
property bool sticky: false // can key be stickied?
property bool becomesSticky: false // will this become sticky after release?
property int stickiness: 0 // current stickiness status

// mouse input handling
Expand Down Expand Up @@ -110,6 +111,18 @@ Rectangle {
util.keyPressFeedback();

keyRepeatStarter.start();

if (sticky) {
keyboard.keyModifiers |= code;
key.becomesSticky = true;
keyboard.currentStickyPressed = key;
} else {
if (keyboard.currentStickyPressed != null) {
// Pressing a non-sticky key while a sticky key is pressed:
// the sticky key will not become sticky when released
keyboard.currentStickyPressed.becomesSticky = false;
}
}
}

function handleMove(touchArea, x, y) {
Expand Down Expand Up @@ -143,12 +156,21 @@ Rectangle {
window.wakeVKB();
}

if (sticky) {
keyboard.keyModifiers &= ~code
keyboard.currentStickyPressed = null;
}

if (vkb.keyAt(x, y) == key) {
util.keyReleaseFeedback();

setStickiness(-1);
if (key.sticky && key.becomesSticky) {
setStickiness(-1);
}

window.vkbKeypress(currentCode, keyboard.keyModifiers);

// first non-sticky press will cause the sticky to be released
if( !sticky && keyboard.resetSticky != 0 && keyboard.resetSticky !== key ) {
resetSticky.setStickiness(0);
}
Expand Down Expand Up @@ -189,6 +211,10 @@ Rectangle {
else
stickiness = val

// stickiness == 0 -> not pressed
// stickiness == 1 -> release after next keypress
// stickiness == 2 -> keep pressed

if(stickiness>0) {
keyboard.keyModifiers |= code
} else {
Expand Down
1 change: 1 addition & 0 deletions qml/Keyboard.qml
Expand Up @@ -28,6 +28,7 @@ Rectangle {

property int keyModifiers: 0
property variant resetSticky: 0
property variant currentStickyPressed: null
property variant currentKeyPressed: 0

property string keyFgColor: "#565656"
Expand Down

0 comments on commit a787276

Please sign in to comment.