Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HID mouse support #2916

Merged
merged 14 commits into from
Jan 14, 2022
Merged

Add HID mouse support #2916

merged 14 commits into from
Jan 14, 2022

Commits on Jan 4, 2022

  1. Use separate struct for input manager params

    This avoids to directly pass the options instance (which contains more
    data than strictly necessary), and limit the number of parameters for
    the init function.
    rom1v committed Jan 4, 2022
    Configuration menu
    Copy the full SHA
    2b34e12 View commit details
    Browse the repository at this point in the history
  2. Move input_manager into screen

    The input_manager is strongly tied to the screen, it could not work
    independently of the specific screen implementation.
    
    To implement a user-friendly HID mouse behavior, some SDL events
    will need to be handled both by the screen and by the input manager. For
    example, a click must typically be handled by the input_manager so that
    it is forwarded to the device, but in HID mouse mode, the first click
    should be handled by the screen to capture the mouse (enable relative
    mouse mode).
    
    Make the input_manager a descendant of the screen, so that the screen
    decides what to do on SDL events.
    
    Concretely, replace this structure hierarchy:
    
         +- struct scrcpy
            +- struct input_manager
            +- struct screen
    
    by this one:
    
         +- struct scrcpy
            +- struct screen
               +- struct input_manager
    rom1v committed Jan 4, 2022
    Configuration menu
    Copy the full SHA
    6102a0b View commit details
    Browse the repository at this point in the history
  3. Reorder controller and HID initialization

    This allows to merge two "#ifdef HAVE_AOA_HID" blocks to simplify.
    rom1v committed Jan 4, 2022
    Configuration menu
    Copy the full SHA
    5ce1ccd View commit details
    Browse the repository at this point in the history
  4. Remove duplicate boolean

    The AOA initialization state is already tracked by aoa_hid_initialized.
    rom1v committed Jan 4, 2022
    Configuration menu
    Copy the full SHA
    f04812f View commit details
    Browse the repository at this point in the history
  5. Destroy acksync immediately on error

    If AOA or HID keyboard may not be initialized for some reason, acksync
    is useless.
    rom1v committed Jan 4, 2022
    Configuration menu
    Copy the full SHA
    7121a0d View commit details
    Browse the repository at this point in the history
  6. Pass buttons state in scroll events

    A scroll event might be produced when a mouse button is pressed (for
    example when scrolling while selecting a text). For consistency, pass
    the actual buttons state (instead of 0).
    
    In practice, it seems that this use case does not work properly with
    Android event injection, but it will work with HID mouse.
    rom1v committed Jan 4, 2022
    Configuration menu
    Copy the full SHA
    9243754 View commit details
    Browse the repository at this point in the history
  7. Add relative mode flag to mouse processors

    The default mouse injection works in absolute mode: it forwards clicks
    at a specific position on screen.
    
    To support HID mouse, add a flag to indicate that the mouse processor
    works in relative mode: it forwards mouse motion vectors, without any
    absolute reference to the screen.
    rom1v committed Jan 4, 2022
    Configuration menu
    Copy the full SHA
    b5855e5 View commit details
    Browse the repository at this point in the history
  8. Provide relative mouse motion vector in event

    This will allow the mouse processor to handle relative motion easily.
    rom1v committed Jan 4, 2022
    Configuration menu
    Copy the full SHA
    6432937 View commit details
    Browse the repository at this point in the history
  9. Forward all motion events to mouse processors

    The decision to not send motion events when no click is pressed is
    specific to Android mouse injection. Other mouse processors (e.g. for
    HID mouse) will need to receive all events.
    rom1v committed Jan 4, 2022
    Configuration menu
    Copy the full SHA
    40fca82 View commit details
    Browse the repository at this point in the history
  10. Add UI/UX support for relative mouse mode

    In relative mouse mode, the mouse pointer must be "captured" from the
    computer.
    
    Toggle (disable/enable) relative mouse mode using any of the hardcoded
    capture keys:
     - left-Alt
     - left-Super
     - right-Super
    
    These capture keys do not conflict with shortcuts, since a shortcut is
    always a combination of the MOD key and some other key, while the
    capture key triggers an action only if it is pressed and released alone.
    
    The relative mouse mode is also automatically enabled on any click in
    the window, and automatically disabled on focus lost (it is possible to
    lose focus even without the mouse).
    rom1v committed Jan 4, 2022
    Configuration menu
    Copy the full SHA
    17d01b5 View commit details
    Browse the repository at this point in the history
  11. Add CLAMP() macro

    rom1v committed Jan 4, 2022
    Configuration menu
    Copy the full SHA
    aee1b39 View commit details
    Browse the repository at this point in the history
  12. Refactor AOA/HID keyboard initialization

    This paves the way to add support for HID mouse initialization.
    rom1v committed Jan 4, 2022
    Configuration menu
    Copy the full SHA
    ed2e45e View commit details
    Browse the repository at this point in the history
  13. Add support for HID mouse

    rom1v committed Jan 4, 2022
    Configuration menu
    Copy the full SHA
    cba84f6 View commit details
    Browse the repository at this point in the history
  14. Document HID mouse in README

    rom1v committed Jan 4, 2022
    Configuration menu
    Copy the full SHA
    43aff4a View commit details
    Browse the repository at this point in the history