1 /*********************************************************** 2 * K O U L E S * 3 *----------------------------------------------------------* 4 * C1995 JAHUSOFT * 5 * Jan Hubicka * 6 * Dukelskych Bojovniku 1944 * 7 * 390 03 Tabor * 8 * Czech Republic * 9 * Phone: 0041-361-32613 * 10 * eMail: hubicka@limax.paru.cas.cz * 11 *----------------------------------------------------------* 12 * Copyright(c)1995,1996 by Jan Hubicka.See README for * 13 * licence details. * 14 *----------------------------------------------------------* 15 * interface.h interface for vgakeyboard * 16 ***********************************************************/ 17 /* Changes: joystick A button included into buttons * 18 * for which function "Pressed()" returns 1 * 19 * (c) 1997 by Ludvik Tesar (Ludv\'{\i}k Tesa\v{r}) * 20 ************************LT*********************************/ 21 #include <vga.h> 22 #include <vgagl.h> 23 #include <vgakeyboard.h> 24 #include <vgamouse.h> 25 #ifdef JOYSTICK 26 extern int joystickdevice[2]; 27 #endif 28 29 #define SCANCODE_P 25 30 31 #define IsPressed(scancode) keyboard_keypressed(scancode) 32 #ifdef MOUSE 33 #define UpdateInput() keyboard_update (),(!nomouse?mouse_update ():0) 34 #define MouseButtons() (!nomouse?mouse_getbutton():0) 35 #define MouseX() (!nomouse?mouse_getx():0) 36 #define MouseY() (!nomouse?mouse_gety():0) 37 #else 38 #define UpdateInput() keyboard_update () 39 #define MouseButtons() DUMMY 40 #define MouseX() DUMMY 41 #define MouseY() DUMMY 42 #endif 43 44 /*here is probably bug.... 45 some users reported that these functions not work... 46 probably sometimes some keys are reported as pressed */ 47 extern inline int Pressed()48Pressed () 49 { 50 int z; 51 #ifdef JOYSTICK 52 int status; 53 struct JS_DATA_TYPE js; 54 if(joystickdevice[0]>=0) 55 { 56 status = read (joystickdevice[0], &js, JS_RETURN); 57 if ((status == JS_RETURN)&&js.buttons)return 1; 58 } 59 #endif 60 #ifdef MOUSE 61 if (!nomouse && MouseButtons ()) 62 return (1); 63 #endif 64 for (z = 0; z < 128; z++) 65 if (keyboard_keypressed (z)) 66 { 67 return 1; 68 } 69 return (0); 70 } 71 extern inline int GetKey()72GetKey () 73 { 74 int z, k = 0; 75 #ifdef MOUSE 76 if (!nomouse && MouseButtons ()) 77 return (1); 78 #endif 79 for (z = 0; z < 128; z++) 80 if (keyboard_keypressed (z)) 81 { 82 if (k) 83 return (0); 84 k = z; 85 } 86 return (k); 87 } 88 #define IsPressedEsc() IsPressed (SCANCODE_ESCAPE) 89 90 #define IsPressedP() IsPressed (SCANCODE_P) 91 #define IsPressedH() IsPressed (35) 92 93 #define IsPressedEnter() (IsPressed (SCANCODE_ENTER)||\ 94 IsPressed (SCANCODE_SPACE)||\ 95 IsPressed (SCANCODE_KEYPADENTER)) 96 97 #define IsPressedUp() (IsPressed (SCANCODE_CURSORUP) ||\ 98 IsPressed (SCANCODE_CURSORBLOCKUP)) 99 100 #define IsPressedDown() (IsPressed (SCANCODE_CURSORDOWN) ||\ 101 IsPressed (SCANCODE_CURSORBLOCKDOWN)) 102 #define IsPressedLeft() (IsPressed (SCANCODE_CURSORLEFT) ||\ 103 IsPressed (SCANCODE_CURSORBLOCKLEFT)) 104 105 #define IsPressedRight() (IsPressed (SCANCODE_CURSORRIGHT) ||\ 106 IsPressed (SCANCODE_CURSORBLOCKRIGHT)) 107