Keyboard Mappings&Constants

Summary
Keyboard Mappings&Constants
Variables
cpct_keyboardStatusBuffer10-bytes (80-bits) array containing pressed / not pressed status of all the keys / buttons the Amstrad CPC can manage (up to 80).
Enumerations
cpct_keyIDEnumerated type with symbols for all the 80 possible Key/Joy definitions.

Variables

cpct_keyboardStatusBuffer

extern u8 cpct_keyboardStatusBuffer[10]

10-bytes (80-bits) array containing pressed / not pressed status of all the keys / buttons the Amstrad CPC can manage (up to 80).  Each bit represents 1 key, with the meaning 0=pressed, 1=not pressed.  This array is filled up using cpct_scanKeyboard or cpct_scanKeyboard_f functions, and then it can be easily read with cpct_isKeyPressed function.  To know more about how this 10 bytes are distributed, consult Keyboard and cpct_scanKeyboard

Enumerations

cpct_keyID

Enumerated type with symbols for all the 80 possible Key/Joy definitions.

Details

Figure 1 shows the layout for an Amstrad CPC Keyboard, along with its firmware Key Codes.  Firmware Key Codes (FKCs) are used in table 1 to map them to cpct_keyID enum values.  Please, take into account that FKCs are not used in CPCtelera.  Do not make comparisons or store values based on firmware values unless you know what you are doing.  To check key / joy statuses, you should use cpct_keyID enum values from table 1.

                                                     __
                                                    | 0|
                                         ENC*     —— —— ——
  AMSTRAD                   CPC464 RGB color     | 8| 9| 1|
                                                  —— —— ——
 __ __ __ __ __ __ __ __ __ __ __ __ __ __ ___      | 2|
|66|64|65|57|56|49|48|41|40|33|32|25|24|16|79 |      ——
 —— —— —— —— —— —— —— —— —— —— —— —— —— —— ———    —— —— ——
|68 |67|59|58|50|51|43|42|35|34|27|26|17|     |  |10|11| 3|
 ——— —— —— —— —— —— —— —— —— —— —— —— —— = 18 |   —— —— ——
| 70 |69|60|61|53|52|44|45|37|36|29|28|19|    |  |20|12| 4|
 ———— —— —— —— —— —— —— —— —— —— —— —— —— ————    —— —— ——
| 21  |71|63|62|55|54|46|38|39|31|30|22|  21  |  |13|14| 5|
 ————— —— —— —— —— —— —— —— —— —— —— —— ——————    —— —— ——
         |            47            |23|         |15| 7| 6|
          —————————————————————————— ——           —— —— ——
     JOY 0   ___               JOY 1   ___
            | 72|                     | 48|
        ——|———————|——             ——|———————|——
       |74| 76| 77|75|           |50| 52| 53|51|
        ——|———————|——             ——|———————|——
            | 73|                     | 49|
             ———                       ———
====================================================================
 Figure 1. Amstrad CPC Keyoard Layout with Firmware Key Codes (FKCs)
 FKC | cpct_keyID      || FKC  | cpct_keyID    ||  FKC  |  cpct_keyID
--------------------------------------------------------------------
   0 | Key_CursorUp    ||  27  | Key_P         ||   54  |  Key_B
     |                 ||      |               ||       |  Joy1_Fire3
   1 | Key_CursorRight ||  28  | Key_SemiColon ||   55  |  Key_V
   2 | Key_CursorDown  ||  29  | Key_Colon     ||   56  |  Key_4
   3 | Key_F9          ||  30  | Key_Slash     ||   57  |  Key_3
   4 | Key_F6          ||  31  | Key_Dot       ||   58  |  Key_E
   5 | Key_F3          ||  32  | Key_0         ||   59  |  Key_W
   6 | Key_Enter       ||  33  | Key_9         ||   60  |  Key_S
   7 | Key_FDot        ||  34  | Key_O         ||   61  |  Key_D
   8 | Key_CursorLeft  ||  35  | Key_I         ||   62  |  Key_C
   9 | Key_Copy        ||  36  | Key_L         ||   63  |  Key_X
  10 | Key_F7          ||  37  | Key_K         ||   64  |  Key_1
  11 | Key_F8          ||  38  | Key_M         ||   65  |  Key_2
  12 | Key_F5          ||  39  | Key_Comma     ||   66  |  Key_Esc
  13 | Key_F1          ||  40  | Key_8         ||   67  |  Key_Q
  14 | Key_F2          ||  41  | Key_7         ||   68  |  Key_Tab
  15 | Key_F0          ||  42  | Key_U         ||   69  |  Key_A
  16 | Key_Clr         ||  43  | Key_Y         ||   70  |  Key_CapsLock
  17 | Key_OpenBracket ||  44  | Key_H         ||   71  |  Key_Z
  18 | Key_Return      ||  45  | Key_J         ||   72  |  Joy0_Up
  19 | Key_CloseBracket||  46  | Key_N         ||   73  |  Joy0_Down
  20 | Key_F4          ||  47  | Key_Space     ||   74  |  Joy0_Left
  21 | Key_Shift       ||  48  | Key_6         ||   75  |  Joy0_Right
     |                 ||      | Joy1_Up       ||
  22 | Key_BackSlash   ||  49  | Key_5         ||   76  |  Joy0_Fire1
     |                 ||      | Joy1_Down     ||
  23 | Key_Control     ||  50  | Key_R         ||   77  |  Joy0_Fire2
     |                 ||      | Joy1_Left     ||       |
  24 | Key_Caret       ||  51  | Key_T         ||   78  |  Joy0_Fire3
     |                 ||      | Joy1 Right    ||
  25 | Key_Hyphen      ||  52  | Key_G         ||   79  |  Key_Del
     |                 ||      | Joy1_Fire1    ||
  26 | Key_At          ||  53  | Key_F         ||
     |                 ||      | Joy1_Fire2    ||
--------------------------------------------------------------------
 Table 1. cpct_keyIDs defined for each possible key, ordered by FKCs
extern u8 cpct_keyboardStatusBuffer[10]
10-bytes (80-bits) array containing pressed / not pressed status of all the keys / buttons the Amstrad CPC can manage (up to 80).
Reads the status of keyboard and joysticks and stores it in the 10 bytes reserved as cpct_keyboardStatusBuffer
Reads the status of keyboard and joysticks and stores it in the 10 bytes reserved as cpct_keyboardStatusBuffer.
Checks if a concrete key is pressed or not.
Keyboard and joystick are connected to AY-3-8912 Programmable Sound Generator (PSG) which receives, processes and stores pressed / not pressed information.
Enumerated type with symbols for all the 80 possible Key/Joy definitions.
Close