-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
AOA/UHID Gamepad Issues. #5362
Comments
In AOA we cannot specify a vendor id or product id. For UHID, please test hardcoding values here: scrcpy/server/src/main/java/com/genymobile/scrcpy/control/UhidManager.java Lines 185 to 186 in 665ccb3
Does it solve your problem? |
i would love to but i cant for the love of god build scrcpy, ive tried in termux debian proot, on windows msys2 and on WSL while following the build guide but i just cant. btw on msys2 i have to use the mingw64 shell right? |
Here is a diff with these vendor and product ids: diff --git a/server/src/main/java/com/genymobile/scrcpy/control/UhidManager.java b/server/src/main/java/com/genymobile/scrcpy/control/UhidManager.java
index d8cfd81f6..34e98aeaf 100644
--- a/server/src/main/java/com/genymobile/scrcpy/control/UhidManager.java
+++ b/server/src/main/java/com/genymobile/scrcpy/control/UhidManager.java
@@ -182,8 +182,8 @@ public final class UhidManager {
buf.putShort((short) reportDesc.length);
buf.putShort(BUS_VIRTUAL);
- buf.putInt(0); // vendor id
- buf.putInt(0); // product id
+ buf.putInt(0x045e); // vendor id
+ buf.putInt(0x028e); // product id
buf.putInt(0); // version
buf.putInt(0); // country;
buf.put(reportDesc); Here is a binary:
(to replace in your scrcpy 2.7 folder) |
I tested this morning to use the same And I tested with the "Game Controller Tester" app (
I guess the driver makes assumptions if it recognizes a vendorId:productId and do not consider the generic HID report descriptor.
|
sorry i didnt respond for so long, i slept right after i made this issue. i was about to report back on the server you built for me (thank you for that), on there the triggers and rstick were messed up and i fixed it by changing the vendor_prod.kl. changing the vendor_prod.kl also messes up LHLaurini's build as it uses the xbox 360 hid descriptor (if i said that right) along with the xbox 360 vid:pid.
yes, there are many vendor:product.kl's that define the correct axis identifiers and keys, here we used the xbox 360 vid:pid while passing generic gamepad values which is why the input got messed up. ill test the gamepad-usb-ids build right now, thanks. |
"scrcpy-win64-gamepad-usb-ids" worked the same as the official scrcpy (without your scrcpy-server) for me and the controller showed up as: Vendor_045e_Product_02ff whereas if i plug the controller directly into my phone it shows up as: on the Game controller test app (uk.co.powgames.gamecondiag). the vid:pid change you made earlier on the scrcpy-server fixed the triggers in Wuthering waves (and partially fixed Human fall flat). so the main issue (apart from the switched axis) is that some games fail to recognize the gamepad, i wish i could successfully build scrcpy myself so i wouldnt have to trouble you. |
i finally figured out how to build scrcpy.. i changed the emulated controller's name to "Microsoft X-Box 360 Pad", replaced the server and now it just works everywhere and gets recognized just fine. public final class UhidManager {
- String actualName = name.isEmpty() ? "scrcpy" : "scrcpy: " + name;
+ String actualName = "Microsoft X-Box 360 Pad";
byte[] utf8Name = actualName.getBytes(StandardCharsets.UTF_8);
int len = StringUtils.getUtf8TruncationIndex(utf8Name, 127);
assert len <= 127;
buf.put(utf8Name, 0, len);
buf.put(empty, 0, 256 - len);
buf.putShort((short) reportDesc.length);
buf.putShort(BUS_VIRTUAL);
- buf.putInt(0); // vendor id
- buf.putInt(0); // product id
+ buf.putInt(0x045e); // vendor id
+ buf.putInt(0x028e); // product id
buf.putInt(0); // version
buf.putInt(0); // country;
buf.put(reportDesc); |
Mind to share me the build files? I actually may need it to play Sky as some buttons flat out doesn't work with it. It doesn't registered d-pad and triggers as an actual buttons. |
here, you can try it: i had to edit the .kl of the emulated controller (you need root to do that) though to make it work, as scrcpy sends generic identifiers from the client, which makes your triggers act as the rstick. and i can only build the server for some reason so i cant fix that. |
when i try to build scrcpy it always gets stuck at SDL_test_random.lo on the client side.
|
is there a way i can skip the building of dependencies like sdl2, ffmpeg, etc.. and use the prebuilt dlls? |
Nope. Controller just straight up doesn't work on Sky completely, or even any games for that matter. I am using a PS4 controller. |
In the game settings, either with scrcpy 2.7, or with the USB ids changed (#5362 (comment)), or with the USB ids + the USB name changed (#5362 (comment)), triggers (L2/R2) do not work. For example, in controller settings, I cannot edit any action to assign L2 or R2 (pressing L2 or R2 do nothing). |
Also, I noticed that if my device is in portrait mode, scrcpy is running, when the game starts it switches to landscape mode, but scrcpy never receives any rotation change event:
So the rotation is broken. Refs #4469 maybe? |
triggers werent working for me either and to make them work, i had to change some identifiers in the .kl to make them match the generic ones: # Copyright (C) 2011 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# XBox 360 USB Controller
#
key 304 BUTTON_A
key 305 BUTTON_B
key 307 BUTTON_X
key 308 BUTTON_Y
key 310 BUTTON_L1
key 311 BUTTON_R1
key 317 BUTTON_THUMBL
key 318 BUTTON_THUMBR
# Left and right stick.
# The reported value for flat is 128 out of a range from -32767 to 32768, which is absurd.
# This confuses applications that rely on the flat value because the joystick actually
# settles in a flat range of +/- 4096 or so.
axis 0x00 X flat 4096
axis 0x01 Y flat 4096
+axis 0x02 Z flat 4096
-axis 0x03 Z flat 4096
+axis 0x05 RZ flat 4096
-axis 0x04 RZ flat 4096
# Triggers.
+axis 0x0a LTRIGGER
-axis 0x02 LTRIGGER
+axis 0x09 RTRIGGER
-axis 0x05 RTRIGGER
# Hat.
axis 0x10 HAT_X
axis 0x11 HAT_Y
# Mapping according to https://www.kernel.org/doc/Documentation/input/gamepad.txt
# Button labeled as "BACK" (left-pointing triangle)
key 314 BUTTON_SELECT
# The branded "X" button in the center of the controller
key 316 BUTTON_MODE
# Button labeled as "START" (right-pointing triangle)
key 315 BUTTON_START
its should be possible to fix this issue by modifying hid_gamepad.c, this would remove the root requirement (for modifying .kl's in /system). |
on another note, @rom1v, is it possible to use prebuilt sdl2 and so on? my pc has a problem building the dependencies, so i cant build the client, only the server. |
Not as is, it was the case before #4713. How do you build? From which OS? For testing, I suggest to build from Linux and to build for Linux (take the latest Debian or Ubuntu version). |
I build from WSL Ubuntu on Windows.
I'll try to do that.
What would i need to do to make it work the way it was before? |
Too much cumbersome work 🙂 |
yeah... i looked at the changes you made in that pr... |
i mean.. install_release.sh worked fine if thats what you meant but i cant test scrcpy on wsl. |
Why? (I have never used WSL, so I don't know if that's expected to work) As an alternative, you should be able to build/run from msys2 on Windows: https://github.com/Genymobile/scrcpy/blob/master/doc/build.md#in-msys2 |
i dunno, wsl should have gui support so it might just be my pc (the scrcpy window doesnt come up)
i tried following that guide but it didnt work, maybe i was using the wrong shell? which one should i be using? |
What didn't work? What was the error message? |
i dont exactly remember but ill try to follow the guide again and see if it works. |
which shell should i use? clang64, mingw64, ucrt64, or msys? |
msys |
okay so on msys it cant find any of the packages i installed:
and on the mingw64 shell, i get:
|
You just want to build natively, so once you installed the packages, follow these steps.
The tests are built with ASAN enabled in the release script, but ASAN is not available on Windows. That won't happen if you build manually (without enabling ASAN explicitly). #4736 (comment)
Oh, I'll have to fix this SDL warning again… |
yeah that + ninja install works, i can also test scrcpy without the shell if i just do --no-playback. |
👍
I'm not sure to understand this part. What do you mean "without the shell"? How do you start it? |
through the exe by a bat file, i just copied over the missing dlls. |
OK, for testing you can just run with ./run d --gamepad=uhid
./run d -G Once you change some code, just re-run |
yeah will do, thanks, ill try some things. the gamepad input gets built in hid_gamepad.c right? i want to change the identifiers sent to android. |
./run d doesnt work:
running scrcpy works so ill just use that. |
😮 (btw, I see that your prompt is You don't have logs in the console either? 🤔
It should not, it probably does not run the version you just compiled. |
it runs as root by default ig or it might be because im using the administrator user on windows
when running scrcpy yes
ninja install in /d should update it right? |
Oh ok you
But then it probably does not build the server: 4c49b27 #42 (comment) |
yeah this works. |
yeah it doesnt, i just copied the server i built on wsl to the share/scrcpy folder. |
Replace RotationWatcher and DisplayFoldListener by a single DisplayListener, which is notified whenever the display size or dpi changes. Still use the old mechanism specifically for Android 14, where DisplayListener may be broken (it is fixed in recent Android 14 upgrades), until we receive the first DisplayListener event (which proves that it works). Fixes #161 <#161> Fixes #1918 <#1918> Fixes #4152 <#4152> Fixes #5362 comment <#5362 (comment)> Refs #4469 <#4469> Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com>
Replace RotationWatcher and DisplayFoldListener by a single DisplayListener, which is notified whenever the display size or dpi changes. However, the DisplayListener mechanism is broken in the first versions of Android 14 (it is fixed in android-14.0.0_r29 by commit [1]), so continue to use the old mechanism specifically for Android 14 (where DisplayListener may be broken), until we receive the first "display changed" event (which proves that it works). [1]: <https://android.googlesource.com/platform/frameworks/base.git/+/5653c6b5875df599307c3e6bfae32fb2fc17ca1f%5E%21/> Fixes #161 <#161> Fixes #1918 <#1918> Fixes #4152 <#4152> Fixes #5362 comment <#5362 (comment)> Refs #4469 <#4469> PR #5415 <#5415> Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com>
I guess we should add an option |
yes, i can use it just fine but my "fix" requires root (changing the keylayout in system), so for the majority of people, it'd just introduce a bigger problem - swapped axis, with no way to fix it. so this feature would be great for people with controller issues and would make no difference for those who dont. i think you should add "major releases" of both xinput and dinput controllers, like: xbox 360, xbox one, ps4 (could fix @Trimint123's issue) and ps5. |
Please test #5623. |
Use Z and Rz for L2/R2, which are more widely supported than Brake/Accelerator. The right stick must then be bound to Rx and Ry. Fixes #5362 <Genymobile/scrcpy#5362> PR #5623 <Genymobile/scrcpy#5623>
Use the vendorId and productId of an Xbox 360 controller for better support (the HID gamepad protocol used in scrcpy is similar to that of the Xbox 360 controller). Fixes #5362 <Genymobile/scrcpy#5362> PR #5623 <Genymobile/scrcpy#5623>
Environment
Describe the bug
the way the UHID/AOA gamepad shows up messes up the input in some games.
on UHID it shows up as:
and on AOA:
so far ive had these issues in 2 games, Wuthering Waves and Human Fall Flat:
in human fall flat it straight up doesnt work, the inputs get ignored.
and in wuthering waves the triggers dont work (the game probably sees it as a generic controller).
but if i use LHLaurini's old controller build, it works just fine in both games, probably because it shows up as an actual Xbox controller:
so, what if you emulated an Xbox 360 or an Xbox One controller for Xinput and a PS4 controller for DInput?
after a lot of digging, i found
bool SDL_IsJoystickXInput(SDL_GUID guid)
, idk if its gonna be of any use to you though.The text was updated successfully, but these errors were encountered: