Skip to content

Commit

Permalink
Smth
Browse files Browse the repository at this point in the history
  • Loading branch information
sergystepanov committed Jul 5, 2024
1 parent d16e353 commit b138302
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
12 changes: 6 additions & 6 deletions web/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ import {
MOUSE_MOVED,
MOUSE_PRESSED,
POINTER_LOCK_CHANGE,
pub,
RECORDING_STATUS_CHANGED,
RECORDING_TOGGLED,
REFRESH_INPUT,
SETTINGS_CHANGED,
sub,
WEBRTC_CONNECTION_CLOSED,
WEBRTC_CONNECTION_READY,
WEBRTC_ICE_CANDIDATE_FOUND,
Expand All @@ -40,6 +38,8 @@ import {
WEBRTC_SDP_ANSWER,
WEBRTC_SDP_OFFER,
WORKER_LIST_FETCHED,
pub,
sub,
} from 'event';
import {gui} from 'gui';
import {input, KEY} from 'input';
Expand Down Expand Up @@ -175,10 +175,10 @@ const startGame = () => {
)

gameList.disable()
input.retropad.disable()
input.retropad.toggle(false)
gui.show(keyButtons[KEY.SAVE]);
gui.show(keyButtons[KEY.LOAD]);
input.retropad.enable()
input.retropad.toggle(true)
};

const saveGame = debounce(() => api.game.save(), 1000);
Expand Down Expand Up @@ -430,7 +430,7 @@ const app = {
updatePlayerIndex(3);
break;
case KEY.QUIT:
input.retropad.disable()
input.retropad.toggle(false)
api.game.quit(room.id)
room.reset();
window.location = window.location.pathname;
Expand Down Expand Up @@ -504,7 +504,7 @@ sub(WEBRTC_ICE_CANDIDATE_RECEIVED, (data) => webrtc.addCandidate(data.candidate)
sub(WEBRTC_ICE_CANDIDATES_FLUSH, () => webrtc.flushCandidates());
sub(WEBRTC_CONNECTION_READY, onConnectionReady);
sub(WEBRTC_CONNECTION_CLOSED, () => {
input.retropad.disable()
input.retropad.toggle(false)
webrtc.stop();
});
sub(LATENCY_CHECK_REQUESTED, onLatencyCheck);
Expand Down
16 changes: 3 additions & 13 deletions web/js/input/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {touch} from './touch.js?v=3';
export {joystick, keyboard, pointer, retropad, touch};

const input_state = {
joystic: true,
joystick: true,
keyboard: false,
pointer: true, // aka mouse
retropad: true,
Expand All @@ -41,24 +41,14 @@ export const input = {
init,
retropad: {
...retropad,
enable: () => {
if (input_state.retropad) return
input_state.retropad = true
retropad.enable()
},
disable: () => {
if (!input_state.retropad) return
input_state.retropad = false
retropad.disable()
},
toggle: (on = true) => {
toggle(on = true) {
if (on === input_state.retropad) return
input_state.retropad = on
on ? retropad.enable() : retropad.disable()
}
},
set kbm(v) {
input_state.kbm = v
input_state.kbm = v
},
get kbm() {
return input_state.kbm
Expand Down
1 change: 0 additions & 1 deletion web/js/input/pointer.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ const trackPointer = (el, cb) => {
}
}


const handleDown = ((b = {b: null, p: true}) => (e) => {
b.b = e.button
pub(MOUSE_PRESSED, b)
Expand Down

0 comments on commit b138302

Please sign in to comment.