-
Notifications
You must be signed in to change notification settings - Fork 0
/
set.go
58 lines (48 loc) · 1.36 KB
/
set.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"fmt"
"github.com/gek64/displayController"
"syscall"
)
func setDisplayByHandle(handle int, vcpCode byte, value int) (err error) {
var found = false
if len(monitors) == 0 {
return fmt.Errorf("can't find any physical display monitor")
}
for _, monitor := range monitors {
if monitor.PhysicalInfo.Handle == syscall.Handle(handle) {
found = true
err := setVCPFeatureValue(monitor, vcpCode, value)
if err != nil {
return err
}
}
}
if !found {
return fmt.Errorf("can't find any physical display monitor with handle %d\n", handle)
}
return nil
}
func setAllDisplay(vcpCode byte, value int) (err error) {
if len(monitors) == 0 {
return fmt.Errorf("can't find any physical display monitor")
}
for _, monitor := range monitors {
err := setVCPFeatureValue(monitor, vcpCode, value)
if err != nil {
fmt.Println(err)
continue
}
}
return nil
}
func setVCPFeatureValue(monitor displayController.CompositeMonitorInfo, vcpCode byte, value int) (err error) {
fmt.Printf("Display Monitor Handle: %d\n", monitor.PhysicalInfo.Handle)
fmt.Printf("Display Monitor Description: %s\n", monitor.PhysicalInfo.Description)
err = displayController.SetVCPFeature(monitor.PhysicalInfo.Handle, vcpCode, value)
if err != nil {
return err
}
fmt.Printf("Display Monitor VCP Code 0x%x, Set to Value %d\n", vcpCode, value)
return nil
}