fix(ags tablet): fix gestures after rotation
This commit is contained in:
parent
b0710205e6
commit
f065d595a1
2 changed files with 20 additions and 37 deletions
|
@ -2,7 +2,6 @@ import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
||||||
import Service from 'resource:///com/github/Aylur/ags/service.js';
|
import Service from 'resource:///com/github/Aylur/ags/service.js';
|
||||||
import TouchGestures from './touch-gestures.js';
|
import TouchGestures from './touch-gestures.js';
|
||||||
import { execAsync, subprocess } from 'resource:///com/github/Aylur/ags/utils.js';
|
import { execAsync, subprocess } from 'resource:///com/github/Aylur/ags/utils.js';
|
||||||
import GUdev from 'gi://GUdev';
|
|
||||||
|
|
||||||
const ROTATION_MAP = {
|
const ROTATION_MAP = {
|
||||||
'normal': 0,
|
'normal': 0,
|
||||||
|
@ -11,6 +10,10 @@ const ROTATION_MAP = {
|
||||||
'left-up': 1,
|
'left-up': 1,
|
||||||
};
|
};
|
||||||
const SCREEN = 'desc:BOE 0x0964';
|
const SCREEN = 'desc:BOE 0x0964';
|
||||||
|
const DEVICES = [
|
||||||
|
'wacom-hid-52eb-finger',
|
||||||
|
'wacom-hid-52eb-pen',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
class Tablet extends Service {
|
class Tablet extends Service {
|
||||||
|
@ -30,9 +33,10 @@ class Tablet extends Service {
|
||||||
|
|
||||||
#tabletMode = false;
|
#tabletMode = false;
|
||||||
#oskState = false;
|
#oskState = false;
|
||||||
|
/** @type typeof imports.gi.Gio.Subprocess */
|
||||||
#autorotate;
|
#autorotate;
|
||||||
|
/** @type typeof imports.gi.Gio.Subprocess */
|
||||||
#blockedInputs;
|
#blockedInputs;
|
||||||
#udevClient = GUdev.Client.new(['input']);
|
|
||||||
|
|
||||||
get tabletMode() {
|
get tabletMode() {
|
||||||
return this.#tabletMode;
|
return this.#tabletMode;
|
||||||
|
@ -44,7 +48,6 @@ class Tablet extends Service {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.#initUdevConnection();
|
|
||||||
this.#listenOskState();
|
this.#listenOskState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,8 +62,7 @@ class Tablet extends Service {
|
||||||
'--device', '/dev/input/by-path/platform-AMDI0010:02-event-mouse',
|
'--device', '/dev/input/by-path/platform-AMDI0010:02-event-mouse',
|
||||||
'--device', '/dev/input/by-path/platform-thinkpad_acpi-event',
|
'--device', '/dev/input/by-path/platform-thinkpad_acpi-event',
|
||||||
'--device', '/dev/video-bus'],
|
'--device', '/dev/video-bus'],
|
||||||
() => { /**/ },
|
() => { /**/ });
|
||||||
(err) => logError(err));
|
|
||||||
this.emit('inputs-blocked', true);
|
this.emit('inputs-blocked', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,31 +115,6 @@ class Tablet extends Service {
|
||||||
this.emit('mode-toggled', true);
|
this.emit('mode-toggled', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#initUdevConnection() {
|
|
||||||
this.#getDevices();
|
|
||||||
this.#udevClient.connect('uevent', (_, action) => {
|
|
||||||
if (action === 'add' || action === 'remove') {
|
|
||||||
this.#getDevices();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#getDevices() {
|
|
||||||
this.devices = [];
|
|
||||||
Hyprland.sendMessage('j/devices').then((out) => {
|
|
||||||
const devices = JSON.parse(out);
|
|
||||||
|
|
||||||
devices.touch.forEach((dev) => {
|
|
||||||
this.devices.push(dev.name);
|
|
||||||
});
|
|
||||||
devices.tablets.forEach((dev) => {
|
|
||||||
this.devices.push(dev.name);
|
|
||||||
});
|
|
||||||
}).catch(print);
|
|
||||||
|
|
||||||
this.emit('device-fetched', true);
|
|
||||||
}
|
|
||||||
|
|
||||||
startAutorotate() {
|
startAutorotate() {
|
||||||
if (this.#autorotate) {
|
if (this.#autorotate) {
|
||||||
return;
|
return;
|
||||||
|
@ -153,7 +130,7 @@ class Tablet extends Service {
|
||||||
`keyword monitor ${SCREEN},transform,${orientation}`,
|
`keyword monitor ${SCREEN},transform,${orientation}`,
|
||||||
).catch(print);
|
).catch(print);
|
||||||
|
|
||||||
const batchRotate = this.devices.map((dev) =>
|
const batchRotate = DEVICES.map((dev) =>
|
||||||
`keyword device:${dev}:transform ${orientation}; `);
|
`keyword device:${dev}:transform ${orientation}; `);
|
||||||
|
|
||||||
Hyprland.sendMessage(`[[BATCH]] ${batchRotate.flat()}`);
|
Hyprland.sendMessage(`[[BATCH]] ${batchRotate.flat()}`);
|
||||||
|
@ -164,7 +141,6 @@ class Tablet extends Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(err) => logError(err),
|
|
||||||
);
|
);
|
||||||
this.emit('autorotate-started', true);
|
this.emit('autorotate-started', true);
|
||||||
}
|
}
|
||||||
|
@ -182,11 +158,14 @@ class Tablet extends Service {
|
||||||
['bash', '-c', 'busctl monitor --user sm.puri.OSK0'],
|
['bash', '-c', 'busctl monitor --user sm.puri.OSK0'],
|
||||||
(output) => {
|
(output) => {
|
||||||
if (output.includes('BOOLEAN')) {
|
if (output.includes('BOOLEAN')) {
|
||||||
this.#oskState = output.match('true|false')[0] === 'true';
|
const match = output.match('true|false');
|
||||||
this.emit('osk-toggled', this.#oskState);
|
|
||||||
|
if (match) {
|
||||||
|
this.#oskState = match[0] === 'true';
|
||||||
|
this.emit('osk-toggled', this.#oskState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(err) => logError(err),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,12 +44,17 @@ class TouchGestures extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
#gestures = new Map();
|
#gestures = new Map();
|
||||||
|
/** @type typeof imports.gi.Gio.Subprocess */
|
||||||
#gestureDaemon;
|
#gestureDaemon;
|
||||||
|
|
||||||
get gestures() {
|
get gestures() {
|
||||||
return this.#gestures;
|
return this.#gestures;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get gestureDaemon() {
|
||||||
|
return this.#gestureDaemon;
|
||||||
|
}
|
||||||
|
|
||||||
addGesture({
|
addGesture({
|
||||||
name,
|
name,
|
||||||
nFingers = '1',
|
nFingers = '1',
|
||||||
|
@ -57,7 +62,7 @@ class TouchGestures extends Service {
|
||||||
edge = '*',
|
edge = '*',
|
||||||
distance = '*',
|
distance = '*',
|
||||||
command,
|
command,
|
||||||
} = {}) {
|
}) {
|
||||||
gesture = String(gesture).toUpperCase();
|
gesture = String(gesture).toUpperCase();
|
||||||
if (!GESTURE_VERIF.includes(gesture)) {
|
if (!GESTURE_VERIF.includes(gesture)) {
|
||||||
logError('Wrong gesture id');
|
logError('Wrong gesture id');
|
||||||
|
@ -119,7 +124,6 @@ class TouchGestures extends Service {
|
||||||
this.#gestureDaemon = subprocess(
|
this.#gestureDaemon = subprocess(
|
||||||
command,
|
command,
|
||||||
() => { /**/ },
|
() => { /**/ },
|
||||||
(err) => logError(err),
|
|
||||||
);
|
);
|
||||||
this.emit('daemon-started', true);
|
this.emit('daemon-started', true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue