Reported by Ross Batten via phone call.
Currently CommandPost uses hidutil to disable the default keyboard layout for Razer devices.
Essentially we remap the Razer device so that all the built-in buttons don't actually "type" anything. Then in our Objective-C Extension (hs.razer) we detect the button presses there.
This has always worked fine in the past, but interestingly Ross is having issues on his machine.
He has a Mac Studio running Ventura - and it's all working fine there. However, he cloned his operating system to an external SSD, and when booting from the external SSD, things no longer work. Given that it's exactly the same hardware, same operating system, and same configuration, makes me think it's some kind of security issue. However, I tried disabling and re-enabling all the various permissions CommandPost needs and it didn't seem to make a difference.
Interestingly however, when looking into this, it seems that hidutil stopped working on macOS Sonoma 14.2, which was fixed in macOS Sonoma 14.3 - but now requires sudo (see here).
I'm currently running macOS 14.3, and it looks like it's broken on my machine.
For a Razer Orbweaver Chroma for example, we use the following Terminal command:
hidutil property --matching '{"ProductID":0x0207}' --set '{"UserKeyMapping":[
{"HIDKeyboardModifierMappingSrc":0x700000051,
"HIDKeyboardModifierMappingDst":0x100000023
},
{"HIDKeyboardModifierMappingSrc":0x700000039,
"HIDKeyboardModifierMappingDst":0x100000011
},
{"HIDKeyboardModifierMappingSrc":0x70000002B,
"HIDKeyboardModifierMappingDst":0x100000006
},
{"HIDKeyboardModifierMappingSrc":0x700000006,
"HIDKeyboardModifierMappingDst":0x100000019
},
{"HIDKeyboardModifierMappingSrc":0x70000001A,
"HIDKeyboardModifierMappingDst":0x100000008
},
{"HIDKeyboardModifierMappingSrc":0x70000004F,
"HIDKeyboardModifierMappingDst":0x100000025
},
{"HIDKeyboardModifierMappingSrc":0x70000001B,
"HIDKeyboardModifierMappingDst":0x100000018
},
{"HIDKeyboardModifierMappingSrc":0x700000052,
"HIDKeyboardModifierMappingDst":0x100000022
},
{"HIDKeyboardModifierMappingSrc":0x700000050,
"HIDKeyboardModifierMappingDst":0x100000024
},
{"HIDKeyboardModifierMappingSrc":0x700000021,
"HIDKeyboardModifierMappingDst":0x100000004
},
{"HIDKeyboardModifierMappingSrc":0x700000035,
"HIDKeyboardModifierMappingDst":0x100000021
},
{"HIDKeyboardModifierMappingSrc":0x70000002C,
"HIDKeyboardModifierMappingDst":0x100000020
},
{"HIDKeyboardModifierMappingSrc":0x700000004,
"HIDKeyboardModifierMappingDst":0x100000012
},
{"HIDKeyboardModifierMappingSrc":0x700000015,
"HIDKeyboardModifierMappingDst":0x100000010
},
{"HIDKeyboardModifierMappingSrc":0x700000020,
"HIDKeyboardModifierMappingDst":0x100000003
},
{"HIDKeyboardModifierMappingSrc":0x70000001E,
"HIDKeyboardModifierMappingDst":0x100000001
},
{"HIDKeyboardModifierMappingSrc":0x70000001D,
"HIDKeyboardModifierMappingDst":0x100000017
},
{"HIDKeyboardModifierMappingSrc":0x700000019,
"HIDKeyboardModifierMappingDst":0x100000026
},
{"HIDKeyboardModifierMappingSrc":0x700000008,
"HIDKeyboardModifierMappingDst":0x100000009
},
{"HIDKeyboardModifierMappingSrc":0x700000016,
"HIDKeyboardModifierMappingDst":0x100000013
},
{"HIDKeyboardModifierMappingSrc":0x700000014,
"HIDKeyboardModifierMappingDst":0x100000007
},
{"HIDKeyboardModifierMappingSrc":0x7000000E1,
"HIDKeyboardModifierMappingDst":0x100000016
},
{"HIDKeyboardModifierMappingSrc":0x700000009,
"HIDKeyboardModifierMappingDst":0x100000015
},
{"HIDKeyboardModifierMappingSrc":0x700000007,
"HIDKeyboardModifierMappingDst":0x100000014
},
{"HIDKeyboardModifierMappingSrc":0x70000001F,
"HIDKeyboardModifierMappingDst":0x100000002
},
{"HIDKeyboardModifierMappingSrc":0x700000022,
"HIDKeyboardModifierMappingDst":0x100000005
}, ]
}'
If I try this on macOS 14.3 I get the error:
Run as root to remap alphanumerics / special characters with UserKeyMapping
If I run with sudo, it works.
However, Ross is currently running macOS Ventura - so I think this might not be his specific issue.
I'm not really sure what the solution is here, as we don't really want CommandPost to have root access.
For reference, here's the Lua code that triggers hidutil:
--- hs.razer:defaultKeyboardLayout(enabled) -> boolean
--- Method
--- Allows you to remap the default Keyboard Layout on a Razer device so that the buttons no longer trigger their factory default actions, or restore the default keyboard layout.
---
--- Parameters:
--- * enabled - If `true` the Razer default will use its default keyboard layout.
---
--- Returns:
--- * The `hs.razer` object.
--- * `true` if successful otherwise `false`
function razerObject:defaultKeyboardLayout(enabled)
local productID = "0x" .. string.upper(string.format("%04x", self:_productID()))
local remapping = self:_remapping()
if not remapping then
log.ef("This Razer device does not support remapping.")
return false
end
local command = [[hidutil property --matching '{"ProductID":]] .. productID .. [[}' --set '{"UserKeyMapping":[]] .. "\n"
for realID, dummyID in pairs(remapping) do
local src = enabled and realID or dummyID
local dst = enabled and dummyID or realID
command = command .. [[ {"HIDKeyboardModifierMappingSrc":]] .. src .. [[,]] .. "\n"
command = command .. [[ "HIDKeyboardModifierMappingDst":]] .. dst .. "\n"
command = command .. [[ },]] .. "\n"
end
command = command:sub(1, #command - 1)
command = command .. " ]" .. "\n"
command = command .. "}'"
local _, status = execute(command)
return self, status == true
end
Reported by Ross Batten via phone call.
Currently CommandPost uses
hidutilto disable the default keyboard layout for Razer devices.Essentially we remap the Razer device so that all the built-in buttons don't actually "type" anything. Then in our Objective-C Extension (
hs.razer) we detect the button presses there.This has always worked fine in the past, but interestingly Ross is having issues on his machine.
He has a Mac Studio running Ventura - and it's all working fine there. However, he cloned his operating system to an external SSD, and when booting from the external SSD, things no longer work. Given that it's exactly the same hardware, same operating system, and same configuration, makes me think it's some kind of security issue. However, I tried disabling and re-enabling all the various permissions CommandPost needs and it didn't seem to make a difference.
Interestingly however, when looking into this, it seems that
hidutilstopped working on macOS Sonoma 14.2, which was fixed in macOS Sonoma 14.3 - but now requiressudo(see here).I'm currently running macOS 14.3, and it looks like it's broken on my machine.
For a Razer Orbweaver Chroma for example, we use the following Terminal command:
If I try this on macOS 14.3 I get the error:
Run as root to remap alphanumerics / special characters with UserKeyMapping
If I run with
sudo, it works.However, Ross is currently running macOS Ventura - so I think this might not be his specific issue.
I'm not really sure what the solution is here, as we don't really want CommandPost to have root access.
For reference, here's the Lua code that triggers
hidutil: