zoukankan      html  css  js  c++  java
  • input

    #include<dinput.h>

    LPDIRECTINPUT8 directInput_;
    LPDIRECTINPUTDEVICE8 keyboardDevice_;
    char keyboardKeys_[256];
    char prevKeyboardKeys_[256];

    ///////////////////////Init//////////////////////
    ZeroMemory(keyboardKeys_,sizeof(keyboardKeys_));
    ZeroMemory(prevKeyboardKeys_,sizeof(prevKeyboardKeys_));

    HRESULT result = DirectInput8Create(hInstance_,DIRECTINPUT_VERSION,IID_IDirecctInput8,(void**)&directInput_,0);

    if(FAILED(result)) return false;

    result = directInput_->CreateDevice(GUID_SysKeyboard,&keyboardDevice_,0);

    if(FAILED(result)) return false;

    result = keyboardDevice_->SetDataFormat(&c_dfDKeyboard);
    if(FAILED(result)) return false;

    result = keyboardDevice_->SetCooperativeLevel(hsnd_,DISCL_FOREGROUND | DISCL_NONECXLUSIVE);
    if(FAILED(result)) return false;

    result = keyboardDevice_->Acquire();
    if(FAILED(result)) return false;


    /////////////////////Update/////////////////////////

    keyboardDevice_->GetDeviceState(sizeof(keyboardKeys_),(LPVOID)&keyboardKeys_);

    if(GetAsyncKeyState(VK_ESCAPE)) PostQuitMessage(0);

    if((prevKeyboardKeys_[DIK_DOWN)&0x80) && (keyboardKeys_[DIK_DOWN)&0x80))
    {
    }

    memcpy( prevKeyboardKeys_, keyboardKeys_, sizeof( keyboardKeys_ ) );

    作者:长风 Email:844064492@qq.com QQ群:607717453 Git:https://github.com/zhaohu19910409Dz 开源项目:https://github.com/OriginMEK/MEK 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利. 感谢您的阅读。如果觉得有用的就请各位大神高抬贵手“推荐一下”吧!你的精神支持是博主强大的写作动力。 如果觉得我的博客有意思,欢迎点击首页左上角的“+加关注”按钮关注我!
  • 相关阅读:
    匹配session
    Jdk1.8+Eclipse+MySql+Tomcat开发Java应用的环境搭建
    MySQL忘记密码怎么办
    MyBatis框架Maven资源
    MyBatis核心配置文件模版
    MyBatis执行过程显示SQL语句的log4j配置
    MyBatis实体类映射文件模板
    Mybatis 学习-4
    Spring Boot + Swagger
    Spring Boot + Swagger
  • 原文地址:https://www.cnblogs.com/zhaohu/p/6995058.html
Copyright © 2011-2022 走看看