Any way to map keyboard keys to PS4 controller?

I'd like to use a PS4 dual shock controller to control a game that uses the arrow keys for movement and I can't figure out how to do this, although it feels like I am close. Here's what I've tried so far:

  1. I looked for macOS native ways to achieve this but couldn't find any. I also took a look at SteerMouse, which I have installed, but the controller doesn't show up.

  2. I then turned to KeyboardMaestro, which initially didn't recognize the controller as a USB device, when it was connected via Bluetooth. Connecting it via a USB cable fixed this.

But here's the problem: When I try to define a USB device key KeyboardMaestro always immediately registers "Wireless Controller #32" and doesn't allow me to enter any other keys.

I suspect this is the case because there are no deadzones defined for the controller's analog sticks and one of them is always giving a slight input, because they are never 100% centered. This input is blocking any other inputs.

Is there any way around this, or am I out of luck?

An interesting problem. There must be a way to log such inputs, but I was unable to find a relevant application or shell command. Perhaps someone else here knows of one.

Have you tried experimenting with USB Overdrive? It seems possible that doing so might yield some clues.

I haven't tried USB Overdrive, as I read some negative reviews and didn't want to install and pay for additional software (with the potential to create conflicts) when I already have Keyboard Maestro at hand...

Is there a way to enter the USB device key manually, instead of by pressing it on the device? If that were the case, I could just go through the numbers, guessing them, until I got it...

I suggested experimenting with USB Overdrive, not buying a licence and using it instead of KM. I don't know what the full current capabilities of the utility (or alternatives such as Steemouse) are. The idea was in any case perhaps too optimistic a hope for finding a way to get a list of the incoming messages from the PS4 controller, and I suppose that some sort of shell command would still be the best hope.

I didn't realise that USB Overdrive was usable for free! I'd still prefer to get by without installing additional software, but if that doesn't work out, I'll try it!

Well you can download it from the developer's site, so I presume it would work as a time-limited demo.

I would again stress that the idea was just to see if USB Overdrive could tell you more about what your controller is sending. But it was a slim hope, and if you're wary about installing applications for any reason, perhaps skip it. I expect better ideas will arrive from someone here soon! :slight_smile:

1 Like

Is the game installed via Steam or via something else? Steam has its own game controller driver, which is the same driver for all apps on that platform. You might want to check the Steam forum for ideas.

It's not a Steam game, but a browser game, unfortunately.

Additionally, I would also like to use the controller for other functions in other software, if possible.

I tried googling it. From what I read, the protocol used by most game controllers is DirectInput, aka dinput. ("xinput" is an older protocol.) For KM to recognize a controller directly, I think it would need to be an HID-compliant game controller. I think there are some on the market.

If you insist on using that PS4 controller, I think what you need to do is find a tool that converts dinput to USB. On github, i was able to find tools that converted dinput to xinput. I also think I found a utility to convert dinput to USB for Windows (not Mac), but I won't mention its name because it often includes malware.

I often qualify my posts by saying that there's only an 80% chance I'm right. In this case it's 70%.