rmst / yoke

Turns your Android device into a customizable gamepad for Windows/Mac/Linux
MIT License
215 stars 24 forks source link

Add gamepad buttons #2

Closed ilinas closed 5 years ago

ilinas commented 6 years ago

This is a very cool concept! However to be usable in vast majority of games, one would need at least A, B, X, Y buttons. Best of luck with the project. :)

rmst commented 6 years ago

Definitely! But we might have to add a TCP connection to transmit button events because the current UDP connection might drop the event and that might be frustrating to a user.

kozec commented 6 years ago

How about transmitting entire state all the time? Then even if packet is dropped, next one will contain missing info.

If you can use binary protocol, it should be possible to fit one axis or all buttons into 2 bytes, so entire state should fit into 16B, if I'm counting it correctly.

rmst commented 6 years ago

Yes, that would be straight forward to implement. We are already transmitting the full state. The problem is if there is packet loss, a fast button press might be completely missed. But maybe that's not actually a big problem in practice.

pzmarzly commented 5 years ago

Well, there is one way to find out - implement it.

It would be nice to have option to configure a button as a toggle button (press once to "press down", press once more to stop "pressing down").

I think transmitting full state with UDP is fine. If someone needs almost-frame-perfect button hits or is fast enough to do them, they won't be using WiFi connection in the first place.

kozec commented 5 years ago

Hey, I've already forgot that I'm following this :)

I've recently implemented support for "Remote RetroPad" in my application, protocol that is used by Retroarch on Android for exactly this. It sends only changes in UDP packet that basically contains 4 numbers and I have yet to see single "lost input" :)

rmst commented 5 years ago

If someone makes a html/javascript version of a controller interface with two joysticks and buttons I'd be very happy to merge this via implementing #17 .

kozec commented 5 years ago

I have gamepads as svgs here, but I'm not sure if it's possible to use js with SVG images.

pzmarzly commented 5 years ago

It is. SVG elements can have HTML id, class or onclick attributes. https://stackoverflow.com/q/2296097/5108318

rmst commented 5 years ago

Interesting! The main thing would be to do (re-)implement the ontouch (down, move, up) lifecycle. Basically replicating in javascript what has been done in https://github.com/rmst/yoke-android/blob/master/app/src/main/java/com/simonramstedt/yoke/JoystickView.java . Here is a tutorial on how this works in javascript https://seb.ly/2011/04/multi-touch-game-controller-in-javascripthtml5-for-ipad/ .

pzmarzly commented 5 years ago

I'll try implementing it

pzmarzly commented 5 years ago

I hate Javascript and Samsung OS is garbage, but there you go https://github.com/pzmarzly/html-touch-joystick.

With right config (see consts in base.js) it will output current status to console, which you can grab.

It was made with user in mind - by editing CSS, user can easily change layout and behavior (animation-name: locking; for locking behavior - on video I set it for left joystick). I also added 4 buttons.

I added 32 buttons in code, but user can disable any unwanted button in UI settings

rmst commented 5 years ago

Awesome, thanks! I'm going to try to incorporate it in the app statically first and then dynamically as proposed in #17 .

EDIT: @pzmarzly if you like you could open a pull request in this repo so you receive proper credit. I think the files could perhaps go in a folder called assets/joypad.

pzmarzly commented 5 years ago

Done in #19 . Thanks

rmst commented 5 years ago

Basically #17 is implemented in master now and serves the html/javascript client that @pzmarzly built. The android app (experimental version in this repo under devel/) loads the html/javascript into a webview. I also made some minimal changes to the client, to get it to work. The buttons should be working now. The next step would be to test the client on windows and to make it a bit nicer. The goal is to keep the same quality when switching to webview in the official app.

rgarrigue commented 5 years ago

Hi ! Seems yoke is exactly what I was looking for, except for this "almost available" feature. Seems only windows is yet to be finished, can I use the RC for linux ? F-Droid release is 7 months old, I guess that's not it.

pzmarzly commented 5 years ago

RC is a redesign, you are welcome to test it (works fine for us, but since it uses Android Webview results may vary depending on the device). Here's the latest APK. You can clone the repo and run pip3 install .. Button configuration can be tweaked in yoke/yoke/assets/joypad/*.css. I'm not sure if Windows build works

rgarrigue commented 5 years ago

Thanks @pzmarzly. Tried it. Honestly it's too raw for me. I found an alternative meanwhile, controlloid, which fit my needs.

medape commented 5 years ago

@rmst: Could you close this issue and #17? They're not needed anymore (and arbitrary controllers are being discussed on #33 anyways).