uwpc++-cx

C++ UWP Implementation


So I have been working on a racing game, so I would like to add steering wheel support. I'm using UWP(here is the page). I have added the code to appxmanifest like Microsoft says you should do, but I still get error messages. Here is the code:

Input.cpp

#include "pch.h"
#include "Input.h"
#include <vector>
#include <Windows.h>
#include <windows.gaming.input.h>
#include <windows.gaming.input.custom.h>
#include <windows.gaming.input.forcefeedback.h>

Input::Input()
{

}

bool Input::Detect()
{
    Windows::Gaming::Input::RacingWheel RacingWheel;

    auto Wheels = ref new Vector<RacingWheel^>();

    for (auto racingwheel : RacingWheel::RacingWheels)
    {
        Wheels->Append(racingwheel);
    }
};

Input.h

#pragma once
#include <windows.gaming.input.h>
#include <windows.gaming.input.custom.h>
#include <windows.gaming.input.forcefeedback.h>

ref class Input sealed
{
public:
    Input();
    bool Detect();

private:
    void Acquire();

};

The errors are as follows:

RacingWheel::RacingWheels

-Name followed by :: must be a class or namespace

Vector<RacingWheel^>

-expected type identifier

-expected an expression

I'm new to C++ so any help is appreciated.


Solution

  • You are mixing C++/Cx and regular C++. If you are writing in C++ you can not use ref and ^ syntax and should use regular COM instead, if you are writing in C++/Cx you don't need to include UWP headers such as #include <windows.gaming.input.h> but need to compile as C++/Cx by creating appropriate kind of VS project.

    Also you need to make sure that you are targeting Windows 10 Anniversary Edition (10.0.14393) so Wheel is awailable.