Native support for input devices | Native support for DIY input devices.



Rep: (1303)
This topic is a continuation of the article.//savagemessiahzine.com/2014/12/12/190359/
Here we discuss how to create native support for input devices and share ready-made solutions.
Attached Image

Tools
Tools:
  • Android 4+ device (checked only on 5.0 and 4.4);
  • USB OTG device support;
  • root access;
  • file manager with root support (in my case, this is Total Commander);
  • text editor (in my case it is Total Commander again);
  • a sheet of paper and a pencil;
  • USB Device Info(to determine the properties of the device);
  • Keytest(to display the device button codes)temporarily unavailable on the link, download from the forum link below.
    Another program that displays button codes and axis actionsGoogle play
    Universal program for testing buttons, editing actions and creating a configGamepad tester

Also, these applications can be downloaded on the forumNative support for input devices (Post # 36465278)

Step one. VID and PID
1. Creating a file with VID and PID
We connect our input device and launch the USB Device Info application. We are interested in the Linux tab, in which we select our device (I had it last in the list) and look for the values ​​of the Vendor ID and Product ID lines. In my case it was 0c45 and 7700, respectively.
Attached Image

Also VID and PID can be viewed by connecting the device to the PC.
Attached Image

For Bluetooth devices:
You can find these values ​​for Bluetooth devices by opening the file / proc / bus / input / devices.

Copy any file from / system / usr / keylayout to sdcard and rename it according to the received data; for my joystick, the name is:Vendor_0c45_Product_7700.kl. (Note that letter case does matter)

Step two. Getting button codes.
2. Getting Button Codes
Launch the KeyTest application and, armed with paper and a pencil, we start alternately pressing the buttons on the device, recording the numbers displayed after scanCode =. I wrote down the codes, placing them on paper, like buttons on a gamepad.
Attached Image
From the program you can exit only by the button "Home".

ATTENTION!
If Gamepad is visible in the first step, butKeytest does not respond on pressing, you may not have the required module in the kernel - say "thank you" to the author of the firmware.
But do not despair, there is a possible solution.Native support for input devices (Post wm-hater # 52134473)

Step three. Mapping buttons.
3. Mapping buttons
Now that the codes for all keys have become known, it is necessary to prescribe their functions. There are two ways:
a) find a device among the configs available in Android that is as close as possible to yours, and simply change the button codes in it by copying the contents to your file;
b) prescribe everything yourself.
I went the second way, because my joystick has only a control cross and four buttons. First you need to understand the syntax of the file layout, it is very simple:

key button code action_key

But then the question arose: what actions of the buttons to write in the config? For many years of using various gamepads on Android, I have determined for myself that the most universal config is the Sony Xperia Play layout, it behaves equally well in games and in the system interface.

Ok Google key mapping for Xperia Play

Key code constant scancode
X 23 KEYCODE_DPAD_CENTER 304
circle 4 KEYCODE_BACK 305
square 99 KEYCODE_BUTTON_X 307
triangle 100 KEYCODE_BUTTON_Y 308
up 19 KEYCODE_DPAD_UP 106
down 20 KEYCODE_DPAD_DOWN 105
left 21 KEYCODE_DPAD_LEFT 103
right 22 KEYCODE_DPAD_RIGHT 108
select 109 KEYCODE_BUTTON_SELECT 314
start 108 KEYCODE_BUTTON_START 28
L trigger 102 KEYCODE_BUTTON_L1 310
R trigger 103 KEYCODE_BUTTON_R1 311

We are interested in the third column, but the record of actions in it is slightly different from those that were found in the system - this is not an obstacle, just remove KEYCODE_.

