2017-06-29 50 views
0

所以我一直在研究赛车游戏,所以我想添加方向盘支持。我正在使用UWP(here is the page)。我已经将代码添加到Microsoft的appxmanifest中,您应该这样做,但我仍然收到错误消息。下面是代码:C++ UWP执行

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(); 

}; 

是错误如下:接着

RacingWheel::RacingWheels 

-Name ::必须是类或名称空间

Vector<RacingWheel^> 

-expected类型标识符

-expected表达

我是新的C++,因此任何帮助表示赞赏。

+0

这不是C++。它是C++/CLI吗? – 2017-06-29 15:18:49

回答

2

你在混合使用C++/Cx和普通的C++。如果使用C++编写代码,则不能使用ref^语法,而应该使用常规COM代替,如果您使用C++/Cx编写代码,则不需要包含诸如#include <windows.gaming.input.h>之类的UWP头文件,但需要编译为C++/Cx创建适合的VS项目。

此外,您需要确保您的目标是Windows 10周年纪念版(10.0.14393),因此Wheel非常令人放心。