| 572 | } |
| 573 | |
| 574 | int keyboard::textureKey(int keyID, int layoutType, string layoutString, int modifiers, string profilePath, int customShader){ |
| 575 | if (keys[keyID]->useImage){ |
| 576 | profilePath += "/images/"; |
| 577 | //int drawImage(const char* src, int x, int y, int width, int height, int a); |
| 578 | if (inMainThread) |
| 579 | keyboardWindow->drawImage((profilePath + layoutString).c_str(), keys[keyID]->z, |
| 580 | keys[keyID]->x, keys[keyID]->y, keys[keyID]->w, keys[keyID]->h, |
| 581 | keys[keyID]->a, keyID, modifiers, customShader); |
| 582 | else{ |
| 583 | keyboardWindow->requestDrawImage((profilePath + layoutString).c_str(), keys[keyID]->z, |
| 584 | keys[keyID]->x, keys[keyID]->y, keys[keyID]->w, keys[keyID]->h, |
| 585 | keys[keyID]->a, keyID, modifiers, customShader); |
| 586 | while (!keyboardWindow->asyncFunctionCompleted()) |
| 587 | __asm__("nop"); |
| 588 | } |
| 589 | } |
| 590 | else { //draw text |
| 591 | if (profileFonts.size() == 0){ |
| 592 | printf("No fonts loaded for this profile\n"); |
| 593 | return -1; |
| 594 | } |
| 595 | if (profileFonts.size() <= keys[keyID]->font){ |
| 596 | printf("Font out of range: %d. Fonts loaded only: %d\n", keys[keyID]->font, static_cast<int>(profileFonts.size())); |
| 597 | return -1; |
| 598 | } |
| 599 | //set font to key's font: |
| 600 | assignKeyboardFont(profileFonts[keys[keyID]->font].c_str()); |
| 601 | //int drawText(const char* text, int x, int y, int width, int height, int r, int g, int b, int a); |
| 602 | if (inMainThread) |
| 603 | keyboardWindow->drawText(layoutString.c_str(), keys[keyID]->z, |
| 604 | keys[keyID]->x, keys[keyID]->y, keys[keyID]->w, keys[keyID]->h, |
| 605 | keys[keyID]->r, keys[keyID]->g, keys[keyID]->b, keys[keyID]->a, |
| 606 | keyID, modifiers, customShader); |
| 607 | else { |
| 608 | keyboardWindow->requestDrawText(layoutString.c_str(), keys[keyID]->z, |
| 609 | keys[keyID]->x, keys[keyID]->y, keys[keyID]->w, keys[keyID]->h, |
| 610 | keys[keyID]->r, keys[keyID]->g, keys[keyID]->b, keys[keyID]->a, |
| 611 | keyID, modifiers, customShader); |
| 612 | while (!keyboardWindow->asyncFunctionCompleted()) |
| 613 | __asm__("nop"); |
| 614 | } |
| 615 | } |
| 616 | return 0; |
| 617 | } |
| 618 | |
| 619 | int keyboard::rectKey(int keyID){ |
| 620 | if (inMainThread) |
nothing calls this directly
no test coverage detected