Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion _start.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import QtQuick 2.5
import QtQuick.Window 2.2
import QtQuick.Controls 2.5

import net.asivery.AppLoad 1.0

Window {
visible: true
title: qsTr("AppLoad - PC emulator")
Expand Down Expand Up @@ -30,7 +32,24 @@ Window {

anchors.centerIn: parent

onLoaded: loader.item.visible = true
onLoaded: {
loader.item.visible = true;
loader.item.virtualKeyboardRef = keyboardLoader;
}
}
}
Loader {
property var layout: null
property var config: null
id: keyboardLoader
source: "qrc:/appload/qml/virtualKeyboard/Keyboard.qml"
active: false
width: parent.width
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter

onLoaded: () => {
keyboardLoader.item.rebuildKeyboard(keyboardLoader.layout, keyboardLoader.config);
}
}
}
6 changes: 4 additions & 2 deletions appload.pro
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ TARGET = appload
TEMPLATE = app

SOURCES += src/main.cpp src/management.cpp src/AppLoad.cpp src/AppLoadCoordinator.cpp src/library.cpp src/libraryexternals.cpp \
src/qtfb/fbmanagement.cpp src/qtfb/FBController.cpp
src/qtfb/fbmanagement.cpp src/qtfb/FBController.cpp \
src/keyboard/layout.cpp

HEADERS += src/AppLoad.h src/AppLoadCoordinator.h src/library.h src/AppLibrary.h \
src/qtfb/FBController.h src/qtfb/fbmanagement.h src/Launcher.h
src/qtfb/FBController.h src/qtfb/fbmanagement.h \
src/keyboard/layout.h src/Launcher.h

