Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 用于MS DOS的GetAsyncKeyState()_C++_Dos_Borland C++ - Fatal编程技术网

C++ 用于MS DOS的GetAsyncKeyState()

C++ 用于MS DOS的GetAsyncKeyState(),c++,dos,borland-c++,C++,Dos,Borland C++,我为Windows制作了一个使用GetAsyncKeyState()的小游戏。现在我想为MS DOS编译这个游戏,但是我找不到任何替代的函数。getch()和kbhit()太慢,无法处理击键。 主要目标是以光速或至少以GetAsyncKeyState()的速度处理击键。 提前感谢.< /P> < P> Borland C++ MSDOS键盘处理示例代码 它使用conio.h、kbhit()和getch()。这应该可以编译 在MSDOS Borland C++中很好。 #include <s

我为Windows制作了一个使用GetAsyncKeyState()的小游戏。现在我想为MS DOS编译这个游戏,但是我找不到任何替代的函数。getch()和kbhit()太慢,无法处理击键。 主要目标是以光速或至少以GetAsyncKeyState()的速度处理击键。
提前感谢.< /P> < P> Borland C++ MSDOS键盘处理示例代码 它使用
conio.h
kbhit()
getch()
。这应该可以编译 在MSDOS Borland C++中很好。
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <dos.h>

#define TRUE 1
#define FALSE (!TRUE)
#define TEXTSCREEN 0xB800


#define esc    27
#define tab    9
#define up     72
#define down   80
#define left   75
#define right  77
#define home   71
#define cend   79
#define pgup   73
#define pgdn   81
#define ins    82
#define del    83
#define plus   43
#define subt   45
#define mult   42
#define devi   47
#define spc    32
#define f1     59
#define f2     60
#define f3     61
#define f4     62
#define f5     63
#define f6     64
#define f7     65
#define f8     66
#define f9     67
#define f10    68
#define ap     53
#define bksp   8
#define enter  13
#define crum   245


void key2(void);

int main(void)
{

    ch=0;
    while(ch!=esc)
    {

       key2(); 

     }

  return 0;
}


void key2(void)
{
  if (kbhit())
  {
    ch=getch();

    if (ch==f1)
    {

    }
    if (ch==f2)
    {

    }
    if (ch==f3)
    {

    }
    if (ch==f4)
    {


    }
    if (ch==f5)
    {


    }
    if (ch==f6)
    {


    }
    if (ch==f7)
    {


    }
    if (ch==f8)
    {


    }
    if (ch==f9)
    {

    }
    if (ch==f10)
    {


    }


    if (ch==tab)
    {

    }

    if (ch==ins)
    {

    }

    if (ch==del)
    {
    }

    if (ch==bksp)
    {



    }

    if (ch==enter)
    {


    }

    if (ch==spc)
    {

    }
    if (ch==49)
    {



    }
    if (ch==50)
    {



    }

    if (ch==up)
    {


    }

    if (ch==down)
    {


    }
    if (ch==home)
    {



    }
    if (ch==cend)
    {



    }
    if (ch==pgup)
    {



    }
    if (ch==pgdn)
    {



    }
  }
}
#包括
#包括
#包括
#包括
#定义真1
#定义FALSE(!TRUE)
#定义文本屏幕0xB800
#定义esc 27
#定义选项卡9
#定义最多72个
#下定义80
#定义左75
#定义权利77
#定义家庭71
#定义cend 79
#定义pgup 73
#定义pgdn 81
#定义INS82
#定义del83
#定义+43
#定义子项45
#定义MULT42
#定义devi 47
#定义spc 32
#定义f1 59
#定义F260
#定义f3 61
#定义f4 62
#定义f5 63
#定义f6 64
#定义F765
#定义f8 66
#定义f9 67
#定义F1068
#定义ap 53
#定义bksp 8
#定义并输入13
#定义crum 245
无效键2(无效);
内部主(空)
{
ch=0;
while(ch!=esc)
{
键2();
}
返回0;
}
无效键2(无效)
{
if(kbhit())
{
ch=getch();
如果(ch==f1)
{
}
如果(ch==f2)
{
}
if(ch==f3)
{
}
如果(ch==f4)
{
}
如果(ch==f5)
{
}
如果(ch==f6)
{
}
如果(ch==f7)
{
}
如果(ch==f8)
{
}
如果(ch==f9)
{
}
如果(ch==f10)
{
}
if(ch==tab)
{
}
if(ch==ins)
{
}
如果(ch==del)
{
}
如果(ch==bksp)
{
}
如果(ch==输入)
{
}
如果(ch==spc)
{
}
如果(ch==49)
{
}
如果(ch==50)
{
}
如果(ch==向上)
{
}
如果(ch==向下)
{
}
如果(ch==主)
{
}
如果(ch==cend)
{
}
如果(ch==pgup)
{
}
if(ch==pgdn)
{
}
}
}

谢谢你的回答!这似乎非常有用,但Borland C++,当我尝试编译这个程序时,CPP 130在信号(SIGINT,SIGIGIN)上说:“不能将‘无效’()”转换为“无效”(int),请你告诉我应该怎样做才能使这个程序运行?我想它是C语言的,这就是为什么我不能编译它。我该怎么办?再次感谢你的回答!您实际上是针对MS DOS,还是指作为Windows的一部分的控制台子系统?