From: is05562 AT salleURL DOT edu Newsgroups: comp.os.msdos.djgpp Subject: keyboard handler... Date: 1 Feb 1999 10:13:57 GMT Organization: CESCA News service. Catalunya Lines: 80 Message-ID: <793up5$hkr$1@pedraforca.cesca.es> NNTP-Posting-Host: cygnus.salleurl.edu Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com /*************************************************************************** Hello... I've been coding some stuff with djgpp, and I've been using the "whole" allegro only for the keyboard handler. But I think that if I wrote my own keyboard handler the application I'm coding would be faster, so I decided to code it on my own. Then I started to read DJGPP FAQ's, specially interrupt handlers section. Everything seemed "easy"... But NO! because my code hangs my PC when I restore the old RSI handler... And I don't know what I'm doing wrong... So I've decided to ask for help here in the news group. I've tried MANY things before asking for help (like adding the *_chain_* function, and/or some other go32 functions), but my program gets hanged in the very same place all the time... I know I "should" lock some code/data, but as this C example should not swap to disk, I'm still not doing it. I'm including the little C example I'm trying to code, to see if someone can see what I'm doing not OK. Please, if you see the error, correct the example and resend it to the news group and/or send it to me via mail. BTW also: What's an "iret_wrapper", and "why" should I need one ? Is it mandatory? In my case (coding an easy keyboard handler), may it be needed ? OK then... thanks in advance... Isaac Santaolalla is05562 AT salleURL DOT edu ***************************************************************************/ #include #include #include #include #include #define KEYBOARD 0x09 static _go32_dpmi_seginfo dpmi_info_old_keyboard,dpmi_info_new_keyboard; unsigned int leave=0; static void my_keyboard_rsi(void){ asm("cli"); leave=1; outportb(0x20,0x20); asm("sti"); } int main(int argc,char* argv[]){ printf("Changing keyboard RSI...\n"); dpmi_info_new_keyboard.pm_offset = (unsigned int)my_keyboard_rsi; dpmi_info_new_keyboard.pm_selector = _my_cs(); _go32_dpmi_allocate_iret_wrapper(&dpmi_info_new_keyboard); _go32_dpmi_get_protected_mode_interrupt_vector(KEYBOARD, &dpmi_info_old_keyboard); _go32_dpmi_set_protected_mode_interrupt_vector(KEYBOARD, &dpmi_info_new_keyboard); while(!leave){ printf("a"); fflush(stdout); delay(100); } _go32_dpmi_set_protected_mode_interrupt_vector(KEYBOARD, &dpmi_info_old_keyboard); printf("Restoring the old keyboard RSI\n"); // apparently here, the old keyboard RSI has NOT been restored... // Because the return 0 is correctly executed, and the dos prompt appears // But the keyboard doesn't respond... :( return 0; }