RESOURCES += resources/resources.qrc
1 change: 1 addition & 0 deletions resources/icons/keyboard.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/keyboard/backspace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 78 additions & 0 deletions resources/keyboard/default.layout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
[
[
["esc", 27, "", 0],
[">", 62, "<", 60],
["|", 124, "&", 38],
["!", 33, "?", 63],
["\"", 34, "$", 36],
["'", 39, "`", 96],
["_", 95, "@", 64],
["=", 61, "~", 126],
["/", 47, "\\", 92],
["*", 42, "del", 127],
[":backspace", 128, "", 0]
],
[
[":tab", 9, "", 0],
["1", 49, "+", 43],
["2", 50, "^", 94],
["3", 51, "#", 35],
["4", 52, "%", 37],
["5", 53, "(", 40],
["6", 54, ")", 41],
["7", 55, "[", 91],
["8", 56, "]", 93],
["9", 57, "{", 123],
["0", 48, "}", 125]
],
[
["q", 81, "", 0],
["w", 87, "", 0],
["e", 69, "", 0],
["r", 82, "", 0],
["t", 84, "", 0],
["y", 89, "", 0],
["u", 85, "", 0],
["i", 73, "", 0],
["o", 79, "", 0],
["p", 80, "", 0],
[":enter", 13, "", 0]
],
[
["a", 65, "", 0],
["s", 83, "", 0],
["d", 68, "", 0],
["f", 70, "", 0],
["g", 71, "", 0],
["h", 72, "", 0],
["j", 74, "", 0],
["k", 75, "", 0],
["l", 76, "", 0],
[":", 58, "", 0],
["pgup", 129, "home", 135]
],
[
[":shift", 1048576, "", 0],
["z", 90, "", 0],
["x", 88, "", 0],
["c", 67, "", 0],
["v", 86, "", 0],
["b", 66, "", 0],
["n", 78, "", 0],
["m", 77, "", 0],
[";", 59, "", 0],
[":up", 132, "", 0],
["pgdn", 130, "end", 136]
],
[
["ctrl", 2097152, "", 0],
["alt", 4194304, "", 0],
["-", 45, "", 0],
[",", 44, "", 0],
[" ", 32, "", 0, 3],
[".", 46, "", 0],
[":left", 133, "", 0],
[":down", 131, "", 0],
[":right", 134, "", 0]
]
]
Binary file added resources/keyboard/down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/keyboard/enter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/keyboard/left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/keyboard/menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/keyboard/right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/keyboard/shift.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/keyboard/tab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/keyboard/up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions resources/qml/appload.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Rectangle {

property var windowArchetype: Qt.createComponent("window.qml")
property var absoluteRoot: _appLoadView
property var virtualKeyboardRef: null

signal requestClose

Expand Down Expand Up @@ -56,8 +57,11 @@ Rectangle {

win.appName = modelData.name;
win.supportsScaling = modelData.supportsScaling;
win.virtualKeyboardLayout = modelData.virtualKeyboardLayout;
win.disablesWindowedMode = modelData.disablesWindowedMode;

win.virtualKeyboardRef = _appLoadView.virtualKeyboardRef;

win.globalWidth = Qt.binding(function() { return _appLoadView.width; })
win.globalHeight = Qt.binding(function() { return _appLoadView.height; })
let deviceAspectRatio, applicationAspectRatio = modelData.aspectRatio;
Expand Down
211 changes: 211 additions & 0 deletions resources/qml/virtualKeyboard/Key.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
/*
Copyright 2011-2012 Heikki Holstila <heikki.holstila@gmail.com>

This work is free software. you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This work is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this work. If not, see <http://www.gnu.org/licenses/>.
*/

import QtQuick 2.0

Rectangle {
id: key
required property var vkb

property string label
property string label_alt
property int code
property int code_alt
property int currentCode: (shiftActive && label_alt != '') ? code_alt : code
property string currentLabel: (shiftActive && label_alt != '') ? label_alt : label
property bool sticky // can key be stickied?
property bool becomesSticky // will this become sticky after release?
property int stickiness // current stickiness status
property real labelOpacity: 1.0

// mouse input handling
property int clickThreshold: 20
property bool isClick
property int pressMouseY
property int pressMouseX
property bool shiftActive: (vkb.keyModifiers & 0x100000) && !sticky

width: vkb.keyWidth // some default
height: vkb.keyHeight
color: label=="" ? "transparent" : vkb.keyBgColor
border.color: label=="" ? "transparent" : vkb.keyBorderColor
border.width: 1
radius: 2

Image {
id: keyImage
anchors.centerIn: parent
opacity: key.labelOpacity
source: { if(key.label.length>1 && key.label.charAt(0)==':') return "qrc:/appload/keyboard/"+key.label.substring(1)+".png"; else return ""; }
}

Column {
visible: keyImage.source == ""
anchors.centerIn: parent
spacing: -17

Text {
id: keyAltLabel
property bool highlighted: key.shiftActive

anchors.horizontalCenter: parent.horizontalCenter

text: key.label_alt
color: vkb.keyFgColor

opacity: key.labelOpacity * (highlighted ? 1.0 : 0.2)
Behavior on opacity { NumberAnimation { duration: 100 } }

font.pointSize: 24 * (text.length > 1 ? 0.5 : 1.0)
Behavior on font.pointSize { NumberAnimation { duration: 100 } }
}

Text {
id: keyLabel
property bool highlighted: key.label_alt == '' || !key.shiftActive

anchors.horizontalCenter: parent.horizontalCenter

text: {
if (key.label.length == 1 && key.label_alt == '') {
if (key.shiftActive) {
return key.label.toUpperCase();
} else {
return key.label.toLowerCase();
}
}

return key.label;
}

color: vkb.keyFgColor

opacity: key.labelOpacity * (highlighted ? 1.0 : 0.2)
Behavior on opacity { NumberAnimation { duration: 100 } }

font.pointSize: 24 * (text.length > 1 ? 0.5 : 1.0)
Behavior on font.pointSize { NumberAnimation { duration: 100 } }
}
}

Rectangle {
id: stickIndicator
visible: sticky && stickiness>0
color: vkb.keyHilightBgColor
anchors.fill: parent
radius: key.radius
opacity: 0.5
anchors.topMargin: key.height/2
}

function handlePress(touchArea, x, y) {
console.log("Press " + label)
isClick = true;
pressMouseX = x;
pressMouseY = y;

key.color = vkb.keyHilightBgColor

vkb.config.keyDown(currentCode | vkb.keyModifiers);

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

function handleMove(touchArea, x, y) {
var mappedPoint = key.mapFromItem(touchArea, x, y)
if (!key.contains(Qt.point(mappedPoint.x, mappedPoint.y))) {
key.handleRelease(touchArea, x, y);
return false;
}

if (key.isClick) {
if (Math.abs(x - key.pressMouseX) > key.clickThreshold
|| Math.abs(y - key.pressMouseY) > key.clickThreshold) {
key.isClick = false
}
}

return true;
}

function handleRelease(touchArea, x, y) {
key.color = vkb.keyBgColor

if (sticky && !becomesSticky) {
vkb.keyModifiers &= ~code
vkb.currentStickyPressed = null
}
if(!sticky) {
vkb.config.keyUp(currentCode | vkb.keyModifiers);
}

if (vkb.keyAt(x, y) == key) {
if (key.sticky && key.becomesSticky) {
setStickiness(-1)
}

// first non-sticky press will cause the sticky to be released
if (!sticky && vkb.resetSticky && vkb.resetSticky !== key) {
resetSticky.setStickiness(0)
}
}
}

function setStickiness(val)
{
if(sticky) {
if( vkb.resetSticky && vkb.resetSticky !== key ) {
resetSticky.setStickiness(0)
}

if(val===-1)
stickiness = (stickiness+1) % 3
else
stickiness = val

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

if(stickiness>0) {
vkb.keyModifiers |= code
} else {
vkb.config.keyUp(currentCode);
vkb.keyModifiers &= ~code
}

vkb.resetSticky = null

if(stickiness==1) {
stickIndicator.anchors.topMargin = key.height/2
vkb.resetSticky = key
} else if(stickiness==2) {
stickIndicator.anchors.topMargin = 0
}
}
}
}
Loading