C 如何在dos中进行鼠标移动和左/右键单击

C 如何在dos中进行鼠标移动和左/右键单击,c,mouse,interrupt,dos,dosbox,C,Mouse,Interrupt,Dos,Dosbox,经过一些阅读,我了解到116处理器应该用于鼠标,在使用它之后,只有鼠标的左/右键点击工作,但当我移动鼠标时,中断不会发生。我怎样才能得到鼠标的移动? 以下是我迄今为止所做的工作: (顺便问一下,我应该称之为原始的116 ISR,还是它是可选的?) #包括 #包括 //将以毫秒为单位计算时间 易失性整数时间计数器=0; volatile int isPressed=0; void exitMode(); 无效中断(*Int116Save)(无效);/*指向组织ISR116的指针*/ 无效中断(*I

经过一些阅读,我了解到116处理器应该用于鼠标,在使用它之后,只有鼠标的左/右键点击工作,但当我移动鼠标时,中断不会发生。我怎样才能得到鼠标的移动? 以下是我迄今为止所做的工作: (顺便问一下,我应该称之为原始的116 ISR,还是它是可选的?)

#包括
#包括
//将以毫秒为单位计算时间
易失性整数时间计数器=0;
volatile int isPressed=0;
void exitMode();
无效中断(*Int116Save)(无效);/*指向组织ISR116的指针*/
无效中断(*Int8Save)(无效);/*指向组织ISR8的指针*/
void中断INT8_处理程序(void){
/*在编辑时钟之前,我们必须调用原始ISR8*/
/*呼叫原始ISR8*/
asm{
普希夫
调用DWORD PTR Int8Save;
} 
计时器++;
//计时器=20是1秒,所以1200是1分钟,2400是2分钟
如果(计时器>2400){
printf(“用户正在做梦,正在退出…”);
exitMode();
}
}/*结束INT8处理程序*/
void中断mouseMoved(void){
/*在侦听鼠标输入之前,我们始终必须调用原始ISR116*/
/*请致电原ISR116*/
asm{
普希夫
调用DWORD PTR Int116Save
}
isPressed++;
printf(“\n使用移动\单击…\n”);
}
/*如果用户在做梦2分钟,我们通过时钟处理器来到这里并退出*/
void exitMode()
{
printf(“\nC:终止…\n”);
setvect(8,Int8Save);/*返回组织ISR8*/
setvect(116,Int116Save);/*返回组织ISR116*/
出口(0);
}
void main(){
printf(“请移动/单击鼠标。\n”);
//老鼠
Int116Save=getvect(116);
setvect(116,鼠标移动);
//钟
Int8Save=getvect(8);
setvect(8,INT8_处理器);
//

while(isPressedWhat是“116处理程序”?我不熟悉您正在使用的C库。这是否等同于汇编中的
int116h
?通常,DOS鼠标中断是
int33h
,但这取决于您安装的驱动程序。@CodyGray是的。关于int33h,我会检查并尽快更新。(我在网上找不到任何关于中断116h的点击率。你确定你不是指16h吗?)好的,谢谢,我相信他们只是指点击鼠标。移动鼠标的中断太多了。谢谢Cody!@CodyGrayNote,你没有钩住中断33h。它不像计时器中断那样是硬件中断(INT 8)INT 33h是一个API,您可以使用各种参数调用它来执行各种与鼠标相关的操作。其中一个操作是安装回调处理程序INT 33h,AX=0Ch。什么是“116处理程序”?我不熟悉您正在使用的C库。这相当于汇编中的
int116h
?通常,DOS鼠标中断是
int33h
,但这取决于您安装的驱动程序。@CodyGray是的。关于int33h,我会尽快检查并更新。(我在网上找不到任何关于中断116h的点击率。你确定你不是指16h吗?)好的,谢谢,我相信他们只是指点击鼠标。移动鼠标的中断太多了。谢谢Cody!@CodyGrayNote,你没有钩住中断33h。它不像计时器中断那样是硬件中断(INT 8)INT 33h是一个API,您可以使用各种参数调用它来执行各种与鼠标相关的操作。其中一个操作是安装回调处理程序INT 33h,AX=0Ch。
#include<stdio.h>
#include<dos.h>

//Will count in milliseconds the time
volatile int timeCounter = 0;
volatile int isPressed = 0;
void exitMode();
void interrupt (*Int116Save)(void);/* Pointer to org ISR116*/
void interrupt (*Int8Save) (void); /* Pointer to org ISR8*/

void interrupt INT8_Handler(void) {
/*We always have to call the original ISR8 before editing the clock*/
/* Call original ISR8 */
    asm{
    PUSHF
    CALL DWORD PTR Int8Save;
    } 
timeCounter++;
//timeCounter = 20 is 1 second, so 1200 is 1 minute, 2400 is 2 minutes
if(timeCounter > 2400){
    printf("User is dreaming, exiting...");
    exitMode();
}
} /* END INT8 Handler */

void interrupt mouseMoved(void){
    /*We always have to call the original ISR116 before listening for a mouse input*/
    /* Call original ISR116 */
     asm{
        PUSHF
        CALL DWORD PTR Int116Save
        }
        isPressed++;
        printf("\nMouse moved\clicked...\n");
}

/*If user is dreaming for 2 minutes, we come here through the clock's handler and exit*/
void exitMode()
{
        printf("\nC: Terminating...\n");
        setvect(8, Int8Save ); /*return org ISR8*/
        setvect(116, Int116Save);/*return org ISR116*/
        exit(0);
}

void main(){
    printf("Please move/click the mouse. \n");

    //Mouse
    Int116Save=getvect(116);
    setvect(116, mouseMoved);


    //Clock
    Int8Save=getvect(8);
    setvect(8, INT8_Handler);

    //
    while(isPressed<100);

    //End the program and return the vect's as needed.
        printf("\nC: Terminating...\n");
        setvect(8, Int8Save ); /*return org ISR8*/
        setvect(116, Int116Save); /*return org ISR116*/

}