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

Help with implementing a config to map Mouse Inputs to custom Keyboard Events #169

Open
TheElixZammuto opened this issue Aug 21, 2024 · 1 comment

Comments

@TheElixZammuto
Copy link

Hi,

First of all I would like to thank you for this project, I managed to make it work immiedately and I love the polish and care even for less experienced users!

I have a very interesting use-case I would like to propose here, but I need help to implement the correct configuration.

The Xbox One and Series console allow the user (via special Development Sandbox mode) to run homebrew software that they can write.

However these software can only access a subset of the input devices that a normal PC can. The worst offender is the KB/M combo. The Xbox Apps can read Keyboard input but not mouse input.

My idea to workaround the missing mouse support (alongside the KB) is by using hid-mapper, via a config that can map a special combo of KB characters from mouse movement and clicks (something like F13 + Shift + a different scan code depending the value of "Cursor X" and "Cursor Y"),

Do you have any pointer on how to implement a config like this and a Keyboard combination that might work best to achieve this?

I've tried "mouse movement to arrow keys, but number of keypresses is proportional to distance" but since the time needed is proportional to how large the mouse is moved, the feeling is pretty much "wrong".

Thank you in advance to anyone that would like to help!

@jfedor2
Copy link
Owner

jfedor2 commented Aug 22, 2024

Sure, you can create an expression like this:

0x00010030 input_state
-8 8 clamp
32 store

32 recall 1 eq 1 store
32 recall 2 eq 2 store
32 recall 3 eq 3 store
32 recall 4 eq 4 store
32 recall 5 eq 5 store
32 recall 6 eq 6 store
32 recall 7 eq 7 store
32 recall 8 eq 8 store
32 recall -1 eq 9 store
32 recall -2 eq 10 store
32 recall -3 eq 11 store
32 recall -4 eq 12 store
32 recall -5 eq 13 store
32 recall -6 eq 14 store
32 recall -7 eq 15 store
32 recall -8 eq 16 store

0x00010031 input_state
-8 8 clamp
32 store

32 recall 1 eq 17 store
32 recall 2 eq 18 store
32 recall 3 eq 19 store
32 recall 4 eq 20 store
32 recall 5 eq 21 store
32 recall 6 eq 22 store
32 recall 7 eq 23 store
32 recall 8 eq 24 store
32 recall -1 eq 25 store
32 recall -2 eq 26 store
32 recall -3 eq 27 store
32 recall -4 eq 28 store
32 recall -5 eq 29 store
32 recall -6 eq 30 store
32 recall -7 eq 31 store
32 recall -8 eq 32 store 

And mappings in the form:
Register 1 -> A
Register 2 -> B
...

Then each key will be pressed when the mouse is moving N units to the left/right/up/down.

If you want to go crazy you can encode individual bits of the mouse input, like so (then you only need 16 keys/registers for two 8-bit values):

0x00010030 input_state
0.001 mul
-0.128 0.127 clamp
32 store

32 recall 0.001 bitwise_and not not 1 store
32 recall 0.002 bitwise_and not not 2 store
32 recall 0.004 bitwise_and not not 3 store
32 recall 0.008 bitwise_and not not 4 store
32 recall 0.016 bitwise_and not not 5 store
32 recall 0.032 bitwise_and not not 6 store
32 recall 0.064 bitwise_and not not 7 store
32 recall 0.128 bitwise_and not not 8 store

0x00010031 input_state
0.001 mul
-0.128 0.127 clamp
32 store

32 recall 0.001 bitwise_and not not 9 store
32 recall 0.002 bitwise_and not not 10 store
32 recall 0.004 bitwise_and not not 11 store
32 recall 0.008 bitwise_and not not 12 store
32 recall 0.016 bitwise_and not not 13 store
32 recall 0.032 bitwise_and not not 14 store
32 recall 0.064 bitwise_and not not 15 store
32 recall 0.128 bitwise_and not not 16 store

Keep in mind you will have to deal with the fact that mouse inputs are relative, while keyboard inputs are absolute. If the key that's encoding the fact that the mouse moved 1 unit to the left is held for 3 milliseconds, it actually means the mouse moved 3 units to the left.

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