int Ufmt(Fmt *f) { int i; Dev *d; Usbdev *ud; char buf[1024]; char *s, *e; s = buf; e = buf+sizeof(buf); d = va_arg(f->args, Dev*); if(d == nil) return fmtprint(f, "<nildev>\n"); s = seprint(s, e, "%s", d->dir); ud = d->usb; if(ud == nil) return fmtprint(f, "%s %ld refs\n", buf, d->Ref.ref); s = seprint(s, e, " csp %s.%uld.%uld", classname(Class(ud->csp)), Subclass(ud->csp), Proto(ud->csp)); s = seprint(s, e, " vid %#ux did %#ux", ud->vid, ud->did); s = seprint(s, e, " refs %ld\n", d->Ref.ref); s = seprint(s, e, "\t%s %s %s\n", ud->vendor, ud->product, ud->serial); for(i = 0; i < Nconf; i++){ if(ud->conf[i] == nil) break; else s = seprintconf(s, e, ud, i); } return fmtprint(f, "%s", buf); }
void parsedescr(Desc *dd) { Audio *a, **ap; uchar *b; int i; if(dd == nil || dd->iface == nil || dd->altc == nil) return; b = (uchar*)&dd->data; if(Subclass(dd->iface->csp) != 2 || b[1] != 0x24 || b[2] != 0x02) return; if(b[4] != audiochan) return; if(b[6] != audiores) return; ap = (Audio**)&dd->altc->aux; if(b[7] == 0){ a = mallocz(sizeof(*a), 1); a->minfreq = b[8] | b[9]<<8 | b[10]<<16; a->maxfreq = b[11] | b[12]<<8 | b[13]<<16; a->next = *ap; *ap = a; } else { for(i=0; i<b[7]; i++){ a = mallocz(sizeof(*a), 1); a->minfreq = b[8+3*i] | b[9+3*i]<<8 | b[10+3*i]<<16; a->maxfreq = a->minfreq; a->next = *ap; *ap = a; } } }
void CSiWindow::Attach(HWND hWnd) { ASSERT(hWnd); Subclass(hWnd); m_timerId = ::SetTimer(hWnd, PW_TIMER_ID, PW_TIMER_ELAPSE, NULL); m_powerMode.Attach(hWnd); }
void Subclassed::Subclass(HWND parent_, UINT id_) { ASSURE(parent_ != NULL) parent = parent_; id = id_; hwnd = ::GetDlgItem(parent, id); ASSURE(hwnd != NULL) Subclass(); }
static int etherinit(Ether *e, int *ei, int *eo) { int ctlid, datid, i, j; Conf *c; Desc *desc; Iface *ctlif, *datif; Usbdev *ud; *ei = *eo = -1; ud = e->dev->usb; /* look for union descriptor with ethernet ctrl interface */ for(i = 0; i < nelem(ud->ddesc); i++){ if((desc = ud->ddesc[i]) == nil) continue; if(desc->data.bLength < 5 || desc->data.bbytes[0] != Cdcunion) continue; ctlid = desc->data.bbytes[1]; datid = desc->data.bbytes[2]; if((c = desc->conf) == nil) continue; ctlif = datif = nil; for(j = 0; j < nelem(c->iface); j++){ if(c->iface[j] == nil) continue; if(c->iface[j]->id == ctlid) ctlif = c->iface[j]; if(c->iface[j]->id == datid) datif = c->iface[j]; if(datif != nil && ctlif != nil){ if(Subclass(ctlif->csp) == Scether && ifaceinit(e, datif, ei, eo) != -1) return 0; break; } } } /* try any other one that seems to be ok */ for(i = 0; i < nelem(ud->conf); i++) if((c = ud->conf[i]) != nil) for(j = 0; j < nelem(c->iface); j++) if(ifaceinit(e, c->iface[j], ei, eo) != -1) return 0; dprint(2, "%s: no valid endpoints", argv0); return -1; }
bool CWndScroller::Init(CWnd* ip_wnd) { if (!ip_wnd) { ASSERT(0); return false; } mp_origWnd = ip_wnd; if (!Subclass(ip_wnd->m_hWnd)) //attach window { ASSERT(0); return false; } return true; }
bool TreeCtrl::Create(const WCHAR* title) { if (!title) { title = L""; } RECT rc = this->initialPos; HMODULE hmod = GetModuleHandleW(nullptr); this->hwnd = CreateWindowExW(this->dwExStyle, WC_TREEVIEWW, title, this->dwStyle, rc.left, rc.top, RectDx(rc), RectDy(rc), this->parent, this->menu, hmod, nullptr); if (!this->hwnd) { return false; } TreeView_SetUnicodeFormat(this->hwnd, true); this->SetFont(GetDefaultGuiFont()); Subclass(this); return true; }
bool CHotKeysToCmdRouter::Init(CWnd* ip_wnd) { if (!ip_wnd) { ASSERT(0); return false; } mp_OriginalWnd = ip_wnd; if (!Subclass(ip_wnd->m_hWnd)) { ASSERT(0); return false; } return true; }
static char * seprintiface(char *s, char *e, Iface *i) { int j; Altc *a; Ep *ep; char *eds, *ets; s = seprint(s, e, "\t\tiface csp %s.%uld.%uld\n", classname(Class(i->csp)), Subclass(i->csp), Proto(i->csp)); for(j = 0; j < Naltc; j++){ a=i->altc[j]; if(a == nil) break; s = seprint(s, e, "\t\t alt %d attr %d ival %d", j, a->attrib, a->interval); if(a->aux != nil) s = seprint(s, e, " devspec %p\n", a->aux); else s = seprint(s, e, "\n"); } for(j = 0; j < Nep; j++){ ep = i->ep[j]; if(ep == nil) break; eds = ets = ""; if(ep->dir <= nelem(edir)) eds = edir[ep->dir]; if(ep->type <= nelem(etype)) ets = etype[ep->type]; s = seprint(s, e, "\t\t ep id %d addr %d dir %s type %s" " itype %d maxpkt %d ntds %d\n", ep->id, ep->addr, eds, ets, ep->isotype, ep->maxpkt, ep->ntds); } return s; }
void CSubclassWnd::Attach(HWND hWnd) { ASSERT(hWnd); Subclass(hWnd); }
/** * @brief Attaches to target combobox. * @param[in] hComboBox window handle of target combobox. * @return TRUE if succeeded. */ BOOL WinComboListSeparators::Attach(HWND hComboBox) { return Subclass(hComboBox); }
bool ListViewEdit::Create(const TCHAR* szText, const UINT iItem, const UINT iSubItem, BaseWindow* pParent, HINSTANCE hInstance, Rect oRect) { // Store item index m_iItem = iItem; m_iSubItem = iSubItem; // Create Edit + Subclass return Edit::Create(szText, WS_CHILD | WS_BORDER | WS_VISIBLE | ES_LEFT, pParent, s_iControlID, hInstance, oRect) AND Subclass(); }
void OnInit() { CSuper::OnInit(); Subclass(); }
ProgressBarEx::~ProgressBarEx(void) { if (_lpfnOldProc) Subclass(_lpfnOldProc); }
void Subclassed::Subclass() { Subclass(WndProc); }
void audio_interface(Dev *_1, Desc *dd) { byte *b = (uint8_t*)&dd->data; byte *bb = b; int nb = dd->data.bLength; int ctl, ch, u, x; byte *p; int class, subclass; Audioalt *aa; char *hd; class = Class(dd->iface->csp); subclass = Subclass(dd->iface->csp); dprint(2, "%d.%d: ", class, subclass); switch (subclass){ case 1: // control switch (b[2]){ case 0x01: dprint(2, "Class-Specific AC Interface Header Descriptor\n"); dprint(2, "\tAudioDevClass release (bcd)%c%c%c%c, " "TotalLength %d, InCollection %d aInterfaceNr %d\n", '0'+((b[4]>>4)&0xf), '0'+(b[4]&0xf), '0'+((b[3]>>4)&0xf), '0'+(b[3]&0xf), b[5]|(b[6]<<8), b[7], b[8]); break; case 0x02: // input dprint(2, "Audio Input Terminal Descriptor\n"); dprint(2, "\tbTerminalId %d, wTerminalType " "0x%x (%s), bAssocTerminal %d bNrChannels %d, " "wChannelConfig %d, iChannelNames %d iTerminal %d\n", b[3], b[4]|(b[5]<<8), namefor(terminal_types, b[4]|(b[5]<<8)), b[6], b[7], b[8]|(b[9]<<8), b[10], b[11]); if((b[4]|b[5]<<8) == 0x101){ if(verbose) fprint(2, "Audio output unit %d\n", b[3]); /* USB streaming input: play interface */ units[Play][nunits[Play]++] = b[3]; }else{ if(verbose) fprint(2, "Dev can record from %s\n", namefor(terminal_types, b[4]|(b[5]<<8))); /* Non-USB input: record interface */ units[Record][nunits[Record]++] = b[3]; } break; case 0x03: // output if(usbdebug){ fprint(2, "Audio Output Terminal Descriptor\n"); fprint(2, "\tbTerminalId %d, wTerminalType 0x%x (%s), bAssocTerminal %d bSourceId %d, iTerminal %d\n", b[3], b[4]|(b[5]<<8), namefor(terminal_types, b[4]|(b[5]<<8)), b[6], b[7], b[8]); } if((b[4]|b[5]<<8) == 0x101){ if(verbose) fprint(2, "Audio input unit %d\n", b[3]); /* USB streaming output: record interface */ units[Record][nunits[Record]++] = b[3]; if(verbose) fprint(2, "Dev can play to %s\n", namefor(terminal_types, b[4]|(b[5]<<8))); /* Non-USB output: play interface */ units[Play][nunits[Play]++] = b[3]; } break; case 0x04: if(verbose) fprint(2, "Audio Mixer Unit %d\n", b[3]); if(usbdebug){ fprint(2, "\t%d bytes:", nb); for(ctl = 0; ctl < nb; ctl++) fprint(2, " 0x%2.2x", b[ctl]); fprint(2, "\n\tbUnitId %d, bNrInPins %d", b[3], b[4]); } if(b[4]){ dprint(2, ", baSourceIDs: [%d", b[5]); u = findunit(b[5]); for(ctl = 1; ctl < b[4]; ctl++){ if(u < 0) u = findunit(b[5+ctl]); else if((x = findunit(b[5+ctl])) >= 0 && u != x && verbose) fprint(2, "\tMixer %d for I & O \n", b[3]); dprint(2, ", %d", b[5+ctl]); } dprint(2, "]\n"); if(u >= 0){ units[u][nunits[u]++] = b[3]; if(mixerid[u] >= 0) fprint(2, "Second mixer (%d, %d) on %s\n", mixerid[u], b[3], u?"record":"playback"); mixerid[u] = b[3]; } if(usbdebug){ fprint(2, "Channels %d, config %d, ", b[ctl+5], b[ctl+5+1] | b[ctl+5+2] << 8); x = b[ctl+5] * b[4]; fprint(2, "programmable: %d bits, 0x", x); x = (x + 7) >> 3; while(x--) fprint(2, "%2.2x", b[ctl+x+5+4]); } } break; case 0x05: if(verbose) fprint(2, "Audio Selector Unit %d\n", b[3]); dprint(2, "\tbUnitId %d, bNrInPins %d", b[3], b[4]); if(b[4]){ u = findunit(b[5]); dprint(2, ", baSourceIDs: %s [%d", u?"record":"playback", b[5]); for(ctl = 1; ctl < b[4]; ctl++){ if(u < 0) u = findunit(b[5+ctl]); else if((x = findunit(b[5+ctl])) >= 0 && u != x && verbose) fprint(2, "\tSelector %d for I & O\n", b[3]); dprint(2, ", %d", b[5+ctl]); } dprint(2, "]\n"); if(u >= 0){ units[u][nunits[u]++] = b[3]; if(selectorid[u] >= 0) fprint(2, "Second selector (%d, %d) on %s\n", selectorid[u], b[3], u?"record":"playback"); selectorid[u] = b[3]; controls[u][Selector_control].readable = 1; controls[u][Selector_control].settable = 1; controls[u][Selector_control].chans = 0; } } break; case 0x06: // feature if(verbose) fprint(2, "Audio Feature Unit %d", b[3]); dprint(2, "\tbUnitId %d, bSourceId %d, bControlSize %d\n", b[3], b[4], b[5]); u = findunit(b[4]); if(u >= 0){ if(verbose) fprint(2, " for %s\n", u?"Record":"Playback"); units[u][nunits[u]++] = b[3]; if(featureid[u] >= 0) if(verbose) fprint(2, "Second feature unit (%d, %d)" " on %s\n", featureid[u], b[3], u?"record":"playback"); featureid[u] = b[3]; }else if(verbose) fprint(2, ", not known what for\n"); p = b + 6; for(ctl = 1; ctl < 0x0b; ctl++) if((1<<(ctl-1)) & (b[6] | ((b[5]>1)?(b[7]<<8):0))){ if(verbose) fprint(2, "\t%s control on master channel\n", controls[0][ctl].name); if(u >= 0){ controls[u][ctl].readable = 1; controls[u][ctl].settable = 1; controls[u][ctl].chans = 0; } } p += (b[5]>1)?2:1; for(ch = 0; ch < (nb - 8)/b[5]; ch++){ for(ctl = 1; ctl < 0x0b; ctl++) if((1<<(ctl-1)) & (p[0] | ((b[5]>1)?(p[1]<<8):0))){ if(verbose) fprint(2, "\t%s control on channel %d\n", controls[0][ctl].name, ch+1); if(u >= 0){ controls[u][ctl].readable = 1; controls[u][ctl].settable = 1; controls[u][ctl].chans |= 1 <<(ch+1); } } p += (b[5]>1)?2:1; } break; default: hd = hexstr(bb, nb); fprint(2, "audio control unknown: %s\n", hd); free(hd); } break; case 2: // stream switch (b[2]){ case 0x01: dprint(2, "Audio stream for TerminalID %d, delay %d, format_tag %#ux\n", b[3], b[4], b[5] | (b[6]<<8)); break; case 0x02: aa = (Audioalt *)dd->altc->aux; if(aa == nil){ aa = mallocz(sizeof(Audioalt), 1); dd->altc->aux = aa; } if(verbose){ if(b[4] <= 2) fprint(2, "Interface %d: %s, %d bits, ", dd->iface->id, (b[4] == 1)?"mono":"stereo", b[6]); else fprint(2, "Interface %d, %d channels, %d bits, ", dd->iface->id, b[4], b[6]); } if(b[7] == 0){ if(verbose) fprint(2, "frequency variable between %d and %d\n", b[8] | b[9]<<8 | b[10]<<16, b[11] | b[12]<<8 | b[13]<<16); aa->minfreq = b[8] | b[9]<<8 | b[10]<<16; aa->maxfreq = b[11] | b[12]<<8 | b[13]<<16; aa->caps |= has_contfreq; }else{ if(verbose) fprint(2, "discrete frequencies are:"); for(ch = 0; ch < b[7] && ch < 8; ch++){ aa->freqs[ch] = b[8+3*ch] | b[9+3*ch]<<8 | b[10+3*ch]<<16; if(verbose) fprint(2, " %d", b[8+3*ch] | b[9+3*ch]<<8 | b[10+3*ch]<<16); } if(ch < 8) aa->freqs[ch] = -1; if(verbose) fprint(2, "\n"); if(ch > 1) aa->caps |= has_discfreq; /* more than one frequency */ else aa->caps |= onefreq; /* only one frequency */ } aa->nchan = b[4]; aa->res = b[6]; aa->subframesize = b[5]; break; default: if(usbdebug){ hd = hexstr(bb, nb); fprint(2, "audio stream unknown: %s\n", hd); free(hd); } } break; case 3: // midi default: if(usbdebug){ hd = hexstr(bb, nb); fprint(2, "Unknown audio stream type: CS_INTERFACE: %s\n", hd); free(hd); } } }
///////////////////////////////////////////////////////////////////////////// // CSIFrameWnd CSIFrameWnd::CSIFrameWnd(HWND hSiFrameWnd) { m_pMdiClient = NULL; m_pMdiChildMng = NULL; Subclass(hSiFrameWnd); }
ProductList::~ProductList() { if (_lpfnOldProc) Subclass(_lpfnOldProc); }