void Cedrus::XIDDevice::MatchConfigToModel(char model)
{
    m_config = XIDDeviceScanner::GetDeviceScanner().GetConfigForGivenDevice(GetProductID(), model != -1 ? model : GetModelID(), m_config->GetMajorVersion());
    if (model != -1)
        m_ResponseMgr.reset(m_config->IsInputDevice() ? new ResponseManager(m_config) : nullptr);
}
Exemplo n.º 2
0
static m64p_error OpenConfigurationHandles(void)
{
    float fConfigParamsVersion;
    int bSaveConfig = 0;
    m64p_error rval;

    /* Open Configuration sections for core library and console User Interface */
    rval = (*ConfigOpenSection)("Core", &l_ConfigCore);
    if (rval != M64ERR_SUCCESS)
    {
        DebugMessage(M64MSG_ERROR, "failed to open 'Core' configuration section");
        return rval;
    }

    rval = (*ConfigOpenSection)("Video-General", &l_ConfigVideo);
    if (rval != M64ERR_SUCCESS)
    {
        DebugMessage(M64MSG_ERROR, "failed to open 'Video-General' configuration section");
        return rval;
    }

    rval = (*ConfigOpenSection)("UI-Console", &l_ConfigUI);
    if (rval != M64ERR_SUCCESS)
    {
        DebugMessage(M64MSG_ERROR, "failed to open 'UI-Console' configuration section");
        return rval;
    }

    rval = (*ConfigOpenSection)("Video-Glide64mk2", &l_ConfigVideoGlide64mk2);
    if (rval != M64ERR_SUCCESS)
    {
        DebugMessage(M64MSG_ERROR, "failed to open 'Video-Glide64mk2' configuration section");
        return rval;
    }

    rval = (*ConfigOpenSection)("Video-GLideN64", &l_ConfigVideoGLideN64);
    if (rval != M64ERR_SUCCESS)
    {
        DebugMessage(M64MSG_ERROR, "failed to open 'Video-GLideN64' configuration section");
        return rval;
    }

    if ((*ConfigGetParameter)(l_ConfigUI, "Version", M64TYPE_FLOAT, &fConfigParamsVersion, sizeof(float)) != M64ERR_SUCCESS)
    {
        DebugMessage(M64MSG_WARNING, "No version number in 'UI-Console' config section. Setting defaults.");
        (*ConfigDeleteSection)("UI-Console");
        (*ConfigOpenSection)("UI-Console", &l_ConfigUI);
        bSaveConfig = 1;
    }
    else if (((int) fConfigParamsVersion) != ((int) CONFIG_PARAM_VERSION))
    {
        DebugMessage(M64MSG_WARNING, "Incompatible version %.2f in 'UI-Console' config section: current is %.2f. Setting defaults.", fConfigParamsVersion, (float) CONFIG_PARAM_VERSION);
        (*ConfigDeleteSection)("UI-Console");
        (*ConfigOpenSection)("UI-Console", &l_ConfigUI);
        bSaveConfig = 1;
    }
    else if ((CONFIG_PARAM_VERSION - fConfigParamsVersion) >= 0.0001f)
    {
        /* handle upgrades */
        float fVersion = CONFIG_PARAM_VERSION;
        ConfigSetParameter(l_ConfigUI, "Version", M64TYPE_FLOAT, &fVersion);
        DebugMessage(M64MSG_INFO, "Updating parameter set version in 'UI-Console' config section to %.2f", fVersion);
        bSaveConfig = 1;
    }

    DebugMessage(M64MSG_VERBOSE, "Setting default config values.");
    (*ConfigSetDefaultFloat)(l_ConfigUI, "Version", CONFIG_PARAM_VERSION,  "Mupen64Plus UI-Console config parameter set version number.  Please don't change this version number.");
    (*ConfigSetDefaultString)(l_ConfigUI, "PluginDir", OSAL_CURRENT_DIR, "Directory in which to search for plugins");

    char *product_id = GetProductID();
    if (product_id != NULL)
    {
        if (strcmp(product_id, "l500d") == 0)
        {
            DebugMessage(M64MSG_VERBOSE, "Setting default config values for the Jolla C");
            /* Set default values for my Config parameters */
            (*ConfigSetDefaultString)(l_ConfigUI, "VideoPlugin", "mupen64plus-video-GLideN64" OSAL_DLL_EXTENSION, "Filename of video plugin");
            (*ConfigSetDefaultString)(l_ConfigUI, "AudioPlugin", "mupen64plus-audio-sdl" OSAL_DLL_EXTENSION, "Filename of audio plugin");
            (*ConfigSetDefaultString)(l_ConfigUI, "InputPlugin", "mupen64plus-input-sdltouch" OSAL_DLL_EXTENSION, "Filename of input plugin");
            (*ConfigSetDefaultString)(l_ConfigUI, "RspPlugin", "mupen64plus-rsp-hle" OSAL_DLL_EXTENSION, "Filename of RSP plugin");

            (*ConfigSetDefaultInt)(l_ConfigVideo, "ScreenWidth", 720, "Width of output window or fullscreen width");
            (*ConfigSetDefaultInt)(l_ConfigVideo, "ScreenHeight", 1280, "Height of output window or fullscreen height");
            (*ConfigSetDefaultInt)(l_ConfigVideo, "Rotate", 3, "Rotate screen contents: 0=0 degree, 1=90 degree, 2 = 180 degree, 3=270 degree");

            (*ConfigSetDefaultInt)(l_ConfigVideoGlide64mk2, "aspect", 2, "Aspect ratio: -1=Game default, 0=Force 4:3, 1=Force 16:9, 2=Stretch, 3=Original");

            (*ConfigSetDefaultBool)(l_ConfigVideoGlide64mk2, "force_polygon_offset", 1, "If true, use polygon offset values specified below");
            (*ConfigSetDefaultBool)(l_ConfigVideoGlide64mk2, "polygon_offset_factor", -0.25, "Specifies a scale factor that is used to create a variable depth offset for each polygon");
            (*ConfigSetDefaultBool)(l_ConfigVideoGlide64mk2, "polygon_offset_units", -0.25, "Is multiplied by an implementation-specific value to create a constant depth offset");

	    (*ConfigSetDefaultBool)(l_ConfigVideoGLideN64, "EnableFBEmulation", 0, "Enable frame and|or depth buffer emulation.");
            (*ConfigSetDefaultBool)(l_ConfigVideoGLideN64, "EnableLegacyBlending", 1, "Do not use shaders to emulate N64 blending modes. Works faster on slow GPU. Can cause glitches.");
            (*ConfigSetDefaultInt)(l_ConfigVideoGLideN64, "AspectRatio", 0, "Screen aspect ratio (0=stretch, 1=force 4:3, 2=force 16:9, 3=adjust)");

            (*ConfigSetDefaultBool)(l_ConfigVideoGLideN64, "EnableFBEmulation", 0, "Enable frame and|or depth buffer emulation.");
        }
        else if (strcmp(product_id, "sbj") == 0)
        {
            DebugMessage(M64MSG_VERBOSE, "Setting default config values for the Jolla Phone");
            /* Set default values for my Config parameters */
            (*ConfigSetDefaultString)(l_ConfigUI, "VideoPlugin", "mupen64plus-video-GLideN64" OSAL_DLL_EXTENSION, "Filename of video plugin");
            (*ConfigSetDefaultString)(l_ConfigUI, "AudioPlugin", "mupen64plus-audio-sdl" OSAL_DLL_EXTENSION, "Filename of audio plugin");
            (*ConfigSetDefaultString)(l_ConfigUI, "InputPlugin", "mupen64plus-input-sdltouch" OSAL_DLL_EXTENSION, "Filename of input plugin");
            (*ConfigSetDefaultString)(l_ConfigUI, "RspPlugin", "mupen64plus-rsp-hle" OSAL_DLL_EXTENSION, "Filename of RSP plugin");

            (*ConfigSetDefaultInt)(l_ConfigVideo, "ScreenWidth", 540, "Width of output window or fullscreen width");
            (*ConfigSetDefaultInt)(l_ConfigVideo, "ScreenHeight", 960, "Height of output window or fullscreen height");
            (*ConfigSetDefaultInt)(l_ConfigVideo, "Rotate", 3, "Rotate screen contents: 0=0 degree, 1=90 degree, 2 = 180 degree, 3=270 degree");

            (*ConfigSetDefaultInt)(l_ConfigVideoGlide64mk2, "aspect", 2, "Aspect ratio: -1=Game default, 0=Force 4:3, 1=Force 16:9, 2=Stretch, 3=Original");

            (*ConfigSetDefaultBool)(l_ConfigVideoGlide64mk2, "force_polygon_offset", 1, "If true, use polygon offset values specified below");
            (*ConfigSetDefaultBool)(l_ConfigVideoGlide64mk2, "polygon_offset_factor", -0.25, "Specifies a scale factor that is used to create a variable depth offset for each polygon");
            (*ConfigSetDefaultBool)(l_ConfigVideoGlide64mk2, "polygon_offset_units", -0.25, "Is multiplied by an implementation-specific value to create a constant depth offset");

	    (*ConfigSetDefaultBool)(l_ConfigVideoGLideN64, "EnableFBEmulation", 0, "Enable frame and|or depth buffer emulation.");
            (*ConfigSetDefaultBool)(l_ConfigVideoGLideN64, "EnableLegacyBlending", 1, "Do not use shaders to emulate N64 blending modes. Works faster on slow GPU. Can cause glitches.");
            (*ConfigSetDefaultInt)(l_ConfigVideoGLideN64, "AspectRatio", 0, "Screen aspect ratio (0=stretch, 1=force 4:3, 2=force 16:9, 3=adjust)");

            (*ConfigSetDefaultBool)(l_ConfigVideoGLideN64, "EnableFBEmulation", 0, "Enable frame and|or depth buffer emulation.");
        }
        else if(strcmp(product_id, "tbj") == 0)
        {
            DebugMessage(M64MSG_VERBOSE, "Setting default config values for the Jolla Tablet");
            /* Set default values for my Config parameters */
            (*ConfigSetDefaultString)(l_ConfigUI, "VideoPlugin", "mupen64plus-video-GLideN64" OSAL_DLL_EXTENSION, "Filename of video plugin");
            (*ConfigSetDefaultString)(l_ConfigUI, "AudioPlugin", "mupen64plus-audio-sdl" OSAL_DLL_EXTENSION, "Filename of audio plugin");
            (*ConfigSetDefaultString)(l_ConfigUI, "InputPlugin", "mupen64plus-input-sdltouch" OSAL_DLL_EXTENSION, "Filename of input plugin");
            (*ConfigSetDefaultString)(l_ConfigUI, "RspPlugin", "mupen64plus-rsp-hle" OSAL_DLL_EXTENSION, "Filename of RSP plugin");

            (*ConfigSetDefaultInt)(l_ConfigVideo, "ScreenWidth", 1536, "Width of output window or fullscreen width");
            (*ConfigSetDefaultInt)(l_ConfigVideo, "ScreenHeight", 2048, "Height of output window or fullscreen height");
            (*ConfigSetDefaultInt)(l_ConfigVideo, "Rotate", 3, "Rotate screen contents: 0=0 degree, 1=90 degree, 2 = 180 degree, 3=270 degree");

            (*ConfigSetDefaultInt)(l_ConfigVideoGlide64mk2, "aspect", 2, "Aspect ratio: -1=Game default, 0=Force 4:3, 1=Force 16:9, 2=Stretch, 3=Original");
            (*ConfigSetDefaultBool)(l_ConfigVideoGlide64mk2, "force_polygon_offset", 1, "If true, use polygon offset values specified below");
            (*ConfigSetDefaultBool)(l_ConfigVideoGlide64mk2, "polygon_offset_factor", -0.25, "Specifies a scale factor that is used to create a variable depth offset for each polygon");
            (*ConfigSetDefaultBool)(l_ConfigVideoGlide64mk2, "polygon_offset_units", -0.25, "Is multiplied by an implementation-specific value to create a constant depth offset");

	    (*ConfigSetDefaultBool)(l_ConfigVideoGLideN64, "EnableFBEmulation", 0, "Enable frame and|or depth buffer emulation.");
            (*ConfigSetDefaultBool)(l_ConfigVideoGLideN64, "EnableLegacyBlending", 1, "Do not use shaders to emulate N64 blending modes. Works faster on slow GPU. Can cause glitches.");
            (*ConfigSetDefaultInt)(l_ConfigVideoGLideN64, "AspectRatio", 0, "Screen aspect ratio (0=stretch, 1=force 4:3, 2=force 16:9, 3=adjust)");

            (*ConfigSetDefaultBool)(l_ConfigVideoGLideN64, "EnableFBEmulation", 0, "Enable frame and|or depth buffer emulation.");
        }
        else if (strcmp(product_id, "hammerhead") == 0)
        {
            DebugMessage(M64MSG_VERBOSE, "Setting default config values for the Nexus 5");
            /* Set default values for my Config parameters */
            (*ConfigSetDefaultString)(l_ConfigUI, "VideoPlugin", "mupen64plus-video-GLideN64" OSAL_DLL_EXTENSION, "Filename of video plugin");
            (*ConfigSetDefaultString)(l_ConfigUI, "AudioPlugin", "mupen64plus-audio-sdl" OSAL_DLL_EXTENSION, "Filename of audio plugin");
            (*ConfigSetDefaultString)(l_ConfigUI, "InputPlugin", "mupen64plus-input-sdltouch" OSAL_DLL_EXTENSION, "Filename of input plugin");
            (*ConfigSetDefaultString)(l_ConfigUI, "RspPlugin", "mupen64plus-rsp-hle" OSAL_DLL_EXTENSION, "Filename of RSP plugin");

            (*ConfigSetDefaultInt)(l_ConfigVideo, "ScreenWidth", 1080, "Width of output window or fullscreen width");
            (*ConfigSetDefaultInt)(l_ConfigVideo, "ScreenHeight", 1920, "Height of output window or fullscreen height");
            (*ConfigSetDefaultInt)(l_ConfigVideo, "Rotate", 3, "Rotate screen contents: 0=0 degree, 1=90 degree, 2 = 180 degree, 3=270 degree");

            (*ConfigSetDefaultInt)(l_ConfigVideoGlide64mk2, "aspect", 2, "Aspect ratio: -1=Game default, 0=Force 4:3, 1=Force 16:9, 2=Stretch, 3=Original");
            (*ConfigSetDefaultBool)(l_ConfigVideoGlide64mk2, "force_polygon_offset", 1, "If true, use polygon offset values specified below");
            (*ConfigSetDefaultBool)(l_ConfigVideoGlide64mk2, "polygon_offset_factor", -0.25, "Specifies a scale factor that is used to create a variable depth offset for each polygon");
            (*ConfigSetDefaultBool)(l_ConfigVideoGlide64mk2, "polygon_offset_units", -0.25, "Is multiplied by an implementation-specific value to create a constant depth offset");

	    (*ConfigSetDefaultBool)(l_ConfigVideoGLideN64, "EnableFBEmulation", 0, "Enable frame and|or depth buffer emulation.");
            (*ConfigSetDefaultBool)(l_ConfigVideoGLideN64, "EnableLegacyBlending", 1, "Do not use shaders to emulate N64 blending modes. Works faster on slow GPU. Can cause glitches.");
            (*ConfigSetDefaultInt)(l_ConfigVideoGLideN64, "AspectRatio", 0, "Screen aspect ratio (0=stretch, 1=force 4:3, 2=force 16:9, 3=adjust)");

            (*ConfigSetDefaultBool)(l_ConfigVideoGLideN64, "EnableFBEmulation", 0, "Enable frame and|or depth buffer emulation.");
        }
        else
        {
            DebugMessage(M64MSG_VERBOSE, "Setting default config values.");
            /* Set default values for my Config parameters */
            (*ConfigSetDefaultString)(l_ConfigUI, "VideoPlugin", "mupen64plus-video-GLideN64" OSAL_DLL_EXTENSION, "Filename of video plugin");
            (*ConfigSetDefaultString)(l_ConfigUI, "AudioPlugin", "mupen64plus-audio-sdl" OSAL_DLL_EXTENSION, "Filename of audio plugin");
            (*ConfigSetDefaultString)(l_ConfigUI, "InputPlugin", "mupen64plus-input-sdltouch" OSAL_DLL_EXTENSION, "Filename of input plugin");
            (*ConfigSetDefaultString)(l_ConfigUI, "RspPlugin", "mupen64plus-rsp-hle" OSAL_DLL_EXTENSION, "Filename of RSP plugin");

            (*ConfigSetDefaultInt)(l_ConfigVideo, "Rotate", 3, "Rotate screen contents: 0=0 degree, 1=90 degree, 2 = 180 degree, 3=270 degree");

            (*ConfigSetDefaultInt)(l_ConfigVideoGlide64mk2, "aspect", 2, "Aspect ratio: -1=Game default, 0=Force 4:3, 1=Force 16:9, 2=Stretch, 3=Original");
            (*ConfigSetDefaultBool)(l_ConfigVideoGlide64mk2, "force_polygon_offset", 1, "If true, use polygon offset values specified below");
            (*ConfigSetDefaultBool)(l_ConfigVideoGlide64mk2, "polygon_offset_factor", -0.25, "Specifies a scale factor that is used to create a variable depth offset for each polygon");
            (*ConfigSetDefaultBool)(l_ConfigVideoGlide64mk2, "polygon_offset_units", -0.25, "Is multiplied by an implementation-specific value to create a constant depth offset");

	    (*ConfigSetDefaultBool)(l_ConfigVideoGLideN64, "EnableFBEmulation", 0, "Enable frame and|or depth buffer emulation.");
            (*ConfigSetDefaultBool)(l_ConfigVideoGLideN64, "EnableLegacyBlending", 1, "Do not use shaders to emulate N64 blending modes. Works faster on slow GPU. Can cause glitches.");
            (*ConfigSetDefaultInt)(l_ConfigVideoGLideN64, "AspectRatio", 0, "Screen aspect ratio (0=stretch, 1=force 4:3, 2=force 16:9, 3=adjust)");

            (*ConfigSetDefaultBool)(l_ConfigVideoGLideN64, "EnableFBEmulation", 0, "Enable frame and|or depth buffer emulation.");
        }

        if(product_id != NULL) free(product_id);
    }
    else
    {
        (*ConfigSetDefaultString)(l_ConfigUI, "VideoPlugin", "mupen64plus-video-rice" OSAL_DLL_EXTENSION, "Filename of video plugin");
        (*ConfigSetDefaultString)(l_ConfigUI, "AudioPlugin", "mupen64plus-audio-sdl" OSAL_DLL_EXTENSION, "Filename of audio plugin");
        (*ConfigSetDefaultString)(l_ConfigUI, "InputPlugin", "mupen64plus-input-sdltouch" OSAL_DLL_EXTENSION, "Filename of input plugin");
        (*ConfigSetDefaultString)(l_ConfigUI, "RspPlugin", "mupen64plus-rsp-hle" OSAL_DLL_EXTENSION, "Filename of RSP plugin");
    }

    if (bSaveConfig && ConfigSaveSection != NULL) /* ConfigSaveSection was added in Config API v2.1.0 */
        (*ConfigSaveSection)("UI-Console");

    return M64ERR_SUCCESS;
}