Q3270
A Qt-based 3270 Terminal Emulator
Loading...
Searching...
No Matches
Keyboard Class Reference

Keyboard::Keyboard - Keyboard input processing. More...

#include <Keyboard.h>

Inheritance diagram for Keyboard:

Public Slots

void setConnected (bool state)
 Keyboard::setConnected - invoked when connection status changes.
 
void setMap (const KeyboardMap &kmap)
 Keyboard::setMap - set a keyboard map.
 

Signals

void setEnterInhibit ()
 
void setInsert (bool ins)
 
void key_Copy ()
 
void key_moveCursor (int x, int y, bool absolute)
 
void key_Backspace ()
 
void key_AID (int aid, bool short_read)
 
void key_Attn ()
 
void key_Tab (int offset)
 
void key_Backtab ()
 
void key_Home ()
 
void key_EraseEOF ()
 
void key_Delete ()
 
void key_Newline ()
 
void key_End ()
 
void key_toggleRuler ()
 
void key_Character (unsigned char keycode, bool insMode)
 
void key_Reset ()
 
void key_showInfo ()
 
void key_showFields ()
 
void key_dumpScreen ()
 

Public Member Functions

 Keyboard ()
 Keyboard::Keyboard - constructor.
 
bool processKey ()
 Keyboard::processKey.
 
void invoke (const QString &functionName)
 
void setLocked (const bool locked)
 

Static Public Member Functions

static QStringList allFunctionNames ()
 Keyboard::allFunctionNames - return a list of all function names.
 

Protected Member Functions

bool eventFilter (QObject *dist, QEvent *event)
 Keyboard::eventFilter - process keyboard events.
 

Detailed Description

Keyboard::Keyboard - Keyboard input processing.

The Keyboard class is how the keyboard is mapped to various 3270 and Q3270 functions. Each function has a name, and can be mapped to a key. There are 4 maps defined, one for normal, one for Shift, one for Ctrl and one for Alt (or Meta, depending). Keyboards can be mapped through the KeyboardTheme class to store user-defined maps. An internal Factory map which is set in here is the default and cannot be updated by the user.

Keyboard also handles type-ahead for when the host is still busy, but the user wants to continue typing to fill in the next field or enter the next command etc.

The Keyboard function map is held as a QMap with the name of the Qt key ("Enter", etc) and the target routine (Keyboard::enter, for example). If a key is pressed that doesn't generate a normal character, the function map is searched for a matching entry, and if found, called.

Constructor & Destructor Documentation

◆ Keyboard()

Keyboard::Keyboard ( )

Keyboard::Keyboard - constructor.

Keyboard initializes the keyboard state, and sets the default keyboard map to the factory map.

Member Function Documentation

◆ allFunctionNames()

QStringList Keyboard::allFunctionNames ( )
static

Keyboard::allFunctionNames - return a list of all function names.

Returns
a QStringList of all function names

Keyboard::allFunctionNames returns a list of all function names. This is used to populate the list of functions that can be mapped in the keyboard mapping dialog.

◆ eventFilter()

bool Keyboard::eventFilter ( QObject *  dist,
QEvent *  event 
)
protected

Keyboard::eventFilter - process keyboard events.

Parameters
dist
event
Returns
true if the event was processed, otherwise call the parent eventFilter.

The eventFilter is used to handle keyboard events. Depending on the key being pressed, the event can be processed immediately (as in the case of a normal character) or it may be deferred until the key is released (as in the case of, say, CTRL).

CTRL needs to be deferred because it may be used as the mapping for Enter, as well as being used for Copy (CTRL-C).

◆ processKey()

bool Keyboard::processKey ( )

Keyboard::processKey.

Returns
true if the key was processed, false if it is ignored

processKey determines whether the current keyboard buffer position contains a key that doesn't need to be mapped (as in the case of a standard character key) or whether it is mapped to a Q3270 function, and whether they key must be mapped for it to make sense.

If the keyboard map contains a mapping for the key, the target function of the key is stored in the keyboard buffer, to be processed later by nextKey().

Eg, if the Home key is pressed, that must be mapped to a Q3270 function for it to be processed, but if it isn't mapped, the key is ignored.

The key is stored in the keyboard buffer, and if the key can be processed immediately, nextKey is called, but if the keyboard is locked, the current buffer position is incremented so that the next key can be stored.

The buffer is a wrap-around buffer.

If the key is processed or stored in the buffer, processKey returns true, otherwise it returns false.

◆ setConnected

void Keyboard::setConnected ( bool  state)
slot

Keyboard::setConnected - invoked when connection status changes.

Parameters
state- true for connected, false for not

setConnected is triggered when the connection is opened or closed so Keyboard knows when to process keys.

◆ setMap

void Keyboard::setMap ( const KeyboardMap kmap)
slot

Keyboard::setMap - set a keyboard map.

Parameters
kmap- the keyboard map

setTheme takes a keyboard map and sets up the mappings of keys to functions. Keyboard maps are defined as QMap<QString, QStringList>; each function can have multiple keys assigned to it (e.g. F8 and PgDown are both defined to call F8 by default).


The documentation for this class was generated from the following files: