BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
rawkeylib.c File Reference
#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

Macro Definition Documentation

◆ __NOLIBBASE__

#define __NOLIBBASE__

Function Documentation

◆ codefinit()

void codefinit ( void )
static

Library finit: free the signal and close console.device.

◆ codeinit()

ULONG codeinit ( void )
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.

Returns
d0: d0 of the last convertkey call (code 104, shifted); stored by the compiler, used by nobody

◆ convertkey()

void convertkey ( void )

◆ convertkey_c()

ULONG convertkey_c ( ULONG key,
ULONG qual )
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.

Parameters
keyd0: the raw key code (low word)
quald1: the qualifier
Returns
d0.w: the character; d1 = the character on the RawKeyConvert path, else the qualifier (set by the thunk)

◆ qconvertkey()

void qconvertkey ( void )

◆ qconvertkey_c()

ULONG qconvertkey_c ( ULONG key,
ULONG qual )
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).

Parameters
keyd0: the raw key code (low word)
quald1: the qualifier
Returns
d0.w: the character (0 if none)

◆ unconvert()

void unconvert ( void )

◆ unconvert_c()

ULONG unconvert_c ( ULONG ch)
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.

Parameters
chd0.b: the character
Returns
d0: the raw key code, -1 if not found; d1 = 0 (normal table) or 1 (shifted table, also when not found)

Variable Documentation

◆ buf

UWORD buf
static

◆ [struct]

struct { ... } con

◆ ConsoleDevice

struct Library* ConsoleDevice
static

◆ event

struct InputEvent event ( void ) = { .ie_Class = IECLASS_RAWKEY }
static

◆ io

struct IOStdReq io

◆ [struct]

struct { ... } maps

◆ normmap

UBYTE normmap[105]

◆ port

struct MsgPort port ( void )

◆ rawkey_d1

ULONG rawkey_d1

◆ shiftmap

UBYTE shiftmap[105]