binarynonsense / comic-book-reader

ACBR - A comic book reader and converter for CBZ, CBR, CB7, EPUB and PDF files (Windows & Linux)
BSD 2-Clause "Simplified" License
184 stars 8 forks source link

"wasd" don't work. #94

Closed VanTuz5 closed 8 months ago

VanTuz5 commented 11 months ago

The description of the program states that using wasd you can scroll pages in different directions. But in reality these keys don't do anything. UPD. The keys work, but somehow strange. At some point the program stops responding to them.

binarynonsense commented 11 months ago

Thanks for the bug report.

That's quite strange, yes, I can't think of a reason why they would stop working after a while and so far I haven't been able to reproduce the bug, they seem to work fine for me, but I'll keep trying.

Are you using Windows or Linux? Does it always happen to you or only under some circumstances: a particular zoom mode (fit to width, height...), full screen, with the scrollbar hidden...? I don't know... Unless I find a way to reproduce it or figure out a possible cause it'll be hard to fix.

VanTuz5 commented 11 months ago

OS windows 11. And I just open .cbz file, push w or s and nothing happens. After a little time, the program begins to respond to the keys, but stops at a random moment, or if you turn the mouse wheel. The scrollbar is not hidden, the zoom mode is not by width or height, but by a certain percentage As I looked - if you press the spacebar a couple of times so that it scrolls the page, the program begins to respond to wasd, but that won't last long.

binarynonsense commented 11 months ago

In my brief attempts so far, I haven't been able to reproduce the problem on Linux or Windows 10 (don't have a machine with Windows 11). When I have the time I will keep trying to figure out a reason things don't work for you but I'm a bit lost right now, not being able to make it happen myself.

You mean pressing the spacebar scrolls the page? That's really strange, the spacebar key should do nothing.

Do you have more than one keyboard connected? or a gamepad or any other type of input?... I don't think it should matter but I'm just trying to think of any potential factor/particularity of your setup that comes to mind that may help me find somewhere to start finding a reason.

trzyglow commented 10 months ago

Tested it on my Windows 11 machine; I can confirm that WASD indeed doesn't work, but was unable to replicate any of the other bugs.

VanTuz5 commented 10 months ago

If I understand correctly, then for the keys to work correctly, the English layout must be set.

trzyglow commented 10 months ago

Tested multiple keyboard layouts, it doesn't seem to have any impact on the issue.

binarynonsense commented 10 months ago

Quite curious... I wasn't able to replicate it on any of my machines when I tried, but I don't have one with Windows 11, only 10. Looks like running the program on W11 is key to trigger the bug.

There were a couple of questions I asked when the issue was first opened that may help me narrow the cause down, or at least discard possible reasons / clues:

You mean pressing the spacebar scrolls the page? That's really strange, the spacebar key should do nothing.

Do you have more than one keyboard connected? or a gamepad or any other type of input?... I don't think it should matter but I'm just trying to think of any potential factor/particularity of your setup that comes to mind that may help me find somewhere to start finding a reason.

