mcpelauncher-linux icon indicating copy to clipboard operation
mcpelauncher-linux copied to clipboard

Gamepad support

Open MCMrARM opened this issue 7 years ago • 14 comments

I'd like to have gamepad support. Implementing gamepad support with MCPE is pretty trivial, but I'm unsure how to handle gamepads at the system-level. I got something working with my own gamepad but the mappings are hardcoded and it uses the deprecated joystick API. I'd like to use evdev instead, but then getting this to compile is a mess.

MCMrARM avatar Sep 04 '17 15:09 MCMrARM

Maybe a higher level API like SDL?

guppy42 avatar Sep 04 '17 17:09 guppy42

@guppy42 I'm not fully sure if I want to include SDL only for gamepads though?

MCMrARM avatar Sep 04 '17 17:09 MCMrARM

Is it really hard to compile with evdev?

NyaomiDEV avatar Sep 04 '17 23:09 NyaomiDEV

I'm right now trying to get something working with evdev, but no promises (yet).

MCMrARM avatar Sep 05 '17 14:09 MCMrARM

I did some experimenting with this on the gamepad-support branch and this commit: https://github.com/MCMrARM/mcpelauncher-linux/commit/5986a61369e3d4e279cefc63b5309ea4591ceda8 I plan on implementing support for the sdl gamepad mappings and this currently might work on some gamepads (the pad for which my mappings were done was a Xbox One pad).

MCMrARM avatar Sep 06 '17 17:09 MCMrARM

SDL mappings look not compatible with evdev though.

MCMrARM avatar Sep 06 '17 18:09 MCMrARM

When this cool enhancement could materialize? I tried it with my Xbox 360 controller that works fine with for example retropie but here no movement or action is detected even though i am using the right branch.

janisroze avatar Nov 06 '17 09:11 janisroze

Hello, @MCMrARM can you tell me how extacly function feedButtom/Trigger/Stick work?

wiktorek140 avatar Dec 24 '17 12:12 wiktorek140

Buttons that MCPE supports https://github.com/MCMrARM/mcpelauncher-linux/blob/8e0d035f062df06c13a1cfd925a631982b5271cf/src/gamepad.h#L10-L21

feedButton(int gamepadIndex, int buttonId, int state, bool unknown) - state afaik can be only 1 (pressed) or 0 (released) feedStick(int gamepadIndex, int stickId, int flags, float axisX, float axisY) - afaik there can be only 2 sticks (from what I remember: 0 - the left one on xbox controller, used for movement, 1 - the right one used for camera), flags determine whether axis x or axis y should be updated, use 3 to update both (it's a bitmask so probably 1 will be axis x, and 2 will be axis y, or the reverse). feedTrigger(int gamepadIndex, int triggerId, float value) - in my code I used two triggers, I think it's self explainatory

The float values are in the range 0.f-1.f.

You'll also want to use setGameControllerConnected to notify MCPE about a controller connection/disconnection.

MCMrARM avatar Dec 24 '17 13:12 MCMrARM

I tried to add splitscreen support but unfortunately only one splited screen renders and the other one is blue. I don't know why is this the case, but looks like no split screen multiplayer for us :(

MCMrARM avatar Dec 29 '17 13:12 MCMrARM

@MCMrARM I suppose that is not fully implemented on android

wiktorek140 avatar Dec 29 '17 14:12 wiktorek140

I am using an xbox 360 wireless gamepad and I noticed that analog sticks' deadzones don't exist. My gamepad is old so its analog sticks don't return precisely to the center; as a result my character moves even when I am doing nothing. This isn't an issue when I move the character but I can't aim precisely at a certain player/block and this isn't good for PvP or competitive games. @MCMrARM

NyaomiDEV avatar Jan 21 '18 18:01 NyaomiDEV

Hmm, there is a deadzone of 0.1, I guess I should make it a larger value.

MCMrARM avatar Jan 21 '18 18:01 MCMrARM

I think you should make it configurable. Hardcoding, the value would be a pain in the *** for compatibility with generic and non-generic controllers

InusualZ avatar Jan 21 '18 19:01 InusualZ