Skip to content
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

Closed
Withoutruless opened this issue Oct 9, 2024 · 45 comments
Closed

AOA/UHID Gamepad Issues. #5362

Withoutruless opened this issue Oct 9, 2024 · 45 comments

Comments

@Withoutruless
Copy link
Contributor

Environment

  • Scrcpy 2.7 (prebuilt) on Windows 11.
  • samsung A52s 5G running A14 OneUI.

Describe the bug

the way the UHID/AOA gamepad shows up messes up the input in some games.

on UHID it shows up as:

  • Name: "scrcpy: Xbox One Controller"
  • Product: "Vendor_0000_Product_0000"

and on AOA:

  • Name: blank, it has no name.
  • Product: "Vendor_ffff_Product_ffff"

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:

  • Name: "Microsoft X-Box 360 Pad"
  • Product: "Vendor_045e_Product_028e"

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.

@rom1v
Copy link
Collaborator

rom1v commented Oct 9, 2024

In AOA we cannot specify a vendor id or product id.

For UHID, please test hardcoding values here:

buf.putInt(0); // vendor id
buf.putInt(0); // product id

Does it solve your problem?

@Withoutruless
Copy link
Contributor Author

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?

@rom1v
Copy link
Collaborator

rom1v commented Oct 9, 2024

Product: "Vendor_045e_Product_028e"

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:

  • scrcpy-server SHA-256: fb510e94e2596b8cd93c6ebef5a11969334e2db510b6dc7e59e70cfa2a7b373

(to replace in your scrcpy 2.7 folder)

@rom1v
Copy link
Collaborator

rom1v commented Oct 10, 2024

I tested this morning to use the same vendorId, productId and productVersion as the physical gamepad: https://github.com/Genymobile/scrcpy/commits/gamepad_usb_ids/

And I tested with the "Game Controller Tester" app (uk.co.powgames.gamecondiag):

  • with a PS4 controller, the app shows the real buttons (X, O, square, triangle) instead of A, B, X, Y, so this is better
  • however, the mapping becomes incorrect (buttons are swapped), and L2/R2 do not work :/

I guess the driver makes assumptions if it recognizes a vendorId:productId and do not consider the generic HID report descriptor.

@rom1v rom1v mentioned this issue Oct 10, 2024
3 tasks
@Withoutruless
Copy link
Contributor Author

Withoutruless commented Oct 10, 2024

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.
wuthering waves worked perfectly after doing and so does human fall flat... but only with a "jumpstart" (by first connecting with LHLaurini's build, moving it a bit then switching to scrcpy with the custom server)

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.

I guess the driver makes assumptions if it recognizes a vendorId:productId and do not consider the generic HID report descriptor.

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.

@Withoutruless
Copy link
Contributor Author

"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:
Vendor_0e6f_Product_02e8

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,
so would it be possible to change the name of the emulated gamepad to "Microsoft X-Box 360 Pad" like in LHLaurini's build to see if fully emulating an xbox 360 controller fixes the recognition issue?

i wish i could successfully build scrcpy myself so i wouldnt have to trouble you.

@Withoutruless
Copy link
Contributor Author

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);

@Trimint123
Copy link

Trimint123 commented Oct 15, 2024

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.

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.

@Withoutruless
Copy link
Contributor Author

here, you can try it:
scrcpy-server.zip
just replace the scrcpy-server in your scrcpy folder.

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.

@Withoutruless
Copy link
Contributor Author

when i try to build scrcpy it always gets stuck at SDL_test_random.lo on the client side.
do you have any idea why @rom1v?

  CC     build/SDL_windows_main.lo
  CC     build/SDL_test_imageBlitBlend.lo
  CC     build/SDL_test_imageBlit.lo
  CC     build/SDL_test_fuzzer.lo
  CC     build/SDL_test_imageFace.lo
  CC     build/SDL_test_imagePrimitives.lo
  CC     build/SDL_test_log.lo
  CC     build/SDL_test_imagePrimitivesBlend.lo
  CC     build/SDL_test_md5.lo
  CC     build/SDL_test_random.lo

@Withoutruless
Copy link
Contributor Author

is there a way i can skip the building of dependencies like sdl2, ffmpeg, etc.. and use the prebuilt dlls?

@Trimint123
Copy link

Trimint123 commented Oct 16, 2024

here, you can try it: scrcpy-server.zip just replace the scrcpy-server in your scrcpy folder.

