Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Common Mouse Shortcut Keys to the Tool #63

Closed
zoushiyin opened this issue Nov 24, 2024 · 9 comments
Closed

Adding Common Mouse Shortcut Keys to the Tool #63

zoushiyin opened this issue Nov 24, 2024 · 9 comments
Assignees

Comments

@zoushiyin
Copy link

Hi,

We often use shortcut keys on common mice, such as copy, paste, cut, previous page, next page, etc. Would it be possible to add support for these shortcut keys to this tool?

@No0ne No0ne self-assigned this Nov 25, 2024
@No0ne
Copy link
Owner

No0ne commented Nov 25, 2024

The IMPS/2 protocol supports 5 mouse buttons, so previous page and next page should be mapped to button 4 and 5 and working. More mouse buttons are only implemented by proprietary drivers which I can't support.

@zoushiyin
Copy link
Author

I want to map the "Previous Page" and "Next Page" buttons to "Copy" and "Paste" actions. The ms_db values for these buttons are 0x10 and 0x08, respectively. Thanks.

@No0ne
Copy link
Owner

No0ne commented Nov 25, 2024

I don't know what "Copy" and "Paste" actions are on mouse buttons. Do you mean the mouse button should send a keyboard key?

@No0ne
Copy link
Owner

No0ne commented Nov 25, 2024

Regarding to https://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/translate.pdf the keyboard copy/paste keys don't have PS/2 equivalents.

@zoushiyin
Copy link
Author

I have the following code to detect and handle mouse shortcuts:

// Detect and handle mouse shortcuts
if (buttons == 0x10) { // Copy shortcut (Ctrl+C)
printf("Copy (Ctrl+C) triggered\n");
// Simulate pressing the Ctrl key
kb_send_key(0x14, true, 0);
// Simulate pressing the 'C' key
kb_send_key(0x21, true, 0);
// Simulate releasing the 'C' key
kb_send_key(0x21, false, 0);
// Simulate releasing the Ctrl key
kb_send_key(0x14, false, 0);
} else if (buttons == 0x08) { // Paste shortcut (Ctrl+V)
printf("Paste (Ctrl+V) triggered\n");
// Simulate pressing the Ctrl key
kb_send_key(0x14, true, 0);
// Simulate pressing the 'V' key
kb_send_key(0x2a, true, 0);
// Simulate releasing the 'V' key
kb_send_key(0x2a, false, 0);
// Simulate releasing the Ctrl key
kb_send_key(0x14, false, 0);
}
My code is as follows, but the serial output shows this, and it does not execute the correct commands:

Paste (Ctrl+V) triggered
kb > host 15
kb > host 66
kb > host f0
kb > host 66
kb > host f0
kb > host 15
Mouse Move: X = 0, Y = 0, Z = 0, Buttons = 0x08
Paste (Ctrl+V) triggered
kb > host 15
kb > host 66
kb > host f0
kb > host 66
kb > host f0
kb > host 15
Why is it not executing the correct commands?

@No0ne
Copy link
Owner

No0ne commented Nov 25, 2024

Try this:

kb_send_key(KEYBOARD_MODIFIER_LEFTCTRL, true, 0);
kb_send_key(HID_KEY_C, true, 0);
kb_send_key(HID_KEY_C, false, 0);
kb_send_key(KEYBOARD_MODIFIER_LEFTCTRL, false, 0);
kb_send_key(KEYBOARD_MODIFIER_LEFTCTRL, true, 0);
kb_send_key(HID_KEY_V, true, 0);
kb_send_key(HID_KEY_V, false, 0);
kb_send_key(KEYBOARD_MODIFIER_LEFTCTRL, false, 0);

@zoushiyin
Copy link
Author

zoushiyin commented Nov 26, 2024

The keys are being sent multiple times each time they are triggered. I'm not sure where to control the number of times they are sent. I am using the ms_send_packet function to send the mouse movements and button states. Thank you for your help.
Mouse Move: X = 0, Y = 0, Z = 0, Buttons = 0x00
Mouse Move: X = 0, Y = 0, Z = 0, Buttons = 0x08
Paste (Ctrl+V) triggered
kb > host 14
kb > host 2a
kb > host f0
kb > host 2a
kb > host f0
kb > host 14
Mouse Move: X = 0, Y = 0, Z = 0, Buttons = 0x08
Paste (Ctrl+V) triggered
kb > host 14
kb > host 2a
kb > host f0
kb > host 2a
kb > host f0
kb > host 14
Mouse Move: X = 0, Y = 0, Z = 0, Buttons = 0x08
Paste (Ctrl+V) triggered
kb > host 14
kb > host 2a
kb > host f0
kb > host 2a
kb > host f0
kb > host 14
Mouse Move: X = 0, Y = 0, Z = 0, Buttons = 0x08
Paste (Ctrl+V) triggered
kb > host 14
kb > host 2a
kb > host f0
kb > host 2a
kb > host f0
kb > host 14
Mouse Move: X = 0, Y = 0, Z = 0, Buttons = 0x08
Paste (Ctrl+V) triggered
kb > host 14
kb > host 2a
kb > host f0
kb > host 2a
kb > host f0
kb > host 14
Mouse Move: X = 0, Y = 0, Z = 0, Buttons = 0x00

@No0ne
Copy link
Owner

No0ne commented Nov 26, 2024

You need to set a new boolean true on the first click detection and false on button release and check that for false before sending out key scancodes.

@No0ne
Copy link
Owner

No0ne commented Jan 9, 2025

I'm closing this issue because it became inactive.

@No0ne No0ne closed this as not planned Won't fix, can't repro, duplicate, stale Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants