|
|
#include <scancode.h>int sc_init (filedes) int filedes;
int sc_exit ()
int sc_mapinit (filedes) int filedes;
ulong *sc_getkbmap ()
void sc_receive_kb (scancode) scancode_t scancode;
keymap_t *sc_getkeymap ()
void sc_setkeymap (keymap_ptr) keymap_t *keymap_ptr;
char *sc_getfkeystr (keyno) int keyno;
int sc_setfkeystr (keyno, string) int keyno; char *string;
char sc_getled ()
int sc_setled (value) char value;
sc_init takes a file descriptor parameter and initializes the tty software to accept scancode input. It performs the following steps:
sc_exit restores the terminal mode and tty settings that sc_init saves. Do not call sc_exit if you did not use sc_init to initialize scancode mode. sc_exit performs the following steps:
sc_mapinit takes a file descriptor as a parameter and initializes the maps used by the input/output mapping functions. It reads the keymap and mapchan tables into local data structures, constructs the mapcode-to-scancode table used by sc_str2kb(S), and initializes the function key table. sc_mapinit provides a lower level initialization interface than sc_init. If the application itself sets tty modes, it should call sc_mapinit instead of sc_init. The application can only use one of these two functions. It does not need to call either function to simply read scancodes or mapcodes or to translate scancodes to mapcodes. However, if the desired end result is ASCII data, or if the application wants the API to do screen switching, the application must call one of these routines.
sc_getkbmap returns a pointer to sc_bitmap, which contains the make/break state of all the keys on the keyboard. The sc_kb2mapcode(S) and sc_receive_kb(S) functions maintain this map and they are called by sc_readkb(S), sc_readmapcode(S) and sc_readstr(S). If the ``read'' functions have not read all the characters in the input buffer, sc_bitmap will not accurately reflect the current state of the keyboard.
sc_receive_kb parses an input scancode to maintain the internal state of the <Shift>, <Ctrl>, <Alt>, and <Lock> keys. It also performs screen switching (on the console only). sc_receive_kb returns a scancode that is usually the same as its input parameter. The application needs to call sc_receive_kb only if it reads scancodes on its own and does not want any other translation performed but does want screen switching to occur. If the application uses any other input or translation routines (such as sc_readkb(S) or sc_kb2mapcode(S)) it should not call sc_receive_kb.
sc_getkeymap returns the current active keymap table in the API. sc_setkeymap takes a pointer to a keymap structure as a parameter and sets the current active keymap table in the API.
sc_getfkeystr returns a pointer to the character string associated with the function key specified by the input parameter. A parameter of 1 returns <F1>, and so on. sc_setfkeystr sets the character string of the function key associated with the input parameter. A parameter of 1 causes <F1> to be set, and so on.
sc_getled gets the current keyboard LED state. sc_setled sets the keyboard LED state. These functions only work if the application is running on the console. The LED state is defined as follows:
#define LED_CLK 0x01 /* caps lock on */ #define LED_NLK 0x02 /* num lock on */ #define LED_SLK 0x04 /* scroll lock on */
If an API function returns failure status, the global variable sc_error might contain a number corresponding to an error condition listed in scancode.h.
sc_init(S) and sc_mapinit(S) affect only one terminal at a time, and the application using the API affects only the terminal specified for sc_init(S) or sc_mapinit(S).
sc_getkeymap does not return the keymap table stored in the kernel.