General Info

Interface: Keyboard
Files: keyboard.h
Last change: 24/11/2002
Author: Luiz Henrique Shigunov
Description
Structures
Configuration
System Functions

0x00 - GetLayout - Get current layout

0x01 - SetLayout - Set current layout
User Functions

0x02 - UGetLayout - Get current layout

0x03 - USetLayout - Set current layout

Description

This page describes the Keyboard interface which provides access to the keyboard.

A module that implements this interface must map scancodes to virtual keys and these virtual keys to characters.

To do so, the module must use mapping tables from a module that implements the KbdLayout interface.

Besides that, the module must control keyboard leds (CapsLock, NumLock, ScrollLock).

Structures

typedef struct {
    unsigned int type;
    unsigned short charCode;
    unsigned char vKey;
    unsigned char reserved;
    unsigned int flags;
    unsigned int reserved2[5];
} Keyboard_Event;

type values between 0x00-0x0f are reserved for keyboard.

Currently this types are defined:

ValueDescription
0x00Key down
0x01Key up

scancode is the value read from the keyboard, charCode is the character code in Unicode, zero if it doesn't exist and flags has shifts states (ctrl, shift, alt, etc) and will be the sum of:

vKey is a virtual key, which can be:

ValueCodeDescription
0x00 Not used
0x01Keyboard_VK_0Number 0
0x02Keyboard_VK_1Number 1
0x03Keyboard_VK_2Number 2
0x04Keyboard_VK_3Number 3
0x05Keyboard_VK_4Number 4
0x06Keyboard_VK_5Number 5
0x07Keyboard_VK_6Number 6
0x08Keyboard_VK_7Number 7
0x09Keyboard_VK_8Number 8
0x0aKeyboard_VK_9Number 9
0x0bKeyboard_VK_ALetter A
0x0cKeyboard_VK_BLetter B
0x0dKeyboard_VK_CLetter C
0x0eKeyboard_VK_DLetter D
0x0fKeyboard_VK_ELetter E
0x10Keyboard_VK_FLetter F
0x11Keyboard_VK_GLetter G
0x12Keyboard_VK_HLetter H
0x13Keyboard_VK_ILetter I
0x14Keyboard_VK_JLetter J
0x15Keyboard_VK_KLetter K
0x16Keyboard_VK_LLetter L
0x17Keyboard_VK_MLetter M
0x18Keyboard_VK_NLetter N
0x19Keyboard_VK_OLetter O
0x1aKeyboard_VK_PLetter P
0x1bKeyboard_VK_QLetter Q
0x1cKeyboard_VK_RLetter R
0x1dKeyboard_VK_SLetter S
0x1eKeyboard_VK_TLetter T
0x1fKeyboard_VK_ULetter U
0x20Keyboard_VK_VLetter V
0x21Keyboard_VK_WLetter W
0x22Keyboard_VK_XLetter X
0x23Keyboard_VK_YLetter Y
0x24Keyboard_VK_ZLetter Z
0x25Keyboard_VK_SPACESpace
0x26Keyboard_VK_KEYPAD0Number 0 from keypad
0x27Keyboard_VK_KEYPAD1Number 1 from keypad
0x28Keyboard_VK_KEYPAD2Number 2 from keypad
0x29Keyboard_VK_KEYPAD3Number 3 from keypad
0x2aKeyboard_VK_KEYPAD4Number 4 from keypad
0x2bKeyboard_VK_KEYPAD5Number 5 from keypad
0x2cKeyboard_VK_KEYPAD6Number 6 from keypad
0x2dKeyboard_VK_KEYPAD7Number 7 from keypad
0x2eKeyboard_VK_KEYPAD8Number 8 from keypad
0x2fKeyboard_VK_KEYPAD9Number 9 from keypad
0x30Keyboard_VK_KEYPAD_DIV/ from keypad
0x31Keyboard_VK_KEYPAD_MUL* from keypad
0x32Keyboard_VK_KEYPAD_MINUS- from keypad
0x33Keyboard_VK_KEYPAD_PLUS+ from keypad
0x34Keyboard_VK_KEYPAD_DOT. from keypad
0x35Keyboard_VK_KEYPAD_COMMA, from keypad
0x36Keyboard_VK_PUNCT0Punctuation
0x37Keyboard_VK_PUNCT1Punctuation
0x38Keyboard_VK_PUNCT2Punctuation
0x39Keyboard_VK_PUNCT3Punctuation
0x3aKeyboard_VK_PUNCT4Punctuation
0x3bKeyboard_VK_PUNCT5Punctuation
0x3cKeyboard_VK_PUNCT6Punctuation
0x3dKeyboard_VK_PUNCT7Punctuation
0x3eKeyboard_VK_PUNCT8Punctuation
0x3fKeyboard_VK_PUNCT9Punctuation
0x40Keyboard_VK_PUNCT10Punctuation
0x41Keyboard_VK_PUNCT11Punctuation
0x42Keyboard_VK_PUNCT12Punctuation
0x43Keyboard_VK_PUNCT13Punctuation
0x44Keyboard_VK_PUNCT14Punctuation
0x45Keyboard_VK_PUNCT15Punctuation
0x46Keyboard_VK_PUNCT16Punctuation
0x47Keyboard_VK_PUNCT17Punctuation
0x48Keyboard_VK_PUNCT18Punctuation
0x49Keyboard_VK_PUNCT19Punctuation
0x4aKeyboard_VK_PUNCT20Punctuation
0x4bKeyboard_VK_ESCEscape
0x4cKeyboard_VK_BACKBackspace
0x4dKeyboard_VK_TABTab
0x4eKeyboard_VK_RETURNEnter
0x4fKeyboard_VK_KEYBAD_RETURNEnter from keypad
0x50Keyboard_VK_LSHIFTLeft shift
0x51Keyboard_VK_RSHIFTRight shift
0x52Keyboard_VK_LCTRLLeft ctrl
0x53Keyboard_VK_RCTRLRight ctrl
0x54Keyboard_VK_LALTLeft alt
0x55Keyboard_VK_RALTRight alt
0x56Keyboard_VK_PAGEUPPage up
0x57Keyboard_VK_PAGEDOWNPage down
0x58Keyboard_VK_HOMEHome
0x59Keyboard_VK_ENDEnd
0x5aKeyboard_VK_INSERTInsert
0x5bKeyboard_VK_DELETEDelete
0x5cKeyboard_VK_UPUp
0x5dKeyboard_VK_DOWNDown
0x5eKeyboard_VK_LEFTLeft
0x5fKeyboard_VK_RIGHTRight
0x60Keyboard_VK_NUMLOCKNumlock
0x61Keyboard_VK_CAPSLOCKCapslock
0x62Keyboard_VK_SCROLLLOCKScrolllock
0x63Keyboard_VK_SYSRQSysRq
0x64Keyboard_VK_PAUSEPause
0x65Keyboard_VK_F1F1
0x66Keyboard_VK_F2F2
0x67Keyboard_VK_F3F3
0x68Keyboard_VK_F4F4
0x69Keyboard_VK_F5F5
0x6aKeyboard_VK_F6F6
0x6bKeyboard_VK_F7F7
0x6cKeyboard_VK_F8F8
0x6dKeyboard_VK_F9F9
0x6eKeyboard_VK_F10F10
0x6fKeyboard_VK_F11F11
0x70Keyboard_VK_F12F12
0x71Keyboard_VK_F13F13
0x72Keyboard_VK_F14F14
0x73Keyboard_VK_F15F15
0x74Keyboard_VK_F16F16
0x75Keyboard_VK_F17F17
0x76Keyboard_VK_F18F18
0x77Keyboard_VK_F19F19
0x78Keyboard_VK_F20F20
0x79Keyboard_VK_F21F21
0x7aKeyboard_VK_F22F22
0x7bKeyboard_VK_F23F23
0x7cKeyboard_VK_F24F24
0x7dKeyboard_VK_LWINLeft window
0x7eKeyboard_VK_RWINRight window
0x7fKeyboard_VK_MENUMenu
0x80Keyboard_VK_MACROMacro
0x81-0xff Not used