Another one would be: does the same happen with older versions of the program? (if anyone having this problem is willing to try, I understand if it's too tedious). If it hasn't always happened that could be a good clue too.

In any case, given that it only happens in one OS I'm thinking maybe the cause could be a bug in Electron, not the input checking code, so hopefully the next time I make a new release with an updated version of Electron the root of the problem is something they've fixed and things will work as expected...

I don't know when I'll be able to work on it, but I'll let you know here when there's a new beta to test so you can let me know if then things work as they should even on W11.

Thanks for the feedback!

binarynonsense commented 10 months ago

Also: are those keys the only ones that don't work as expected? do the arrows, page up, page down, f11... work?

trzyglow commented 10 months ago

Also: are those keys the only ones that don't work as expected? do the arrows, page up, page down, f11... work?

(At least on my machine) all keys and key-combinations (except WASD) are working properly.

Another one would be: does the same happen with older versions of the program? (if anyone having this problem is willing to try, I understand if it's too tedious). If it hasn't always happened that could be a good clue too.

I'll check it out. Edit: WASD works if the page is very zoomed in Edit2: Cleaned up the registry (and reinstalled), which resolved the issue on my end completely

binarynonsense commented 10 months ago

(At least on my machine) all keys and key-combinations (except WASD) are working properly.

That's very strange, I'm a bit lost as to why :)

I'll check it out. Edit: WASD works if the page is very zoomed in Edit2: Cleaned up the registry (and reinstalled), which resolved the issue on my end completely

What do you mean by "Cleaned up the registry" and by "reinstalled"?

trzyglow commented 10 months ago

What do you mean by "Cleaned up the registry" and by "reinstalled"?

Used an uninstaller software that can also remove remnants of software (including windows registry keys) and then just copied a fresh version of ACBR Version 3.3.2 to where the (now deleted) instance was.

(the registry system on windows 11 was overheauled a few times, so sometimes "older" registry keys end up in compatibility issues; the OS is still somewhat janky in certain regards)

Allthough admittedly, that may not resolve (or have anything to do with) the issue universally (I don't have a second win11 machine to sanity check). I certainly can't reproduce the bug on my PC anymore.

Addendum: (if it was/is a bug that's tied to a certain version of Windows) I tested on Windows 11 Home (Version 23H2 Build 22631.3085)

binarynonsense commented 10 months ago

Did the software show you if there were indeed registry keys associated to ACBR? As far as I know, using ACBR shouldn't add anything to the registry but maybe Electron/Chromium needs to add something to work. Honestly, I don't know enough about the Windows' registry (edit: or Electron's internals) to know for sure but I was under the impression that only if I made a version with an installer would the registry come into play and Electron just had to create a regular configuration folder for Chromium to work (which I clean as much as I can every time the program exits).

Now I'm even more lost :P

The fact that "WASD works if the page is very zoomed" before is also a head-scratcher :)

binarynonsense commented 10 months ago

@VanTuz5 was it the first time you used ACBR or had you previously used older versions on that machine? That may help figure out if it has anything to do with old registry keys/configuration files or it's just coincidence/there's more to it.

trzyglow commented 10 months ago

Did the software show you if there were indeed registry keys associated to ACBR? As far as I know, using ACBR shouldn't add anything to the registry but maybe Electron/Chromium needs to add something to work. Honestly, I don't know enough about the Windows' registry (edit: or Electron's internals) to know for sure but I was under the impression that only if I made a version with an installer would the registry come into play and Electron just had to create a regular configuration folder for Chromium to work (which I clean as much as I can every time the program exits).

The registry entries were probably tied to electron (likely node api, which afaik uses the registry). (the windows registry doesn't clean itself, which usually isn't a problem [until microsoft decides to change stuff])

Now I'm even more lost :P

The fact that "WASD works if the page is very zoomed" before is also a head-scratcher :)

Could've also just been my PC bugging out, and me not noticing it.

binarynonsense commented 10 months ago

I'm still not sure about Electron needing to create registry entries (edit: did the cleanup software show you there were in fact entries created by Electron/ACBR or are you guessing?), can't find any info about it, but I can't think of any reason why that would make wasd sometimes work and not others... quite curious that the problem disappeared after cleaning things up, not sure if that's it, it was a coincidence or it's a clue to some other cause.

@VanTuz5 did you check lately if the problem is still happening? just in case it's something W11 related and an OS update or something else fixed it for you (who knows... :)). You also mentioned changing the layout to English may fix it... that didn't work for @trzyglow but did you try that and it worked?

The issue doesn't seem to happen to many people, or at least nobody else has reported it yet (maybe it's something rare or, as using wasd to navigate is probably not something many people do, not many W11 users have tried it), but hopefully when I release a version with an updated Electron things will work fine... it's a shot in the dark but right now I can't think of anything else to do and I can't even reproduce it myself to know for sure.

binarynonsense commented 10 months ago

I've release a new beta version that updates some of the core libraries (including Electron), to see if that helps fix the issue.

Please, give it a try and let me know if that's the case, especially @VanTuz5 as @trzyglow will only be able to check if things still work fine (which is important too) given that the issue was no longer happening after the cleanup.

VanTuz5 commented 10 months ago

With english layout wasd working, with another - not.

binarynonsense commented 10 months ago

With english layout wasd working, with another - not.

Is this happening with the new beta I just released? edit: Or you mean that was the case previously and haven't tested the new version yet.

VanTuz5 commented 10 months ago

I checked the new version and the problem remains.

binarynonsense commented 10 months ago

That's a pity, but it was a shot in the dark anyway...

@VanTuz5 Can you answer some of the questions I asked you previously to try to narrow the problem down?

