Skip to content

Commit

Permalink
M55 key assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
jurkovic-nikola committed Feb 3, 2025
1 parent dd23967 commit 3d8ff6f
Show file tree
Hide file tree
Showing 11 changed files with 702 additions and 79 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ dashboard.json
database/temperatures/*.json
database/profiles/*.json
database/rgb/*.json
database/key-assignments/*.json
database/macros/*.json
database/scheduler.json
org.openlinkhub.OpenLinkHub.json
.flatpak-builder/
Expand Down
Empty file.
2 changes: 2 additions & 0 deletions src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ func upgradeFile(cfg string) {
DecodeMemorySku: true,
MemorySku: "",
ResumeDelay: 15000,
LogLevel: log.InfoLevel,
LogFile: "",
}
saveConfigSettings(value)
} else {
Expand Down
24 changes: 24 additions & 0 deletions src/devices/devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import (
"OpenLinkHub/src/devices/virtuosorgbXTW"
"OpenLinkHub/src/devices/virtuosorgbXTWU"
"OpenLinkHub/src/devices/xc7"
"OpenLinkHub/src/inputmanager"
"OpenLinkHub/src/logger"
"OpenLinkHub/src/metrics"
"OpenLinkHub/src/rgb"
Expand Down Expand Up @@ -664,6 +665,29 @@ func ChangeDeviceButtonOptimization(deviceId string, buttonOptimizationMode int)
return 0
}

// ChangeDeviceKeyAssignment will change device key assignment
func ChangeDeviceKeyAssignment(deviceId string, keyIndex int, keyAssignment inputmanager.KeyAssignment) uint8 {
if device, ok := devices[deviceId]; ok {
methodName := "UpdateDeviceKeyAssignment"
method := reflect.ValueOf(GetDevice(device.Serial)).MethodByName(methodName)
if !method.IsValid() {
logger.Log(logger.Fields{"method": methodName}).Warn("Method not found or method is not supported for this device type")
return 0
} else {
var reflectArgs []reflect.Value
reflectArgs = append(reflectArgs, reflect.ValueOf(keyIndex))
reflectArgs = append(reflectArgs, reflect.ValueOf(keyAssignment))
results := method.Call(reflectArgs)
if len(results) > 0 {
val := results[0]
uintResult := val.Uint()
return uint8(uintResult)
}
}
}
return 0
}

// ChangeDeviceMuteIndicator will change device mute indicator
func ChangeDeviceMuteIndicator(deviceId string, muteIndicator int) uint8 {
if device, ok := devices[deviceId]; ok {
Expand Down
Loading

0 comments on commit 3d8ff6f

Please sign in to comment.