src/gui/keyboard/keyboard.c
// Update Keyboard Buttons with Latest Display and Locations
Update Keyboard Buttons with Latest Display and Locations
Update Keyboard Buttons with Latest Display and Locations
int pg_keyboard_guiKeyboardUpdate(gslc_tsGui* pGui) {
  int keyY = 60;
  int xHei = ((rFullscreen.h - 65) / (pg_keyboard_data->layoutRowsLen));
  int keyId = 0;
  int offsetX = 0;
  for (int lR = 0; lR < pg_keyboard_data->layoutRowsLen; ++lR) {
    int rowLen = pg_keyboard_data->layoutRows[lR];
    int xWid = (rFullscreen.w / pg_keyboard_data->layoutRowsWid[lR]);
    for (int l = 0; l < rowLen; ++l) {
      int xLen = 2;
      char* x = NULL;
      switch (pg_keyboard_data->layout[keyId]) {
        case -1:
          gslc_ElemSetTxtStr(pGui, pg_keyboard_data->layoutEl[keyId], (char*)" ");
          ++keyId;
          continue;
        break;
        case 13: 
          xLen = snprintf(NULL, 0, "%s", "Enter") + 1;
          x = (char *)calloc(xLen, sizeof(char));
          snprintf(x, xLen, "%s", "Enter");
        break;
        case 15: 
          xLen = snprintf(NULL, 0, "%s", "Shift") + 1;
          x = (char *)calloc(xLen, sizeof(char));
          snprintf(x, xLen, "%s", "Shift");
        break;
        default: 
          xLen = snprintf(NULL, 0, "%c", pg_keyboard_data->layout[keyId]) + 1;
          x = (char *)calloc(xLen, sizeof(char));
          snprintf(x, xLen, "%c", pg_keyboard_data->layout[keyId]);
        break;
      }
      if (keyId < pg_keyboard_data->layoutLen - 1
         && pg_keyboard_data->layout[keyId + 1] == pg_keyboard_data->layout[keyId]) {
        offsetX += xWid;
        gslc_ElemSetTxtStr(pGui, pg_keyboard_data->layoutEl[keyId], (char*)" ");
      } else {
        pg_keyboard_data->layoutEl[keyId]->pElem->rElem = (gslc_tsRect) {(rFullscreen.x + (l * xWid)) - offsetX, (keyY + (lR * xHei)), xWid + offsetX, xHei};
        gslc_ElemSetTxtStr(pGui, pg_keyboard_data->layoutEl[keyId], x);
        offsetX = 0;
      }
      if (x != NULL) { free(x); }
      ++keyId;
    }
  }
  return 1;
}
int pg_keyboard_guiKeyboardUpdate ( gslc_tsGui * pGui ) { int keyY = 60 ; int xHei = ( ( rFullscreen . h - 65 ) / ( pg_keyboard_data -> layoutRowsLen ) ) ; int keyId = 0 ; int offsetX = 0 ; for ( int lR = 0 ; lR < pg_keyboard_data -> layoutRowsLen ; ++ lR ) { int rowLen = pg_keyboard_data -> layoutRows [ lR ] ; int xWid = ( rFullscreen . w / pg_keyboard_data -> layoutRowsWid [ lR ] ) ; for ( int l = 0 ; l < rowLen ; ++ l ) { int xLen = 2 ; char * x = NULL ; switch ( pg_keyboard_data -> layout [ keyId ] ) { case -1 : gslc_ElemSetTxtStr ( pGui , pg_keyboard_data -> layoutEl [ keyId ] , ( char * ) " " ) ; ++ keyId ; continue ; break ; case 13 : xLen = snprintf ( NULL , 0 , " " , " " ) + 1 ; x = ( char * ) calloc ( xLen , sizeof ( char ) ) ; snprintf ( x , xLen , " " , " " ) ; break ; case 15 : xLen = snprintf ( NULL , 0 , " " , " " ) + 1 ; x = ( char * ) calloc ( xLen , sizeof ( char ) ) ; snprintf ( x , xLen , " " , " " ) ; break ; default : xLen = snprintf ( NULL , 0 , " " , pg_keyboard_data -> layout [ keyId ] ) + 1 ; x = ( char * ) calloc ( xLen , sizeof ( char ) ) ; snprintf ( x , xLen , " " , pg_keyboard_data -> layout [ keyId ] ) ; break ; } if ( keyId < pg_keyboard_data -> layoutLen - 1 && pg_keyboard_data -> layout [ keyId + 1 ] == pg_keyboard_data -> layout [ keyId ] ) { offsetX += xWid ; gslc_ElemSetTxtStr ( pGui , pg_keyboard_data -> layoutEl [ keyId ] , ( char * ) " " ) ; } else { pg_keyboard_data -> layoutEl [ keyId ] -> pElem -> rElem = ( gslc_tsRect ) { ( rFullscreen . x + ( l * xWid ) ) - offsetX , ( keyY + ( lR * xHei ) ) , xWid + offsetX , xHei } ; gslc_ElemSetTxtStr ( pGui , pg_keyboard_data -> layoutEl [ keyId ] , x ) ; offsetX = 0 ; } if ( x != NULL ) { free ( x ) ; } ++ keyId ; } } return 1 ; }
Update Keyboard Buttons with Latest Display and Locations
Update Keyboard Buttons with Latest Display and Locations
// W/out System Row at Bottom // New Row // System Enter // system Shift // Everything Else // New Key In Row