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

More settings can be changed #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bcaller
Copy link

@bcaller bcaller commented Dec 4, 2021

Added contrast, sharpness, blue light reduction, black equalizer and osd
timeout.

Also wasted some time making a silly data class Property so that you
can do transitions without needing to duplicate lots of code.

Added contrast, sharpness, blue light reduction, black equalizer and osd
timeout.

Also wasted some time making a silly data class `Property` so that you
can do transitions without needing to duplicate lots of code.
@bcaller
Copy link
Author

bcaller commented Dec 4, 2021

@P403n1x87 by the way, which file did you disassemble to work out how things work and what the codes are? There are a load of DLLs and I haven't looked through them yet.

@bcaller
Copy link
Author

bcaller commented Dec 4, 2021

Also, thanks for this tool. I thought I would have to reverse engineer to get software KVM switch on Linux, but I saw you've already done it!

Copy link
Owner

@P403n1x87 P403n1x87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌 @bcaller this is awesome, thanks a lot! I've left just a couple of comments.

As for the decompiled binaries, I have used dotPeek to decompile the OSD Sidekick application and I found the magic values by poking around the classes. E.g. KVMWindow (as well as other classes, have GetOSD and SetOSD methods).

if current != target:
self.set_property(property, target)

def set_brightness(self, brightness: int):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this new abstraction perhaps we could leverage __getattr__ to avoid implementing all these methods, e.g.

def __getattr__(self, name):
    action, _, property_name = name.partition("_")
    property_obj = getattr(MonitorControl, property_name.upper())
    if action == "get":
        return lambda: self.get_property(property_obj)
    elif action == "set":
        return lambda v: self.set_property(property_obj, v)

    raise AttributeError()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look at doing this when I get a chance.

Comment on lines +14 to +34
@dataclass
class BasicProperty:
minimum: int
maximum: int
message_a: int
message_b: int = 0

def clamp(self, v: int):
return max(self.minimum, min(self.maximum, v))


@dataclass
class EnumProperty:
allowed: t.List[int]
message_a: int
message_b: int = 0

def clamp(self, v: int):
if v not in self.allowed:
raise Exception(f"Only allowed values: {self.allowed}")
return v
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could have an abstract base property class with the common attributes plus a method that returns the list expected by set_osd.

@bcaller
Copy link
Author

bcaller commented Dec 9, 2021

Thanks for recommending dotPeek. I found you can really control everything, even emulate pressing the joystick (up down left right centre) in the OSD.

@ghostface
Copy link

FYI for brightness and input switching etc. just use the ddc protocol (e.g. ddcutil), for anything not available there (like the kvm switching) the python script is still useful

@bcaller
Copy link
Author

bcaller commented Dec 14, 2021

@ghostface oh cool I didn't know about ddcutil. I might close this PR then since then it doesn't add much.

@ghostface
Copy link

I am not sure if ddcutil works if the only thing you have attached to your pc is usb-c tho, so it might still have a use case.
I know that ddcutil added some usb support but I haven't checked if it works with the m27q.

mithwick93 added a commit to mithwick93/Gigabyte-M27Q-Settings-Controller that referenced this pull request Jun 29, 2024
Add requirements.txt
Enhance the MonitorControl class based on changes suggested in P403n1x87#1

Signed-off-by: mithwick93 <mithwick93@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants