示例#1
0
Wrappers::HString GetAppDataPath() {
    Wrappers::HString toReturn;
    ComPtr<IStorageFolder> folder;
    ComPtr<IApplicationDataStatics> applicationDataStatics;
    ComPtr<IApplicationData> applicationData;
    ComPtr<IStorageItem> storageItem;

    if (FAILED(GetActivationFactory(Wrappers::HStringReference(RuntimeClass_Windows_Storage_ApplicationData).Get(),
                                    &applicationDataStatics))) {
        return toReturn;
    }

    if (FAILED(applicationDataStatics->get_Current(&applicationData))) {
        return toReturn;
    }

    if (FAILED(applicationData->get_LocalFolder(&folder))) {
        return toReturn;
    }

    if (FAILED(folder.As<IStorageItem>(&storageItem))) {
        return toReturn;
    }

    if (FAILED(storageItem->get_Path(toReturn.GetAddressOf()))) {
        return toReturn;
    }

    return toReturn;
}
示例#2
0
    void GetCapabilities( int player, _Out_ Capabilities& caps )
    {
        using namespace Microsoft::WRL;
        using namespace ABI::Windows::Xbox::Input;

        if ( WaitForSingleObjectEx( mChanged.get(), 0, FALSE ) == WAIT_OBJECT_0 )
        {
            ScanGamePads();
        }

        if ( ( player >= 0 ) && ( player < MAX_PLAYER_COUNT ) )
        {
            if ( mGamePad[ player ] )
            {
                caps.connected = true;
                caps.gamepadType = Capabilities::UNKNOWN;

                ComPtr<IController> ctrl;
                HRESULT hr = mGamePad[ player ].As( &ctrl );
                if ( SUCCEEDED(hr) && ctrl )
                {
                    hr = ctrl->get_Id( &caps.id );
                    if ( FAILED(hr) )
                        caps.id = 0;

                    Wrappers::HString str;
                    hr = ctrl->get_Type(str.GetAddressOf());
                    if ( SUCCEEDED(hr) )
                    {
                        const wchar_t* typeStr = str.GetRawBuffer(nullptr);
                        if ( _wcsicmp(typeStr, L"Windows.Xbox.Input.Gamepad") == 0 )
                        {
                            caps.gamepadType = Capabilities::GAMEPAD;
                        }
                        else if ( _wcsicmp(typeStr, L"Microsoft.Xbox.Input.ArcadeStick") == 0 )
                        {
                            caps.gamepadType = Capabilities::ARCADE_STICK;
                        }
                        else if ( _wcsicmp(typeStr, L"Microsoft.Xbox.Input.Wheel") == 0 )
                        {
                            caps.gamepadType = Capabilities::WHEEL;
                        }
                    }
                }
                else
                    caps.id = 0;
                
                return;
            }
        }

        memset( &caps, 0, sizeof(Capabilities) );
    }
示例#3
0
    void GetCapabilities( int player, _Out_ Capabilities& caps )
    {
        using namespace Microsoft::WRL;
        using namespace ABI::Windows::System;
        using namespace ABI::Windows::Gaming::Input;

        if ( WaitForSingleObjectEx( mChanged.get(), 0, FALSE ) == WAIT_OBJECT_0 )
        {
            ScanGamePads();
        }

        if ( ( player >= 0 ) && ( player < MAX_PLAYER_COUNT ) )
        {
            if ( mGamePad[ player ] )
            {
                caps.connected = true;
                caps.gamepadType = Capabilities::GAMEPAD;
                caps.id.clear();

                ComPtr<IGameController> ctrl;
                HRESULT hr = mGamePad[player].As(&ctrl);
                if (SUCCEEDED(hr) && ctrl)
                {
                    ComPtr<IUser> user;
                    hr = ctrl->get_User(user.GetAddressOf());
                    if (SUCCEEDED(hr))
                    {
                        Wrappers::HString str;
                        hr = user->get_NonRoamableId(str.GetAddressOf());
                        if (SUCCEEDED(hr))
                        {
                            caps.id = str.GetRawBuffer(nullptr);
                        }
                    }
                }
                return;
            }
        }

        caps.id.clear();
        caps = {};
    }