Closed woodleader closed 8 years ago
Would love to use that cheap and robust gamepad with moonlight too. If I can help with testing or anything other than coding, give me a call.
Yup, same here. Happens on Fire TV and Android App (via tablet). Button mapping of the controller is fine in every other map.
Please consider looking at it, if you need additional data or logs etc. don't hesitate to ask. Moonlight was the main reason I bought the Xiaomi controller.
+1
Would also love if someone yould fix this :)
I'm disappointed at how long this has gone without a fix. I can't even seem to find where the key mapping is handled in the code to try and solve this.
I haven't dealt with this and other mapping issues because the next major version of Moonlight will support controller mapping.
Another thing, I'm using all standard Android button codes. The fact that the Xiaomi controller doesn't work is because they aren't sending the correct key codes that the Android input API expects. The only controller that Moonlight supports that sends incorrect keycodes is the PS4 controller, which was popular enough to warrant hacking around the issue (and long ago where controller mapping wasn't being considered).
The controller code is in ControllerHandler.java. If you want to take a stab at it, I would accept a PR that added support for the controller as long as it wasn't too messy.
Cameron is right, it's really the Xiaomi Controllers fault. It works correctly in Android, but for some reason the mapping is completely bonkers outside of it. It also happens in Windows 7 and 10, and you have to use workarounds for games to work correctly. I am interested when the next major version with button mapping will come, any ETA?
Here is my solution, root access required.
Connect gamepad via Bluetooth.
Download and install the Terminal Emulator, press more and check "Default to UTF-8", go back. Type "cat /proc/bus/input/devices", there should be a name call "小米蓝牙手柄“ or "XiaoMi Bluetooth Wireless GameController". Write down its Vendor CODE and Product CODE.
Download the file 1.txt Rename as "Vendor_YOUR VENDOR CODE_Product_YOUR PRODUCT CODE.kl" For example, my vendor code is 2717 and my Product code is 3144, so the file name is "Vendor_2717_Product_3144.kl"
Use root explorer or other root file manager to place the file to "/system/usr/keylayout/"
Download the file 2.txt Rename as "Vendor_YOUR VENDOR CODE_Product_YOUR PRODUCT CODE.kcm" and place it to "/system/usr/keychars/"
Reconnect gamepad.
Done.
Any news on how long until the version with button mapping is out? I can't use this fix cause my nexus player isn't rooted
It would be nice if you guys could push an update for the xiaomi controller. Brianumbrellaus's modifications seem to do the trick, however, the D-pad buttons do not work.
Ok, I think it will just be easier to create a mapping since so many people are affected.
Please remove any new kl or kcm files added for the gamepad (undo Brianumbrellaus's modifications) or pair to a device without the modifications.
Run this app: https://play.google.com/store/apps/details?id=com.chiarly.gamepad&hl=en
Go through all of the buttons on the controller and write down the mapping for each. For example: A: 1 B: 5 X: 4 Y: 6 L1: 8 and so on...
Post the mapping here and I'll add it.
A 96 B 97 X 99 Y 100 L1 102 R1 103 L2 104 R2 105 TL 106 TR 107 START 108 SELECT 109 Up HatY-1.0 Down HatY+1.0 Left HatX-1.0 Right HatX+1.0
That's weird, because that seems to be the default mapping in Android (and correct). I have a theory of why it's not working though. Can you collect ADB logcat logs with this modified APK, upload them to pastebin.com, and drop a link here?
Hope this works had to use my phone cause I don't have a lo g enough cable to reach the Nexus player http://pastebin.com/aYsyqavv
@ZombieBear Sorry, I made a mistake in my instructions. While the logging is running, you should start a stream from your PC and push some buttons on the Xiaomi controller.
I did, launched binding of Isaac rebirth and tried every button
Played through a few rooms, mapping was all over the place, b worked as a, a as X, X as y, y as left bumper
@ZombieBear ok, maybe try immediately stopping the log after pressing 1 button.
If you get the data I'm looking for, you'll see the text "Creating controller context for device" appear in the log.
Here we go, confirmed the line's there https://drive.google.com/open?id=0B1HJwgCS8FlGUXAtNFhsXzRxUFk
OK, try this build. Please check that all buttons, sticks, and triggers are mapped correctly.
Everything but the back button!
That being select
@ZombieBear does it back out of streaming or just do nothing?
nothing
@ZombieBear ok, one more time. Give this build a try. If the back button works correctly, let me know. If not, please take another log and look for that same line. In either case, please confirm that the triggers are definitely working correctly too.
Flawless! Thanks dude!
@ZombieBear ok, you're sure that the triggers aren't swapped (L2 is R2)?
Yeah they're good :D
Fix released in v4.5.9. Thanks for your help.
The Xiaomi Gamepad does not work with Moonlight. The Android OS recognizes the right keymap, but Somehow Moonlight doesnt. The A button on the Controller gets swapped with the B button. Any other button does not seem to work although the analog sticks are working fine. If needed I can try to provide more information that would be needed to implement the right keymap.