You mean pressing the spacebar scrolls the page? That's really strange, the spacebar key should do nothing.

Do you have more than one keyboard connected? or a gamepad or any other type of input?...

does the same happen with older versions of the program? (if anyone having this problem is willing to try, I understand if it's too tedious). If it hasn't always happened that could be a good clue too.

was it the first time you used ACBR or had you previously used older versions on that machine? That may help figure out if it has anything to do with old registry keys/configuration files or it's just coincidence/there's more to it.

are those keys (wasd) the only ones that don't work as expected? do the arrows, page up, page down, f11... work?

Also: which layout do you use normally? Could be a clue, but @trzyglow tried changing to an English layout and that didn't help fix the issue (something else did, which is confusing)

VanTuz5 commented 10 months ago

1 - yes 2 - no, I use a laptop 3,4 - I don't know, didn't use previous versions 5 - f11 work normally on any layout 6- russian

binarynonsense commented 10 months ago

5 - f11 work normally on any layout

I'm assuming the others too (arrows, page up, page down)

If that's the case, I'm starting to thing think the problem in your case is in fact related to using a Russian layout and what happened to @trzyglow was weirdly unrelated.

This is what I'm thinking:

In my code I check if event.key is "w", "a", "s" or "d", and event.key returns a non-empty Unicode character string containing the printable representation of the key... could it be that with a Russian layout when you press, for example, "w" the returned key is not "w" but the Russian alternative for the key?

image

Is there any way for you to check that, or for you to force it one way or the other (make sure it's w for example). I don't know if usually you can use Alt Gr + the key to alternate between Russian and English characters for a key while using the keyboard (sorry if these are silly questions, I don't have experience with Russian or similar keyboards, I use mine with a Spanish layout but the alphabet is mostly the same and regular keys just have one letter assigned to them, but with keys with alternate meanings you usually have to use Alt Gr + the key to switch)

binarynonsense commented 10 months ago

1 - yes

So pressing the spacebar scrolls the page? Right now, that I have no idea why it happens to you, even if the theory about the wasd problem being related to the layout is correct (edit: unless I'm missing something, the value returned by the spacebar should be the same for all so it should always happen, to everyone, and I can't reproduce the problem, edit 2: even worse, it should return a value of an arrow or w/d for it to scroll the page)... I'm confused :)

trzyglow commented 10 months ago

If that's the case, I'm starting to thing the problem in your case is in fact related to using a Russian layout and what happened to @trzyglow was weirdly unrelated.

I suspect that as well.

In my code I check if event.key is "w", "a", "s" or "d", and event.key returns a non-empty Unicode character string containing the printable representation of the key...

Did some digging, and it seems like there is a degree of incompatibility between cyrillic and latin keyboards when it comes to the unicode symbols regarding the alphabets (unless the layout is switched via the OS)

Edit: checked out a couple of standard layouts (russian, ukrainian, serbian & bulgarian) and the layout is completely different across all of them, so this might cause additional problems regarding potential unicode based solutions.

binarynonsense commented 10 months ago

I could use event.code instead of event.key as that "represents a physical key on the keyboard (as opposed to the character generated by pressing the key). In other words, this property returns a value that isn't altered by keyboard layout or the state of the modifier keys". But that would work incorrectly, for example, if the keyboard is AZERTY instead of QWERTY...

In the future I may add a tool to customize the key mapping to assign whatever key you like to some of the navigation functions, like in a videogame, that would help with this type of issues.

Edit: here's an interesting article about the topic: https://hacks.mozilla.org/2017/03/internationalize-your-keyboard-controls/.

Right now, if the Russian keyboard doesn't return a "w" for the event.key when pressing the w key I don't see an easy/universal solution for this besides adding a key mapper.

binarynonsense commented 10 months ago

Maybe I could in fact use event.code so I check the physical keys, and change the documentation from:

to something like:

I think this could be a good solution to the issue at least for now (edit: although I'm not sure if I really like it).

binarynonsense commented 9 months ago

I've uploaded a new beta (3.3.3-beta4) that adds the option to remap the navigation keys in the "User Interface" section of the "Preferences". This way people with different layouts, or that don't like the defaults, should be able to reconfigure them. Let me know if this helps solve/bypass your issues.

Also, the Spacebar should no longer scroll the page by default when the focus is on the page image (or anytime).