Skip to content

Commit

Permalink
"Typing on mobile a little better.
Browse files Browse the repository at this point in the history
Only regards to backspace behaviour I believe.

Not perfect but I think some things are improved.

Re #15"
  • Loading branch information
o0101 committed Feb 14, 2020
1 parent 1375fe6 commit 01a03f3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
4 changes: 2 additions & 2 deletions common.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ export const DEBUG = {
whether created with createTarget or simply spawning,
we must use legacy shots */
IMAGE_FORMAT, /* JPEG, PNG, or WEBP (if supported (so not Safari)) */
shotDebug: true,
shotDebug: false,
noShot: false,
dev: false,
val: 6,
val: 2,
low: 1,
med: 3,
high: 5
Expand Down
1 change: 1 addition & 0 deletions public/translateVoodooCRDP.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const DOM_DELTA_PAGE = 2;
const LINE_HEIGHT_GUESS = 32;

const SYNTHETIC_CTRL = e => keyEvent({key:'Control',originalType:e.originalType}, 2, true);
const SYNTHETIC_ENTER = () => keyEvent({key:'Enter',originalType:"keypress"}, 0, true);

let scrollShot = false;

Expand Down
13 changes: 13 additions & 0 deletions public/voodoo/src/subviews/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,26 @@ export function Controls(state) {
state.latestData = "";
} else if ( e.inputType == 'deleteContentBackward' ) {
if ( ! state.backspaceFiring ) {
H({
type: "keydown",
key: "Backspace"
});
H({
type: "keyup",
key: "Backspace"
});
if ( state.viewState.shouldHaveFocus ) {
state.viewState.shouldHaveFocus.value = "";
}
/**
H({
synthetic: true,
type: 'typing-deleteContentBackward',
event: e,
contextId: state.contextIdOfFocusedInput,
valueToDelete: state.latestCommitData,
});
**/
}
state.latestData = "";
} else if ( e.inputType == 'insertReplacementText' ) {
Expand Down
4 changes: 2 additions & 2 deletions zombie-lord/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,11 @@ const controller_api = {
retVal.frameBuffer = move([], connection.frameBuffer)
retVal.frameBuffer = retVal.frameBuffer.filter(frame => {
if ( frame.hash == connection.lastHash ) {
DEBUG.val > DEBUG.med && console.log(`DROP frame ${frame.hash}`);
DEBUG.shotDebug && DEBUG.val > DEBUG.med && console.log(`DROP frame ${frame.hash}`);
return false;
} else {
connection.lastHash = frame.hash;
DEBUG.val > DEBUG.med && console.log(`SEND frame ${frame.hash}`);
DEBUG.shotDebug && DEBUG.val > DEBUG.med && console.log(`SEND frame ${frame.hash}`);
return true;
}
});
Expand Down
10 changes: 5 additions & 5 deletions zombie-lord/screenShots.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,18 @@ export function makeCamera(connection) {
const timeNow = Date.now();
const dur = timeNow - lastShot;
if ( dur < MIN_TIME_BETWEEN_SHOTS ) {
if ( DEBUG.shotDebug || DEBUG.val > DEBUG.low ) {
if ( DEBUG.shotDebug && DEBUG.val > DEBUG.low ) {
console.log(`Dropping as duration (${dur}) too short.`);
}
return NOIMAGE;
}
if ( DEBUG.shotDebug || DEBUG.val > DEBUG.low ) {
if ( DEBUG.shotDebug && DEBUG.val > DEBUG.low ) {
console.log(`Do shot ${dur}ms`);
}
const targetId = connection.sessions.get(connection.sessionId);
let response;
const ShotCommand = (connection.isSafari || connection.isFirefox ? SAFARI_SHOT : WEBP_SHOT).command;
DEBUG.val > DEBUG.med && console.log(`XCHK screenShot.js (${ShotCommand.name}) call response`, ShotCommand, response ? JSON.stringify(response).slice(0,140) : response );
DEBUG.val > DEBUG.high && console.log(`XCHK screenShot.js (${ShotCommand.name}) call response`, ShotCommand, response ? JSON.stringify(response).slice(0,140) : response );
response = await connection.sessionSend(ShotCommand);
lastShot = timeNow;
response = response || {};
Expand All @@ -100,7 +100,7 @@ export function makeCamera(connection) {
const F = {img, frame: frameId, targetId};
F.hash = `${F.img.length}${KEYS.map(k => F.img[k]).join('')}${F.img[F.img.length-1]}`;
if ( lastHash == F.hash ) {
if ( DEBUG.shotDebug || DEBUG.val > DEBUG.low ) {
if ( DEBUG.shotDebug && DEBUG.val > DEBUG.low ) {
console.log(`Dropping as image did not change.`);
}
return NOIMAGE;
Expand All @@ -111,7 +111,7 @@ export function makeCamera(connection) {
}
} else {
DEBUG.val > DEBUG.med && console.log("Sending no frame");
if ( DEBUG.shotDebug || DEBUG.val > DEBUG.low ) {
if ( DEBUG.shotDebug && DEBUG.val > DEBUG.low ) {
console.log(`Dropping as shot produced no data.`);
}
return NOIMAGE;
Expand Down

0 comments on commit 01a03f3

Please sign in to comment.