haimgel / display-switch

Turn a $30 USB switch into a full-featured multi-monitor KVM switch
https://haim.dev/posts/2020-07-28-dual-monitor-kvm/
MIT License
2.85k stars 112 forks source link

Support for raw InputSource values #6

Closed shanempope closed 3 years ago

shanempope commented 4 years ago

Currently the values supported are:

    DisplayPort1 = 0x0f,
    DisplayPort2 = 0x10,
    Hdmi1 = 0x11,
    Hdmi2 = 0x12,

My monitor seems to have HDMI1 as 0x05. Adding support for raw values would probably do the trick.

GazzaHazza commented 4 years ago

@shanempope - how did you find out the raw values for your monitor inputs?

shanempope commented 4 years ago

@GazzaHazza the logs tell you at startup what the value is. You can find the logfile here:

/// | macOS   | `$HOME`/Library/Application Support      | /Users/Alice/Library/Application Support |
/// | Windows | `{FOLDERID_LocalAppData}`                | C:\Users\Alice\AppData\Local             |

So for me there are C:\Users\USERNAME\AppData\Local\display-switch

and the first two lines of the log when it starts are

05:25:27 [INFO] Configuration loaded ("C:\\Users\\USERNAME\\AppData\\Roaming\\display-switch\\display-switch.ini"): Configuration { usb_device: "0abc:c123", monitor_input: MyHdmi1 }
05:25:27 [INFO] Monitor 'Monitor { handle: 0x0, description: "Generic PnP Monitor" }' is currently set to 0x5

That last value of 0x5 was what I needed. And you can see above I added my own MyHdmi1 to the display_control.rs InputSource enum with a value of 0x05

GazzaHazza commented 4 years ago

Thank you!

shanempope commented 4 years ago

I found this:

Simple NC values: 0x01: VGA-1 0x02: VGA-2 0x03: DVI-1 0x04: DVI-2 0x05: Composite video 1 0x06: Composite video 2 0x07: S-Video-1 0x08: S-Video-2 0x09: Tuner-1 0x0a: Tuner-2 0x0b: Tuner-3 0x0c: Component video (YPrPb/YCrCb) 1 0x0d: Component video (YPrPb/YCrCb) 2 0x0e: Component video (YPrPb/YCrCb) 3 0x0f: DisplayPort-1 0x10: DisplayPort-2 0x11: HDMI-1 0x12: HDMI-2

In practice, any given monitor will implement only a few of the NC values, and some monitors will implement undocumented values. The only way to know for sure is by testing.

On here: https://www.ddcutil.com/faq/

nmostafavi commented 4 years ago

Likewise, I was able to use this freeware Windows application to query (and try out!) the DCC/CI display input values supported by my monitor: https://www.nirsoft.net/utils/control_my_monitor.html

For anyone else with my monitor: Dell U2720Q appears to use 0x1B for its USB-C input. I manually added this as a new enum and it's working great!

Thank you Haim for making this! You've saved me from writing it myself :)

haimgel commented 4 years ago

Yeah, with the zoo of different monitor implementations I can see how this could be useful. Will look into this.

nathang21 commented 4 years ago

The value of DisplayPort-1 caused #14 for me. I fixed by modifying to DisplayPort1

haimgel commented 3 years ago

This should be implemented in "master" now :-)