Monday, September 2, 2013

PS Move with GLFW (tested only on Linux)

I recently discovered by accident that GLFW sees the ps move as a 28-axis joystick with 19 buttons. I don't think it would have worked unless I had first paired via usb cable the PS Move using Thomas Perl's psmoveapi. I will report more when I have more info. For now I've only tested it on Ubuntu 13.04 64-bit.

When I start my engine I query for which controller has 28 axes and I assign that GLFW_JOYSTICK_x to an int variable called moveController. Then I check using the following snippet:

void Engine::checkMove()
{
    float position[28];
    unsigned char buttons[19];
    std::fill_n(position,28,0.0f);

    if (glfwGetJoystickPos( moveController, position,28) == 28 ) {

        glfwGetJoystickButtons(moveController,buttons,19);

        // for loop limited to 16 because 16-17-18 seemed
        // to be always GLFW_PRESS for some reason
        for (int i=0;i < 16;++i) {                                      
            if (buttons[i] == GLFW_PRESS) {
                std::cout << "Button " << i <<  " pressed " <<std::endl;
            }
        }
    }

}

No comments:

Post a Comment