J2Kbr / GtunerIV

Gtuner IV - Titan Two's software bug report.
http://www.consoletuner.com
25 stars 4 forks source link

Input Traslator - remap a 'button to key' and a 'key to key' #152

Closed Scachi closed 7 years ago

Scachi commented 7 years ago

We are already able to map a key to a button, "duplicating" (wasting) a button. If I can bind the button itself to a key I am able to use the button for a completely new function/control in the scripts easily.

As an example: I can add an interactive configuration option for some advanced script controls like [rapid fire preset switching] with a combobox to select a key to use for it ( a..Z)

If a user owns a footswitch, he/she can enable this option and assign a key to it according what their footswitch send, like: 'A'

If the user want to use the footswitch 'A' for crouching and instead use the crouch button X for rapid fire preset switching, he/she have to edit the code or I have to add support for it to the code wasting some more bytecode space.

If the 'Input Translator' allows to rebind 'key to key' and 'button to key' there is no work needed for the coder. The user just configures the Input Translator: Controller Mapping: 'Button X' -> 'A' Keyboard Mapping: 'A' -> 'Button X'

Maybe adding an additional "Button mapping" to the Input Translator would be a cleaner solution.

If the user owns a footswitch with three pedals and I added support for more keys to my script, like 'A' , 'B' , 'C' the user can use the Input Translator to map his pedals keypress output (it may be 1,2,3) to my scripts estimated keys without having to mess with their configuration of the footswitch itself by using the 'key to key' mapping feature.

J2Kbr commented 7 years ago

The Input Translator configuration is evaluated at the "device driver" level, associated to the input port. An Input Translator instruct/help the device driver to convert the raw data from the device and store the values in the normalized data structure (BUTTON_*, STICK_*, POINTER_*, etc), so it can be used by scripts in an standardized form.

The HID report of keyboards are read only and private to the device driver. The device driver of a controller have no knowledge and can't access the data/reports of others device drivers. Therefore, is not possible to have an Input Translator being evaluated by a controller device driver configured to stimulate an key in a keyboard device driver. Even if we implement a way to overcome this limitation, the mapping of an button to a key will not work if there is no keyboard connected.

As you observed, a possible solution can be provided via the script code.