qdesk 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  import { CallNextHookEx, decodeKeyboardHookLParam, DispatchMessageW, GetAsyncKeyState, GetMessageW, GetModuleHandleW, registerKeyboardHookCallback, SetWindowsHookExW, TranslateMessage, UnhookWindowsHookEx, unregisterCallback, } from "./koffi-utils.js";
2
+ const process = globalThis.process;
2
3
  const MOD_ALT = 0x0001;
3
4
  const MOD_CONTROL = 0x0002;
4
5
  const MOD_SHIFT = 0x0004;
@@ -6,6 +7,7 @@ const MOD_WIN = 0x0008;
6
7
  const VK_SHIFT = 0x10;
7
8
  const VK_CONTROL = 0x11;
8
9
  const VK_MENU = 0x12;
10
+ const VK_ESCAPE = 0x1b;
9
11
  const VK_LWIN = 0x5b;
10
12
  const VK_RWIN = 0x5c;
11
13
  const HC_ACTION = 0;
@@ -164,11 +166,20 @@ export function startListening(options) {
164
166
  return passThrough();
165
167
  }
166
168
  const kb = decodeKeyboardHookLParam(lParam);
167
- const combo = buildCurrentChord(Number(kb.vkCode));
169
+ const vkCode = Number(kb.vkCode);
170
+ let shouldStopPropagation = false;
171
+ if (vkCode === VK_ESCAPE) {
172
+ options.onEscape?.(() => {
173
+ shouldStopPropagation = true;
174
+ });
175
+ if (shouldStopPropagation) {
176
+ return 1n;
177
+ }
178
+ }
179
+ const combo = buildCurrentChord(vkCode);
168
180
  if (!combo) {
169
181
  return passThrough();
170
182
  }
171
- let shouldStopPropagation = false;
172
183
  if (activationNormalized && combo === activationNormalized) {
173
184
  options.onActivation?.(() => {
174
185
  shouldStopPropagation = true;
package/dist/index.js CHANGED
@@ -33,6 +33,22 @@ const toolWindowAtStartup = getActiveWindowHandleAndName() ?? undefined;
33
33
  console.log("[info] Tool window at startup:", toolWindowAtStartup?.name ?? "(unknown)");
34
34
  let removalReturnWindow;
35
35
  const listener = startListening({
36
+ onEscape: (stopPropagating) => {
37
+ if (!activeRecording && !awaitingChordRemoval) {
38
+ return;
39
+ }
40
+ if (activeRecording) {
41
+ console.log("[add] Canceled recording mode via Escape.");
42
+ activeRecording = undefined;
43
+ }
44
+ if (awaitingChordRemoval) {
45
+ console.log("[drop] Canceled removal mode via Escape.");
46
+ awaitingChordRemoval = false;
47
+ }
48
+ setScreenHue("off");
49
+ printBindings();
50
+ stopPropagating();
51
+ },
36
52
  onChord: (chord, stopPropagating) => {
37
53
  if (activeRecording) {
38
54
  if ([ADD_CHORD, DROP_CHORD].includes(chord)) {
@@ -49,9 +49,9 @@ function buildGammaRamp(redScale, greenScale, blueScale) {
49
49
  function buildColorEffectMatrix(mode) {
50
50
  // MAGCOLOREFFECT is a 5x5 float matrix.
51
51
  const matrix = Buffer.alloc(25 * 4);
52
- const redScale = mode === "record" ? 1.0 : mode === "remove" ? 0.35 : 1.0;
53
- const greenScale = mode === "record" ? 0.3 : mode === "remove" ? 1.0 : 1.0;
54
- const blueScale = mode === "record" ? 0.18 : mode === "remove" ? 0.35 : 1.0;
52
+ const redScale = mode === "record" ? 0.35 : mode === "remove" ? 1.0 : 1.0;
53
+ const greenScale = mode === "record" ? 1.0 : mode === "remove" ? 0.3 : 1.0;
54
+ const blueScale = mode === "record" ? 0.35 : mode === "remove" ? 0.18 : 1.0;
55
55
  const values = [
56
56
  redScale,
57
57
  0,
@@ -108,13 +108,13 @@ export function setScreenHue(mode) {
108
108
  if (mode !== "off") {
109
109
  // Try requested tint first, then a milder fallback accepted by more drivers.
110
110
  const primaryRamp = mode === "record"
111
- ? buildGammaRamp(1.0, 0.22, 0.35)
112
- : buildGammaRamp(0.4, 1.0, 0.4);
111
+ ? buildGammaRamp(0.4, 1.0, 0.4)
112
+ : buildGammaRamp(1.0, 0.22, 0.35);
113
113
  let ok = Number(SetDeviceGammaRamp(screenDc, primaryRamp));
114
114
  if (!ok) {
115
115
  const fallbackRamp = mode === "record"
116
- ? buildGammaRamp(1.0, 0.58, 0.35)
117
- : buildGammaRamp(0.65, 1.0, 0.65);
116
+ ? buildGammaRamp(0.65, 1.0, 0.65)
117
+ : buildGammaRamp(1.0, 0.58, 0.35);
118
118
  ok = Number(SetDeviceGammaRamp(screenDc, fallbackRamp));
119
119
  }
120
120
  if (ok) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qdesk",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,6 +16,13 @@
16
16
  "files": [
17
17
  "dist"
18
18
  ],
19
+ "scripts": {
20
+ "dev": "tsx src/index.ts",
21
+ "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
22
+ "build": "pnpm clean && tsc -p tsconfig.json",
23
+ "start": "node dist/index.js",
24
+ "prepack": "pnpm build"
25
+ },
19
26
  "dependencies": {
20
27
  "koffi": "^3.0.2"
21
28
  },
@@ -23,11 +30,5 @@
23
30
  "@types/node": "^22.15.30",
24
31
  "tsx": "^4.19.4",
25
32
  "typescript": "^5.8.3"
26
- },
27
- "scripts": {
28
- "dev": "tsx src/index.ts",
29
- "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
30
- "build": "pnpm clean && tsc -p tsconfig.json",
31
- "start": "node dist/index.js"
32
33
  }
33
- }
34
+ }