Dudemanguy / mpv-manga-reader

Manga reading script for mpv
GNU General Public License v3.0
119 stars 4 forks source link

[Feature request] Enable key repeating for panning #7

Closed aqxa1 closed 3 years ago

aqxa1 commented 3 years ago

Panning up and down on an image is a bit slow/inconvenient because key repeating is not enabled by default. You can set it with something like this:

local binding_options = { repeatable = true } mp.add_forced_key_binding("UP", "pan-up", pan_up, binding_options)}

It doesn't seem to be a good idea to set it for switching images, though, as it seems to be too "quick" for archives and the like, which results in missing image errors.

It would also be nice to have an option for jumping to the top and bottom of an image with a single keypress.

Dudemanguy commented 3 years ago

Wait sorry I'm a massive retard. I thought this was the mpv repo at first (in case you saw my old, now deleted comment).

Actually, I had a commit back in December that made the panning commands repeatable but forgot to push it until today (!).

It would also be nice to have an option for jumping to the top and bottom of an image with a single keypress.

You could always add this to input.conf using the video-align-y property. I could possibly make it part of the default bindings though.

aqxa1 commented 3 years ago

Got it, thanks. I haven't really explored input.conf before, but I'll look into it.

Tried it out, although video-align-y doesn't seem to do anything when set in input.conf (maybe some issue with my tiling window manager, although I did enable float mode). video-pan-y kind of does what I need, although the right values seem to depend on the autofit value and output resolution (of the display). But it works at least.

Dudemanguy commented 3 years ago

Setting the video-align-y property to 1 sets the page alignment at the top while setting it to -1 sets it to the bottom. Example, something like: KEY set video-align-y 1

You could also cycle through all the values if you wish (0 here sets the alignment back to normal/default): KEY cycle-values video-align-y 1 -1 0

aqxa1 commented 3 years ago

Yeah, I got that but it didn't seem to have that effect on my machine. I.e., it just outputs video-align-y: <value> on the OSD and then the image moves very slightly up or down, but that's it.

With these values, that is: PGUP set video-align-y 1 PGDWN set video-align-y -1

Dudemanguy commented 3 years ago

Weird, that should have worked. Continuous mode internally uses that property. Maybe it doesn't trigger on runtime or something? I haven't tested it too carefully.

aqxa1 commented 3 years ago

I'll add that the properties do work when set by mpv, e.g. with --reset-on-next-file=video-pan-x,video-pan-y. Those settings alone actually to a lot of what I want actually, although it would be nice it it instantly jumped to the top, rather than the kind of choppy scrolling it does (presumably that's a mpv issue, though).

aqxa1 commented 3 years ago

Okay, I see the problem with video-align-y. It seems to be a problem with autofit, which only seems to work in floating mode, with fullscreen disabled (possibly more issues with Sway). So the video-align-y binding just doesn't work properly in that case, with the exception of reset-on-next-file.

However, video-zoom gives a similar result, but it actually works in fullscreen mode, and video-align-y works properly.

aqxa1 commented 3 years ago

I've found that video-align-y doesn't entirely work with video-zoom. Firstly, it doesn't start with the image aligned at the top (but the center) but this can be worked around by setting video-align-y=-1 and reset-on-next-file=video-align-y. Secondly, any sort of cursor movement breaks vertical alignment. In other words, align will reliably work if you only use the video-align-y command to move around the image and any subsequent images, but the moment you introduce any arrow-key (up/down) movement, the alignment becomes offset the amount of 'steps' that the arrow-key movement has introduced. You can fix this by manually moving back the same amount of arrow-key 'steps' in the opposite direction but ideally it would just return to the absolute top and bottom of the image, ignoring any arrow-key movement within.

Lastly, one more minor issue is the OSD messages for video-align-y, can I disable these through input.conf? Had a quick look in the manual but couldn't find anything. I can always just set these in the lua script itself, so it's not a big deal.

Anyway, thanks for the project. It looks really promising just some minor annoyances to iron out.

Dudemanguy commented 3 years ago

Wouldn't it work if you also reset the video-pan-y property on the next file?

aqxa1 commented 3 years ago

Okay, that works, good call.

Here's the final set of parameters to get this working for anyone reading. mpv.conf:

video-align-y=-1
reset-on-next-file=video-pan-y,video-align-y
video-zoom=1

and in input.conf:

PGUP set video-align-y -1
PGDWN set video-align-y 1

This will fill most of a 16:9 screen with small borders on the sides. Sometimes if the images are particularly wide, content will be cut off on the sides. You can add bindings for video-align-x to workaround this, in the same way as video-align-y. autofit handles these cases better (no horizontal movement ever), but this will do for the moment.

Dudemanguy commented 3 years ago

Nice. I think I will close this one now. That setup seems a bit too specific to add in this script but yeah anyone can duplicate it in their mpv.conf pretty easily. Feel free to re-open if there's something you feel is unaddressed.