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

Allow arbitrary scancodes #857

Closed
mondalaci opened this issue Nov 14, 2018 · 16 comments
Closed

Allow arbitrary scancodes #857

mondalaci opened this issue Nov 14, 2018 · 16 comments
Assignees

Comments

@mondalaci
Copy link
Member

Let's allow users to provide custom scancodes. There are 3 types of scancodes according to the USB interfaces that the UHK exposes:

  • The basic keyboard interface implements the Keyboard/Keypad Page. See chapter 10, page 53 of HID Usage Tables. Scancode type abbreviation is B for basic.
  • The media keyboard interface implements the Consumer Page. See chapter 15, page 75 of HID Usage Tables. Scancode type abbreviation is M for media.
  • The system keyboard interface implements the Generic Desktop Page. See chapter 4, page 26 of HID Usage Tables. Scancode type abbreviation is S for system.

As for the valid numeric intervals of the scancodes, it's 1-255 for basic and system scancodes and 1-65535 for media scancodes.

Users will be able to write a string composed of the scancode type and scancode number into the scancode field of the key action popover and the macro editor to specify the desired scancode. Examples are B62, M180, and S10.

The scancode select2 widget won't contain custom scancodes because they're of no use for most. This way, the feature will be available for advanced users, but it won't confuse regular users.

When entering a custom scancode, Agent will look up the scancode.

  • If the scancode is already part of the scancodes that Agent exposes in the scancode select2 widget then choose the relevant select2 item, and render its key as such.
  • Otherwise, display the custom scancode as it is, like B62 in the select2 widget, and render its key as such.

Currently, Agent replaces unknown scancodes that are not part of the select2 widget with none actions when encountering with them. For this feature to work correctly, Agent must not replace such scancodes anymore, but leave them as they are.

@luteijn
Copy link

luteijn commented Nov 14, 2018

Great news, thanks for coming up with this way of making it workable.

@laxu
Copy link
Contributor

laxu commented Nov 18, 2018

Can we find if there is some software that could deduce the scancodes needed, e.g. by using the custom keys on a laptop and the software telling the scancodes received? We could then recommend this software for finding out the scancodes needed as that can be an endeavour in itself because a lot of manufacturers don't document them anywhere.

E.g. "To add custom scancode, run this software, press the custom key on your laptop and use the received scancode in UHK Agent".

@mondalaci
Copy link
Member Author

@laxu To my knowledge, every OS does some sort of abstraction under the hood that makes user space applications unable to retrieve this information, and so, no such software exists.

@kareltucek
Copy link
Contributor

On linux there's showkey (showkey --scancodes). It has to be run from tty.

Of course, if some sort of laptop firmware translates its specific scancodes on too low abstraction level, it might not tell you anything.

@luteijn
Copy link

luteijn commented Nov 18, 2018

The technique explained at https://jacksautohotkeyblog.wordpress.com/2016/04/14/understanding-autohotkey-keyboard-scan-codes-and-virtual-key-codes-beginning-hotkeys-part-12/ might be helpful for windows - especially if you plan to use AHK to receive special scancodes and act on them.

@skaldesh
Copy link

skaldesh commented Sep 5, 2019

May I ask, what is the status of this issue?

@mondalaci
Copy link
Member Author

No progress has been made with this issue yet. We don't have an ETA for GitHub issues, and we'll update them when progress is made.

@debbiev
Copy link

debbiev commented Mar 14, 2020

Will this let me add a handful of emojis?

@mondalaci
Copy link
Member Author

No, emojis can be implemented with macros, not with special scancodes. See https://ultimatehackingkeyboard.com/blog/2018/06/23/how-can-i-type-accented-characters-with-my-uhk

@DDzwiedziu
Copy link

I'd like this quite much. As I've tried to generate a XF86XK_AudioMicMute keysym to capture it in the agent. The agent just went "None" for the scancode, but the mic mute toggled.

@FatBoyXPC
Copy link

FatBoyXPC commented May 24, 2021

I was just looking for XF86XK_AudioMicMute and realized I might need to do the scancode option. I'll be trying it soon!

Edit - I hit capture and it didn't seem to see that capture that keypress for me. Were you able to make this work @DDzwiedziu?

Edit again: Apparently F20 works to send that keycode for me, see this tweet for details

@mondalaci
Copy link
Member Author

This feature has been implemented, and it will be included in the next Agent release.

@FatBoyXPC
Copy link

I've downloaded the latest release but I'm unsure how to input said arbitrary scancode?

@kareltucek
Copy link
Contributor

kareltucek commented Nov 30, 2021

As stated above, entering a code like B24 in the scancode field (tested with 1.5.17, works fine). Agent tries to lookup the scancode and if found, it will show just the actual entry. E.g., for "b24" it will show "letter U", which is confusing, but sort-of correct.

It might be a good idea to always show custom-scancode entry when custom code is entered - @mondalaci, @ert78gb?

Also, custom scancodes could be mentioned in the "?" popover.

@ert78gb
Copy link
Member

ert78gb commented Nov 30, 2021

It depends from Laci. I am fine with both solution

@mondalaci
Copy link
Member Author

The scancode of B24 and U is the same, and from Agent's standpoint, they're identical. Also, from a usability standpoint, it's better to show the symbolic name of the scancode whenever possible, so we won't change the current behavior.

I'll document the custom scancode feature and mention it in the scancode tooltip according to #1642.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants