From 1e6684044cbbe10e38e96103d250ca3c00a183a4 Mon Sep 17 00:00:00 2001 From: giongto35 Date: Fri, 12 Apr 2019 01:02:42 +0800 Subject: [PATCH] Update bit --- static/js/gameboy_controller.js | 1 + ui/gameview.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/static/js/gameboy_controller.js b/static/js/gameboy_controller.js index 04d0422b..db9c2897 100644 --- a/static/js/gameboy_controller.js +++ b/static/js/gameboy_controller.js @@ -138,6 +138,7 @@ document.body.onkeydown = function (e) { } } + // game keys setState(e, true); } }; diff --git a/ui/gameview.go b/ui/gameview.go index 5eb44633..f20d595d 100644 --- a/ui/gameview.go +++ b/ui/gameview.go @@ -69,7 +69,8 @@ func (view *GameView) ListenToInputChannel() { for { keysInBinary := <-view.inputChannel for i := 0; i < NumKeys*2; i++ { - view.keyPressed[i] = ((keysInBinary & 1) == 1) + b := ((keysInBinary & 1) == 1) + view.keyPressed[i] = (view.keyPressed[i] && b) || b keysInBinary = keysInBinary >> 1 } }