gsp.c File Reference

Generic scancode parser. More...

#include <gsp.h>
#include <adt/hash_table.h>
#include <stdlib.h>
#include <stdio.h>

Go to the source code of this file.

Defines

#define TRANS_TABLE_CHAINS   256

Functions

void gsp_init (gsp_t *p)
 Initialise scancode parser.
int gsp_insert_defs (gsp_t *p, const int *defs)
 Insert a series of definitions into the parser.
int gsp_insert_seq (gsp_t *p, const int *seq, unsigned mods, unsigned key)
 Insert one sequence into the parser.
int gsp_step (gsp_t *p, int state, int input, unsigned *mods, unsigned *key)
 Compute one parser step.
static void trans_insert (gsp_t *p, gsp_trans_t *t)
 Define a new transition.
static gsp_trans_ttrans_lookup (gsp_t *p, int state, int input)
 Transition function lookup.
static gsp_trans_ttrans_new (void)
 Allocate transition structure.
static int trans_op_compare (unsigned long key[], hash_count_t keys, link_t *item)
static hash_index_t trans_op_hash (unsigned long key[])
static void trans_op_remove_callback (link_t *item)

Variables

static hash_table_operations_t trans_ops


Detailed Description

Generic scancode parser.

The scancode parser is a simple finite state machine. It is described using sequences of input symbols (scancodes) and the corresponding output value (mods, key pair). When the parser recognizes a sequence, it outputs the value and restarts. If a transition is undefined, the parser restarts, too.

Apart from precise values, GSP_DEFAULT allows to catch general cases. I.e. if we knew that after 0x1b 0x4f there always follow two more scancodes, we can define (0x1b, 0x4f, GSP_DEFAULT, GSP_DEFAULT, GSP_END) with null output. This will force the parser to read the entire sequence, not leaving garbage on the input if it does not recognize the specific sequence.

Definition in file gsp.c.


Generated on Thu Jun 2 07:45:55 2011 for HelenOS/USB by  doxygen 1.4.7