Browse Source

no repeatable presses

master
Alexander Yakovlev 5 years ago
parent
commit
0b71eb99a9
  1. 10
      src/init.coffee

10
src/init.coffee

@ -6,10 +6,10 @@ selectUp = (event, button) ->
return
$(".options li").removeClass("active")
count = $(".options li").length
window.selectedoption ?= count + 1
window.selectedoption--
if window.selectedoption < 0
if window.selectedoption <= 0
window.selectedoption = count
console.log window.selectedoption
$(".options li:nth-child(#{window.selectedoption}").addClass("active")
# Select the next choice
@ -19,11 +19,11 @@ selectDown = (event, button) ->
if $(".options li").length == 0
return
$(".options li").removeClass("active")
window.selectedoption ?= -1
window.selectedoption++
count = $(".options li").length
if window.selectedoption > count
window.selectedoption = 1
console.log window.selectedoption
$(".options li:nth-child(#{window.selectedoption})").addClass("active")
selectOption = (event, button) ->
@ -38,7 +38,8 @@ joystick = () ->
if pad?
temp = new Gamepad(pad)
if temp.pressed?
$(document).trigger("press", temp.pressed)
if salet.view.gamepads[pad.id].pressed != temp.pressed
$(document).trigger("press", temp.pressed)
salet.view.gamepads[pad.id] = temp
$(document).on("viewinit", () ->
@ -59,6 +60,7 @@ $(document).on("viewinit", () ->
})
)
window.selectedoption ?= 1
$(document).on("press", selectUp)
$(document).on("press", selectDown)
$(document).on("press", selectOption)

Loading…
Cancel
Save