[go: up one dir, main page]

Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
[qol] kb: show brightness level on osd when adjusting
Browse files Browse the repository at this point in the history
  • Loading branch information
zllovesuki committed Apr 2, 2021
1 parent 994d24d commit 010c66e
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 33 deletions.
5 changes: 5 additions & 0 deletions .github/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ Invoke-Expression $RSRC
$MOD = "go mod download"
Invoke-Expression $MOD 2>&1

Write-Hose "Installing tools"

$STRINGER = "go get golang.org/x/tools/cmd/stringer"
Invoke-Expression $STRINGER

Write-Host "Generating static assets"

$PACKED = "go generate .\..."
Expand Down
76 changes: 43 additions & 33 deletions cxx/plugin/keyboard/control.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:generate stringer -type=Level -linecomment
package keyboard

/*
Expand Down Expand Up @@ -89,10 +90,10 @@ type Level byte

// Brightness level
const (
OFF Level = 0x00
LOW = 0x01
MEDIUM = 0x02
HIGH = 0x03
OFF Level = 0x00 // Off
LOW Level = 0x01 // Low
MEDIUM Level = 0x02 // Medium
HIGH Level = 0x03 // High
)

// Control allows you to set the hid related functionalities directly.
Expand Down Expand Up @@ -191,39 +192,48 @@ func (c *Control) loop(haltCtx context.Context, cb chan<- plugin.Callback) {
}
switch keycode {
case keyboard.KeyTpadToggle:
cb <- plugin.Callback{
Event: plugin.CbNotifyToast,
Value: util.Notification{
Message: "Toggle Disable/Enable Touchpad",
Delay: time.Second,
},
if err := c.ToggleTouchPad(); err != nil {
c.errChan <- err
} else {
cb <- plugin.Callback{
Event: plugin.CbNotifyToast,
Value: util.Notification{
Message: "Toggle Disable/Enable Touchpad",
Delay: time.Second,
},
}
}
c.errChan <- c.ToggleTouchPad()
case keyboard.KeyFnDown:
cb <- plugin.Callback{
Event: plugin.CbNotifyToast,
Value: util.Notification{
Message: "Keyboard Brightness Down",
Delay: time.Millisecond * 500,
Immediate: true,
},
}
c.errChan <- c.BrightnessDown()
cb <- plugin.Callback{
Event: plugin.CbPersistConfig,
if err := c.BrightnessDown(); err != nil {
c.errChan <- err
} else {
cb <- plugin.Callback{
Event: plugin.CbNotifyToast,
Value: util.Notification{
Message: fmt.Sprintf("Keyboard Brightness Down: %s", c.CurrentBrightness()),
Delay: time.Millisecond * 500,
Immediate: true,
},
}
cb <- plugin.Callback{
Event: plugin.CbPersistConfig,
}
}
case keyboard.KeyFnUp:
cb <- plugin.Callback{
Event: plugin.CbNotifyToast,
Value: util.Notification{
Message: "Keyboard Brightness Up",
Delay: time.Millisecond * 500,
Immediate: true,
},
}
c.errChan <- c.BrightnessUp()
cb <- plugin.Callback{
Event: plugin.CbPersistConfig,
if err := c.BrightnessUp(); err != nil {
c.errChan <- err
} else {
cb <- plugin.Callback{
Event: plugin.CbNotifyToast,
Value: util.Notification{
Message: fmt.Sprintf("Keyboard Brightness Up: %s", c.CurrentBrightness()),
Delay: time.Millisecond * 500,
Immediate: true,
},
}
cb <- plugin.Callback{
Event: plugin.CbPersistConfig,
}
}
case keyboard.KeyFnLeft, keyboard.KeyFnRight:
if remap, ok := c.Config.Remap[keycode]; ok {
Expand Down
26 changes: 26 additions & 0 deletions cxx/plugin/keyboard/level_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require (
github.com/thejerf/suture/v4 v4.0.0
golang.org/x/net v0.0.0-20201021035429-f5854403a974 // indirect
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4
golang.org/x/tools v0.1.0 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/grpc v1.34.0
google.golang.org/protobuf v1.25.0
Expand Down
11 changes: 11 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,29 @@ github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/thejerf/suture/v4 v4.0.0 h1:GX3X+1Qaewtj9flL2wgoTBfLA5NcmrCY39TJRpPbUrI=
github.com/thejerf/suture/v4 v4.0.0/go.mod h1:g0e8vwskm9tI0jRjxrnA6lSr0q6OfPdWJVX7G5bVWRs=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand All @@ -114,6 +120,11 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY=
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
1 change: 1 addition & 0 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ $env:CGO_ENABLED = 1

rsrc.exe -arch amd64 -manifest .\cmd\manager\G14Manager.exe.manifest -ico .\cmd\manager\go.ico -o .\cmd\manager\G14Manager.exe.syso

go get golang.org/x/tools/cmd/stringer
go generate .\...
go build -ldflags="-H=windowsgui -s -w -X 'main.Version=v0.0.0-staging' -X 'main.IsDebug=no'" -o "build/G14Manager.exe" .\cmd\manager
go build -gcflags="-N -l" -ldflags="-X 'main.Version=v0.0.0-debug' -X 'main.IsDebug=yes'" -o "build/G14Manager.debug.exe" .\cmd\manager
Expand Down

0 comments on commit 010c66e

Please sign in to comment.