⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 makekbd.c

📁 关于rcp2c_v3.rar协议在LINUX下的实现程序
💻 C
📖 第 1 页 / 共 2 页
字号:
    {'#', '#', '#', stdPuncKeyWidth, 0},
  };
  KeyboardLayoutType punc1KeyboardLayout_All = {
    {{2, 69}, {stdPuncKeyWidth * 4 + 1, keyboardRows * 13 + 1}},
    13, keyboardFont, 0,
    {4, 4, 4, 4},
    kbdNoKey, kbdNoKey, fFalse
  };

#define numNumberKeys 12
  KeyboardKeyType numberKeys_All[numNumberKeys] = {
    // First row
    {'1', '1', '1', stdNumberKeyWidth, 0},
    {'2', '2', '2', stdNumberKeyWidth, 0},
    {'3', '3', '3', stdNumberKeyWidth, 0},
    // Second row
    {'4', '4', '4', stdNumberKeyWidth, 0},
    {'5', '5', '5', stdNumberKeyWidth, 0},
    {'6', '6', '6', stdNumberKeyWidth, 0},
    // Third row
    {'7', '7', '7', stdNumberKeyWidth, 0},
    {'8', '8', '8', stdNumberKeyWidth, 0},
    {'9', '9', '9', stdNumberKeyWidth, 0},
    // Fourth row
    {'(', '(', '(', stdNumberKeyWidth, 0},
    {'0', '0', '0', stdNumberKeyWidth, 0},
    {')', ')', ')', stdNumberKeyWidth, 0},
  };
  KeyboardLayoutType numberKeyboardLayout_All = {
    {{49, 59}, {stdNumberKeyWidth * 3 + 1, keyboardRows * 16 + 1}},
    16, keyboardLargeFont, 0,
    {3, 3, 3, 3},
    kbdNoKey, kbdNoKey, fFalse
  };

  KeyboardKeyType accentKeys_US[kNumAccentKeys_US] = {
    // First row
    {upAAcuteChr, upAAcuteChr, lowAAcuteChr, stdAccentKeyWidth, 0},
    {upAGraveChr, upAGraveChr, lowAGraveChr, stdAccentKeyWidth, 0},
    {upADiaeresisChr, upADiaeresisChr, lowADiaeresisChr, stdAccentKeyWidth,
     0},
    {upACircumflexChr, upACircumflexChr, lowACircumflexChr,
     stdAccentKeyWidth, 0},
    {upARingChr, upARingChr, lowARingChr, stdAccentKeyWidth, 0},
    {upATildeChr, upATildeChr, lowATildeChr, stdAccentKeyWidth, 0},
    {upAEChr, upAEChr, lowAEChr, stdAccentKeyWidth, 0},
    {upCCedillaChr, upCCedillaChr, lowCCedillaChr, stdAccentKeyWidth, 0},
    {upNTildeChr, upNTildeChr, lowNTildeChr, stdAccentKeyWidth, 0},
    {upOSlashChr, upOSlashChr, lowOSlashChr, stdAccentKeyWidth, 0},
    {kbdBackspaceKey, kbdBackspaceKey, kbdBackspaceKey,
     2 * stdAlphaKeyWidth + 1, kbdBackspaceKey},
    // Second row
    {kbdTabKey, kbdTabKey, kbdTabKey, stdAccentKeyWidth + 3, kbdTabKey},
    {upEAcuteChr, upEAcuteChr, lowEAcuteChr, stdAccentKeyWidth, 0},
    {upEGraveChr, upEGraveChr, lowEGraveChr, stdAccentKeyWidth, 0},
    {upEDiaeresisChr, upEDiaeresisChr, lowEDiaeresisChr, stdAccentKeyWidth,
     0},
    {upECircumflexChr, upECircumflexChr, lowECircumflexChr,
     stdAccentKeyWidth, 0},
    {upIAcuteChr, upIAcuteChr, lowIAcuteChr, stdAccentKeyWidth, 0},
    {upIGraveChr, upIGraveChr, lowIGraveChr, stdAccentKeyWidth, 0},
    {upIDiaeresisChr, upIDiaeresisChr, lowIDiaeresisChr, stdAccentKeyWidth,
     0},
    {upICircumflexChr, upICircumflexChr, lowICircumflexChr,
     stdAccentKeyWidth, 0},
    {lowSharpSChr, lowSharpSChr, lowSharpSChr, stdAccentKeyWidth, 0},
    {upYAcuteChr, upYAcuteChr, lowYAcuteChr, stdAccentKeyWidth - 1, 0},
    {upYDiaeresisChr, upYDiaeresisChr, lowYDiaeresisChr,
     stdAccentKeyWidth - 1, 0},
    // Third row
    {kbdCapsKey, kbdCapsKey, kbdCapsKey, stdAccentKeyWidth * 3 / 2 + 2,
     keyTopCapLabel},
    {upOAcuteChr, upOAcuteChr, lowOAcuteChr, stdAccentKeyWidth, 0},
    {upOGraveChr, upOGraveChr, lowOGraveChr, stdAccentKeyWidth, 0},
    {upODiaeresisChr, upODiaeresisChr, lowODiaeresisChr, stdAccentKeyWidth,
     0},
    {upOCircumflexChr, upOCircumflexChr, lowOCircumflexChr,
     stdAccentKeyWidth, 0},
    {upOTildeChr, upOTildeChr, lowOTildeChr, stdAccentKeyWidth, 0},
    {upUAcuteChr, upUAcuteChr, lowUAcuteChr, stdAccentKeyWidth, 0},
    {upUGraveChr, upUGraveChr, lowUGraveChr, stdAccentKeyWidth, 0},
    {upUDiaeresisChr, upUDiaeresisChr, lowUDiaeresisChr, stdAccentKeyWidth,
     0},
    {upUCircumflexChr, upUCircumflexChr, lowUCircumflexChr,
     stdAccentKeyWidth, 0},
    {kbdReturnKey, kbdReturnKey, kbdReturnKey, stdAccentKeyWidth + 6, kbdReturnKey},    // carriage return
    // Fourth row
    {kbdShiftKey, kbdShiftKey, kbdShiftKey, stdAccentKeyWidth * 2 + 4,
     keyTopShiftLabel},
    {' ', ' ', ' ', 7 * stdAccentKeyWidth + 10, keyTopSpaceLabel},
    {invertedExclamationChr, invertedExclamationChr, invertedQuestionChr,
     stdAccentKeyWidth, 0},
    {rightGuillemetChr, rightGuillemetChr, leftGuillemetChr,
     stdAccentKeyWidth, 0},
  };
  KeyboardLayoutType accentKeyboardLayout_US = {
    {{-1, 65}, {158, keyboardRows * 14 + 1}},
    14, keyboardFont, 0,
    {11, 12, 11, 4},
    34, 23, fTrue
  };
  KeyboardKeyType accentKeys_Other[kNumAccentKeys_Other] = {
    // First row
    {upAAcuteChr, upAAcuteChr, lowAAcuteChr, stdAccentKeyWidth, 0},
    {upAGraveChr, upAGraveChr, lowAGraveChr, stdAccentKeyWidth, 0},
    {upADiaeresisChr, upADiaeresisChr, lowADiaeresisChr, stdAccentKeyWidth,
     0},
    {upACircumflexChr, upACircumflexChr, lowACircumflexChr,
     stdAccentKeyWidth, 0},
    {upARingChr, upARingChr, lowARingChr, stdAccentKeyWidth, 0},
    {upATildeChr, upATildeChr, lowATildeChr, stdAccentKeyWidth, 0},
    {upAEChr, upAEChr, lowAEChr, stdAccentKeyWidth, 0},
    {upCCedillaChr, upCCedillaChr, lowCCedillaChr, stdAccentKeyWidth, 0},
    {upNTildeChr, upNTildeChr, lowNTildeChr, stdAccentKeyWidth, 0},
    {upOSlashChr, upOSlashChr, lowOSlashChr, stdAccentKeyWidth, 0},
    {kbdBackspaceKey, kbdBackspaceKey, kbdBackspaceKey,
     2 * stdAlphaKeyWidth + 1, kbdBackspaceKey},
    // Second row
    {kbdTabKey, kbdTabKey, kbdTabKey, stdAccentKeyWidth + 3, kbdTabKey},
    {upEAcuteChr, upEAcuteChr, lowEAcuteChr, stdAccentKeyWidth, 0},
    {upEGraveChr, upEGraveChr, lowEGraveChr, stdAccentKeyWidth, 0},
    {upEDiaeresisChr, upEDiaeresisChr, lowEDiaeresisChr, stdAccentKeyWidth,
     0},
    {upECircumflexChr, upECircumflexChr, lowECircumflexChr,
     stdAccentKeyWidth, 0},
    {upIAcuteChr, upIAcuteChr, lowIAcuteChr, stdAccentKeyWidth, 0},
    {upIGraveChr, upIGraveChr, lowIGraveChr, stdAccentKeyWidth, 0},
    {upIDiaeresisChr, upIDiaeresisChr, lowIDiaeresisChr, stdAccentKeyWidth,
     0},
    {upICircumflexChr, upICircumflexChr, lowICircumflexChr,
     stdAccentKeyWidth, 0},
    {lowSharpSChr, lowSharpSChr, lowSharpSChr, stdAccentKeyWidth, 0},
    {upYAcuteChr, upYAcuteChr, lowYAcuteChr, stdAccentKeyWidth - 1, 0},
    {upYDiaeresisChr, upYDiaeresisChr, lowYDiaeresisChr,
     stdAccentKeyWidth - 1, 0},
    // Third row
    {kbdCapsKey, kbdCapsKey, kbdCapsKey, stdAccentKeyWidth * 3 / 2 + 2,
     kbdCapsKey},
    {upOAcuteChr, upOAcuteChr, lowOAcuteChr, stdAccentKeyWidth, 0},
    {upOGraveChr, upOGraveChr, lowOGraveChr, stdAccentKeyWidth, 0},
    {upODiaeresisChr, upODiaeresisChr, lowODiaeresisChr, stdAccentKeyWidth,
     0},
    {upOCircumflexChr, upOCircumflexChr, lowOCircumflexChr,
     stdAccentKeyWidth, 0},
    {upOTildeChr, upOTildeChr, lowOTildeChr, stdAccentKeyWidth, 0},
    {upUAcuteChr, upUAcuteChr, lowUAcuteChr, stdAccentKeyWidth, 0},
    {upUGraveChr, upUGraveChr, lowUGraveChr, stdAccentKeyWidth, 0},
    {upUDiaeresisChr, upUDiaeresisChr, lowUDiaeresisChr, stdAccentKeyWidth,
     0},
    {upUCircumflexChr, upUCircumflexChr, lowUCircumflexChr,
     stdAccentKeyWidth, 0},
    {kbdReturnKey, kbdReturnKey, kbdReturnKey, stdAccentKeyWidth + 6, kbdReturnKey},    // carriage return
    // Fourth row
    {kbdShiftKey, kbdShiftKey, kbdShiftKey, stdAccentKeyWidth * 2 + 4,
     kbdShiftKey},
    {upOEChr, upOEChr, lowOEChr, stdAccentKeyWidth, 0},
    {' ', ' ', ' ', 6 * stdAccentKeyWidth + 10, 0},
    {invertedExclamationChr, invertedExclamationChr, invertedQuestionChr,
     stdAccentKeyWidth, 0},
    {rightGuillemetChr, rightGuillemetChr, leftGuillemetChr,
     stdAccentKeyWidth, 0},
  };
  KeyboardLayoutType accentKeyboardLayout_Other = {
    {{-1, 65}, {158, keyboardRows * 14 + 1}},
    14, keyboardFont, 0,
    {11, 12, 11, 5},
    34, 23, fTrue
  };

  switch (country)
  {
    case COUNTRY_UNITED_STATES:
      numAlphaKeys = kNumAlphaKeys_US;
      pAlphaKeys = alphaKeys_US;
      pAlphaKeyboardLayout = &alphaKeyboardLayout_US;
      pPunc2Keys = punc2Keys_US;
      pPunc2KeyboardLayout = &punc2KeyboardLayout_All;
      pPunc1Keys = punc1Keys_Other;
      pPunc1KeyboardLayout = &punc1KeyboardLayout_All;
      pNumberKeys = numberKeys_All;
      pNumberKeyboardLayout = &numberKeyboardLayout_All;
      numAccentKeys = kNumAccentKeys_US;
      pAccentKeys = accentKeys_US;
      pAccentKeyboardLayout = &accentKeyboardLayout_US;
      break;

    case COUNTRY_FRANCE:
      numAlphaKeys = kNumAlphaKeys_France;
      pAlphaKeys = alphaKeys_France;
      pAlphaKeyboardLayout = &alphaKeyboardLayout_France;
      pPunc2Keys = punc2Keys_Other;
      pPunc2KeyboardLayout = &punc2KeyboardLayout_All;
      pPunc1Keys = punc1Keys_Other;
      pPunc1KeyboardLayout = &punc1KeyboardLayout_All;
      pNumberKeys = numberKeys_All;
      pNumberKeyboardLayout = &numberKeyboardLayout_All;
      numAccentKeys = kNumAccentKeys_Other;
      pAccentKeys = accentKeys_Other;
      pAccentKeyboardLayout = &accentKeyboardLayout_Other;
      break;

    case COUNTRY_GERMANY:
      numAlphaKeys = kNumAlphaKeys_Germany;
      pAlphaKeys = alphaKeys_Germany;
      pAlphaKeyboardLayout = &alphaKeyboardLayout_Germany;
      pPunc2Keys = punc2Keys_Other;
      pPunc2KeyboardLayout = &punc2KeyboardLayout_All;
      pPunc1Keys = punc1Keys_Germany;
      pPunc1KeyboardLayout = &punc1KeyboardLayout_All;
      pNumberKeys = numberKeys_All;
      pNumberKeyboardLayout = &numberKeyboardLayout_All;
      numAccentKeys = kNumAccentKeys_Other;
      pAccentKeys = accentKeys_Other;
      pAccentKeyboardLayout = &accentKeyboardLayout_Other;
      break;

    default:
      Error("Unknown country keyboard");
      return;
      break;
  }

  // Copy the KeyboardLayout structures
  pkeyboardLayout = (KeyboardLayoutType *) kbdResImage;
  memcpy(pkeyboardLayout, pAlphaKeyboardLayout, sizeof(KeyboardLayoutType));
  memcpy(pkeyboardLayout + 1, pNumberKeyboardLayout,
         sizeof(KeyboardLayoutType));
  memcpy(pkeyboardLayout + 2, pPunc1KeyboardLayout,
         sizeof(KeyboardLayoutType));
  memcpy(pkeyboardLayout + 3, pPunc2KeyboardLayout,
         sizeof(KeyboardLayoutType));
  memcpy(pkeyboardLayout + 4, pAccentKeyboardLayout,
         sizeof(KeyboardLayoutType));
  realResOffset = CbEmitStruct(pkeyboardLayout, szRCKEYBOARDLAYOUT, NULL, fFalse);      /* pAlphaKeyboardLayout */
  realResOffset += CbEmitStruct(pkeyboardLayout + 1, szRCKEYBOARDLAYOUT, NULL, fFalse); /* pNumberKeyboardLayout */
  realResOffset += CbEmitStruct(pkeyboardLayout + 2, szRCKEYBOARDLAYOUT, NULL, fFalse); /* pPunc1KeyboardLayout */
  realResOffset += CbEmitStruct(pkeyboardLayout + 3, szRCKEYBOARDLAYOUT, NULL, fFalse); /* pPunc2KeyboardLayout */
  realResOffset += CbEmitStruct(pkeyboardLayout + 4, szRCKEYBOARDLAYOUT, NULL, fFalse); /* pAccentKeyboardLayout */

  pRunning = (char *)(pkeyboardLayout + 5);

  // Copy the alpha keycaps
  if (numAlphaKeys != pAlphaKeyboardLayout->keysPerRow[0] +
      pAlphaKeyboardLayout->keysPerRow[1] +
      pAlphaKeyboardLayout->keysPerRow[2] +
      pAlphaKeyboardLayout->keysPerRow[3])
  {
    Error("Wrong number of alpha keys");
    return;
  }
  pkeyboardLayout->keys = realResOffset;         // offset to keys
  memcpy(pRunning, pAlphaKeys, sizeof(KeyboardKeyType) * numAlphaKeys);
  pRunning += sizeof(KeyboardKeyType) * numAlphaKeys;
  realResOffset += keyboardKeyEmit(pAlphaKeys, numAlphaKeys, fFalse);   /* pAlphaKeys */

  // Copy the number keycaps
  if (numNumberKeys != pNumberKeyboardLayout->keysPerRow[0] +
      pNumberKeyboardLayout->keysPerRow[1] +
      pNumberKeyboardLayout->keysPerRow[2] +
      pNumberKeyboardLayout->keysPerRow[3])
  {
    Error("Wrong number of keys");
    return;
  }
  (pkeyboardLayout + 1)->keys = realResOffset;   // offset to keys
  memcpy(pRunning, pNumberKeys, sizeof(KeyboardKeyType) * numNumberKeys);
  pRunning += sizeof(KeyboardKeyType) * numNumberKeys;
  realResOffset += keyboardKeyEmit(pNumberKeys, numNumberKeys, fFalse); /* pNumberKeys */

  // Copy the punc1 keycaps
  if (numPunc1Keys != pPunc1KeyboardLayout->keysPerRow[0] +
      pPunc1KeyboardLayout->keysPerRow[1] +
      pPunc1KeyboardLayout->keysPerRow[2] +
      pPunc1KeyboardLayout->keysPerRow[3])
  {
    Error("Wrong number of punc1 keys");
    return;
  }
  (pkeyboardLayout + 2)->keys = realResOffset;   // offset to keys
  memcpy(pRunning, pPunc1Keys, sizeof(KeyboardKeyType) * numPunc1Keys);
  pRunning += sizeof(KeyboardKeyType) * numPunc1Keys;
  realResOffset += keyboardKeyEmit(pPunc1Keys, numPunc1Keys, fFalse);   /* pPunc1Keys */

  // Copy the punc2 keycaps
  if (numPunc2Keys != pPunc2KeyboardLayout->keysPerRow[0] +
      pPunc2KeyboardLayout->keysPerRow[1] +
      pPunc2KeyboardLayout->keysPerRow[2] +
      pPunc2KeyboardLayout->keysPerRow[3])
  {
    Error("Wrong number of punc2 keys");
    return;
  }
  (pkeyboardLayout + 3)->keys = realResOffset;   // offset to keys
  memcpy(pRunning, pPunc2Keys, sizeof(KeyboardKeyType) * numPunc2Keys);
  pRunning += sizeof(KeyboardKeyType) * numPunc2Keys;
  realResOffset += keyboardKeyEmit(pPunc2Keys, numPunc2Keys, fFalse);   /* pPunc2Keys */

  // Copy the accent keycaps
  if (numAccentKeys != pAccentKeyboardLayout->keysPerRow[0] +
      pAccentKeyboardLayout->keysPerRow[1] +
      pAccentKeyboardLayout->keysPerRow[2] +
      pAccentKeyboardLayout->keysPerRow[3])
  {
    Error("Wrong number of accent keys");
    return;
  }
  (pkeyboardLayout + 4)->keys = realResOffset;   // offset to keys
  memcpy(pRunning, pAccentKeys, sizeof(KeyboardKeyType) * numAccentKeys);
  pRunning += sizeof(KeyboardKeyType) * numAccentKeys;
  realResOffset += keyboardKeyEmit(pAccentKeys, numAccentKeys, fFalse); /* pAccentKeys */

  // Copy the key top labels and point keys to them
  pFirstKeyTopLabel = pRunning;
  stringsSize = 0;
  for (i = 0; i < numKeyTopLabels; i++)
  {
    pThisKeyTopLabel = pRunning;
    strcpy((char *)pThisKeyTopLabel, keyTopLabels[i]);
    thisKeyTopLabelSize = strlen((char *)pThisKeyTopLabel) + 1;
    stringsSize += thisKeyTopLabelSize;
    pRunning += thisKeyTopLabelSize;
    // For all keys if they use a string label update the offset
    pkeyboardKey = (KeyboardKeyType *) (pkeyboardLayout + 5);
    while ((char *)pkeyboardKey < (char *)pFirstKeyTopLabel)
    {
      if (pkeyboardKey->labelOffset == (firstKeyTopLabel + i))
        pkeyboardKey->labelOffset = realResOffset;
      pkeyboardKey++;
    }
    realResOffset += thisKeyTopLabelSize;
  }

  // We write the datas to disk
  OpenOutput(kPalmResType[kKeyboardType], resID);       /* RMa "tkbd" */

  pkeyboardLayout = (KeyboardLayoutType *) kbdResImage;

  // Emit the KeyboardLayout structures
  CbEmitStruct(pkeyboardLayout, szRCKEYBOARDLAYOUT, NULL, fTrue);       /* pAlphaKeyboardLayout */
  CbEmitStruct(pkeyboardLayout + 1, szRCKEYBOARDLAYOUT, NULL, fTrue);   /* pNumberKeyboardLayout */
  CbEmitStruct(pkeyboardLayout + 2, szRCKEYBOARDLAYOUT, NULL, fTrue);   /* pPunc1KeyboardLayout */
  CbEmitStruct(pkeyboardLayout + 3, szRCKEYBOARDLAYOUT, NULL, fTrue);   /* pPunc2KeyboardLayout */
  CbEmitStruct(pkeyboardLayout + 4, szRCKEYBOARDLAYOUT, NULL, fTrue);   /* pAccentKeyboardLayout */
  // Emit the alpha keycaps
  pRunning = (char *)(pkeyboardLayout + 5);
  keyboardKeyEmit((KeyboardKeyType *) pRunning, numAlphaKeys, fTrue);   /* pAlphaKeys */
  pRunning += sizeof(KeyboardKeyType) * numAlphaKeys;
  // Emit the number keycaps
  keyboardKeyEmit((KeyboardKeyType *) pRunning, numNumberKeys, fTrue);  /* pNumberKeys */
  pRunning += sizeof(KeyboardKeyType) * numNumberKeys;
  // Emit the punc1 keycaps
  keyboardKeyEmit((KeyboardKeyType *) pRunning, numPunc1Keys, fTrue);   /* pPunc1Keys */
  pRunning += sizeof(KeyboardKeyType) * numPunc1Keys;
  // Emit the punc2 keycaps
  keyboardKeyEmit((KeyboardKeyType *) pRunning, numPunc2Keys, fTrue);   /* pPunc2Keys */
  pRunning += sizeof(KeyboardKeyType) * numPunc2Keys;
  // Emit the accent keycaps
  keyboardKeyEmit((KeyboardKeyType *) pRunning, numAccentKeys, fTrue);  /* pAccentKeys */
  pRunning += sizeof(KeyboardKeyType) * numAccentKeys;
  // Emit the strings
  DumpBytes(pRunning, stringsSize);

  CloseOutput();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -