static void shortcutInput(int& shortcut) { StringBuilder<50> popup_name(""); popup_name << (Lumix::int64)&shortcut; char key_string[30]; PlatformInterface::getKeyName(shortcut, key_string, 30); StringBuilder<50> button_label(key_string); button_label << "##" << (Lumix::int64)&shortcut; if (ImGui::Button(button_label, ImVec2(50, 0))) shortcut = -1; auto& io = ImGui::GetIO(); if (ImGui::IsItemHovered()) { for (int i = 0; i < Lumix::lengthOf(ImGui::GetIO().KeysDown); ++i) { if (io.KeysDown[i]) { shortcut = i; break; } } } }
static void shortcutInput(int& shortcut) { Lumix::StaticString<50> popup_name(""); popup_name << (Lumix::i64)&shortcut; Lumix::StaticString<50> button_label(SDL_GetKeyName(SDL_GetKeyFromScancode((SDL_Scancode)shortcut))); button_label << "###" << (Lumix::i64)&shortcut; if (ImGui::Button(button_label, ImVec2(65, 0))) shortcut = -1; auto& io = ImGui::GetIO(); int key_count; auto* state = SDL_GetKeyboardState(&key_count); if (ImGui::IsItemHovered()) { for (int i = 0; i < key_count; ++i) { if (state[i]) { shortcut = i; break; } } } }
int title_screen(const char *commands[100], int *f, double noteinfo[2][1000], char output[1000]){ int xsize=1250; int ysize=1000; int xpos; int ypos; int height=400; int width=(xsize-50)/16; int i,j; char input[20]; char initial[1000]; char c; gfx_open(xsize, ysize, "Digital Piano"); quit_button(); draw_title(100); draw_name(50); draw_name2(50); draw_button(295,600,70,310); draw_button(645,600,70,310); button_label(60); button_label2(60); while (1){ c=gfx_wait(); xpos=gfx_xpos(); ypos=gfx_ypos(); //user clicks the quit button if (xpos>=1110 && xpos<=1210 && ypos>=850 && ypos<=890){ return 0; } //user clicks free play button if (xpos>=295 && xpos<=605 && ypos>=600 && ypos<=670){ gfx_clear(); piano_graphic(commands, f); } //user clicks load file button if (xpos>=645 && xpos<=955 && ypos>=600 && ypos<=670){ terminal_message(); printf("Please enter the name of the file, including the extension.\nThe file content should follow the same format as the examples in lab 8:\n"); scanf("%s", input); //scans file name into input FILE *music=fopen(input, "r"); if ((music=fopen(input, "r")) == NULL){ //returns error if file not found puts("File could not be opened"); return 0; } else{ //scans the file into output for (j=0; j<1000; j++){ fscanf(music, "%c", &output[j]); if (output[j]=='X'){ break; } } } piano2(noteinfo, output); //fork to play sound while lighting up keys if (fork()){ system("play sound.wav"); } else{ gfx_clear(); draw_piano(width, height); draw_arrow(50, f); gfx_color(255,255,255); draw_box(); octave_label(30); quit_button(); gfx_flush(); key_animation(noteinfo, f); return 0; } } } }