Many virtual keys have a different meaning depending on the keyboard layout.

typedef struct {
    unsigned short interSize;
    unsigned short impSize;
    char names[1];
} Keyboard_LayoutInfo;

Where interSize it's the size of the name of the interface including the terminating zero, impSize it's the size of the name of the implementation including the terminating zero and names it's the area where the names are, first the name of the interface followed by the name of the implementation.

Configuration

This interface defines the following groups and keys available using the CfgManager interface:

/system/Keyboard

These keys are defined:

  • layout - the name of the implementation of the KbdLayout interface that must be used as layout

Some examples:

  • layout=us
  • layout=usintl

System Functions

These functions are exclusive for system modules.

0x00 - GetLayout

Syntax

const char *Keyboard_GetLayout(void);

Properties

Description

This function gets the name of the implementation of the KbdLayout interface that is been used by the keyboard.

Return value

The name of the implementation or NULL in case of error.

0x01 - SetLayout

Syntax

int Keyboard_SetLayout(const char *imp);

Properties

Description

This function sets the keyboard layout to imp, which is the name of a KbdLayout interface implementation.

Return value

User Functions

These functions were designed for user modules.

0x02 - UGetLayout

Syntax

int Keyboard_UGetLayout(Keyboard_LayoutInfo *info, unsigned int size);

Properties

User modules

Description

This function gets informations about the implementation of the KbdLayout interface that is been used by the keyboard.

size it's the total size of info.

In case of success, info will be filled with the informations.

Return value

0x03 - USetLayout

Syntax

int Keyboard_USetLayout(const char *imp);

Properties

User modules

Description

This function sets the keyboard layout to imp, which is the name of a KbdLayout interface implementation.

Return value