Is it just me? I use Mac OS Mojave in 2018 Mac Book Pro 15. Does anybody have the same issue? it seems to be working fine in my Ubuntu though
What is "natural" scrolling?
@rom1v so when you scroll up (two finger swiping "up") it scrolls down and vice versa. there's a option in mouse and touchpad settings in the Mac where you can tick the box
Lovely application, but I'm checking if I'm the only one who has the issue. I've installed Scrcpy with brew
So you are saying that the scroll is reversed in scrcpy?
yes so it's acting as if the "natural scroll" has been turned off. do you have a mac? you can probably quickly try it by enabling it in the settings
do you have a mac?
No, I don't.
If you are comfortable with building it and play with the source code, here is the relevant part:
Ref: #49 and f9a63ec272a6051bd2f1a92a580640018124a34c
EDIT: More precisely, do you receive a different direction and y value when you use "natural scroll" compared to when you scroll using a mouse?
is this part the server?
No, it's the client (it's in app/ and is written in C; the server is in server/ and is written in Java).
https://wiki.libsdl.org/SDL_MouseWheelEvent seems there is a FLIPPED option on event, but this only has to be activated when the user activates in the settings. Any idea on this?
SDL_MOUSEWHEEL_FLIPPED is just a possible value of direction (and is already handled in the code):
int mul = from->direction == SDL_MOUSEWHEEL_NORMAL ? 1 : -1;
Just tested on my machine with LOGD("x=%"PRIu32", y=%"PRIi32" (x%d), direction=%"PRIu32, from->x, from->y, mul, from->direction); right before convert_mouse_wheel's return statement.
Here's what I get:
Natural scroll enabled:
direction=1direction=1Natural scroll disabled:
direction=0direction=0In both cases, when using the trackpad, I get Unknown touch device id -1, cannot reset, so there's that...
Let me know if you need additional testing and/or info!
Scrcpy built locally from master
./run x --versionscrcpy 1.11
dependencies:
- SDL 2.0.10
- libavcodec 58.54.100
- libavformat 58.29.100
- libavutil 56.31.100
sw_versProductName: Mac OS X
ProductVersion: 10.15.1
BuildVersion: 19B88
uname -aDarwin parprpmc008675a 19.0.0 Darwin Kernel Version 19.0.0: Thu Oct 17 16:17:15 PDT 2019; root:xnu-6153.41.3~29/RELEASE_X86_64 x86_64
@r4dixx Thank you for the feedbacks.
Here is a summary of the results (I post them here to keep a trace).
Both with scroll or trackpad, when natural scroll is enabled:
# scroll up
x=0, y=-1 (mul=-1), direction=1
# scroll down
x=0, y=1 (mul=-1), direction=1
When natural scroll is disabled:
# scroll up
x=0, y=1 (mul=1), direction=0
# scroll down
x=0, y=-1 (mul=1), direction=0
So I guess the correct behavior is to just ignore the direction field (which forces the scroll to be "unnatural":
Movements down (scroll backward) generate negative y values and up (scroll forward) generate positive y values.
[鈥
If direction is SDL_MOUSEWHEEL_FLIPPED the values in x and y will be opposite. Multiply by -1 to change them back.
https://wiki.libsdl.org/SDL_MouseWheelEvent#Remarks
diff --git a/app/src/input_manager.c b/app/src/input_manager.c
index 7d333c1..49faa11 100644
--- a/app/src/input_manager.c
+++ b/app/src/input_manager.c
@@ -550,13 +550,8 @@ convert_mouse_wheel(const SDL_MouseWheelEvent *from, struct screen *screen,
to->type = CONTROL_MSG_TYPE_INJECT_SCROLL_EVENT;
to->inject_scroll_event.position = position;
-
- int mul = from->direction == SDL_MOUSEWHEEL_NORMAL ? 1 : -1;
- // SDL behavior seems inconsistent between horizontal and vertical scrolling
- // so reverse the horizontal
- // <https://wiki.libsdl.org/SDL_MouseWheelEvent#Remarks>
- to->inject_scroll_event.hscroll = -mul * from->x;
- to->inject_scroll_event.vscroll = mul * from->y;
+ to->inject_scroll_event.hscroll = from->x;
+ to->inject_scroll_event.vscroll = from->y;
return true;
}
Works perfectly. Vertically and horizontally. Thanks a whole bunch!
Fixed by 3100533e56b2efdfc6f07b96681a7eef25ff63e0.
Most helpful comment
@r4dixx Thank you for the feedbacks.
Here is a summary of the results (I post them here to keep a trace).
Both with scroll or trackpad, when natural scroll is enabled:
When natural scroll is disabled:
So I guess the correct behavior is to just ignore the
directionfield (which forces the scroll to be "unnatural":https://wiki.libsdl.org/SDL_MouseWheelEvent#Remarks