add plugin
@@ -28,7 +28,7 @@ public class Listener
|
|||||||
|
|
||||||
var options = new JsonSerializerOptions
|
var options = new JsonSerializerOptions
|
||||||
{
|
{
|
||||||
PropertyNameCaseInsensitive = true // чтобы Email/email/EMAIL не ломалось
|
PropertyNameCaseInsensitive = true
|
||||||
};
|
};
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
|
|||||||
|
After Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 83 KiB |
|
After Width: | Height: | Size: 83 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 65 KiB |
|
After Width: | Height: | Size: 65 KiB |
@@ -0,0 +1,10 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<!-- <script src="pi.js"></script> -->
|
||||||
|
<script src="main.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
let websocket = null;
|
||||||
|
let uuid = null;
|
||||||
|
let ctxSettings = new Map();
|
||||||
|
|
||||||
|
const ACTION_MAP = {
|
||||||
|
"ru.wildtail.httpkeys.discord_micro_mute": {
|
||||||
|
actionId: "discord_micro_mute"
|
||||||
|
},
|
||||||
|
"ru.wildtail.httpkeys.discord_mute": {
|
||||||
|
actionId: "discord_mute"
|
||||||
|
},
|
||||||
|
"ru.wildtail.httpkeys.teamspeak_micro_mute": {
|
||||||
|
actionId: "teamspeak_micro_mute"
|
||||||
|
},
|
||||||
|
"ru.wildtail.httpkeys.talk_micro_mute": {
|
||||||
|
actionId: "talk_micro_mute"
|
||||||
|
},
|
||||||
|
"ru.wildtail.httpkeys.system_micro_mute": {
|
||||||
|
actionId: "system_micro_mute"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// подключение от D6
|
||||||
|
function connectElgatoStreamDeckSocket(inPort, inUUID, inRegisterEvent, inInfo) {
|
||||||
|
uuid = inUUID;
|
||||||
|
|
||||||
|
websocket = new WebSocket("ws://127.0.0.1:" + inPort);
|
||||||
|
|
||||||
|
websocket.onopen = function () {
|
||||||
|
websocket.send(JSON.stringify({
|
||||||
|
event: inRegisterEvent,
|
||||||
|
uuid: uuid
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
websocket.onmessage = function (evt) {
|
||||||
|
const msg = JSON.parse(evt.data);
|
||||||
|
|
||||||
|
const { event, action, context, payload } = msg;
|
||||||
|
|
||||||
|
if (event === "willAppear") {
|
||||||
|
const s = (payload && payload.settings) || { isOn: false };
|
||||||
|
ctxSettings.set(context, s);
|
||||||
|
setState(context, s.isOn ? 1 : 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event === "didReceiveSettings") {
|
||||||
|
const s = payload.settings || { isOn: false };
|
||||||
|
ctxSettings.set(context, s);
|
||||||
|
setState(context, s.isOn ? 1 : 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event === "keyDown") {
|
||||||
|
handleKeyDown(action, context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// обработка нажатия
|
||||||
|
function handleKeyDown(action, context) {
|
||||||
|
|
||||||
|
let s = ctxSettings.get(context) || { isOn: false };
|
||||||
|
const prevState = s.isOn;
|
||||||
|
|
||||||
|
s.isOn = !s.isOn;
|
||||||
|
const newState = s.isOn;
|
||||||
|
|
||||||
|
ctxSettings.set(context, s);
|
||||||
|
|
||||||
|
setState(context, newState ? 1 : 0);
|
||||||
|
|
||||||
|
websocket.send(JSON.stringify({
|
||||||
|
event: "setSettings",
|
||||||
|
context: context,
|
||||||
|
payload: s
|
||||||
|
}));
|
||||||
|
|
||||||
|
const cfg = ACTION_MAP[action];
|
||||||
|
if (!cfg) return;
|
||||||
|
|
||||||
|
post("http://127.0.0.1:16888/press", {
|
||||||
|
actionUUID: action,
|
||||||
|
actionId: cfg.actionId,
|
||||||
|
|
||||||
|
toggleChanged: prevState !== newState,
|
||||||
|
state: newState ? "on" : "off",
|
||||||
|
|
||||||
|
isOn: newState,
|
||||||
|
context: context,
|
||||||
|
timestamp: Date.now()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// смена state
|
||||||
|
function setState(context, stateIndex) {
|
||||||
|
websocket.send(JSON.stringify({
|
||||||
|
event: "setState",
|
||||||
|
context: context,
|
||||||
|
payload: { state: stateIndex }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTP POST
|
||||||
|
function post(url, data) {
|
||||||
|
fetch(url, {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify(data)
|
||||||
|
}).catch(err => console.error(err));
|
||||||
|
}
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
{
|
||||||
|
"Author": "you",
|
||||||
|
"CodePath": "index.html",
|
||||||
|
"Description": "D6 plugin: button -> HTTP POST to localhost",
|
||||||
|
"Icon": "icon",
|
||||||
|
"Name": "HTTP Keys",
|
||||||
|
"Version": "0.1.0",
|
||||||
|
"SDKVersion": 2,
|
||||||
|
"OS": [
|
||||||
|
{ "Platform": "windows", "MinimumVersion": "10" }
|
||||||
|
],
|
||||||
|
"Software": { "MinimumVersion": "1.0" },
|
||||||
|
"Category": "Utilities",
|
||||||
|
"CategoryIcon": "icon",
|
||||||
|
|
||||||
|
"Actions": [
|
||||||
|
{
|
||||||
|
"Name": "Discord Mute Micro",
|
||||||
|
"UUID": "ru.wildtail.httpkeys.discord_micro_mute",
|
||||||
|
"Icon": "icon",
|
||||||
|
"Tooltip": "Toggle Discord Mute Micro",
|
||||||
|
"PropertyInspectorPath": "index.html",
|
||||||
|
"States": [
|
||||||
|
{
|
||||||
|
"Image": "icons/DiscordUnmuteMicro",
|
||||||
|
"TitleAlignment": "middle",
|
||||||
|
"FontSize": "12"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Image": "icons/DiscordMuteMicro",
|
||||||
|
"TitleAlignment": "middle",
|
||||||
|
"FontSize": "12"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"Name": "Discord Mute",
|
||||||
|
"UUID": "ru.wildtail.httpkeys.discord_mute",
|
||||||
|
"Icon": "icon",
|
||||||
|
"Tooltip": "Toggle Discord Full Mute",
|
||||||
|
"PropertyInspectorPath": "index.html",
|
||||||
|
"States": [
|
||||||
|
{
|
||||||
|
"Image": "icons/DiscordUnmute",
|
||||||
|
"TitleAlignment": "middle",
|
||||||
|
"FontSize": "12"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Image": "icons/DiscordMute",
|
||||||
|
"TitleAlignment": "middle",
|
||||||
|
"FontSize": "12"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"Name": "Teamspeak Mute Micro",
|
||||||
|
"UUID": "ru.wildtail.httpkeys.teamspeak_micro_mute",
|
||||||
|
"Icon": "icon",
|
||||||
|
"Tooltip": "Toggle Teamspeak Mute Micro",
|
||||||
|
"PropertyInspectorPath": "index.html",
|
||||||
|
"States": [
|
||||||
|
{
|
||||||
|
"Image": "icons/TeamspeakUnmuteMicro",
|
||||||
|
"TitleAlignment": "middle",
|
||||||
|
"FontSize": "12"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Image": "icons/TeamspeakMuteMicro",
|
||||||
|
"TitleAlignment": "middle",
|
||||||
|
"FontSize": "12"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"Name": "Talk Mute Micro",
|
||||||
|
"UUID": "ru.wildtail.httpkeys.talk_micro_mute",
|
||||||
|
"Icon": "icon",
|
||||||
|
"Tooltip": "Toggle Talk Mute",
|
||||||
|
"PropertyInspectorPath": "index.html",
|
||||||
|
"States": [
|
||||||
|
{
|
||||||
|
"Image": "icons/TalkUnmuteMicro",
|
||||||
|
"TitleAlignment": "middle",
|
||||||
|
"FontSize": "12"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Image": "icons/TalkMuteMicro",
|
||||||
|
"TitleAlignment": "middle",
|
||||||
|
"FontSize": "12"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"Name": "System Mute Micro",
|
||||||
|
"UUID": "ru.wildtail.httpkeys.system_micro_mute",
|
||||||
|
"Icon": "icon",
|
||||||
|
"Tooltip": "Toggle System Mute Micro",
|
||||||
|
"PropertyInspectorPath": "index.html",
|
||||||
|
"States": [
|
||||||
|
{
|
||||||
|
"Image": "icons/SystemUnmuteMicro",
|
||||||
|
"TitleAlignment": "middle",
|
||||||
|
"FontSize": "12"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Image": "icons/SystemMuteMicro",
|
||||||
|
"TitleAlignment": "middle",
|
||||||
|
"FontSize": "12"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
const { streamDeckClient } = window; // если у тебя SDPI lib иначе ниже смотри
|
||||||
|
|
||||||
|
document.getElementById("action").addEventListener("change", () => {
|
||||||
|
const action = document.getElementById("action").value;
|
||||||
|
$SD.api.setSettings($SD.uuid, { action }); // сохраняем строку
|
||||||
|
});
|
||||||