Disable multitouch

This commit is contained in:
Dominic Zimmer 2022-10-28 18:25:29 +02:00
parent 535cff8612
commit e9a55080bd
2 changed files with 14 additions and 3 deletions

View File

@ -11,7 +11,14 @@ const Client = () => {
const [buttonMap, setButtonMap] = useState<ButtonMap>(defaultButtonMap);
const updateButtonEvent = (button: ButtonType, state: "down" | "up") =>
() => setButtonMap((m) => ({ ...m, [button]: (state === "down") }));
() => setButtonMap((m) => {
const newMap = { ...m, [button]: (state === "down") };
if (mapToBitvector(newMap).reduce((a,b) => a+b, 0) > 1) {
return m;
} else {
return newMap;
}
});
// Send data to server

View File

@ -27,7 +27,7 @@ const TVMode = () => {
}, [])
const totalCount = useMemo(() => buttonTypeList.reduce((acc, v) => (state?.votes?.[v] ?? 0) + acc, 0), [state]);
const voteList = useMemo(() => buttonTypeList.map(b => [b, state?.votes?.[b] ?? 0] as [ButtonType, number]).sort((a, b) => a[1] < b[1] ? -1 : 1), [state]);
const voteList = useMemo(() => buttonTypeList.map(b => [b, state?.votes?.[b] ?? 0] as [ButtonType, number]).sort((a, b) => b[1] - a[1]), [state]);
return <div className="stream">
{state === undefined ?
@ -40,7 +40,11 @@ const TVMode = () => {
</div>
<div className="voting">
{voteList.flatMap(([b, numVotes], index) => numVotes === 0
? []
? [
<div className="vote" key={index}>
<span>{b}</span><span></span>
</div>
]
: [
<div className="vote" key={index}>
<span>{b}</span><span> {Math.round(numVotes / totalCount * 100) + "%"} </span>