コード例 #1
0
void AppStage_ControllerSettings::enter()
{
    m_app->setCameraType(_cameraFixed);
    m_selectedControllerIndex= -1;

    request_controller_list();
}
コード例 #2
0
void AppStage_ComputeTrackerPoses::enter()
{
    // Kick off this async request chain with a controller list request
    // -> controller start request
    // -> tracker list request
    // -> reacker start request
    request_controller_list();

    m_app->setCameraType(_cameraFixed);
}
コード例 #3
0
bool AppStage_ControllerSettings::onClientAPIEvent(
    ClientPSMoveAPI::eEventType event, 
    ClientPSMoveAPI::t_event_data_handle opaque_event_handle)
{
    bool bHandled= false;

    switch(event)
    {
    case ClientPSMoveAPI::controllerListUpdated:
        {
            bHandled= true;
            request_controller_list();
        } break;
    }

    return bHandled;
}
コード例 #4
0
void AppStage_ComputeTrackerPoses::enter()
{
    // Allocate a new HMD stream
    assert(m_hmdView == nullptr);

    if (m_app->getOpenVRContext()->getIsInitialized())
    {
        m_hmdView = m_app->getOpenVRContext()->allocateHmdView();
    }

    // Kick off this async request chain with a controller list request
    // -> controller start request
    // -> tracker list request
    // -> reacker start request
    request_controller_list();

    m_app->setCameraType(_cameraFixed);
}
コード例 #5
0
void AppStage_ControllerSettings::renderUI()
{
    const char *k_window_title= "Controller Settings";
    const ImGuiWindowFlags window_flags = 
        ImGuiWindowFlags_ShowBorders |
        ImGuiWindowFlags_NoResize | 
        ImGuiWindowFlags_NoMove |
        ImGuiWindowFlags_NoScrollbar |
        ImGuiWindowFlags_NoCollapse;

    switch (m_menuState)
    {
    case eControllerMenuState::idle:
        {
            ImGui::SetNextWindowPosCenter();
            ImGui::SetNextWindowSize(ImVec2(350, 350));
            ImGui::Begin(k_window_title, nullptr, window_flags);

            if (m_hostSerial.length() > 1 && m_hostSerial != "00:00:00:00:00:00")
            {
                ImGui::Text("Host Serial: %s", m_hostSerial.c_str());
            }
            else
            {
                ImGui::Text("No bluetooth adapter detected!");
            }
            
            ImGui::Separator();

            if (m_bluetoothControllerInfos.size() > 0)
            {
                const ControllerInfo &controllerInfo= m_bluetoothControllerInfos[m_selectedControllerIndex];

                if (m_selectedControllerIndex > 0)
                {
                    if (ImGui::Button("<##ControllerIndex"))
                    {
                        --m_selectedControllerIndex;
                    }
                    ImGui::SameLine();
                }
                ImGui::Text("Controller: %d", m_selectedControllerIndex);
                if (m_selectedControllerIndex + 1 < static_cast<int>(m_bluetoothControllerInfos.size()))
                {
                    ImGui::SameLine();
                    if (ImGui::Button(">##ControllerIndex"))
                    {
                        ++m_selectedControllerIndex;
                    }
                }

                ImGui::BulletText("Controller ID: %d", controllerInfo.ControllerID);

                // Display the tracking color being used for the controller
                {
                    const char *color_string = "UNKNOWN";

                    switch (controllerInfo.TrackingColorType)
                    {
                    case PSMoveTrackingColorType::Magenta:
                        color_string = "Magenta";
                        break;
                    case PSMoveTrackingColorType::Cyan:
                        color_string = "Cyan";
                        break;
                    case PSMoveTrackingColorType::Yellow:
                        color_string = "Yellow";
                        break;
                    case PSMoveTrackingColorType::Red:
                        color_string = "Red";
                        break;
                    case PSMoveTrackingColorType::Green:
                        color_string = "Green";
                        break;
                    case PSMoveTrackingColorType::Blue:
                        color_string = "Blue";
                        break;
                    default:
                        break;
                    }

                    ImGui::BulletText("Tracking Color: %s", color_string);
                }

                switch(controllerInfo.ControllerType)
                {
                    case AppStage_ControllerSettings::PSMove:
                        {
                            ImGui::BulletText("Controller Type: PSMove");
                        } break;
                    case AppStage_ControllerSettings::PSNavi:
                        {
                            ImGui::BulletText("Controller Type: PSNavi");
                        } break;
                    default:
                        assert(0 && "Unreachable");
                }

                ImGui::BulletText("Device Serial: %s", controllerInfo.DeviceSerial.c_str());
                ImGui::BulletText("Assigned Host Serial: %s", controllerInfo.AssignedHostSerial.c_str());
                ImGui::BulletText("Device Path:");
                ImGui::SameLine();
                ImGui::TextWrapped("%s", controllerInfo.DevicePath.c_str());

                if (controllerInfo.ControllerType == AppStage_ControllerSettings::PSMove)
                {
                    if (ImGui::Button("Calibrate Magnetometer"))
                    {
                        m_app->getAppStage<AppStage_MagnetometerCalibration>()->setBypassCalibrationFlag(false);
                        m_app->setAppStage(AppStage_MagnetometerCalibration::APP_STAGE_NAME);
                    }
                }

                if (controllerInfo.ControllerType == AppStage_ControllerSettings::PSMove)
                {
                    if (ImGui::Button("Test Orientation"))
                    {
                        m_app->getAppStage<AppStage_MagnetometerCalibration>()->setBypassCalibrationFlag(true);
                        m_app->setAppStage(AppStage_MagnetometerCalibration::APP_STAGE_NAME);
                    }

                    if (ImGui::Button("Test Rumble"))
                    {
                        m_app->setAppStage(AppStage_TestRumble::APP_STAGE_NAME);
                    }
                }
            }
            else
            {
                ImGui::Text("No Bluetooth connected controllers");
            }

            ImGui::Separator();

            // If there are any controllers waiting to be paired, 
            // just present the first one as an option
            if (m_usbControllerInfos.size() > 0)
            {
                // Only consider the first controller connected via usb
                ControllerInfo &controllerInfo = m_usbControllerInfos[0];

                // We can only unpair controllers connected via usb
                if (controllerInfo.PairedToHost)
                {
                    if (ImGui::Button("Unpair USB Controller"))
                    {
                        m_app->getAppStage<AppStage_PairController>()->request_controller_unpair(controllerInfo.ControllerID);
                        m_app->setAppStage(AppStage_PairController::APP_STAGE_NAME);
                    }
                }
                else
                {
                    if (ImGui::Button("Pair USB Controller"))
                    {
                        m_app->getAppStage<AppStage_PairController>()->request_controller_pair(controllerInfo.ControllerID);
                        m_app->setAppStage(AppStage_PairController::APP_STAGE_NAME);
                    }
                }
            }
            else
            {
                ImGui::Text("No USB connected controllers");
            }

            ImGui::Separator();

            if (ImGui::Button("Return to Main Menu"))
            {
                m_app->setAppStage(AppStage_MainMenu::APP_STAGE_NAME);
            }

            ImGui::End();
        } break;
    case eControllerMenuState::pendingControllerListRequest:
        {
            ImGui::SetNextWindowPosCenter();
            ImGui::SetNextWindowSize(ImVec2(300, 150));
            ImGui::Begin(k_window_title, nullptr, window_flags);

            ImGui::Text("Waiting for controller list response...");

            ImGui::End();
        } break;
    case eControllerMenuState::failedControllerListRequest:
        {
            ImGui::SetNextWindowPosCenter();
            ImGui::SetNextWindowSize(ImVec2(300, 150));
            ImGui::Begin(k_window_title, nullptr, window_flags);

            ImGui::Text("Failed to get controller list!");

            if (ImGui::Button("Retry"))
            {
                request_controller_list();
            }

            if (ImGui::Button("Return to Main Menu"))
            {
                m_app->setAppStage(AppStage_MainMenu::APP_STAGE_NAME);
            }

            ImGui::End();
        } break;

    default:
        assert(0 && "unreachable");
    }
}