【问题标题】:KeyDown latency C++ UWP Windows 10 Direct3D 12 ApplicationKeyDown 延迟 C++ UWP Windows 10 Direct3D 12 应用程序
【发布时间】:2016-07-11 20:24:15
【问题描述】:

我的问题是,在 KeyDown 上,几乎有一秒钟的延迟,直到所有事件队列开始被处理,请参阅video demo here。其次,不会处理并行键,我可以选择 W、S 或其他,但不能同时使用。

我已经尝试过异步运行 Render() 并使用 ProcessUntiLQuit ,改变我读取输入的方式等...

我目前在经典的Run(while not closed) 循环中使用ProcessAllIfPresent

在我的 IFrameworkView 实例应用程序中,以下是我的 KeyDown 处理程序:

void OnKeyDown(CoreWindow^ wnd, KeyEventArgs^ args) {
    for(int i = 0; i < g_MainApplication->InputMap().size(); ++i) {
        if(g_MainApplication->InputMap()[i] == args->VirtualKey) {
            g_MainApplication->FlagInput((Application::INPUT_MAP)i);
        }
    }
}

总共只有 K 个映射键,因此它运行在恒定时间。这会设置所有标志并将其传递给应用程序,应用程序只需调用“UpdatePosition”方法直接修改值:

void MyApp::ProcessKeyboard(INPUT_MAP key, double delta) {
    delta *= g_SpeedModifier;
    switch(key) {
    case FORWARD: 
        g_SelectedEntity->Translate(DIRECTION::WORLD_FORWARD, static_cast<float>(delta));
        break;
... // more of the same code here.
}

应用程序以 60 FPS 的速度呈现。

感谢您的帮助。

【问题讨论】:

    标签: c++ input uwp direct3d12


    【解决方案1】:

    我刚试过

    CoreWindow::GetForCurrentThread()->GetAsyncKeyState(VirtualKey)
    

    ... 在一个连续的循环中。效果很好。

    【讨论】:

    猜你喜欢
    • 2015-11-08
    • 1970-01-01
    • 2018-10-10
    • 2018-10-31
    • 2016-08-02
    • 2015-01-23
    • 1970-01-01
    • 2018-07-06
    • 2018-08-31
    相关资源
    最近更新 更多