mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-07 21:53:04 -04:00
add toggleVideoBind (#138)
* Add fullVcPfp * merge latest * Add toggleVideoBind * oops * Clearer modifier key descriptions * Delete src/equicordplugins/fullVcPfp/index.css --------- Co-authored-by: thororen <78185467+thororen1234@users.noreply.github.com>
This commit is contained in:
parent
3aa5a5f35f
commit
c9541dc156
2 changed files with 72 additions and 1 deletions
|
@ -10,7 +10,7 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch
|
||||||
|
|
||||||
### Extra included plugins
|
### Extra included plugins
|
||||||
<details>
|
<details>
|
||||||
<summary>150 additional plugins</summary>
|
<summary>151 additional plugins</summary>
|
||||||
|
|
||||||
### All Platforms
|
### All Platforms
|
||||||
- AllCallTimers by MaxHerbold & D3SOX
|
- AllCallTimers by MaxHerbold & D3SOX
|
||||||
|
@ -136,6 +136,7 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch
|
||||||
- ThemeLibrary by Fafa
|
- ThemeLibrary by Fafa
|
||||||
- Timezones by Aria
|
- Timezones by Aria
|
||||||
- Title by Kyuuhachi
|
- Title by Kyuuhachi
|
||||||
|
- toggleVideoBind by mochie
|
||||||
- TosuRPC by AutumnVN
|
- TosuRPC by AutumnVN
|
||||||
- Translate+ by Prince527 & Ven
|
- Translate+ by Prince527 & Ven
|
||||||
- UnitConverter by sadan
|
- UnitConverter by sadan
|
||||||
|
|
70
src/equicordplugins/toggleVideoBind/index.ts
Normal file
70
src/equicordplugins/toggleVideoBind/index.ts
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2025 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { definePluginSettings } from "@api/Settings";
|
||||||
|
import { EquicordDevs } from "@utils/constants";
|
||||||
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
import { findByPropsLazy } from "@webpack";
|
||||||
|
import { FluxDispatcher } from "@webpack/common";
|
||||||
|
|
||||||
|
const validKeycodes = [
|
||||||
|
"Backspace", "Tab", "Enter", "ShiftLeft", "ShiftRight", "ControlLeft", "ControlRight", "AltLeft", "AltRight", "Pause", "CapsLock",
|
||||||
|
"Escape", "Space", "PageUp", "PageDown", "End", "Home", "ArrowLeft", "ArrowUp", "ArrowRight", "ArrowDown", "PrintScreen", "Insert",
|
||||||
|
"Delete", "Digit0", "Digit1", "Digit2", "Digit3", "Digit4", "Digit5", "Digit6", "Digit7", "Digit8", "Digit9", "KeyA", "KeyB", "KeyC",
|
||||||
|
"KeyD", "KeyE", "KeyF", "KeyG", "KeyH", "KeyI", "KeyJ", "KeyK", "KeyL", "KeyM", "KeyN", "KeyO", "KeyP", "KeyQ", "KeyR", "KeyS", "KeyT",
|
||||||
|
"KeyU", "KeyV", "KeyW", "KeyX", "KeyY", "KeyZ", "MetaLeft", "MetaRight", "ContextMenu", "Numpad0", "Numpad1", "Numpad2", "Numpad3",
|
||||||
|
"Numpad4", "Numpad5", "Numpad6", "Numpad7", "Numpad8", "Numpad9", "NumpadMultiply", "NumpadAdd", "NumpadSubtract", "NumpadDecimal",
|
||||||
|
"NumpadDivide", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "NumLock", "ScrollLock",
|
||||||
|
];
|
||||||
|
|
||||||
|
const settings = definePluginSettings({
|
||||||
|
keyBind: {
|
||||||
|
description: "The key to toggle webcam when pressed.",
|
||||||
|
type: OptionType.STRING,
|
||||||
|
default: "KeyX",
|
||||||
|
isValid: (value: string) => validKeycodes.includes(value),
|
||||||
|
},
|
||||||
|
reqCtrl: {
|
||||||
|
description: "Require control to be held.",
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
reqShift: {
|
||||||
|
description: "Require shift to be held.",
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
reqAlt: {
|
||||||
|
description: "Require alt to be held.",
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const { isVideoEnabled } = findByPropsLazy("isVideoEnabled");
|
||||||
|
|
||||||
|
function handleKeydown({ code, ctrlKey, shiftKey, altKey }: KeyboardEvent) {
|
||||||
|
const { keyBind, reqCtrl, reqShift, reqAlt } = settings.store;
|
||||||
|
if (keyBind !== code || ctrlKey !== reqCtrl || shiftKey !== reqShift || altKey !== reqAlt) { return; } // please don't think about it
|
||||||
|
|
||||||
|
FluxDispatcher.dispatch({
|
||||||
|
type: "MEDIA_ENGINE_SET_VIDEO_ENABLED",
|
||||||
|
enabled: !isVideoEnabled(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "toggleVideoBind",
|
||||||
|
description: "Adds a customizable bind to toggle webcam.",
|
||||||
|
authors: [EquicordDevs.mochienya],
|
||||||
|
settings,
|
||||||
|
start() {
|
||||||
|
document.addEventListener("keydown", handleKeydown);
|
||||||
|
},
|
||||||
|
stop() {
|
||||||
|
document.removeEventListener("keydown", handleKeydown);
|
||||||
|
},
|
||||||
|
});
|
Loading…
Add table
Add a link
Reference in a new issue