Skip to content

Commit

Permalink
long press start
Browse files Browse the repository at this point in the history
  • Loading branch information
thewh1teagle committed Nov 19, 2023
1 parent 2795a46 commit 6686bfd
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
3 changes: 3 additions & 0 deletions desktop/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ fn press(controller: State<'_, Controller>, key: &str) {
"PG_DN" => {
controller.key_down(Key::PageDown);
},
"F5" => {
controller.key_down(Key::F5);
}
_ => {}
}
}
Expand Down
1 change: 1 addition & 0 deletions desktop/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ enum Action {
VOL_DN,
PG_UP,
PG_DN,
F5
}

interface Message {
Expand Down
9 changes: 9 additions & 0 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"peerjs": "^1.5.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"use-long-press": "^3.2.0",
"uuid": "^9.0.1"
},
"devDependencies": {
Expand Down
17 changes: 14 additions & 3 deletions web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Peer, { DataConnection } from "peerjs";
import { useEffect, useState } from "react";
import NoSleep from "nosleep.js";
import { v4 as uuidv4 } from 'uuid';

import { useLongPress } from 'use-long-press';
const noSleep = new NoSleep();


Expand All @@ -11,6 +11,7 @@ enum Action {
VOL_DN,
PG_UP,
PG_DN,
F5
}
interface Message {
action: Action;
Expand All @@ -19,6 +20,8 @@ interface Message {


function App() {


const params = new URLSearchParams(window.location.search);
const [loading, setLoading] = useState(true);
const [id,] = useState(uuidv4())
Expand All @@ -27,7 +30,7 @@ function App() {
const [conn, setConn] = useState<DataConnection | null>(null);

function sendMessage(data: Message) {
navigator.vibrate(100)
navigator.vibrate(300)
if (!noSleep.isEnabled) {
console.log('No sleep enabled')
noSleep.enable()
Expand All @@ -47,6 +50,10 @@ function App() {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const nextButtonBind = useLongPress(() => {
sendMessage({ action: Action.F5 })
});

if (loading) {
return (
<div className="flex flex-col gap-5 w-[100vw] h-[100vh] items-center justify-center">
Expand All @@ -59,7 +66,7 @@ function App() {
return (
<div className="w-full h-[100vh]">
<div className="flex flex-col gap-1 items-center h-full">
<div className="flex gap-3 items-center mt-52">
<div className="flex gap-3 items-center mt-20">
<button
className="btn btn-circle w-[100px] h-[100px]"
onClick={() => sendMessage({ action: Action.VOL_UP })}
Expand Down Expand Up @@ -100,7 +107,11 @@ function App() {
</button>
</div>
<div className="flex flex-col gap-5 mt-auto items-center mb-[35%]">



<button
{...nextButtonBind()}
onClick={() => sendMessage({ action: Action.PG_DN })} // next
className="btn btn-circle w-[150px] h-[150px]"
>
Expand Down

0 comments on commit 6686bfd

Please sign in to comment.