davinci resolve 是一款非线性影片剪辑软件,mac 下快捷键配置文件位于:
lucas@lucasdeMacBook-Pro DaVinci Resolve % pwd
/Users/lucas/Library/Preferences/Blackmagic Design/DaVinci Resolve
lucas@lucasdeMacBook-Pro DaVinci Resolve % ll | grep key
-rw-rw-rw- 1 lucas staff 181908 12 9 15:43 keyboard.preset.xml
文件部分内容如下:
lucas@lucasdeMacBook-Pro DaVinci Resolve % cat keyboard.preset.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--DbAppVer="18.1.1.0007" DbPrjVer="11"-->
<SmKeyboardPresetList DbId="b343b0c6-f893-4b46-8ac8-dad2a6503b88">
<FieldsBlob/>
<PresetListBA>00000001000000020000001a0064006100760069006e00630065005f...............0072000000010000000100000041</PresetListBA>
</SmKeyboardPresetList>
lucas@lucasdeMacBook-Pro DaVinci Resolve %
因篇幅较多,中间部分省略。可以看到虽然是 xml 文件,但具体配置内容做了处理。细看的话配置部分全是16进制,且基本16位一组,或许可以转成 ascii 字符看看。于是将这部分单独拿出放在 key.txt 文件中:
int main()
{
char str[200000] = {0};
FILE *fp = fopen("/Users/lucas/Desktop/key.txt", "r");
fgets(str, 200000, fp);
int len = strlen(str);
int i = 0;
string s = "";
while (i < len) {
int sum = 0, val = 0;
char c = ' ';
for (int j = 0; j < 4; ++j) {
switch (str[i+j]) {
case 'a': val = 10; break;
case 'b': val = 11; break;
case 'c': val = 12; break;
case 'd': val = 13; break;
case 'e': val = 14; break;
case 'f': val = 15; break;
default: val = str[i+j] - '0'; break;
}
sum = sum * 16 + val;
}
c = ((sum < 33) || (sum > 126)) ? ' ' : (char)sum;
s = s + c;
i += 4;
}
cout << s << endl;
return 0;
}
执行后部分输出结果如下:
lucas@lucasdeMacBook-Pro testCpp % g++ -g -Wall test.cpp -o test
lucas@lucasdeMacBook-Pro testCpp % ./test
davince_lucas *editMulticamNextAngle TFusionWidget..fuHotkey_GLView_Viewer
_Reset.......controlPlayAroundToPlayAroundCurrentSelection /
nodesAddCPW C nFusionWidget..fuHotkey_FuFrame_Tool_ViewO 2 2 editPointer A
格式有点乱,但信息还是比较清晰,开头的 davince_lucas 恰好就是修改快捷键配置时的自定义预设:
将其导出后可以看到前面部分:
editPointer := A
controlPlayAroundToPlayAroundCurrentSelection := /
nodesAddCPW := Alt+C
editAutoSelectToggleAudio4 := Ctrl+Alt+F4......
如 editPointer 和 controlPlayAroundToPlayAroundCurrentSelection 部分看着还是吻合的,说明思路大体是正确的。但格式上依然还存在些问题,且没打印出 ctrl、alt 等控制符,这块私以为是开发人员将这些控制符等特殊字符与某个特定的16进制数字做了个映射,只要程序识别出对应的16进制数字,将其替换成相应的符号或按键即可。