Skip to content

Commit 759ee60

Browse files
committed
New: Preliminary support for gamepads
1 parent 7233ede commit 759ee60

File tree

9 files changed

+783
-56
lines changed

9 files changed

+783
-56
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
* Bookmarks and continue reading
3737
* Floating magnifying glass
3838
* Reading in scroll or slide
39+
<!--- * 🎮 Gamepad navigation --->
3940

4041
## Installation and Starting for development
4142
__Requirements__: Git, Node and NPM

scripts/dom.js

+19-2
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,8 @@ function loadIndexPage(animation = true, path = false, content = false, keepScro
513513

514514
justifyViewModule();
515515

516+
gamepad.updateBrowsableItems();
517+
516518
$(window).off('resize').on('resize', function(){
517519
justifyViewModule();
518520
});
@@ -697,7 +699,7 @@ function getFolderThumbnailsAsync(path)
697699
if(file.containsCompressed(error.compressedPath) && fs.existsSync(realPath) && fs.statSync(realPath).size < 52428800)
698700
{
699701
(function(folderSha){
700-
702+
701703
addFolderImagesQueue(path, 4, function(images){
702704

703705
for(var i = 0; i < images.length; i++)
@@ -1596,10 +1598,12 @@ function openComic(animation = true, path = true, mainPath = true, end = false,
15961598

15971599
generateAppMenu();
15981600

1601+
gamepad.updateBrowsableItems();
1602+
15991603
}
16001604
else if(file.containsCompressed(path))
16011605
{
1602-
fileCompressed.decompressRecursive(path, function(){
1606+
fileCompressed.decompressRecursive(path, function() {
16031607

16041608
openComic(animation, path, mainPath, end);
16051609

@@ -1617,6 +1621,19 @@ function skipPreviousComicF()
16171621
return skipPreviousComic;
16181622
}
16191623

1624+
// Gamepad events
1625+
gamepad.setButtonEvent('reading', 1, function(key, button) {
1626+
1627+
if(key == 1)
1628+
{
1629+
let barBack = document.querySelector('.bar-back.active, .bar-back.show');
1630+
1631+
if(barBack)
1632+
eval(barBack.getAttribute('onclick'));
1633+
}
1634+
1635+
});
1636+
16201637
module.exports = {
16211638
loadIndexPage: loadIndexPage,
16221639
loadLanguagesPage: loadLanguagesPage,

0 commit comments

Comments
 (0)