nut.js icon indicating copy to clipboard operation
nut.js copied to clipboard

Question: Support for controller inputs?

Open DebVortex opened this issue 4 years ago • 7 comments

Short summary

Is there controller support in nut.js or is it planned? If not, is there a way of sending "custom keys"?

Desired execution environment / tested on

  • [ ] Virtual machine
  • [ ] Docker container
  • [x] Dev/Host system

Detailed question

Hey there! Nice to see a package thats better maintained than robot.js. As the short summary tells: is there "controller support" in nut.js or is it planned? I guess no to the first question, because I was not able to find anything in the documentation. In particular, I would be interested in e.g. "emulating" a d-pad, joystick or shoulderbuttons (L1, L2 and so on).

If it's not planned, is there a way of sending non-us keyboard characters? I would guess so, because the README says there is support for german special characters, however they are not listed in the key section of the documentation.

DebVortex avatar Nov 10 '20 20:11 DebVortex

Hi @DebVortex,

thanks for reaching out!

We're doing our best to maintain nut.js, although our user base is by far not that big as it is with robot.js (yet).

So far, there is no roadmap or so for nut.js. I'm documenting stuff I want to work on via issues, but I didn't think about controller emulation or anything similar. Mostly because it's out of my current scope and I'm unexperienced.

there is support for german special characters

What's meant here is the fact that it's possible to type things like Cool, Umlaute! ÄäÖöÜü" via keyboard.type`. Something that's not possible with e.g. https://github.com/robot/robot-js. Unfortunately, this is just half the truth, since typing umlauts and special characters is not working on Linux.

Long story short: Support for controller input requires a bit of refinement.

Are controllers really sending unique input? Or is is just some kind of mapping?

Could you elaborate a bit on a way of sending non-us keyboard characters? Are you referring to proper Unicode support or what kind of sequences do you want to send?

Best regards

Simon

s1hofmann avatar Nov 13 '20 17:11 s1hofmann

Hi @s1hofmann !

Thanks for your reply.

Could you elaborate a bit on `a way of sending non-us keyboard characters`? Are you referring to proper Unicode support or what kind of sequences do you want to send?

Good Question. The questions points in a similar direction like the support for controller inport or e.g. "play", "pause", "mute" or buttons for screen brightness. Like: If it's not directly supported, maybe there is a way to "cheat" it a bit.

Here is an controller example. Not sure if it helps but :

I just have plugged in my "XBox like controller" and wrote a short python script to check what the buttons give back. I checked it with the inputs library. I get back event.ev_type, event.code, event.state.

If I try the left shoulder button, I get the following:

  • type: 'Absolute'
  • code: 'ABS_Z'
  • state: 0 (state seems to be a value between 0 and 255, depending on how far you pull the trigger).

The right shoulder button acts the same, however has the code "ABS_RZ".

The left stick sends also type absolute, however as code "ABS_X" with the state -32767 (full left) to 32767 (full right) and "ABS_Y" for up/down.

The right stick sends ABS_RX and ABS_RY

Clicking the sticks gived BTN_THUMBL and BTN_THUMBR with 1 and a 0 on release.

DPad sends ABS_HAT0X -1 or 1 for left/right. ABS_HAT0X -1 or 1 for bottom/top.

The A, B, X and Y Buttons send BTN_SOUTH, BTN_EAST, BTN_WEST and BTN_NORTH with 1 if pressed.

There is also BTN_START or BTN_SELECT

DebVortex avatar Nov 13 '20 19:11 DebVortex

Ok, so I'll have to play around a bit to get a feeling, but I can't promise anything yet.

Mind sharing your Python snippet?

s1hofmann avatar Nov 13 '20 22:11 s1hofmann

Just the one from the documentation:

>>> from inputs import get_gamepad
>>> while 1:
...     events = get_gamepad()
...     for event in events:
...         print(event.ev_type, event.code, event.state)

DebVortex avatar Nov 14 '20 06:11 DebVortex

Thanks anyway!

s1hofmann avatar Nov 14 '20 15:11 s1hofmann

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Apr 28 '22 02:04 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar May 13 '22 02:05 github-actions[bot]