Is it possible to proxy or inhert a gamepad mapping? I’ve just created one for the Gamesir X2 (Expandable controller) and the only difference between it and the Android Xbox Wireless mapping is the device name
Defold doesn’t capture R2 & L2 inputs from Xbox X Controller S. I had this issue when I was playing @Alex_8BitSkull 's Bore Blast. I thought it was because the miss configuration, but I just test is with latest (1.7.0) buildins-default.gamepads and there is no action triggered (even raw). I would like to test it with gdc but it has a issue on MacOS.
Gamepad buttons are working with online gamepad testers and I’m already using it while playing games. Anyone has this issue?
Yeah, it seems we introduced a new concept of worker threads in our graphics backend, and the gdc tool was left out of that update. I’m fixing now.
We have a PR for it now.
I can confirm that even gdc(macos) tool doesn’t capture L and R triggers for latest Xbox X Controller
Here’s a mapping for my 8BitDo Pro 2 gamepad (android + windows):
driver {
device: "8BitDo Pro 2"
platform: "android"
dead_zone: 0.2
map { input: GAMEPAD_LSTICK_LEFT type: GAMEPAD_TYPE_AXIS index: 0 mod { mod: GAMEPAD_MODIFIER_NEGATE } mod { mod: GAMEPAD_MODIFIER_CLAMP } }
map { input: GAMEPAD_LSTICK_RIGHT type: GAMEPAD_TYPE_AXIS index: 0 mod { mod: GAMEPAD_MODIFIER_CLAMP } }
map { input: GAMEPAD_LSTICK_DOWN type: GAMEPAD_TYPE_AXIS index: 1 mod { mod: GAMEPAD_MODIFIER_CLAMP } }
map { input: GAMEPAD_LSTICK_UP type: GAMEPAD_TYPE_AXIS index: 1 mod { mod: GAMEPAD_MODIFIER_NEGATE } mod { mod: GAMEPAD_MODIFIER_CLAMP } }
map { input: GAMEPAD_LSTICK_CLICK type: GAMEPAD_TYPE_BUTTON index: 17 }
map { input: GAMEPAD_RSTICK_LEFT type: GAMEPAD_TYPE_AXIS index: 2 mod { mod: GAMEPAD_MODIFIER_NEGATE } mod { mod: GAMEPAD_MODIFIER_CLAMP } }
map { input: GAMEPAD_RSTICK_RIGHT type: GAMEPAD_TYPE_AXIS index: 2 mod { mod: GAMEPAD_MODIFIER_CLAMP } }
map { input: GAMEPAD_RSTICK_DOWN type: GAMEPAD_TYPE_AXIS index: 3 mod { mod: GAMEPAD_MODIFIER_CLAMP } }
map { input: GAMEPAD_RSTICK_UP type: GAMEPAD_TYPE_AXIS index: 3 mod { mod: GAMEPAD_MODIFIER_NEGATE } mod { mod: GAMEPAD_MODIFIER_CLAMP } }
map { input: GAMEPAD_RSTICK_CLICK type: GAMEPAD_TYPE_BUTTON index: 18 }
map { input: GAMEPAD_LPAD_LEFT type: GAMEPAD_TYPE_HAT index: 0 hat_mask: 8 }
map { input: GAMEPAD_LPAD_RIGHT type: GAMEPAD_TYPE_HAT index: 0 hat_mask: 2 }
map { input: GAMEPAD_LPAD_DOWN type: GAMEPAD_TYPE_HAT index: 0 hat_mask: 4 }
map { input: GAMEPAD_LPAD_UP type: GAMEPAD_TYPE_HAT index: 0 hat_mask: 1 }
map { input: GAMEPAD_RPAD_UP type: GAMEPAD_TYPE_BUTTON index: 3 }
map { input: GAMEPAD_RPAD_DOWN type: GAMEPAD_TYPE_BUTTON index: 1 }
map { input: GAMEPAD_RPAD_RIGHT type: GAMEPAD_TYPE_BUTTON index: 0 }
map { input: GAMEPAD_RPAD_LEFT type: GAMEPAD_TYPE_BUTTON index: 6 }
map { input: GAMEPAD_LSHOULDER type: GAMEPAD_TYPE_BUTTON index: 4 }
map { input: GAMEPAD_RSHOULDER type: GAMEPAD_TYPE_BUTTON index: 5 }
map { input: GAMEPAD_LTRIGGER type: GAMEPAD_TYPE_BUTTON index: 8 }
map { input: GAMEPAD_RTRIGGER type: GAMEPAD_TYPE_BUTTON index: 9 }
map { input: GAMEPAD_START type: GAMEPAD_TYPE_BUTTON index: 15 }
map { input: GAMEPAD_BACK type: GAMEPAD_TYPE_BUTTON index: 16 }
map { input: GAMEPAD_GUIDE type: GAMEPAD_TYPE_BUTTON index: 19 }
}
driver {
device: "8BitDo Pro 2"
platform: "windows"
dead_zone: 0.2
map { input: GAMEPAD_LPAD_LEFT type: GAMEPAD_TYPE_HAT index: 0 hat_mask: 8 }
map { input: GAMEPAD_LPAD_RIGHT type: GAMEPAD_TYPE_HAT index: 0 hat_mask: 2 }
map { input: GAMEPAD_LPAD_DOWN type: GAMEPAD_TYPE_HAT index: 0 hat_mask: 4 }
map { input: GAMEPAD_LPAD_UP type: GAMEPAD_TYPE_HAT index: 0 hat_mask: 1 }
map { input: GAMEPAD_START type: GAMEPAD_TYPE_BUTTON index: 15 }
map { input: GAMEPAD_BACK type: GAMEPAD_TYPE_BUTTON index: 14 }
map { input: GAMEPAD_RPAD_UP type: GAMEPAD_TYPE_BUTTON index: 7 }
map { input: GAMEPAD_RPAD_DOWN type: GAMEPAD_TYPE_BUTTON index: 5 }
map { input: GAMEPAD_RPAD_RIGHT type: GAMEPAD_TYPE_BUTTON index: 4 }
map { input: GAMEPAD_RPAD_LEFT type: GAMEPAD_TYPE_BUTTON index: 8 }
map { input: GAMEPAD_LSHOULDER type: GAMEPAD_TYPE_BUTTON index: 10 }
map { input: GAMEPAD_RSHOULDER type: GAMEPAD_TYPE_BUTTON index: 11 }
map { input: GAMEPAD_LTRIGGER type: GAMEPAD_TYPE_BUTTON index: 12 }
map { input: GAMEPAD_RTRIGGER type: GAMEPAD_TYPE_BUTTON index: 13 }
map { input: GAMEPAD_GUIDE type: GAMEPAD_TYPE_BUTTON index: 16 }
map { input: GAMEPAD_LSTICK_LEFT type: GAMEPAD_TYPE_AXIS index: 0 mod { mod: GAMEPAD_MODIFIER_NEGATE } mod { mod: GAMEPAD_MODIFIER_CLAMP } }
map { input: GAMEPAD_LSTICK_RIGHT type: GAMEPAD_TYPE_AXIS index: 0 mod { mod: GAMEPAD_MODIFIER_CLAMP } }
map { input: GAMEPAD_LSTICK_DOWN type: GAMEPAD_TYPE_AXIS index: 1 mod { mod: GAMEPAD_MODIFIER_CLAMP } }
map { input: GAMEPAD_LSTICK_UP type: GAMEPAD_TYPE_AXIS index: 1 mod { mod: GAMEPAD_MODIFIER_NEGATE } mod { mod: GAMEPAD_MODIFIER_CLAMP } }
map { input: GAMEPAD_LSTICK_CLICK type: GAMEPAD_TYPE_BUTTON index: 17 }
map { input: GAMEPAD_RSTICK_LEFT type: GAMEPAD_TYPE_AXIS index: 3 mod { mod: GAMEPAD_MODIFIER_NEGATE } mod { mod: GAMEPAD_MODIFIER_CLAMP } }
map { input: GAMEPAD_RSTICK_RIGHT type: GAMEPAD_TYPE_AXIS index: 3 mod { mod: GAMEPAD_MODIFIER_CLAMP } }
map { input: GAMEPAD_RSTICK_DOWN type: GAMEPAD_TYPE_AXIS index: 4 mod { mod: GAMEPAD_MODIFIER_CLAMP } }
map { input: GAMEPAD_RSTICK_UP type: GAMEPAD_TYPE_AXIS index: 4 mod { mod: GAMEPAD_MODIFIER_NEGATE } mod { mod: GAMEPAD_MODIFIER_CLAMP } }
map { input: GAMEPAD_RSTICK_CLICK type: GAMEPAD_TYPE_BUTTON index: 18 }
}
This defold project is another variation of mapping for gamepads:
GAMEPAD_TESTER.zip (92.3 KB)
It’s assembled from two projects:
- from @britzl (mentioned in the topic Big thread of gamepad testing)
- from @Alex_8BitSkull (mentioned in the topic Steam Deck input (SOLVED) - #12 by Alex_8BitSkull)
Could you pls create a PR similar to Added Linux layouts for 2 gamepads by Domarius · Pull Request #8605 · defold/defold · GitHub ?
Here is a gamepad mapping for my Logitech Dual Action on Windows.
driver {
device: "Logitech Dual Action"
platform: "windows"
dead_zone: 0.200
map { input: GAMEPAD_LSTICK_LEFT type: GAMEPAD_TYPE_AXIS index: 0 mod { mod: GAMEPAD_MODIFIER_NEGATE } mod { mod: GAMEPAD_MODIFIER_CLAMP } }
map { input: GAMEPAD_LSTICK_RIGHT type: GAMEPAD_TYPE_AXIS index: 0 mod { mod: GAMEPAD_MODIFIER_CLAMP } }
map { input: GAMEPAD_LSTICK_DOWN type: GAMEPAD_TYPE_AXIS index: 1 mod { mod: GAMEPAD_MODIFIER_CLAMP } }
map { input: GAMEPAD_LSTICK_UP type: GAMEPAD_TYPE_AXIS index: 1 mod { mod: GAMEPAD_MODIFIER_NEGATE } mod { mod: GAMEPAD_MODIFIER_CLAMP } }
map { input: GAMEPAD_LSTICK_CLICK type: GAMEPAD_TYPE_BUTTON index: 14 }
map { input: GAMEPAD_LTRIGGER type: GAMEPAD_TYPE_BUTTON index: 10 }
map { input: GAMEPAD_LSHOULDER type: GAMEPAD_TYPE_BUTTON index: 8 }
map { input: GAMEPAD_LPAD_LEFT type: GAMEPAD_TYPE_BUTTON index: 2 }
map { input: GAMEPAD_LPAD_RIGHT type: GAMEPAD_TYPE_BUTTON index: 3 }
map { input: GAMEPAD_LPAD_DOWN type: GAMEPAD_TYPE_BUTTON index: 1 }
map { input: GAMEPAD_LPAD_UP type: GAMEPAD_TYPE_BUTTON index: 0 }
map { input: GAMEPAD_RSTICK_LEFT type: GAMEPAD_TYPE_AXIS index: 2 mod { mod: GAMEPAD_MODIFIER_NEGATE } mod { mod: GAMEPAD_MODIFIER_CLAMP } }
map { input: GAMEPAD_RSTICK_RIGHT type: GAMEPAD_TYPE_AXIS index: 2 mod { mod: GAMEPAD_MODIFIER_CLAMP } }
map { input: GAMEPAD_RSTICK_DOWN type: GAMEPAD_TYPE_AXIS index: 3 mod { mod: GAMEPAD_MODIFIER_CLAMP } }
map { input: GAMEPAD_RSTICK_UP type: GAMEPAD_TYPE_AXIS index: 3 mod { mod: GAMEPAD_MODIFIER_NEGATE } mod { mod: GAMEPAD_MODIFIER_CLAMP } }
map { input: GAMEPAD_RSTICK_CLICK type: GAMEPAD_TYPE_BUTTON index: 15 }
map { input: GAMEPAD_RTRIGGER type: GAMEPAD_TYPE_BUTTON index: 11 }
map { input: GAMEPAD_RSHOULDER type: GAMEPAD_TYPE_BUTTON index: 9 }
map { input: GAMEPAD_RPAD_LEFT type: GAMEPAD_TYPE_BUTTON index: 4 }
map { input: GAMEPAD_RPAD_RIGHT type: GAMEPAD_TYPE_BUTTON index: 6 }
map { input: GAMEPAD_RPAD_DOWN type: GAMEPAD_TYPE_BUTTON index: 5 }
map { input: GAMEPAD_RPAD_UP type: GAMEPAD_TYPE_BUTTON index: 7 }
map { input: GAMEPAD_START type: GAMEPAD_TYPE_BUTTON index: 13 }
map { input: GAMEPAD_BACK type: GAMEPAD_TYPE_BUTTON index: 12 }
}
Here is a gamepad mapping for the Retroid Pocket 4 Pro
driver {
device: "Retroid Pocket Controller"
platform: "android"
dead_zone: 0.2
map {
input: GAMEPAD_LSTICK_LEFT
type: GAMEPAD_TYPE_AXIS
index: 0
mod {
mod: GAMEPAD_MODIFIER_NEGATE
}
mod {
mod: GAMEPAD_MODIFIER_CLAMP
}
hat_mask: 0
}
map {
input: GAMEPAD_LSTICK_RIGHT
type: GAMEPAD_TYPE_AXIS
index: 0
mod {
mod: GAMEPAD_MODIFIER_CLAMP
}
hat_mask: 0
}
map {
input: GAMEPAD_LSTICK_DOWN
type: GAMEPAD_TYPE_AXIS
index: 1
mod {
mod: GAMEPAD_MODIFIER_CLAMP
}
hat_mask: 0
}
map {
input: GAMEPAD_LSTICK_UP
type: GAMEPAD_TYPE_AXIS
index: 1
mod {
mod: GAMEPAD_MODIFIER_NEGATE
}
mod {
mod: GAMEPAD_MODIFIER_CLAMP
}
hat_mask: 0
}
map {
input: GAMEPAD_LSTICK_CLICK
type: GAMEPAD_TYPE_BUTTON
index: 17
hat_mask: 0
}
map {
input: GAMEPAD_RSTICK_LEFT
type: GAMEPAD_TYPE_AXIS
index: 2
mod {
mod: GAMEPAD_MODIFIER_NEGATE
}
mod {
mod: GAMEPAD_MODIFIER_CLAMP
}
hat_mask: 0
}
map {
input: GAMEPAD_RSTICK_RIGHT
type: GAMEPAD_TYPE_AXIS
index: 2
mod {
mod: GAMEPAD_MODIFIER_CLAMP
}
hat_mask: 0
}
map {
input: GAMEPAD_RSTICK_DOWN
type: GAMEPAD_TYPE_AXIS
index: 3
mod {
mod: GAMEPAD_MODIFIER_CLAMP
}
hat_mask: 0
}
map {
input: GAMEPAD_RSTICK_UP
type: GAMEPAD_TYPE_AXIS
index: 3
mod {
mod: GAMEPAD_MODIFIER_NEGATE
}
mod {
mod: GAMEPAD_MODIFIER_CLAMP
}
hat_mask: 0
}
map {
input: GAMEPAD_RSTICK_CLICK
type: GAMEPAD_TYPE_BUTTON
index: 18
hat_mask: 0
}
map {
input: GAMEPAD_LPAD_LEFT
type: GAMEPAD_TYPE_AXIS
index: 6
mod {
mod: GAMEPAD_MODIFIER_NEGATE
}
hat_mask: 16
}
map {
input: GAMEPAD_LPAD_RIGHT
type: GAMEPAD_TYPE_AXIS
index: 6
hat_mask: 16
}
map {
input: GAMEPAD_LPAD_DOWN
type: GAMEPAD_TYPE_AXIS
index: 7
hat_mask: 15
}
map {
input: GAMEPAD_LPAD_UP
type: GAMEPAD_TYPE_AXIS
index: 7
mod {
mod: GAMEPAD_MODIFIER_NEGATE
}
hat_mask: 15
}
map {
input: GAMEPAD_RPAD_UP
type: GAMEPAD_TYPE_BUTTON
index: 3
hat_mask: 0
}
map {
input: GAMEPAD_RPAD_DOWN
type: GAMEPAD_TYPE_BUTTON
index: 1
hat_mask: 0
}
map {
input: GAMEPAD_RPAD_RIGHT
type: GAMEPAD_TYPE_BUTTON
index: 0
hat_mask: 0
}
map {
input: GAMEPAD_RPAD_LEFT
type: GAMEPAD_TYPE_BUTTON
index: 6
hat_mask: 0
}
map {
input: GAMEPAD_LSHOULDER
type: GAMEPAD_TYPE_BUTTON
index: 4
hat_mask: 0
}
map {
input: GAMEPAD_RSHOULDER
type: GAMEPAD_TYPE_BUTTON
index: 5
hat_mask: 0
}
map {
input: GAMEPAD_LTRIGGER
type: GAMEPAD_TYPE_BUTTON
index: 8
hat_mask: 0
}
map {
input: GAMEPAD_RTRIGGER
type: GAMEPAD_TYPE_BUTTON
index: 9
hat_mask: 0
}
map {
input: GAMEPAD_START
type: GAMEPAD_TYPE_BUTTON
index: 15
hat_mask: 0
}
map {
input: GAMEPAD_BACK
type: GAMEPAD_TYPE_BUTTON
index: 17
hat_mask: 0
}
}```
Hi, I am posting for the PS4 controller “DUALSHOCK 4 Wireless Controller” for macOS, here is the bindings:
macos-dualshock.txt (2.3 KB)
Hi, I’ve added a PR for a ‘Wireless Xbox Controller’ mapping for windows os.
q: is a PR better for you (engine devs) or should I have just posted it here?
Thanks!
We do prefer PR’s to be honest. Less work for us!
Added a mapping for the Switch Pro Controller on Windows, see https://github.com/defold/defold/pull/9499.
Another thought, on the game pad there are four leds signaling what player the controller the belongs to (player 1, player 2…) and those leds keep displaying the “connecting” animation. Would it be possible for Defold to send some “you are player x” message back to the controller?
Perhaps if you create a native extension? Is there some sdk or library that can do this?
I have zero experience with cpp, zero experience wrestling the low levels of windows and zero experience with the defold source, so bear with me.
From digging a bit in the defold source I’m guessing that gamepad input is handled through glfw. glfw does at the moment not support “gamepad callbacks” and haptic feedback, see Support for haptic feedback (vibration, rumble) · Issue #57 · glfw/glfw · GitHub and https://github.com/glfw/glfw/pull/1590.
I ended up reading the SDL2 manual, which supports setting the player index: SDL2/SDL_GameControllerSetPlayerIndex - SDL Wiki. Seems like it handles haptic feedback as well.
Does writing a native extension using SDL2 sound like a reasonable way forward to achieve correct led displays and support for rumble / other haptic feedback?
Bonus: sanity check, this isn’t correct anymore is it? Gamepad input in Defold
I found this device is still not listed- and since I new on Gamepad (I’m using this 8BitDo Lite 2). Could anyone please help if already list the map
Ref: https://download.8bitdo.com/Manual/Controller/Lite2/Lite2_Manual.pdf?20231201
Addition debugger
INFO:DLIB: Log server started on port 52855
INFO:ENGINE: Target listening with name: C02G27H1Q05P - 192.168.1.23 - Darwin
INFO:ENGINE: Engine service started on port 52856
INFO:GRAPHICS: Installed graphics device 'ADAPTER_FAMILY_OPENGL'
INFO:ENGINE: Defold Engine 1.9.4 (a927777)
INFO:DLIB: Initialized Remotery (ws://127.0.0.1:17815/rmt)
INFO:ENGINE: Loading data from: build/default
INFO:ENGINE: Initialised sound device 'default'
WARNING:INPUT: No gamepad map found for gamepad 0 (8BitDo Lite 2). The raw gamepad map will be used.
DEBUG:SCRIPT: Listening for debugger on 0.0.0.0
DEBUG:SCRIPT: Debugger connected from 127.0.0.1
[UPDATE]
This what I get best so far
driver {
device: "8BitDo Lite 2"
platform: "osx"
dead_zone: 0.2
map {
input: GAMEPAD_LSTICK_LEFT
type: GAMEPAD_TYPE_AXIS
index: 0
mod {
mod: GAMEPAD_MODIFIER_NEGATE
}
mod {
mod: GAMEPAD_MODIFIER_CLAMP
}
}
map {
input: GAMEPAD_LSTICK_RIGHT
type: GAMEPAD_TYPE_AXIS
index: 0
mod {
mod: GAMEPAD_MODIFIER_CLAMP
}
}
map {
input: GAMEPAD_LSTICK_DOWN
type: GAMEPAD_TYPE_AXIS
index: 1
mod {
mod: GAMEPAD_MODIFIER_CLAMP
}
}
map {
input: GAMEPAD_LSTICK_UP
type: GAMEPAD_TYPE_AXIS
index: 1
mod {
mod: GAMEPAD_MODIFIER_NEGATE
}
mod {
mod: GAMEPAD_MODIFIER_CLAMP
}
}
map {
input: GAMEPAD_LSTICK_CLICK
type: GAMEPAD_TYPE_BUTTON
index: 13
}
map {
input: GAMEPAD_LTRIGGER
type: GAMEPAD_TYPE_BUTTON
index: 8
}
map {
input: GAMEPAD_LSHOULDER
type: GAMEPAD_TYPE_BUTTON
index: 6
}
map {
input: GAMEPAD_LPAD_LEFT
type: GAMEPAD_TYPE_BUTTON
index: 23
mod {
mod: GAMEPAD_MODIFIER_NEGATE
}
}
map {
input: GAMEPAD_LPAD_RIGHT
type: GAMEPAD_TYPE_BUTTON
index: 21
}
map {
input: GAMEPAD_LPAD_DOWN
type: GAMEPAD_TYPE_BUTTON
index: 22
mod {
mod: GAMEPAD_MODIFIER_NEGATE
}
}
map {
input: GAMEPAD_LPAD_UP
type: GAMEPAD_TYPE_BUTTON
index: 20
}
map {
input: GAMEPAD_RSTICK_LEFT
type: GAMEPAD_TYPE_AXIS
index: 2
mod {
mod: GAMEPAD_MODIFIER_NEGATE
}
mod {
mod: GAMEPAD_MODIFIER_CLAMP
}
}
map {
input: GAMEPAD_RSTICK_RIGHT
type: GAMEPAD_TYPE_AXIS
index: 2
mod {
mod: GAMEPAD_MODIFIER_CLAMP
}
}
map {
input: GAMEPAD_RSTICK_DOWN
type: GAMEPAD_TYPE_AXIS
index: 3
mod {
mod: GAMEPAD_MODIFIER_CLAMP
}
}
map {
input: GAMEPAD_RSTICK_UP
type: GAMEPAD_TYPE_AXIS
index: 3
mod {
mod: GAMEPAD_MODIFIER_NEGATE
}
mod {
mod: GAMEPAD_MODIFIER_CLAMP
}
}
map {
input: GAMEPAD_RSTICK_CLICK
type: GAMEPAD_TYPE_BUTTON
index: 14
}
map {
input: GAMEPAD_RTRIGGER
type: GAMEPAD_TYPE_BUTTON
index: 9
}
map {
input: GAMEPAD_RSHOULDER
type: GAMEPAD_TYPE_BUTTON
index: 7
}
map {
input: GAMEPAD_RPAD_LEFT
type: GAMEPAD_TYPE_BUTTON
index: 4
}
map {
input: GAMEPAD_RPAD_RIGHT
type: GAMEPAD_TYPE_BUTTON
index: 0
}
map {
input: GAMEPAD_RPAD_DOWN
type: GAMEPAD_TYPE_BUTTON
index: 1
}
map {
input: GAMEPAD_RPAD_UP
type: GAMEPAD_TYPE_BUTTON
index: 3
}
map {
input: GAMEPAD_START
type: GAMEPAD_TYPE_BUTTON
index: 11
}
map {
input: GAMEPAD_BACK
type: GAMEPAD_TYPE_BUTTON
index: 10
}
You can use GDC tool to map your gamepad:
Yup, but not sure why always return this error, command not found
$user defold % sudo ./gdc-macos
Password:
sudo: ./gdc-macos: command not found