如何配置 Qt - DirectX - Xinput.h

发布于 2024-12-28 21:34:00 字数 1920 浏览 0 评论 0原文

我对 C++ 编程和 Qt 比较陌生,所以这个问题可能是我对相互依赖性的误解。我正在尝试在源代码中使用 Xinput.h 文件,该文件是带有 Qt 创建者的 DirectX SDK 的一部分。 我的解决方案有工作源代码,可以在 Visual Studio 2008 中正常编译和执行,但是当我在 Qt 中使用它时,不会出现头文件丢失之类的情况。我尝试使用内置的库加法器导入 XInput.dll

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x64/ -lXInput
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x64/ -lXInputd
else:symbian: LIBS += -lXInput
else:unix: LIBS += -L$$PWD/../../../../../Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x64/ -lXInput

INCLUDEPATH += $$PWD/../../../../../Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x64
DEPENDPATH += $$PWD/../../../../../Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x64

但是,这无法编译,因为我没有在此范围内声明“_in”,有谁知道我如何解决这个问题?

_in 和 _out 错误来自 Direct X SDK 中包含的 Xinput.h 头文件。

DWORD WINAPI XInputGetState
(
    __in  DWORD         dwUserIndex,  // Index of the gamer associated with the device
    __out XINPUT_STATE* pState        // Receives the current state
);

我想我应该为任何不确定发生了什么的人提供一个演示:

来自 QT 的 .Pro 文件:

QT += core

QT       -= gui

TARGET = testxbox
CONFIG   += console
CONFIG   -= app_bundle

TEMPLATE = app


SOURCES += main.cpp

   INCLUDEPATH += "...path to include file.../Include"

win32: LIBS += -L$$PWD/../../../Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Lib/ -lXinput

INCLUDEPATH += $$PWD/../../../Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Lib
DEPENDPATH += $$PWD/../../../Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Lib

然后我只是尝试将 Xinput.h 包含在我的源文件中,然后我收到了大量可怕的消息。 Windows VS 2008 就让我做

#include <windows.h>
#include <XInput.h>
#pragma comment(lib, "XInput.lib")

,它就能工作吗?

I'm relatively new to C++ programming and Qt so this issue is probably my miss understanding of codependency. I'm trying to use the Xinput.h file within my source code, which is part of the DirectX SDK with Qt creator.
I have working source code for my solution that compiles and executes fine within Visual Studio 2008 however when I come to use it within Qt no such like as the header file is missing. I have tried to import the XInput.dll using the inbuilt libary adder

win32:CONFIG(release, debug|release): LIBS += -L$PWD/../../../../../Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x64/ -lXInput
else:win32:CONFIG(debug, debug|release): LIBS += -L$PWD/../../../../../Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x64/ -lXInputd
else:symbian: LIBS += -lXInput
else:unix: LIBS += -L$PWD/../../../../../Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x64/ -lXInput

INCLUDEPATH += $PWD/../../../../../Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x64
DEPENDPATH += $PWD/../../../../../Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x64

However this fails to compile giving me '_in' was not declared in this scope, does any one know how i might fix this?

The _in and _out errors come from the Xinput.h header file included in the Direct X SDK.

DWORD WINAPI XInputGetState
(
    __in  DWORD         dwUserIndex,  // Index of the gamer associated with the device
    __out XINPUT_STATE* pState        // Receives the current state
);

I thought i would include a demo for anyone unsure of what is happening:

The .Pro file from QT:

QT += core

QT       -= gui

TARGET = testxbox
CONFIG   += console
CONFIG   -= app_bundle

TEMPLATE = app


SOURCES += main.cpp

   INCLUDEPATH += "...path to include file.../Include"

win32: LIBS += -L$PWD/../../../Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Lib/ -lXinput

INCLUDEPATH += $PWD/../../../Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Lib
DEPENDPATH += $PWD/../../../Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Lib

Then i just try to include the Xinput.h in my source files, and i get loads of horrendous messages. Windows VS 2008 just let's me do

#include <windows.h>
#include <XInput.h>
#pragma comment(lib, "XInput.lib")

and it works?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吻泪 2025-01-04 21:34:00

我已将 xinput.lib 放入项目文件夹中,并将此行添加到 .pro 文件中:

win32: LIBS += -lXInput

当然,还在代码中添加了 #include 。

它起作用了。

I've put xinput.lib in my project folder and added this line to a .pro file:

win32: LIBS += -lXInput

And of course added #include in the code.

It worked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文