DualShock 4 - won't work on mac build
So, I've got a regular PS4 controller - Dual Shock 4. I'm connecting it via USB, MacOS recognises it in System Report > USB
section as a "Wireless Controller" manufactured by Sony.
I've turned off Logitech gaming software (for my mouse, as suggested in related topic).
I don't have any other input connected to the box as I'm testing this.
I've added two Axes in InputManager:
Horizontal
gravity: 1000
dead: 0.001
sensitivity: 1000
type: Joystick Axis
axis: X axis
joy num: Joystick 1
Vertical
gravity: 1000
dead: 0.001
sensitivity: 1000
type: Joystick Axis
axis: Y axis
joy num: Joystick 1
Code for controls (nothing fancy, taken from the official tutorial):
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
public float speed;
private Rigidbody rb;
void Start() {
rb = GetComponent<Rigidbody>();
}
void FixedUpdate() {
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Debug.Log(Input.GetJoystickNames());
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rb.AddForce(movement * speed);
}
}
Input.GetJoystickNames()
returns empty string, however... The controller works fine in "Play mode".
The problem occurs when I'm trying to use it to play mac build (webgl too, haven't tested others):
Input manager won't register any input from the joystick, so I can't set it up
There's no reaction in the game to my input This leads me to believe that the game build doesn't recognise the pad at all.
I've verified the controller is working in several ways:
by using Controllers Lite app - it's highlighting the correct buttons
by playing games with it on my mac
by using it in the play mode in Unity Editor
and by playing games on PS4
I'm running:
Latest MacOs: 10.12.5
Latest Unity: 5.6.2f1
Please advise. I'm at the end of my tether.
Answer by mwsmws · Jun 26, 2017 at 05:27 PM
Found the culprit - Karabiner-Elements!!! I'm using it to remap a few keys, like parens and ctrl. After quitting it (no need for uninstalling), the dual shock pad works fine in the build!
Case closed.