Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions src/routes/trackpad.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ function TrackpadPage() {
const bufferText = buffer.join(" + ");
const hiddenInputRef = useRef<HTMLInputElement>(null);
const isComposingRef = useRef(false);

// Load Client Settings
const [sensitivity] = useState(() => {
if (typeof window === 'undefined') return 1.0;
const s = localStorage.getItem('rein_sensitivity');
return s ? parseFloat(s) : 1.0;
});

const [invertScroll] = useState(() => {
if (typeof window === 'undefined') return false;
const s = localStorage.getItem('rein_invert');
Expand All @@ -49,7 +49,7 @@ function TrackpadPage() {

const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
const key = e.key.toLowerCase();

if (modifier !== "Release") {
if (key === 'backspace') {
e.preventDefault();
Expand All @@ -68,15 +68,22 @@ function TrackpadPage() {
}
return;
}
if (key === 'backspace') send({ type: 'key', key: 'backspace' });
else if (key === 'enter') send({ type: 'key', key: 'enter' });
else if (key !== 'unidentified' && key.length > 1) {

if (key === 'backspace') {
e.preventDefault();
if (hiddenInputRef.current) hiddenInputRef.current.value = '';
send({ type: 'key', key: 'backspace' });
} else if (key === 'enter') {
e.preventDefault();
if (hiddenInputRef.current) hiddenInputRef.current.value = '';
send({ type: 'key', key: 'enter' });
} else if (key !== 'unidentified' && key.length > 1) {
send({ type: 'key', key });
}
};

const handleModifierState = () => {
switch(modifier){
switch (modifier) {
case "Active":
if (buffer.length > 0) {
setModifier("Hold");
Expand All @@ -96,11 +103,8 @@ function TrackpadPage() {
};

const handleModifier = (key: string) => {
console.log(`handleModifier called with key: ${key}, current modifier: ${modifier}, buffer:`, buffer);

if (modifier === "Hold") {
const comboKeys = [...buffer, key];
console.log(`Sending combo:`, comboKeys);
sendCombo(comboKeys);
return;
} else if (modifier === "Active") {
Expand Down Expand Up @@ -139,7 +143,7 @@ function TrackpadPage() {
// Don't send text during modifier mode
if (modifier !== "Release") {
handleModifier(val);
}else{
} else {
sendText(val);
}
(e.target as HTMLInputElement).value = '';
Expand Down