Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions src-tauri/src/app/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pub enum MouseButton {
Left,
Right,
Middle,
Back,
Forward,
Other,
}

Expand All @@ -28,6 +30,9 @@ pub fn map_mouse_button(button: Button) -> MouseButton {
Button::Left => MouseButton::Left,
Button::Right => MouseButton::Right,
Button::Middle => MouseButton::Middle,
// Common side-button codes across Windows, macOS, and Linux/X11.
Button::Unknown(code) if matches!(code, 1 | 3 | 8) => MouseButton::Back,
Button::Unknown(code) if matches!(code, 2 | 4 | 9) => MouseButton::Forward,
_ => MouseButton::Other,
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/components/custom-filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ export const CustomFilter = () => {
<ButtonKey rawKey={RawKey.Drag} />
</div>
<ButtonKey rawKey={RawKey.Right} className="mt-7" />
<ButtonKey rawKey={RawKey.Back} />
<div />
<ButtonKey rawKey={RawKey.Forward} />
</div>
}
{
Expand Down
12 changes: 12 additions & 0 deletions src/lib/keymaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,18 @@ export const keymaps: Record<string, DisplayData> = {
icon: MouseRightClickIcon,
category: "mouse",
},
Back: {
label: "mouse back",
shortLabel: "back",
icon: ArrowLeftIcon,
category: "mouse",
},
Forward: {
label: "mouse forward",
shortLabel: "forward",
icon: ArrowRightIcon,
category: "mouse",
},
Drag: {
label: "drag",
icon: MouseRightDragIcon,
Expand Down
2 changes: 2 additions & 0 deletions src/stores/key_event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ const createKeyEventStore = createSyncedStore<KeyEventStore>(
},
onMouseButtonPress(event: MouseButtonEvent) {
const state = get();
if (event.button === "Other") return;
// set drag start position
const mouse = {
...state.mouse,
Expand All @@ -298,6 +299,7 @@ const createKeyEventStore = createSyncedStore<KeyEventStore>(
},
onMouseButtonRelease(event: MouseButtonEvent) {
const state = get();
if (event.button === "Other") return;
// reset drag state
const mouse = {
...state.mouse,
Expand Down
4 changes: 4 additions & 0 deletions src/types/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export type MouseButton =
| "Left"
| "Right"
| "Middle"
| "Back"
| "Forward"
| "Other";

export const RawKey = {
Expand Down Expand Up @@ -177,6 +179,8 @@ export const RawKey = {
Left: "Left",
Middle: "Middle",
Right: "Right",
Back: "Back",
Forward: "Forward",
Drag: "Drag",
ScrollUp: "ScrollUp",
ScrollDown: "ScrollDown",
Expand Down