Nope. Controller just straight up doesn't work on Sky completely, or even any games for that matter. I am using a PS4 controller.

@rom1v
Copy link
Collaborator

rom1v commented Oct 16, 2024

and in wuthering waves the triggers dont work (the game probably sees it as a generic controller).

the vid:pid change you made earlier on the scrcpy-server fixed the triggers in Wuthering waves (and partially fixed Human fall flat).

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.

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).

@rom1v
Copy link
Collaborator

rom1v commented Oct 16, 2024

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:

public void onRotationChanged(int rotation) {

So the rotation is broken.

Refs #4469 maybe?

@Withoutruless
Copy link
Contributor Author

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).

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).

@Withoutruless
Copy link
Contributor Author

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.

@rom1v
Copy link
Collaborator

rom1v commented Oct 16, 2024

is it possible to use prebuilt sdl2

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).

@Withoutruless
Copy link
Contributor Author

How do you build? From which OS?

I build from WSL Ubuntu on Windows.

For testing, I suggest to build from Linux and to build for Linux (take the latest Debian or Ubuntu version).

I'll try to do that.

Not as is, it was the case before #4713.

What would i need to do to make it work the way it was before?

@rom1v
Copy link
Collaborator

rom1v commented Oct 16, 2024

What would i need to do to make it work the way it was before?

Too much cumbersome work 🙂

@Withoutruless
Copy link
Contributor Author

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...

@Withoutruless
Copy link
Contributor Author

For testing, I suggest to build from Linux and to build for Linux (take the latest Debian or Ubuntu version).

i mean.. install_release.sh worked fine if thats what you meant but i cant test scrcpy on wsl.

@rom1v
Copy link
Collaborator

rom1v commented Oct 16, 2024

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

@Withoutruless
Copy link
Contributor Author

but i cant test scrcpy on wsl.

Why? (I have never used WSL, so I don't know if that's expected to work)

i dunno, wsl should have gui support so it might just be my pc (the scrcpy window doesnt come up)

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 tried following that guide but it didnt work, maybe i was using the wrong shell? which one should i be using?
afaik building with msys2 would be much faster than a vm so if i can i would love to set that up.

@rom1v
Copy link
Collaborator

rom1v commented Oct 16, 2024

i tried following that guide but it didnt work

What didn't work? What was the error message?

@Withoutruless
Copy link
Contributor Author

i tried following that guide but it didnt work

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.

@Withoutruless
Copy link
Contributor Author

which shell should i use? clang64, mingw64, ucrt64, or msys?

@rom1v
Copy link
Collaborator

rom1v commented Oct 16, 2024

msys

@Withoutruless
Copy link
Contributor Author

okay so on msys it cant find any of the packages i installed:

pacman -S mingw-w64-x86_64-SDL2 \
          mingw-w64-x86_64-ffmpeg \
          mingw-w64-x86_64-libusb

# client build dependencies
pacman -S mingw-w64-x86_64-make \
          mingw-w64-x86_64-gcc \
          mingw-w64-x86_64-pkg-config \
          mingw-w64-x86_64-meson

and on the mingw64 shell, i get:

Administrator@GHOST-PC MINGW64 ~/scrcpy
# ./release.sh
./gradlew clean

BUILD SUCCESSFUL in 6s
1 actionable task: 1 up-to-date
rm -rf "dist" "build-test" "build-server" \
        "build-win32" "build-win64"
[ -d "build-test" ] || ( mkdir "build-test" && \
        meson setup "build-test" -Db_sanitize=address )
The Meson build system
Version: 1.5.0
Source dir: C:/msys64/home/Administrator/scrcpy
Build dir: C:/msys64/home/Administrator/scrcpy/build-test
Build type: native build
Project name: scrcpy
Project version: 2.7
C compiler for the host machine: cc (gcc 14.1.0 "cc (Rev3, Built by MSYS2 project) 14.1.0")
C linker for the host machine: cc ld.bfd 2.42
Host machine cpu family: x86_64
Host machine cpu: x86_64
Windows resource compiler: GNU windres (GNU Binutils) 2.42
Found pkg-config: YES (C:\msys64\mingw64\bin/pkg-config.EXE) 2.2.0
Run-time dependency libavformat found: YES 60.16.100
Run-time dependency libavcodec found: YES 60.31.102
Run-time dependency libavutil found: YES 58.29.100
Run-time dependency libswresample found: YES 4.12.100
Run-time dependency sdl2 found: YES 2.30.5
Run-time dependency libusb-1.0 found: YES 1.0.27
Library mingw32 found: YES
Library ws2_32 found: YES
Checking for function "strdup" : YES
Checking for function "asprintf" : YES
Checking for function "vasprintf" : YES
Checking for function "nrand48" : NO
Checking for function "jrand48" : NO
Checking for function "reallocarray" : NO
Configuring config.h using configuration
Program ./scripts/build-wrapper.sh found: YES (bash C:/msys64/home/Administrator/scrcpy/server/./scripts/build-wrapper.sh)
Build targets in project: 14

