Skip to content

Commit

Permalink
Add SDR brightness hotkey support
Browse files Browse the repository at this point in the history
  • Loading branch information
xanderfrangos committed Jan 5, 2025
1 parent 9411b80 commit 167c59d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/SettingsWindow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,7 @@ function ActionItem(props) {
return null
} else {
let selectBoxValue = action.target
if (!(selectBoxValue === "brightness" || selectBoxValue === "contrast" || selectBoxValue === "volume" || selectBoxValue === "powerState")) {
if (!(selectBoxValue === "brightness" || selectBoxValue === "sdr" || selectBoxValue === "contrast" || selectBoxValue === "volume" || selectBoxValue === "powerState")) {
selectBoxValue = "vcp"
}
const selectBox = (
Expand All @@ -1670,6 +1670,7 @@ function ActionItem(props) {
<option value="contrast">{T.t("PANEL_LABEL_CONTRAST")}</option>
<option value="volume">{T.t("PANEL_LABEL_VOLUME")}</option>
<option value="vcp">{T.t("SETTINGS_FEATURES_ADD_VCP")}</option>
<option value="sdr">{T.t("SETTINGS_FEATURES_SDR_BRIGHTNESS")}</option>
</select>
</div>
)
Expand Down
7 changes: 7 additions & 0 deletions src/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,8 @@ async function doHotkey(hotkey) {
let currentValue = 0
if (action.target === "brightness") {
currentValue = monitor.brightness
} else if (action.target === "sdr") {
currentValue = monitor.sdrLevel ?? 0
} else if (action.target === "contrast") {
currentValue = await getVCP(monitor, parseInt("0x12"))
} else if (action.target === "volume") {
Expand All @@ -1136,6 +1138,8 @@ async function doHotkey(hotkey) {
let currentCycleValue = 0
if (action.target === "brightness") {
currentCycleValue = monitor.brightness
} else if (action.target === "sdr") {
currentCycleValue = monitor.sdrLevel ?? 0
} else if (action.target === "contrast") {
currentCycleValue = await getVCP(monitor, parseInt("0x12"))
} else if (action.target === "volume") {
Expand Down Expand Up @@ -1196,6 +1200,8 @@ async function doHotkey(hotkey) {
writeSettings({ linkedLevelsActive: false })
}
showOverlay = true
} else if(action.target === "sdr") {
updateBrightnessThrottle(monitor.id, parseInt(value), false, true, "sdr")
} else {
let vcpCode = action.target
if (action.target === "contrast") {
Expand Down Expand Up @@ -1933,6 +1939,7 @@ function updateBrightness(index, newLevel, useCap = true, vcpValue = "brightness
brightness: level,
id: monitor.id
})
monitor.sdrLevel = level
} else if (monitor.type == "ddcci") {
if (vcp === "brightness") {
monitor.brightness = level
Expand Down
1 change: 1 addition & 0 deletions src/localization/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
"SETTINGS_FEATURES_VCP_LIST_TITLE": "All VCP codes reported by this display",
"SETTINGS_FEATURES_VCP_LIST_DESC": "The following is a list of available VCP codes reported by this display to Windows. Twinkle Tray does not validate the functionality or stability of these VCP codes. Use them at your own risk.",
"SETTINGS_FEATURES_VCP_EXPECTED": "Expected values",
"SETTINGS_FEATURES_SDR_BRIGHTNESS": "SDR Brightness",
"SETTINGS_TIME_TITLE": "Time of Day Adjustments",
"SETTINGS_TIME_DESC": "Automatically set your monitors to a specific brightness level at a desired time. All monitors will be set to the same, normalized levels.",
"SETTINGS_TIME_ADD": "Add a time",
Expand Down

0 comments on commit 167c59d

Please sign in to comment.