I register my buttons (remember the sheet of pencil notes? It's time to find it ...):
!!! ATTENTION !!!
Need a text editor with support for unix encoding!
Notepad from Windows is NOT suitable,
Use, for example, Notepad ++
key 147 DPAD_CENTER
key 149 BUTTON_B
key 148 BUTTON_Y
key 146 BUTTON_X
key 157 DPAD_DOWN
key 145 DPAD_LEFT
key 155 DPAD_UP
key 156 DPAD_RIGHT

But here it was not without nuances. At Sony, the KEYCODE_BACK action (the “back” button, which is familiar to us, is assigned to the “circle” button). It is easy to guess that pressing such a button in the game can cause a nervous breakdown. And the thing is that during the game on Xplay, this button takes an alternative value - KEYCODE_BUTTON_B. Here we prescribe it.
The offset along the axis is written as:
axis 0x00 HAT_X
axis 0x01 HAT_Y


Step Four. The moment of truth.
4. The moment of truth
Save our file and copy it to the / system / usr / keylayout folder. Set rights -rw -r -r (644). We reboot the device (I didn’t do this myself, just blocked and unlocked, but for the purity of conscience and experiment I had to write it).

We connect our device, and if everything is done correctly, then you can immediately use the “crossbar” to navigate the Android menu. The button assigned to DPAD_CENTER will be the select button, and BUTTON_B the back button.


Problems and possible solutions
Q:I prescribe everything correctly, but the config does not cling.
BUT: If you register action codes with an error, for example:
key 123BUTTON_HOMEinstead of key 123HOME
then the system will consider this file erroneous.
The best way to check if your kl file is picked up by the system or not is to erase all keycodes or comment them out with a # sign:
#key 123 BUTTON_HOME
If the file is picked up - there will be no reaction to the buttons, but everything will be displayed in KeyTest.

Q:I prescribe everything correctly and without errors, but all or part of the buttons do not work.
BUT: Try writing scancode in hex format: Native support for input devices (Post romanctest # 69194647)
Q:Dualshok 4 constantly falls off or works with a delay.
BUT: Native support for input devices (Post maxmergov # 81264882)

Useful links:

Video instruction if the letters are tight.

Ready * .kl files

Cap in design mode.

Post has been editedderak1129 - 26.01.20, 20:39
Reason for editing: Editing.



Rep: (7)
and clave with a mouse for wot blitz so it will be possible to sip?



Rep: (1)
usb device info joystick sees, but keytest does not see. What to do cm11



Rep: (24)
* Dreamer ...,
The result is zero, did this:
Attached Image

Attached Image



Rep: (1)
I have an interesting situation. Gamepad Defender, without sticks, without vibration, is determined by the tablet machine. And it scrolls through the menus and even works in games (although not always as it should, but it depends on the game). But Logitech F310 doesn’t want to be defined in the system, only the USB / BT Joy program helps. Moreover, the config (or driver) for the latter is in the keylaout, but not for the Defender.



Rep: (365)
* Dreamer ...,
I think that the link toReassigning the functions of buttons on android devices, as well as the fact that you can see the VID | PID through the Windows Device Manager.
Attached Image



Rep: (1303)
* ivanew, in theory you can.
* Pinfo4er try to create an empty .kl file, reboot and check in keyTest again.
* Shadow326159 and keikody prescribed?

Posted 12.12.2014, 23:37:

Hanzo_Hassashi @ 12.12.2014, 21:27*
Moreover, the config (or driver) for the latter is in keylaout,
But are the values ​​of the buttons in it correct?
* ottiwell, Yes. You can view this info in any system.



Rep: (7)
Well, what about wireless devices?
I want to close the windows with the mouse (c) ;)

Attached Image



Rep: (2)
Damn the whole evening, I got drunk with a PS4 gamepad, but it came out not without someone else's effort!
Dualshock 4, although it is connected without any settings, doesn’t work properly, because the settings from Dualshock 3.
I decided to fix them a little and then it started ....
KeyTest sees only the key codes and does not track the axis (although it can and tracks it, but I did not get along) and DPAD doesn’t work that way.
In general, I found out who did most of the work for me, although the guys there were doing something else, they were screwing Dualshock 4 to Amazon Fire TV for which thanks.
http: //forum.xda-devel…rrect-keymaps-t2817223
In the end, I redid it a bit, well, everything, or rather, the majority earned.
Checked on SGS3 and asphalt 8.
It is only necessary to change the extension from txt to kl.

Attached files

Attached fileVendor_054c_Product_05c4.txt(1.22 KB)


Post has been editedspace_cat - 13.12.14, 00:44



Rep: (11)
Guys, I can not download Key Test for the link ...?



Rep: (1)
guys, put the action codes under dualshock or xbox controller
what to prescribe so under gta sa



Rep: (12)
Here is the finished file for such a joey.http://www.exeq.ru/pro..orma-pc/neonlight.html

Attached files

Attached fileEXEQ NEONLight.zip(534 bytes)


Post has been editedbati7 - 13.12.14, 02:50



Rep: (11)
Can someone post the installation apk KeyTest? Why through the cloud, does he weigh less than a canary?

Post has been editedDranyonito - 13.12.14, 04:10



Rep: (24)
Dreamer ... 12.12.2014, 23:37*
Shadow326159, and prescribed keikody?

No, I took it from xbox360 and just renamed it, threw it and set the rights.



Rep: (170)
With bluetooth joey nobody understood? I have an Ipega pg-9025, how do I determine the Vendor / Product ID?



Rep: (1)
* Dreamer ...,
did not help



Rep: (1)
Gluck92 @ 12/13/2014, 12:08*
With bluetooth joey nobody understood? I have an Ipega pg-9025, how do I determine the Vendor / Product ID?
I was helped to find the buttons via KeyTest "scan code", and their change in Generic.kl
And yes, there is a question of determining BT devices



Rep: (365)
Can someone post the installation apk KeyTest?


Attached files

Attached fileKeyTest.apk(13.72 KB)
Attached fileUSBDeviceInfo.apk(63.84 KB)



Rep: (1303)
MEEP! Joystick
Picture
Attached Image

Attached fileMEEP Joystick.zip(618 bytes)



Genius MaxFire Pandora Pro
Picture
Attached Image

Attached fileGenius MaxFire Pandora Pro.zip(634 bytes)


Post has been editedDreamer ... - 13.12.14, 20:37



Rep: (1303)
Hanzo_Hassashi @ 12.12.2014, 21:27*
But Logitech F310 doesn’t want to be defined in the system, only the USB / BT Joy program helps. Moreover, the config (or driver) for the latter is in the keylaout, but for Defender it is not

Once USB / BT Joy sees, it means you can set up a native definition
Well, what about wireless devices?

Posted in cap
guys, put the action codes under dualshock or xbox controller

Under xbox and dualshock are already built into the system + above they wrote and uploaded the finished file.
I was helped to find the buttons via KeyTest "scan code", and their change in Generic.kl

The change in Generic.kl is not the most elegant way.
Shadow326159 @ 12.12.2014, 06:45*
No, I took it from xbox360 and just renamed it, threw it and set the rights.

Well, the keikods may not be the same.



Rep: (11)
* Dreamer ..., Thrustmaster LightBack is determined by USBDeviceinfo, but in Key Test there is no response to pressing. Checked on Surfpad 3.


Full version    

Help     rules

Time is now: 09/01/20, 10:18