Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
112.35k stars 10.74k forks source link

How to send all mouse motion to device without button press? #1849

Open Mohammad699 opened 4 years ago

Mohammad699 commented 4 years ago

is it this input manager method that handles mouse motion?

input_manager_process_mouse_motion(struct input_manager *im,
                                   const SDL_MouseMotionEvent *event) {
    if (!event->state) {
        // do not send motion events when no button is pressed
        //return;  // I commented this line to pass the motion even if there is no button but it didn't work
    }
    if (event->which == SDL_TOUCH_MOUSEID) {
        // simulated from touch events, so it's a duplicate
        return;
    }
    struct control_msg msg;
    if (!convert_mouse_motion(event, im->screen, &msg)) {
        return;
    }

    if (!controller_push_msg(im->controller, &msg)) {
        LOGW("Could not request 'inject mouse motion event'");
    }

    if (im->vfinger_down) {
        struct point mouse = msg.inject_touch_event.position.point;
        struct point vfinger = inverse_point(mouse, im->screen->frame_size);
        simulate_virtual_finger(im, AMOTION_EVENT_ACTION_MOVE, vfinger);
    }
}

I commented the return line to pass the motion even if there is no button but it didn't work Can we make a constant that can be toggled with a short cut to pass the motion with no button and only with buttons?

I couldn't get the app flow because I'm a newbie in C

If there is a chance to pass mouse motion to device please guide me to do it

Thank you very much

rom1v commented 4 years ago

It's disabled because in practice it does nothing. What's your use case?

Mohammad699 commented 4 years ago

Hand drawing using mouse and gaming It will be much helpful if there is a short cut to toggle it on and off. I'll work on it but I need a guide

michael-ts commented 3 years ago

@rom1v Some first person games use mouse movement (if a mouse is present) to look around.

connorbode commented 3 years ago

@rom1v yeah I'm also trying to play Android games via scrcpy. Would be really great just to have a flag that allows all mouse motion to be sent regardless of if a button is being pressed.

connorbode commented 3 years ago

@michael-ts my workaround is just to connect a USB mouse directly to the Android.

zhubinsheng commented 3 years ago

@michael-ts我的解决方法只是将 USB 鼠标直接连接到 Android。

In which code are the received clicks, swipes, or multi-touch events executed?