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

Refactor OSD for screenpad backlight #1

Open
Qonfused opened this issue Feb 27, 2023 · 0 comments · May be fixed by #2
Open

Refactor OSD for screenpad backlight #1

Qonfused opened this issue Feb 27, 2023 · 0 comments · May be fixed by #2

Comments

@Qonfused
Copy link
Owner

There is currently no OSD indicator for brightness when controlling backlight for screenpad devices. This may limit the practicality of ACPI patches that implement more than a handful of brightness steps. Refer to SSDT-SPLC.dsl#L42-L63 for an implementation example.

There is already a function for extracting and calling the same OSD method in AsusSMC (AsusSMCDaemon/OSD.h), though perhaps a clearer reference comes from ExternalDisplayBrightness for handling multiple displays:

// @fnesveda/ExternalDisplayBrightness/src/ExternalDisplayBrightness/BrightnessManager.swift#L330-L349
330 | // shows the brightness HUD with the correct brightness indicator on the correct display
331 | // unfortunately Apple doesn't provide a public API for this, so we have to manually extract the function from the OSD framework
332 | private static var showBrightnessHUD: ((CGDirectDisplayID, Int, Int) -> Void)? {
333 | 	if let osdLoaded = Bundle(path: "/System/Library/PrivateFrameworks/OSD.framework")?.load(), osdLoaded {
334 | 		if let sharedOSDManager = NSClassFromString("OSDManager")?.value(forKeyPath: "sharedManager") as AnyObject? {
335 | 			let showImageSelector = Selector(("showImage:onDisplayID:priority:msecUntilFade:filledChiclets:totalChiclets:locked:"))
336 | 			if sharedOSDManager.responds(to: showImageSelector) {
337 | 				let showImageImplementation = sharedOSDManager.method(for: showImageSelector)
338 | 				
339 | 				typealias ShowImageFunctionType = @convention(c) (AnyObject, Selector, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, Bool) -> Void
340 | 				let showImage = unsafeBitCast(showImageImplementation, to: ShowImageFunctionType.self)
341 | 				
342 | 				return {(onDisplayID: CGDirectDisplayID, filledChiclets: Int, totalChiclets: Int) -> Void in
343 | 					showImage(sharedOSDManager, showImageSelector, 1, onDisplayID, 0x1f3, 1000, UInt32(filledChiclets), UInt32(totalChiclets), false)
344 | 				}
345 | 			}
346 | 		}
347 | 	}
348 | 	return nil
349 | }
@Qonfused Qonfused linked a pull request Mar 31, 2023 that will close this issue
10 tasks
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 a pull request may close this issue.

1 participant