Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
T
Taiko Web
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Taiko Web
Commits
121a8491
Commit
121a8491
authored
Aug 29, 2018
by
LoveEevee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add gamepad support
parent
64a93f14
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
93 additions
and
0 deletions
+93
-0
public/index.html
public/index.html
+1
-0
public/src/js/gamepad.js
public/src/js/gamepad.js
+86
-0
public/src/js/keyboard.js
public/src/js/keyboard.js
+6
-0
No files found.
public/index.html
View file @
121a8491
...
...
@@ -46,6 +46,7 @@
<script
type=
'application/javascript'
src=
'/src/js/view.js'
></script>
<script
type=
'application/javascript'
src=
'/src/js/bufferedloop.js'
></script>
<script
type=
'application/javascript'
src=
'/src/js/mekadon.js'
></script>
<script
type=
'application/javascript'
src=
'/src/js/gamepad.js'
></script>
</head>
<body>
...
...
public/src/js/gamepad.js
0 → 100644
View file @
121a8491
class
Gamepad
{
constructor
(
keyboard
){
var
kbd
=
keyboard
.
getBindings
()
this
.
gameBtn
=
{}
this
.
gameBtn
[
kbd
[
"
don_l
"
]]
=
[
"
u
"
,
"
d
"
,
"
l
"
,
"
r
"
]
this
.
gameBtn
[
kbd
[
"
don_r
"
]]
=
[
"
a
"
,
"
b
"
,
"
x
"
,
"
y
"
]
this
.
gameBtn
[
kbd
[
"
ka_l
"
]]
=
[
"
lb
"
,
"
lt
"
]
this
.
gameBtn
[
kbd
[
"
ka_r
"
]]
=
[
"
rb
"
,
"
rt
"
]
this
.
menuBtn
=
{}
this
.
menuBtn
[
kbd
[
"
pause
"
]]
=
[
"
start
"
]
this
.
b
=
{
"
a
"
:
"
0
"
,
"
b
"
:
"
1
"
,
"
x
"
:
"
2
"
,
"
y
"
:
"
3
"
,
"
lb
"
:
"
4
"
,
"
rb
"
:
"
5
"
,
"
lt
"
:
"
6
"
,
"
rt
"
:
"
7
"
,
"
back
"
:
"
8
"
,
"
start
"
:
"
9
"
,
"
ls
"
:
"
10
"
,
"
rs
"
:
"
11
"
,
"
u
"
:
"
12
"
,
"
d
"
:
"
13
"
,
"
l
"
:
"
14
"
,
"
r
"
:
"
15
"
,
"
guide
"
:
"
16
"
}
this
.
btn
=
{}
this
.
keyboard
=
keyboard
}
play
(
menuPlay
){
if
(
"
getGamepads
"
in
navigator
){
var
gamepads
=
navigator
.
getGamepads
()
}
else
{
return
}
var
bindings
=
menuPlay
?
this
.
menuBtn
:
this
.
gameBtn
for
(
var
i
=
0
;
i
<
gamepads
.
length
;
i
++
){
if
(
gamepads
[
i
]){
var
buttons
=
gamepads
[
i
].
buttons
this
.
toRelease
=
{}
for
(
var
i
in
bindings
){
this
.
toRelease
[
i
]
=
bindings
[
i
].
length
}
for
(
var
btnName
in
buttons
){
buttonSearch
:
{
for
(
var
bind
in
bindings
){
for
(
var
name
in
bindings
[
bind
]){
if
(
btnName
==
this
.
b
[
bindings
[
bind
][
name
]]){
this
.
checkButton
(
buttons
,
btnName
,
bind
)
break
buttonSearch
}
}
}
}
}
}
}
}
checkButton
(
buttons
,
btnName
,
keyCode
){
var
button
=
buttons
[
btnName
]
var
pressed
=
!
this
.
btn
[
btnName
]
&&
button
.
pressed
var
released
=
this
.
btn
[
btnName
]
&&
!
button
.
pressed
if
(
pressed
){
this
.
btn
[
btnName
]
=
true
}
else
if
(
released
){
delete
this
.
btn
[
btnName
]
}
if
(
pressed
){
if
(
this
.
keyboard
.
getKeys
()[
keyCode
]){
this
.
keyboard
.
setKey
(
keyCode
,
false
)
}
this
.
keyboard
.
setKey
(
keyCode
,
true
)
}
else
if
(
!
button
.
pressed
&&
this
.
keyboard
.
getKeys
()[
keyCode
]){
if
(
released
){
this
.
toRelease
[
keyCode
+
"
released
"
]
=
true
}
this
.
toRelease
[
keyCode
]
--
if
(
this
.
toRelease
[
keyCode
]
==
0
&&
this
.
toRelease
[
keyCode
+
"
released
"
]){
this
.
keyboard
.
setKey
(
keyCode
,
false
)
}
}
}
}
public/src/js/keyboard.js
View file @
121a8491
...
...
@@ -18,6 +18,8 @@ function Keyboard(controller){
return
_kbd
}
var
_gamepad
=
new
Gamepad
(
this
)
$
(
document
).
keydown
(
function
(
e
){
if
(
e
.
which
===
8
&&
!
$
(
e
.
target
).
is
(
"
input, textarea
"
))
...
...
@@ -49,6 +51,9 @@ function Keyboard(controller){
}
this
.
checkGameKeys
=
function
(){
if
(
!
controller
.
autoPlayEnabled
){
_gamepad
.
play
()
}
_this
.
checkKeySound
(
_kbd
[
"
don_l
"
],
"
note_don
"
)
_this
.
checkKeySound
(
_kbd
[
"
don_r
"
],
"
note_don
"
)
_this
.
checkKeySound
(
_kbd
[
"
ka_l
"
],
"
note_ka
"
)
...
...
@@ -56,6 +61,7 @@ function Keyboard(controller){
}
this
.
checkMenuKeys
=
function
(){
_gamepad
.
play
(
1
)
_this
.
checkKey
(
_kbd
[
"
back
"
],
"
menu
"
,
function
(){
controller
.
pauseSound
(
"
main-music
"
,
true
);
controller
.
songSelection
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment