int main(int argc, char **argv) { /* connect to localhost, port 9777 using a UDP socket this only needs to be done once. by default this is where XBMC will be listening for incoming connections. */ CAddress my_addr; // Address => localhost on 9777 int sockfd = socket(AF_INET, SOCK_DGRAM, 0); if (sockfd < 0) { printf("Error creating socket\n"); return -1; } my_addr.Bind(sockfd); CPacketHELO HeloPackage("Example Remote", ICON_PNG, "../../icons/bluetooth.png"); HeloPackage.Send(sockfd, my_addr); sleep(5); // press 'S' CPacketBUTTON btn1('S', true); btn1.Send(sockfd, my_addr); sleep(2); // press the enter key (13 = enter) CPacketBUTTON btn2(13, true); btn2.Send(sockfd, my_addr); // BYE is not required since XBMC would have shut down CPacketBYE bye; // CPacketPing if you want to ping bye.Send(sockfd, my_addr); }
int CUIManager::UIBid(int iAtLeast) { CBox box(200, 260, 225, 32, 80, 50, 200, 128, false); CButton btn1(1, 205, 265, 50, 22, 250, 70, 250); CButton btn2(2, 260, 265, 50, 22, 250, 70, 250); CButton btn3(3, 315, 265, 50, 22, 250, 70, 250); CButton btn4(0, 370, 265, 50, 22, 250, 70, 250); gpGeneral->DrawImage(iAtLeast > 1 ? IMG_1PD : IMG_1P, 210, 267); gpGeneral->DrawImage(iAtLeast > 2 ? IMG_2PD : IMG_2P, 265, 267); gpGeneral->DrawImage(IMG_3P, 320, 267); gpGeneral->DrawImage(IMG_NOTCALL, 375, 267); time_t t; time(&t); while (time(NULL) - t < 30) { DrawTime(30 - (time(NULL) - t)); int key = gpGeneral->ReadKey(false) - SDLK_LAST; if ((key >= iAtLeast && key <= 3) || !key) { return key; } // allow using the keyboard as well key += SDLK_LAST - '0'; if ((key >= iAtLeast && key <= 3) || !key) { return key; } } return 0; }
int main(int argc, char** argv) { QApplication app(argc, argv); QDialogButtonBox box(Qt::Vertical); QPushButton btn1(QIcon(":/qicon-resource.png"), "QIcon(\":/qicon-resource.png\")"); QPushButton btn2(QIcon(":/qicon-resource"), "QIcon(\":/qicon-resource\")"); box.addButton(&btn1, QDialogButtonBox::YesRole); box.addButton(&btn2, QDialogButtonBox::NoRole); box.show(); app.exec(); }
LRESULT CLogContentFilterEditDlg::OnOK(WORD , WORD , HWND , BOOL& ) { CStringW text; GetDlgItemText(IDC_EDIT_LOGCONTENT, text); CButton btn((HWND)GetDlgItem(IDC_CHECK_IGNORECASE)); bool ics = (btn.GetCheck() == 1); CButton btn2((HWND)GetDlgItem(IDC_CHECK_REGEX)); bool use_regex = (btn2.GetCheck() == 1); if (!m_filter->setfilter((LPCWSTR)text, ics, use_regex)) { ::MessageBoxW(m_hWnd, IDS(IDS_REGEX_PARSE_ERROR), IDS(IDS_ERROR), MB_ICONWARNING|MB_OK); return 0; } EndDialog(IDOK); return 0; }
void button_key::on_pushButton_2_clicked()//2 { emit btn2(); }
/**************************************************************************** * WindowPrompt * * Displays a prompt window to user, with information, an error message, or * presenting a user with a choice ***************************************************************************/ void updatePrompt(string rev) { // bool stop = true; GuiWindow promptWindow(520,360); promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); promptWindow.SetPosition(0, -10); GuiTrigger trigA; trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); GuiImageData dialogBox(Theme.dialog_background); GuiImage dialogBoxImg(&dialogBox); GuiImageData btnOutline(Theme.button_small); GuiImage btn1Img(&btnOutline); GuiImage btn2Img(&btnOutline); GuiImageData btnOutlineOver(Theme.button_small_focus); GuiImage btn1ImgOver(&btnOutlineOver); GuiImage btn2ImgOver(&btnOutlineOver); GuiText titleTxt(tr("Update"), 26, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255}); titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); titleTxt.SetPosition(0, 40); GuiText downloadTxt(tr("Downloading file..."), 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255}); downloadTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); downloadTxt.SetPosition(0, -20); GuiText msgTxt(tr("please wait"), 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255}); msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); msgTxt.SetPosition(0, 20); GuiText btn1Txt(tr("Yes"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255}); GuiButton btn1(btnOutline.GetWidth(), btnOutline.GetHeight()); btn1.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); btn1.SetPosition(20, -25); btn1.SetLabel(&btn1Txt); btn1.SetImage(&btn1Img); btn1.SetImageOver(&btn1ImgOver); btn1.SetTrigger(&trigA); btn1.SetState(STATE_SELECTED); btn1.SetEffectGrow(); GuiText btn2Txt(tr("No"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255}); GuiButton btn2(btnOutline.GetWidth(), btnOutline.GetHeight()); btn2.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); btn2.SetPosition(-20, -25); btn2.SetLabel(&btn2Txt); btn2.SetImage(&btn2Img); btn2.SetImageOver(&btn2ImgOver); btn2.SetTrigger(&trigA); btn2.SetEffectGrow(); promptWindow.Append(&dialogBoxImg); promptWindow.Append(&titleTxt); promptWindow.Append(&downloadTxt); promptWindow.Append(&msgTxt); HaltGui(); mainWindow->SetState(STATE_DISABLED); mainWindow->Append(&promptWindow); mainWindow->ChangeFocus(&promptWindow); ResumeGui(); char url[100]; #ifdef STBOOTVWII if(rev == "Beta") sprintf(url, "http://www.nanolx.org/hbf/DOL.st.vwii/Beta/boot.dol"); else sprintf(url, "http://www.nanolx.org/hbf/DOL.st.vwii/rev%s/boot.dol", rev.c_str()); // copy boot.dol to prev.dol std::ifstream infile((Settings.device_dat + ":/apps/HomebrewFilter.vWii.Standalone/boot.dol").c_str(), std::ios_base::binary); std::ofstream outfile((Settings.device_dat + ":/apps/HomebrewFilter.vWii.Standalone/prev.dol").c_str(), std::ios_base::binary); #elif VWII if(rev == "Beta") sprintf(url, "http://www.nanolx.org/hbf/DOL.vwii/Beta/boot.dol"); else sprintf(url, "http://www.nanolx.org/hbf/DOL.vwii/rev%s/boot.dol", rev.c_str()); // copy boot.dol to prev.dol std::ifstream infile((Settings.device_dat + ":/apps/HomebrewFilter.vWii/boot.dol").c_str(), std::ios_base::binary); std::ofstream outfile((Settings.device_dat + ":/apps/HomebrewFilter.vWii/prev.dol").c_str(), std::ios_base::binary); #elif STDBOOT if(rev == "Beta") sprintf(url, "http://www.nanolx.org/hbf/DOL.st/Beta/boot.dol"); else sprintf(url, "http://www.nanolx.org/hbf/DOL.st/rev%s/boot.dol", rev.c_str()); // copy boot.dol to prev.dol std::ifstream infile((Settings.device_dat + ":/apps/HomebrewFilter.Standalone/boot.dol").c_str(), std::ios_base::binary); std::ofstream outfile((Settings.device_dat + ":/apps/HomebrewFilter.Standalone/prev.dol").c_str(), std::ios_base::binary); #else if(rev == "Beta") sprintf(url, "http://www.nanolx.org/hbf/DOL/Beta/boot.dol"); else sprintf(url, "http://www.nanolx.org/hbf/DOL/rev%s/boot.dol", rev.c_str()); // copy boot.dol to prev.dol std::ifstream infile((Settings.device_dat + ":/apps/HomebrewFilter/boot.dol").c_str(), std::ios_base::binary); std::ofstream outfile((Settings.device_dat + ":/apps/HomebrewFilter/prev.dol").c_str(), std::ios_base::binary); #endif outfile << infile.rdbuf(); struct block file = downloadfile(url); if (file.data && file.size > 0) { // write file #ifdef STBOOTVWII if(opendir(check_path(Settings.device_dat + ":/apps/HomebrewFilter.vWii.Standalone").c_str()) == NULL) mkdir((Settings.device_dat + ":/apps/HomebrewFilter.vWii.Standalone").c_str(), 0777); FILE * data = fopen((Settings.device_dat + ":/apps/HomebrewFilter.vWii.Standalone/boot.dol").c_str(), "wb"); if(data) { fwrite(file.data, 1, file.size, data); fclose(data); } #elif VWII if(opendir(check_path(Settings.device_dat + ":/apps/HomebrewFilter.vWii").c_str()) == NULL) mkdir((Settings.device_dat + ":/apps/HomebrewFilter.vWii").c_str(), 0777); FILE * data = fopen((Settings.device_dat + ":/apps/HomebrewFilter.vWii/boot.dol").c_str(), "wb"); if(data) { fwrite(file.data, 1, file.size, data); fclose(data); } #elif STDBOOT if(opendir(check_path(Settings.device_dat + ":/apps/HomebrewFilter.Standalone").c_str()) == NULL) mkdir((Settings.device_dat + ":/apps/HomebrewFilter.Standalone").c_str(), 0777); FILE * data = fopen((Settings.device_dat + ":/apps/HomebrewFilter.Standalone/boot.dol").c_str(), "wb"); if(data) { fwrite(file.data, 1, file.size, data); fclose(data); } #else if(opendir(check_path(Settings.device_dat + ":/apps/HomebrewFilter").c_str()) == NULL) mkdir((Settings.device_dat + ":/apps/HomebrewFilter").c_str(), 0777); FILE * data = fopen((Settings.device_dat + ":/apps/HomebrewFilter/boot.dol").c_str(), "wb"); if(data) { fwrite(file.data, 1, file.size, data); fclose(data); } #endif if(file.data) free(file.data); boot_buffer = true; updatehbf = true; } else { if(file.data) free(file.data); } HaltGui(); mainWindow->Remove(&promptWindow); mainWindow->SetState(STATE_DEFAULT); ResumeGui(); }
/**************************************************************************** * WindowPrompt * * Displays a prompt window to user, with information, an error message, or * presenting a user with a choice ***************************************************************************/ int WindowPrompt(const char *title, const char *msg, const char *btn1Label, const char *btn2Label) { int choice = -1; // GuiWindow promptWindow(448, 288); GuiWindow promptWindow(640, 360); promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); promptWindow.SetPosition(0, -10); GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM); GuiImageData btnOutline(xenon_button_png); GuiImageData btnOutlineOver(xenon_button_over_png); GuiTrigger trigA; // trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); trigA.SetSimpleTrigger(-1, 0, PAD_BUTTON_A); // GuiImageData dialogBox(dialogue_box_png); GuiImageData dialogBox(xenon_popup_png); GuiImage dialogBoxImg(&dialogBox); GuiText titleTxt(title, 26, ColorGrey); titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); titleTxt.SetPosition(0, 40); GuiText msgTxt(msg, 22, ColorGrey); msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); msgTxt.SetPosition(0, -20); msgTxt.SetWrap(true, 600); GuiText btn1Txt(btn1Label, 22, ColorGrey); GuiImage btn1Img(&btnOutline); GuiImage btn1ImgOver(&btnOutlineOver); GuiButton btn1(btnOutline.GetWidth(), btnOutline.GetHeight()); if (btn2Label) { btn1.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM); btn1.SetPosition(20, -25); } else { btn1.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); btn1.SetPosition(0, -25); } btn1.SetLabel(&btn1Txt); btn1.SetImage(&btn1Img); btn1.SetImageOver(&btn1ImgOver); btn1.SetSoundOver(&btnSoundOver); btn1.SetTrigger(&trigA); btn1.SetState(STATE_SELECTED); btn1.SetEffectGrow(); GuiText btn2Txt(btn2Label, 22, ColorGrey); GuiImage btn2Img(&btnOutline); GuiImage btn2ImgOver(&btnOutlineOver); GuiButton btn2(btnOutline.GetWidth(), btnOutline.GetHeight()); btn2.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); btn2.SetPosition(-20, -25); btn2.SetLabel(&btn2Txt); btn2.SetImage(&btn2Img); btn2.SetImageOver(&btn2ImgOver); btn2.SetSoundOver(&btnSoundOver); btn2.SetTrigger(&trigA); btn2.SetEffectGrow(); promptWindow.Append(&dialogBoxImg); promptWindow.Append(&titleTxt); promptWindow.Append(&msgTxt); promptWindow.Append(&btn1); if (btn2Label) promptWindow.Append(&btn2); promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); HaltGui(); mainWindow->SetState(STATE_DISABLED); mainWindow->Append(&promptWindow); mainWindow->ChangeFocus(&promptWindow); ResumeGui(); while (choice == -1) { UGUI(); usleep(THREAD_SLEEP); if (btn1.GetState() == STATE_CLICKED) choice = 1; else if (btn2.GetState() == STATE_CLICKED) choice = 0; } promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); while (promptWindow.GetEffect() > 0) { UGUI(); usleep(THREAD_SLEEP); } HaltGui(); mainWindow->Remove(&promptWindow); mainWindow->SetState(STATE_DEFAULT); ResumeGui(); return choice; }