|
BB2 C port
API reference: Blitz libraries in C and the shared code
|
#include "blitzlib.h"#include "blitzexec.h"#include <exec/io.h>#include <exec/ports.h>#include <devices/inputevent.h>#include <proto/console.h>Macros | |
| #define | __NOLIBBASE__ |
Functions | |
| void | convertkey (void) |
| void | unconvert (void) |
| void | qconvertkey (void) |
| static ULONG | codeinit (void) |
| Library init: open console.device and fill the two tables. | |
| static void | codefinit (void) |
| Library finit: free the signal and close console.device. | |
| static ULONG | convertkey_c (ULONG key, ULONG qual) |
| convertkey (+1, for other libraries) - raw key code to a character through console.device. | |
| static ULONG | unconvert_c (ULONG ch) |
| unconvert (+2, for other libraries) - character to raw key code. | |
| static ULONG | qconvertkey_c (ULONG key, ULONG qual) |
| qconvertkey (+3, for other libraries) - raw key code to a character by table look-up (no console.device). | |
Variables | |
| struct { | |
| UBYTE normmap [105] | |
| UBYTE shiftmap [105] | |
| } | maps |
| struct { | |
| struct IOStdReq io | |
| struct MsgPort port | |
| } | con |
| static struct Library * | ConsoleDevice |
| static UWORD | buf |
| static struct InputEvent | event = { .ie_Class = IECLASS_RAWKEY } |
| ULONG | rawkey_d1 |
| #define __NOLIBBASE__ |
|
static |
Library finit: free the signal and close console.device.
|
static |
Library init: open console.device and fill the two tables.
Clears the IOStdReq and MsgPort, sets them up (signal from AllocSignal), opens console.device unit -1 and fills the tables for the raw codes 0-104 with convertkey(code, 0) and convertkey(code, 1) (shift). Neither the signal nor OpenDevice is checked.
| void convertkey | ( | void | ) |
|
static |
convertkey (+1, for other libraries) - raw key code to a character through console.device.
F1-F10 ($50-$59) -> 129-138, cursor keys ($4C-$4F) -> 28-31, Help ($5F) -> 139; everything else through RawKeyConvert (one character, keymap NULL, the qualifier as given; 0 if nothing comes, the buffer's first byte also on an error). The result is only in the low word of d0 (MOVE.w / ADDI.w): the upper word is the caller's (fixed codes) or the one of RawKeyConvert's result.
| key | d0: the raw key code (low word) |
| qual | d1: the qualifier |
| void qconvertkey | ( | void | ) |
|
static |
qconvertkey (+3, for other libraries) - raw key code to a character by table look-up (no console.device).
The normal table (qualifier & 3 = 0) or the shifted one; with CTRL (bit 3) A-Z/a-z -> 1-26 and the other characters 65-122 except 91-96 (AND #$FFDF:SUB #64: [ \ ] ^ _ and the backquote stay), else CAPS LOCK (bit 2) makes a-z upper case. Only the low word of d0 changes. A raw code (& 255) above 104 gives 0 (Fixed (#245): the original read behind the table, the shifted table or the library's own code).
| key | d0: the raw key code (low word) |
| qual | d1: the qualifier |
| void unconvert | ( | void | ) |
|
static |
unconvert (+2, for other libraries) - character to raw key code.
Looks through both tables in one run (normal, then shifted), so a character that exists in both gives the unshifted key.
| ch | d0.b: the character |
|
static |
| struct { ... } con |
|
static |
|
static |
| struct IOStdReq io |
| struct { ... } maps |
| UBYTE normmap[105] |
| struct MsgPort port | ( | void | ) |
| ULONG rawkey_d1 |
| UBYTE shiftmap[105] |