Category : C Source Code
Archive   : JJBQC.ZIP
Filename : JJBKBD.H

 
Output of file : JJBKBD.H contained in archive : JJBQC.ZIP



/****************************************************************************
* *
* jjbkbd.h *
* *
* Copyright (c) 1989, JJB. All rights reserved. *
* *
* Purpose: *
* *
* The purpose of this file is to make definitions for the keyboard *
* and to explain to you how important the get_ch() function is *
* and why it is considered to be at the heart of the entire JJB *
* programming environment. *
* *
* *
* JJB, 9236 church Rd suite 1082, Dallas, Tx 75231 (214) 341-1635 *
****************************************************************************/

#ifndef BL

#define BL 32
#define RET '\015'
#define AST '\052'
#define ESC '\033'
#define BSPC '\010'

/****************************************************************************
* *
* get_ch() get_num() get_any(); *
* *
* If you have the printed documentation of JJB, you can see how there are *
* 5 low level functions you can use below the function get_ch() and 3 *
* higher level functions above it which give you absolute control over *
* keyboard. *
* *
* The printed documentation also explains how you can define a string *
* of characters which get_ch() will read thinking it is coming from *
* the keyboard instead of from the user of your program. *
* *
* char get_ch(); wait for alphanumberic or function keypress *
* char get_num(); wait for numeric or function keypress *
* char get_any(); wait for any key to be pressed *
* *
****************************************************************************/

#define SPACEBAR_PRESSED (get(IKE) == 32)
#define ESC_PRESSED (getc(KE) == ESC)
#define F1_PRESSED (!get(IKE) && get(IKEE) == 59)
#define F9_PRESSED (!get(IKE) && get(IKEE) == 68)
#define ALT_PRESSED (get(IKCODE) & 8)
#define RET_PRESSED (getc(KE) == RET)
#define REMOVE_PRESSED (getc(KE) == getc(REMOVE) )
#define BSPC_PRESSED (getc(KE) == BSPC)
#define LEFTSHIFT_PRESSED (get(IKCODE) & 1)
#define RIGHTSHIFT_PRESSED (get(IKCODE) & 2)
#define SHIFT_PRESSED (get(IKCODE) & 3)
#define CTRL_PRESSED (get(IKCODE) & 4)
#define SCROLLLOCK_ACTIVE (get(IKCODE) & 16)
#define NUMLOCK_ACTIVE (get(IKCODE) & 32)
#define CAPS_ACTIVE (get(IKCODE) & 64)
#define INSERT_ACTIVE (get(IKCODE) & 128)

#define LEFTARROW_PRESSED (!get(IKE) && get(IKEE) == 75)
#define RIGHTARROW_PRESSED (!get(IKE) && get(IKEE) == 77)
#define UPARROW_PRESSED (!get(IKE) && get(IKEE) == 72)
#define DOWNARROW_PRESSED (!get(IKE) && get(IKEE) == 80)

#define PGUP_PRESSED (!get(IKE) && get(IKEE) == 73)
#define PGDN_PRESSED (!get(IKE) && get(IKEE) == 81)
#define HOME_PRESSED (!get(IKE) && get(IKEE) == 71)
#define END_PRESSED (!get(IKE) && get(IKEE) == 79)
#define CTRLG_PRESSED (get(IKE) == 7) /* videos grid for testing */
#define FUNCT_PRESSED (!get(IKE) && between(get(IKEE),59,72))


/****************************************************************************
* *
* keyboard *
* *
* Most C programmers are used to 'ch = getch();' *
* *
* In JJB, just use: 'get_ch();' *
* 'get_num();' *
* 'get_any();' *
* *
****************************************************************************/




/****************************************************************************
* *
* get_ch() *
* *
* Use get_ch() instead of getch(). *
* The reason you must use get_ch() is because JJB needs to look at every *
* keypress to see if ALT has been pressed for changing options. *
* *
* also, JJB is designed to execute get_ch() without expecting *
* a return value. Everytime you use get_ch(), JJB does a BIOS *
* read, updating four characters: KE, KEE, KEU & KCODE and four *
* integers: IKE, IKEE, IKEU, and IKCODE. These values are *
* stored in arrays and are accessible from any object module *
* with the 'get(' and 'set(' functions described in 'JJBSET.H'. *
* *
* Here is an example of how to use: *
* *
* get_ch(); *
* *
* if (ESC_PRESSED) do_something(); *
* *
* Everytime you use get_ch(), JJB sets in arrays: *
* KE is the character of the key you pressed. *
* KEU is KE taken to upper case. *
* IKE is the integer of KE. If 'a' is pressed, IKE would be 97. *
* IKEU is the integer of KEU. If 'a' is pressed, IKEU would be 65 *
* KEE if KE = '\0', then KEE holds the value of the special key. *
* IKEE is the integer value of KEE. *
* KCODE is the keyboard scan code. *
* IKCODE is the keyboard scan code taken to an integer value. *
* *
* You may still use 'ch = get_ch()', but it is no longer necessary *
* because JJB handles everything for you. The JJB input and enter *
* functions are designed to be high level functions not requiring *
* low level testing of keypresses. JJB does that for you. *
* *
* There are pluses for you all throughout the JJB system. One of them is *
* that at any time, you can press 'CONTROL G' and a grid will be *
* displayed on the screen. You can use the row and column numbers for *
* placing the cursor or videoing text to the screen. *
* *
* 'get_num()' is the same as get_ch()' except that JJB will only allow *
* you to press a number. *
* *
* 'get_any() will wait for any key to be pressed. *
* *
****************************************************************************/


/* miscellaneous definitions */

#define T 1 /* T for true */
#define beep printf("\a")
#define kk getch() /* JJB uses this only for debugging only */
#define BEGIN while(1) { /* BEGIN....AGAIN is an easy way to see */
#define AGAIN } /* continuous loops */
#define DRAWLINE 99 /* use in jjb_setup() to separate options */

#endif





  3 Responses to “Category : C Source Code
Archive   : JJBQC.ZIP
Filename : JJBKBD.H

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/