diff --git a/client/worker_gesture_processing.js b/client/worker_gesture_processing.js index 026d32b..481fcee 100644 --- a/client/worker_gesture_processing.js +++ b/client/worker_gesture_processing.js @@ -50,13 +50,13 @@ async function fetchStream() { function checkSwipeDirection(json) { - if (json.left > 200 && json.right < 15 && json.up < 15 && json.down < 15) { + if (json.left > 200 && json.right < 75 && json.up < 100 && json.down < 100) { return 'left'; - } else if (json.right > 200 && json.left < 15 && json.up < 15 && json.down < 15) { + } else if (json.right > 200 && json.left < 75 && json.up < 100 && json.down < 100) { return 'right'; - } else if (json.up > 200 && json.right < 15 && json.left < 15 && json.down < 15) { + } else if (json.up > 200 && json.right < 100 && json.left < 100 && json.down < 75) { return 'up'; - } else if (json.down > 200 && json.right < 15 && json.up < 15 && json.left < 15) { + } else if (json.down > 200 && json.right < 100 && json.up < 75 && json.left < 100) { return 'down'; } else { return 'none'; diff --git a/client/workersHandling.js b/client/workersHandling.js index cbecd93..4088d41 100644 --- a/client/workersHandling.js +++ b/client/workersHandling.js @@ -48,12 +48,16 @@ gestureWorker.postMessage({ wsURL: wsGestureURL }); -eventWorker.onmessage = (event) => { +gestureWorker.onmessage = (event) => { const data = event.data; switch (data.type) { case 'gesture': - console.error(event.data.message); + if (event.data.value == 'left') { + document.getElementById('content').contentWindow.postMessage( JSON.stringify({ method: 'left' }), '*' ); + } else if (event.data.value == 'right') { + document.getElementById('content').contentWindow.postMessage( JSON.stringify({ method: 'right' }), '*' ); + } break; case 'error': console.error('Error from worker:', event.data.message);