mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-07-14 04:42:07 +08:00
64e785d00f
* remove webjoystick components that no longer work * remove audio track request
21 lines
466 B
JavaScript
21 lines
466 B
JavaScript
const keyVals = {w: 0, a: 0, s: 0, d: 0}
|
|
|
|
export function getXY() {
|
|
let x = -keyVals.w + keyVals.s
|
|
let y = -keyVals.d + keyVals.a
|
|
return {x, y}
|
|
}
|
|
|
|
export const handleKeyX = (key, setValue) => {
|
|
if (['w', 'a', 's', 'd'].includes(key)){
|
|
keyVals[key] = setValue;
|
|
let color = "#333";
|
|
if (setValue === 1){
|
|
color = "#e74c3c";
|
|
}
|
|
$("#key-"+key).css('background', color);
|
|
const {x, y} = getXY();
|
|
$("#pos-vals").text(x+","+y);
|
|
}
|
|
};
|