scrcpy 2.7

  User defined options
    b_sanitize: address

Found ninja-1.12.1 at C:\msys64\mingw64\bin/ninja.EXE
ninja -C "build-test"
ninja: Entering directory `build-test'
[71/128] Compiling C object app/test_adb_parser.exe.p/tests_test_adb_parser.c.obj
<command-line>: warning: no previous prototype for 'SDL_main' [-Wmissing-prototypes]
../app/tests/test_adb_parser.c:256:5: note: in expansion of macro 'main'
  256 | int main(int argc, char *argv[]) {
      |     ^~~~
[77/128] Compiling C object app/test_binary.exe.p/tests_test_binary.c.obj
<command-line>: warning: no previous prototype for 'SDL_main' [-Wmissing-prototypes]
../app/tests/test_binary.c:138:5: note: in expansion of macro 'main'
  138 | int main(int argc, char *argv[]) {
      |     ^~~~
[80/128] Compiling C object app/test_audiobuf.exe.p/tests_test_audiobuf.c.obj
<command-line>: warning: no previous prototype for 'SDL_main' [-Wmissing-prototypes]
../app/tests/test_audiobuf.c:119:5: note: in expansion of macro 'main'
  119 | int main(int argc, char *argv[]) {
      |     ^~~~
[84/128] Compiling C object app/test_cli.exe.p/tests_test_cli.c.obj
<command-line>: warning: no previous prototype for 'SDL_main' [-Wmissing-prototypes]
../app/tests/test_cli.c:154:5: note: in expansion of macro 'main'
  154 | int main(int argc, char *argv[]) {
      |     ^~~~
[91/128] Compiling C object app/test_control_msg...ize.exe.p/tests_test_control_msg_serialize.c.obj
<command-line>: warning: no previous prototype for 'SDL_main' [-Wmissing-prototypes]
../app/tests/test_control_msg_serialize.c:410:5: note: in expansion of macro 'main'
  410 | int main(int argc, char *argv[]) {
      |     ^~~~
[97/128] Compiling C object app/test_device_msg_...ze.exe.p/tests_test_device_msg_deserialize.c.obj
<command-line>: warning: no previous prototype for 'SDL_main' [-Wmissing-prototypes]
../app/tests/test_device_msg_deserialize.c:86:5: note: in expansion of macro 'main'
   86 | int main(int argc, char *argv[]) {
      |     ^~~~
[101/128] Compiling C object app/test_orientation.exe.p/tests_test_orientation.c.obj
<command-line>: warning: no previous prototype for 'SDL_main' [-Wmissing-prototypes]
../app/tests/test_orientation.c:85:5: note: in expansion of macro 'main'
   85 | int main(int argc, char *argv[]) {
      |     ^~~~
[103/128] Compiling C object app/test_strbuf.exe.p/tests_test_strbuf.c.obj
<command-line>: warning: no previous prototype for 'SDL_main' [-Wmissing-prototypes]
../app/tests/test_strbuf.c:42:5: note: in expansion of macro 'main'
   42 | int main(int argc, char *argv[]) {
      |     ^~~~
[107/128] Compiling C object app/test_str.exe.p/tests_test_str.c.obj
<command-line>: warning: no previous prototype for 'SDL_main' [-Wmissing-prototypes]
../app/tests/test_str.c:379:5: note: in expansion of macro 'main'
  379 | int main(int argc, char *argv[]) {
      |     ^~~~
[110/128] Compiling C object app/test_vecdeque.exe.p/tests_test_vecdeque.c.obj
<command-line>: warning: no previous prototype for 'SDL_main' [-Wmissing-prototypes]
../app/tests/test_vecdeque.c:187:5: note: in expansion of macro 'main'
  187 | int main(int argc, char *argv[]) {
      |     ^~~~
[114/128] Compiling C object app/test_vector.exe.p/tests_test_vector.c.obj
<command-line>: warning: no previous prototype for 'SDL_main' [-Wmissing-prototypes]
../app/tests/test_vector.c:403:5: note: in expansion of macro 'main'
  403 | int main(int argc, char *argv[]) {
      |     ^~~~
[116/128] Linking target app/test_adb_parser.exe
FAILED: app/test_adb_parser.exe
"cc"  -o app/test_adb_parser.exe app/test_adb_parser.exe.p/tests_test_adb_parser.c.obj app/test_adb_parser.exe.p/src_adb_adb_device.c.obj app/test_adb_parser.exe.p/src_adb_adb_parser.c.obj app/test_adb_parser.exe.p/src_util_str.c.obj app/test_adb_parser.exe.p/src_util_strbuf.c.obj app/test_adb_parser.exe.p/src_compat.c.obj "-fsanitize=address" "-Wl,--allow-shlib-undefined" "-Wl,--start-group" "C:/msys64/mingw64/lib/libavformat.dll.a" "C:/msys64/mingw64/lib/libavcodec.dll.a" "C:/msys64/mingw64/lib/libavutil.dll.a" "C:/msys64/mingw64/lib/libswresample.dll.a" "C:/msys64/mingw64/lib/libmingw32.a" "-mwindows" "C:/msys64/mingw64/lib/libSDL2main.a" "C:/msys64/mingw64/lib/libSDL2.dll.a" "C:/msys64/mingw64/lib/libusb-1.0.dll.a" "-lmingw32" "-lws2_32" "-Wl,--subsystem,console" "-lkernel32" "-luser32" "-lgdi32" "-lwinspool" "-lshell32" "-lole32" "-loleaut32" "-luuid" "-lcomdlg32" "-ladvapi32" "-Wl,--end-group"
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lasan: No such file or directory
collect2.exe: error: ld returned 1 exit status
[117/128] Linking target app/scrcpy.exe
FAILED: app/scrcpy.exe
"cc"  -o app/scrcpy.exe app/app_scrcpy-windows.rc_scrcpy-windows.o app/scrcpy.exe.p/src_main.c.obj app/scrcpy.exe.p/src_adb_adb.c.obj app/scrcpy.exe.p/src_adb_adb_device.c.obj app/scrcpy.exe.p/src_adb_adb_parser.c.obj app/scrcpy.exe.p/src_adb_adb_tunnel.c.obj app/scrcpy.exe.p/src_audio_player.c.obj app/scrcpy.exe.p/src_cli.c.obj app/scrcpy.exe.p/src_clock.c.obj app/scrcpy.exe.p/src_compat.c.obj app/scrcpy.exe.p/src_control_msg.c.obj app/scrcpy.exe.p/src_controller.c.obj app/scrcpy.exe.p/src_decoder.c.obj app/scrcpy.exe.p/src_delay_buffer.c.obj app/scrcpy.exe.p/src_demuxer.c.obj app/scrcpy.exe.p/src_device_msg.c.obj app/scrcpy.exe.p/src_display.c.obj app/scrcpy.exe.p/src_events.c.obj app/scrcpy.exe.p/src_icon.c.obj app/scrcpy.exe.p/src_file_pusher.c.obj app/scrcpy.exe.p/src_fps_counter.c.obj app/scrcpy.exe.p/src_frame_buffer.c.obj app/scrcpy.exe.p/src_input_manager.c.obj app/scrcpy.exe.p/src_keyboard_sdk.c.obj app/scrcpy.exe.p/src_mouse_sdk.c.obj app/scrcpy.exe.p/src_opengl.c.obj app/scrcpy.exe.p/src_options.c.obj app/scrcpy.exe.p/src_packet_merger.c.obj app/scrcpy.exe.p/src_receiver.c.obj app/scrcpy.exe.p/src_recorder.c.obj app/scrcpy.exe.p/src_scrcpy.c.obj app/scrcpy.exe.p/src_screen.c.obj app/scrcpy.exe.p/src_server.c.obj app/scrcpy.exe.p/src_version.c.obj app/scrcpy.exe.p/src_hid_hid_gamepad.c.obj app/scrcpy.exe.p/src_hid_hid_keyboard.c.obj app/scrcpy.exe.p/src_hid_hid_mouse.c.obj app/scrcpy.exe.p/src_trait_frame_source.c.obj app/scrcpy.exe.p/src_trait_packet_source.c.obj app/scrcpy.exe.p/src_uhid_gamepad_uhid.c.obj app/scrcpy.exe.p/src_uhid_keyboard_uhid.c.obj app/scrcpy.exe.p/src_uhid_mouse_uhid.c.obj app/scrcpy.exe.p/src_uhid_uhid_output.c.obj app/scrcpy.exe.p/src_util_acksync.c.obj app/scrcpy.exe.p/src_util_audiobuf.c.obj app/scrcpy.exe.p/src_util_average.c.obj app/scrcpy.exe.p/src_util_file.c.obj app/scrcpy.exe.p/src_util_intmap.c.obj app/scrcpy.exe.p/src_util_intr.c.obj app/scrcpy.exe.p/src_util_log.c.obj app/scrcpy.exe.p/src_util_memory.c.obj app/scrcpy.exe.p/src_util_net.c.obj app/scrcpy.exe.p/src_util_net_intr.c.obj app/scrcpy.exe.p/src_util_process.c.obj app/scrcpy.exe.p/src_util_process_intr.c.obj app/scrcpy.exe.p/src_util_rand.c.obj app/scrcpy.exe.p/src_util_strbuf.c.obj app/scrcpy.exe.p/src_util_str.c.obj app/scrcpy.exe.p/src_util_term.c.obj app/scrcpy.exe.p/src_util_thread.c.obj app/scrcpy.exe.p/src_util_tick.c.obj app/scrcpy.exe.p/src_util_timeout.c.obj app/scrcpy.exe.p/src_sys_win_file.c.obj app/scrcpy.exe.p/src_sys_win_process.c.obj app/scrcpy.exe.p/src_usb_aoa_hid.c.obj app/scrcpy.exe.p/src_usb_gamepad_aoa.c.obj app/scrcpy.exe.p/src_usb_keyboard_aoa.c.obj app/scrcpy.exe.p/src_usb_mouse_aoa.c.obj app/scrcpy.exe.p/src_usb_scrcpy_otg.c.obj app/scrcpy.exe.p/src_usb_screen_otg.c.obj app/scrcpy.exe.p/src_usb_usb.c.obj "-fsanitize=address" "-Wl,--allow-shlib-undefined" "-Wl,--start-group" "C:/msys64/mingw64/lib/libavformat.dll.a" "C:/msys64/mingw64/lib/libavcodec.dll.a" "C:/msys64/mingw64/lib/libavutil.dll.a" "C:/msys64/mingw64/lib/libswresample.dll.a" "C:/msys64/mingw64/lib/libmingw32.a" "-mwindows" "C:/msys64/mingw64/lib/libSDL2main.a" "C:/msys64/mingw64/lib/libSDL2.dll.a" "C:/msys64/mingw64/lib/libusb-1.0.dll.a" "-lmingw32" "-lws2_32" "-Wl,--subsystem,console" "-lkernel32" "-luser32" "-lgdi32" "-lwinspool" "-lshell32" "-lole32" "-loleaut32" "-luuid" "-lcomdlg32" "-ladvapi32" "-Wl,--end-group"
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lasan: No such file or directory
collect2.exe: error: ld returned 1 exit status
[118/128] Linking target app/test_binary.exe
FAILED: app/test_binary.exe
"cc"  -o app/test_binary.exe app/test_binary.exe.p/tests_test_binary.c.obj app/test_binary.exe.p/src_compat.c.obj "-fsanitize=address" "-Wl,--allow-shlib-undefined" "-Wl,--start-group" "C:/msys64/mingw64/lib/libavformat.dll.a" "C:/msys64/mingw64/lib/libavcodec.dll.a" "C:/msys64/mingw64/lib/libavutil.dll.a" "C:/msys64/mingw64/lib/libswresample.dll.a" "C:/msys64/mingw64/lib/libmingw32.a" "-mwindows" "C:/msys64/mingw64/lib/libSDL2main.a" "C:/msys64/mingw64/lib/libSDL2.dll.a" "C:/msys64/mingw64/lib/libusb-1.0.dll.a" "-lmingw32" "-lws2_32" "-Wl,--subsystem,console" "-lkernel32" "-luser32" "-lgdi32" "-lwinspool" "-lshell32" "-lole32" "-loleaut32" "-luuid" "-lcomdlg32" "-ladvapi32" "-Wl,--end-group"
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lasan: No such file or directory
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
make: *** [release.mk:56: test] Error 1

@rom1v
Copy link
Collaborator

rom1v commented Oct 16, 2024

./release.sh is the script to build the whole releases from Linux (the server and the Windows binaries). That's not what you want.

You just want to build natively, so once you installed the packages, follow these steps.

cannot find -lasan: No such file or directory

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)

warning: no previous prototype for 'SDL_main'

Oh, I'll have to fix this SDL warning again…

@Withoutruless
Copy link
Contributor Author

If you build from msys2, you don't have to build the deps, you installed them via pacman -S mingw-w64-x86_64-SDL2 for example.

Just run:

meson setup d
ninja -Cd

(if you have the Android SDK installed and configured)

yeah that + ninja install works, i can also test scrcpy without the shell if i just do --no-playback.

@rom1v
Copy link
Collaborator

rom1v commented Oct 16, 2024

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?

@Withoutruless
Copy link
Contributor Author

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.
pretty dumb thing to do now that i think about it.

@rom1v
Copy link
Collaborator

rom1v commented Oct 16, 2024

OK, for testing you can just run with ./run d followed by your arguments:

./run d --gamepad=uhid
./run d -G

Once you change some code, just re-run ninja -Cd.

@Withoutruless
Copy link
Contributor Author

OK, for testing you can just run with ./run d followed by your arguments:

./run d --gamepad=uhid
./run d -G

Once you change some code, just re-run ninja -Cd.

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.

@Withoutruless
Copy link
Contributor Author

OK, for testing you can just run with ./run d followed by your arguments:

./run d --gamepad=uhid
./run d -G

Once you change some code, just re-run ninja -Cd.

./run d doesnt work:

Administrator@GHOST-PC MINGW64 ~/scrcpy
# ./run d --no-playback -G

Administrator@GHOST-PC MINGW64 ~/scrcpy

running scrcpy works so ill just use that.

@rom1v
Copy link
Collaborator

rom1v commented Oct 16, 2024

😮 (btw, I see that your prompt is #, you should not run as root, but I don't really know how MSYS works)

You don't have logs in the console either? 🤔

running scrcpy works so ill just use that.

It should not, it probably does not run the version you just compiled.

@Withoutruless
Copy link
Contributor Author

😮 (btw, I see that your prompt is #, you should not run as root, but I don't really know how MSYS works)

it runs as root by default ig or it might be because im using the administrator user on windows

You don't have logs in the console either? 🤔

when running scrcpy yes

running scrcpy works so ill just use that.

It should not, it probably does not run the version you just compiled.

ninja install in /d should update it right?

@rom1v
Copy link
Collaborator

rom1v commented Oct 16, 2024

Oh ok you ninja installed it 👍

it runs as root by default ig or it might be because im using the administrator user on windows

But then it probably does not build the server: 4c49b27 #42 (comment)

@Withoutruless
Copy link
Contributor Author

ninja install in /d should update it right?

yeah this works.

@Withoutruless
Copy link
Contributor Author

But then it probably does not build the server: 4c49b27 #42 (comment)

yeah it doesnt, i just copied the server i built on wsl to the share/scrcpy folder.

rom1v added a commit that referenced this issue Oct 28, 2024
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>
rom1v added a commit that referenced this issue Oct 30, 2024
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>
@rom1v
Copy link
Collaborator

rom1v commented Nov 18, 2024

I guess we should add an option --gamepad-force-xbox-360 or --gamepad-force-xbox-one with the real report descriptor and the details provided by @yume-chan here: #2130 (comment)

@Withoutruless
Copy link
Contributor Author

I guess we should add an option --gamepad-force-xbox-360 or --gamepad-force-xbox-one with the real report descriptor and the details provided by @yume-chan here: #2130 (comment)

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.

@rom1v
Copy link
Collaborator

rom1v commented Dec 6, 2024

Please test #5623.

rom1v added a commit that referenced this issue Dec 8, 2024
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 <#5362>
PR #5623 <#5623>
rom1v added a commit that referenced this issue Dec 8, 2024
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 <#5362>
PR #5623 <#5623>
rom1v pushed a commit that referenced this issue Dec 8, 2024
Some games do not work without a known gamepad name.

Fixes #5362 <#5362>
Refs #5623 comment <#5623 (comment)>
PR #5623 <#5623>

Signed-off-by: Romain Vimont <rom@rom1v.com>
HighlanderDE pushed a commit to HighlanderDE/Highlanderfirstrep that referenced this issue Dec 9, 2024
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>
HighlanderDE pushed a commit to HighlanderDE/Highlanderfirstrep that referenced this issue Dec 9, 2024
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants