DDR Dance Mat

So I have got it in my head, that I want to use a dance mat for a “joystick” in my project.

I bought a PS3 DDR dance mat controller off amazon to use. (USB connection) http://www.amazon.com/gp/product/B000YG0PUU/ref=s9_simh_gw_p63_d0_i1?pf_rd_m=ATVPDKIKX0DER&pf_rd_s=center-2&pf_rd_r=0ARD9C2CMWDJ09K5TW7W&pf_rd_t=101&pf_rd_p=1688200382&pf_rd_i=507846

I used a application called JoyToKey to figure out what joystick buttons it is using.

I have never used something like this before, and was a little surprised to see that the buttons that are used are not simply joystick button 1 thru 12.

Instead it seems to be as follows:

Joystick Button 1: Select Button
Joystick Button 2: <not used?>
Joystick Button 3: <not used?>
Joystick Button 4: Start Button
Joystick Button 5: Arrow Up (Forward)
Joystick Button 6: Arrow Right
Joystick Button 7: Arrow Down (Back)
Joystick Button 8: Arrow Left
Joystick Button 9: <not used?>
Joystick Button10: <not used?>
Joystick Button11: <not used?>
Joystick Button12: <not used?>
Joystick Button13: Triangle Button
Joystick Button14: Circle Button
Joystick Button15: ‘X’ Button
Joystick Button16: Square Button
Joystick Button17: Playstation Button

So it seems to not use buttons 2,3,9,10,11, and 12.

This doesn’t seem like a big deal to me since you can map the buttons in unity that are used.

I guess my confusion is that I thought there would be 12 buttons.

up,down,left,right,X, O, Square, Triangle, Start, Select, and the PS button have been found as I list above.

Does anyone know if there is a center button on dance mats? Am I missing something?

I searched google trying to find a schematic or something for these things to no avail.

It seems that a “standard” dance mat is referred to as a 9 button controller. Does that mean a center button should exist? Like a 3 x 3 grid of buttons? Or is it just 8 “direction” buttons and 1 start button.

Anyone have any experience with these types of controllers that knows?

Also do I need an app like JoyToKey running to map to unity? or will unity recognize Joystick button # without it?

Hello

Did you got any success for getting Dance Pad work with Unity?

The OP started the thread nearly 9 years ago so I doubt it.

1 Like

Yeah, Do you have any experience with similar stuff, getting Dance Pad work with a Unity Game?

I have never used a dance pad before, but I think you can read the inputs from Unity’s new InputSystem.

Was this response generated by ChatGPT?

It was that bad? :hushed:

If it connects over USB you use SerialPort to talk to it. You may have to try different baud rates to find the right one or look for a specification for your specific pad.

Common baud rates are:
9600
57600
115200

1 Like

I don’t know if this is correct. I’ve gotten the data into Max/MSP using the “hi” (Human Interface) object, but Max’s serial object didn’t read anything. Not sure if the gamepad acts as a typical serial port. That said, I haven’t tried in Unity.

Other threads say Unity should recognize the inputs as joystick buttons. I’m about to try that :slight_smile:

Here’s a script to poll any connected joysticks. These just look for the buttons, not actual sticks. Works great for the DDR mats.

You can do it by setting additional input axes in the Input Manager (Project Settings), but I found this was easier. However, if you want axes you’ll need to set them up in the Input Manager. (Old Input system)

One note: these are considered “key presses” so if you click outside the Game window (like clearing the Console), you’ll lose key focus and these won’t work until you click the Game window again. Same if you use Input.GetButtonDown etc.


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class gamepad1 : MonoBehaviour
{
    string[] joysticks;

    void Start()
    {
        // Get the array of connected joystick names
        joysticks = Input.GetJoystickNames();

        // Check how many joysticks are active
        int activeJoysticks = 0;

        for (int i = 0; i < joysticks.Length; i++)
        {
            if (!string.IsNullOrEmpty(joysticks[i]))
            {
                activeJoysticks++;
                Debug.Log("Joystick " + (i + 1) + " is connected: " + joysticks[i]);
            }
        }
        Debug.Log("Number of active joysticks: " + activeJoysticks);
    }

    void Update()
    {
        for (int k = 1; k < joysticks.Length + 1; k++) // need to add 1 because first joystick is named 1
        {
            for (int i = 0; i <= 19; i++)
            {
                if (Input.GetKeyDown("joystick " + k + " button " + i))
                {
                    Debug.Log("Joystick " + k + " Button Pressed: " + i);
                }

                if (Input.GetKeyUp("joystick " + k + " button " + i))
                {
                    Debug.Log("Joystick " + k + " Button Released: " + i);
                }
            }
        }
    }
}