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 OTG mode (HID only) #2974

Merged
merged 20 commits into from
Jan 27, 2022
Merged

Add OTG mode (HID only) #2974

merged 20 commits into from
Jan 27, 2022

Commits on Jan 27, 2022

  1. Move AOA/HID code to usb/

    rom1v committed Jan 27, 2022
    Configuration menu
    Copy the full SHA
    2762f5d View commit details
    Browse the repository at this point in the history
  2. Rename HAVE_AOA_HID to HAVE_USB

    The condition actually determines whether scrcpy can use libusb or not.
    
    PR #2974 <#2974>
    rom1v committed Jan 27, 2022
    Configuration menu
    Copy the full SHA
    d48d191 View commit details
    Browse the repository at this point in the history
  3. Extract USB handling from AOA

    The AOA code handled both USB initialization and AOA commands/events.
    Extract USB-related code to a separate file and structure.
    
    PR #2974 <#2974>
    rom1v committed Jan 27, 2022
    Configuration menu
    Copy the full SHA
    1d6f995 View commit details
    Browse the repository at this point in the history
  4. Make serial mandatory for sc_usb

    In practice, it is already mandatory.
    
    PR #2974 <#2974>
    rom1v committed Jan 27, 2022
    Configuration menu
    Copy the full SHA
    48e3ff2 View commit details
    Browse the repository at this point in the history
  5. Move sc_usb out of sc_aoa

    This will allow to initialize a USB device separately and pass it to
    sc_aoa.
    
    PR #2974 <#2974>
    rom1v committed Jan 27, 2022
    Configuration menu
    Copy the full SHA
    adda47b View commit details
    Browse the repository at this point in the history
  6. Remove libusb_device field

    It is possible to retrieve the device instance from the handle via
    libusb_get_device(), so we don't need to reference the device one more
    time.
    
    PR #2974 <#2974>
    rom1v committed Jan 27, 2022
    Configuration menu
    Copy the full SHA
    b779eca View commit details
    Browse the repository at this point in the history
  7. Find device with USB context

    An explicit context was used everywhere except for listing the devices.
    
    PR #2974 <#2974>
    rom1v committed Jan 27, 2022
    Configuration menu
    Copy the full SHA
    2114f48 View commit details
    Browse the repository at this point in the history
  8. Split USB initialization and connection

    This will allow to execute other USB calls (retrieving the device list
    for example) before connecting to the selected device.
    
    PR #2974 <#2974>
    rom1v committed Jan 27, 2022
    Configuration menu
    Copy the full SHA
    bbef426 View commit details
    Browse the repository at this point in the history
  9. Add util function to read USB descriptor string

    Use it from accept_device() to simplify (at the cost an additional
    allocation for each serial, but it is not important).
    
    It will also be useful in other functions in further commits.
    
    PR #2974 <#2974>
    rom1v committed Jan 27, 2022
    Configuration menu
    Copy the full SHA
    1ab3692 View commit details
    Browse the repository at this point in the history
  10. Expose function to find a USB device

    The device was automatically found by sc_usb_connect(). Instead, expose
    a function to find a device from a serial, and let the caller connect to
    the device found (if any).
    
    This will allow to list all devices first, then select one device to
    connect to.
    
    PR #2974 <#2974>
    rom1v committed Jan 27, 2022
    Configuration menu
    Copy the full SHA
    0ee9e2f View commit details
    Browse the repository at this point in the history
  11. Wrap libusb_device

    Introduce a structure to wrap a libusb_device and expose its descriptor
    data read during discovery.
    
    PR #2974 <#2974>
    rom1v committed Jan 27, 2022
    Configuration menu
    Copy the full SHA
    d8b37fe View commit details
    Browse the repository at this point in the history
  12. Find a list of devices instead of a single one

    Several devices may match the requested serial, but above all, this
    paves the way to list all devices (when no serial is provided).
    
    PR #2974 <#2974>
    rom1v committed Jan 27, 2022
    Configuration menu
    Copy the full SHA
    1c17f57 View commit details
    Browse the repository at this point in the history
  13. Make serial optional to find USB devices

    If no serial is provided, then list all available USB devices (which can
    be open and having a serial).
    
    PR #2974 <#2974>
    rom1v committed Jan 27, 2022
    Configuration menu
    Copy the full SHA
    8fc9dca View commit details
    Browse the repository at this point in the history
  14. Make acksync optional for AOA initialization

    Acksync is used to delay HID events until some request (in practice,
    device clipboard synchronization) is acknowledged by the device.
    
    This mechanism will not be necessary for OTG mode.
    
    PR #2974 <#2974>
    rom1v committed Jan 27, 2022
    Configuration menu
    Copy the full SHA
    37987b8 View commit details
    Browse the repository at this point in the history
  15. Detect USB device disconnection

    The device disconnection is detected when the video socket closes.
    
    In order to introduce an OTG mode (HID events) without mirroring (and
    without server), we must be able to detect USB device disconnection.
    
    This feature will only be used in OTG mode.
    
    PR #2974 <#2974>
    rom1v committed Jan 27, 2022
    Configuration menu
    Copy the full SHA
    1a03206 View commit details
    Browse the repository at this point in the history
  16. Move input event helpers

    Input events helpers to convert from SDL events to scrcpy events were
    implemented in input_manager. To reuse them for OTG mode, move them to
    input_events.h.
    
    PR #2974 <#2974>
    rom1v committed Jan 27, 2022
    Configuration menu
    Copy the full SHA
    36aaf70 View commit details
    Browse the repository at this point in the history
  17. Add OTG mode

    Add an option --otg to run scrcpy with only physical keyboard and mouse
    simulation (HID over AOA), without mirroring and without requiring adb.
    
    To avoid adding complexity into the scrcpy initialization and screen
    implementation, OTG mode is implemented totally separately, with a
    separate window.
    
    PR #2974 <#2974>
    rom1v committed Jan 27, 2022
    Configuration menu
    Copy the full SHA
    91418c7 View commit details
    Browse the repository at this point in the history
  18. Document OTG mode in README

    rom1v committed Jan 27, 2022
    Configuration menu
    Copy the full SHA
    c5be0d6 View commit details
    Browse the repository at this point in the history
  19. Make HID keyboard and mouse optional in OTG mode

    Allow to only enable HID keyboard or HID mouse:
    
        scrcpy --otg -K   # keyboard only
        scrcpy --otg -M   # mouse only
        scrcpy --otg -KM  # keyboard and mouse
        scrcpy --otg      # keyboard and mouse
    
    PR #2974 <#2974>
    rom1v committed Jan 27, 2022
    Configuration menu
    Copy the full SHA
    ea68a00 View commit details
    Browse the repository at this point in the history
  20. Enable mouse focus clickthrough in OTG mode

    A single click on the window must both give focus and capture the mouse.
    
    PR #2974 <#2974>
    rom1v committed Jan 27, 2022
    Configuration menu
    Copy the full SHA
    5508c63 View commit details
    Browse the repository at this point in the history