void testinit(void) { unsigned char key[32]; setid(1); //acceptor memset(cc->sid, 0x55, 16); ike_rand(cc->a, 32); //set acceptor long term private key scalarmultbase(cc->A, cc->a); //compute public key memcpy(key, cc->A, 32); //copy as originator destination setid(0); //originator memset(cc->sid, 0xAA, 16); ike_rand(cc->a, 32); //set originator long term private key scalarmultbase(cc->A, cc->a); //compute public key memcpy(cc->B, key, 32); //copy as originator destination }
/* * vehicle_part */ void vehicle_part::deserialize(JsonIn &jsin) { JsonObject data = jsin.get_object(); int intpid; std::string pid; if ( data.read("id_enum", intpid) && intpid < 74 ) { pid = legacy_vpart_id[intpid]; } else { data.read("id",pid); } // if we don't know what type of part it is, it'll cause problems later. if (vehicle_part_types.find(pid) == vehicle_part_types.end()) { if (pid == "wheel_underbody") { pid = "wheel_wide"; } else { throw (std::string)"bad vehicle part, id: %s" + pid; } } setid(pid); data.read("mount_dx", mount_dx); data.read("mount_dy", mount_dy); data.read("hp", hp ); data.read("amount", amount ); data.read("blood", blood ); data.read("bigness", bigness ); data.read( "flags", flags ); data.read( "passenger_id", passenger_id ); data.read("items", items); }
int CodesObject::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = TSqlObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; #ifndef QT_NO_PROPERTIES if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< int*>(_v) = getid(); break; case 1: *reinterpret_cast< QString*>(_v) = gettitle(); break; case 2: *reinterpret_cast< QString*>(_v) = getcode(); break; case 3: *reinterpret_cast< QString*>(_v) = getcode_url(); break; case 4: *reinterpret_cast< int*>(_v) = getstatus(); break; case 5: *reinterpret_cast< QDateTime*>(_v) = getcreated_at(); break; case 6: *reinterpret_cast< QDateTime*>(_v) = getupdated_at(); break; case 7: *reinterpret_cast< int*>(_v) = geteditable(); break; case 8: *reinterpret_cast< int*>(_v) = getuser_id(); break; case 9: *reinterpret_cast< QString*>(_v) = getshow_from(); break; } _id -= 10; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setid(*reinterpret_cast< int*>(_v)); break; case 1: settitle(*reinterpret_cast< QString*>(_v)); break; case 2: setcode(*reinterpret_cast< QString*>(_v)); break; case 3: setcode_url(*reinterpret_cast< QString*>(_v)); break; case 4: setstatus(*reinterpret_cast< int*>(_v)); break; case 5: setcreated_at(*reinterpret_cast< QDateTime*>(_v)); break; case 6: setupdated_at(*reinterpret_cast< QDateTime*>(_v)); break; case 7: seteditable(*reinterpret_cast< int*>(_v)); break; case 8: setuser_id(*reinterpret_cast< int*>(_v)); break; case 9: setshow_from(*reinterpret_cast< QString*>(_v)); break; } _id -= 10; } else if (_c == QMetaObject::ResetProperty) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 10; } else if (_c == QMetaObject::RegisterPropertyMetaType) { if (_id < 10) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 10; } #endif // QT_NO_PROPERTIES return _id; }
void setid_af (struct uae_input_device *uid, int i, int slot, int sub, int port, int evt, int af) { setid (uid, i, slot, sub, port, evt); uid[i].flags[slot][sub] &= ~(ID_FLAG_AUTOFIRE | ID_FLAG_TOGGLE); if (af >= JPORT_AF_NORMAL) uid[i].flags[slot][sub] |= ID_FLAG_AUTOFIRE; if (af == JPORT_AF_TOGGLE) uid[i].flags[slot][sub] |= ID_FLAG_TOGGLE; }
/* Set default inputdevice config for Pepper joysticks. */ int input_get_default_joystick (struct uae_input_device *uid, int i, int port, int af, int mode, bool joymouseswap) { if (i >= 2) return 0; setid (uid, i, ID_AXIS_OFFSET + 0, 0, port, port ? INPUTEVENT_JOY2_HORIZ : INPUTEVENT_JOY1_HORIZ); setid (uid, i, ID_AXIS_OFFSET + 1, 0, port, port ? INPUTEVENT_JOY2_VERT : INPUTEVENT_JOY1_VERT); setid_af (uid, i, ID_BUTTON_OFFSET + 0, 0, port, port ? INPUTEVENT_JOY2_FIRE_BUTTON : INPUTEVENT_JOY1_FIRE_BUTTON, af); setid (uid, i, ID_BUTTON_OFFSET + 1, 0, port, port ? INPUTEVENT_JOY2_2ND_BUTTON : INPUTEVENT_JOY1_2ND_BUTTON); return 1; if (i == 0) return 1; return 0; }
void ikeres(void) { unsigned char sea[32]; unsigned char sdb[32]; unsigned char sda[32]; unsigned char seb[32]; unsigned short sasa; unsigned short sasb; setid(0); memcpy(sea, cc->S, 16); memcpy(sda, cc->S+16, 16); sasa=cc->sas; setid(1); memcpy(seb, cc->S, 16); memcpy(sdb, cc->S+16, 16); sasb=cc->sas; }
static void setid (struct uae_input_device *uid, int i, int slot, int sub, int port, int evt, int af, bool gp) { setid (uid, i, slot, sub, port, evt, gp); uid[i].flags[slot][sub] &= ~ID_FLAG_AUTOFIRE_MASK; if (af >= JPORT_AF_NORMAL) uid[i].flags[slot][sub] |= ID_FLAG_AUTOFIRE; if (af == JPORT_AF_TOGGLE) uid[i].flags[slot][sub] |= ID_FLAG_TOGGLE; if (af == JPORT_AF_ALWAYS) uid[i].flags[slot][sub] |= ID_FLAG_INVERTTOGGLE; }
int input_get_default_joystick_analog (struct uae_input_device *uid, int i, int port, int af, bool gp, bool joymouseswap) { struct pidata *pid; if (joymouseswap) { if (i >= num_mouse) return 0; pid = &pi_mouse[i]; } else { if (i >= num_joystick) return 0; pid = &pi_joystick[i]; } setid (uid, i, ID_AXIS_OFFSET + 0, 0, port, port ? INPUTEVENT_JOY2_HORIZ_POT : INPUTEVENT_JOY1_HORIZ_POT, gp); setid (uid, i, ID_AXIS_OFFSET + 1, 0, port, port ? INPUTEVENT_JOY2_VERT_POT : INPUTEVENT_JOY1_VERT_POT, gp); setid (uid, i, ID_BUTTON_OFFSET + 0, 0, port, port ? INPUTEVENT_JOY2_LEFT : INPUTEVENT_JOY1_LEFT, af, gp); if (isrealbutton (pid, 1)) setid (uid, i, ID_BUTTON_OFFSET + 1, 0, port, port ? INPUTEVENT_JOY2_RIGHT : INPUTEVENT_JOY1_RIGHT, gp); if (isrealbutton (pid, 2)) setid (uid, i, ID_BUTTON_OFFSET + 2, 0, port, port ? INPUTEVENT_JOY2_UP : INPUTEVENT_JOY1_UP, gp); if (isrealbutton (pid, 3)) setid (uid, i, ID_BUTTON_OFFSET + 3, 0, port, port ? INPUTEVENT_JOY2_DOWN : INPUTEVENT_JOY1_DOWN, gp); if (i == 0) return 1; return 0; }
int input_get_default_mouse (struct uae_input_device *uid, int i, int port, int af, bool gp, bool wheel, bool joymouseswap) { struct pidata *pid = NULL; if (!joymouseswap) { if (i >= num_mouse) return 0; pid = &pi_mouse[i]; } else { if (i >= num_joystick) return 0; pid = &pi_joystick[i]; } setid (uid, i, ID_AXIS_OFFSET + 0, 0, port, port ? INPUTEVENT_MOUSE2_HORIZ : INPUTEVENT_MOUSE1_HORIZ, gp); setid (uid, i, ID_AXIS_OFFSET + 1, 0, port, port ? INPUTEVENT_MOUSE2_VERT : INPUTEVENT_MOUSE1_VERT, gp); if (wheel) setid (uid, i, ID_AXIS_OFFSET + 2, 0, port, port ? 0 : INPUTEVENT_MOUSE1_WHEEL, gp); setid (uid, i, ID_BUTTON_OFFSET + 0, 0, port, port ? INPUTEVENT_JOY2_FIRE_BUTTON : INPUTEVENT_JOY1_FIRE_BUTTON, af, gp); setid (uid, i, ID_BUTTON_OFFSET + 1, 0, port, port ? INPUTEVENT_JOY2_2ND_BUTTON : INPUTEVENT_JOY1_2ND_BUTTON, gp); setid (uid, i, ID_BUTTON_OFFSET + 2, 0, port, port ? INPUTEVENT_JOY2_3RD_BUTTON : INPUTEVENT_JOY1_3RD_BUTTON, gp); if (i == 0) return 1; return 0; }
event_t(uint event, const char *argnames, const char *codestring) : type(SCRIPT), postuninstall(false), executing(false), filename(getcurrentcsfilename()), event(event), codestring(newstring(codestring)), calls(0), fcptr(NULL) { ok = !argnames || parseargnames(codestring, argnames); if (!ok) { code = NULL; return; } code = compilecode(codestring); setid(); }
void testike(void) { unsigned char buf[36]={0,}; testinit(); memset(buf, 0, 36); setid(1); ike_run_acceptor(buf); setid(0); ike_run_originator(buf); setid(1); ike_2(buf); setid(0); ike_3(buf); setid(1); ike_4(buf); stemu(buf); ike_6(buf); setid(0); ike_5(buf); setid(1); ike_8(buf); setid(0); ike_7(buf); stemu(buf); ike_9(buf); setid(1); ike_10(buf); setid(0); ike_11(buf); ikeres(); }
int PostObject::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = TSqlObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; #ifndef QT_NO_PROPERTIES if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< int*>(_v) = getid(); break; case 1: *reinterpret_cast< int*>(_v) = getblog_id(); break; case 2: *reinterpret_cast< QString*>(_v) = gettitle(); break; case 3: *reinterpret_cast< QString*>(_v) = getcontent(); break; case 4: *reinterpret_cast< QDateTime*>(_v) = getcreated_at(); break; case 5: *reinterpret_cast< QDateTime*>(_v) = getupdated_at(); break; case 6: *reinterpret_cast< int*>(_v) = getlock_revision(); break; } _id -= 7; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setid(*reinterpret_cast< int*>(_v)); break; case 1: setblog_id(*reinterpret_cast< int*>(_v)); break; case 2: settitle(*reinterpret_cast< QString*>(_v)); break; case 3: setcontent(*reinterpret_cast< QString*>(_v)); break; case 4: setcreated_at(*reinterpret_cast< QDateTime*>(_v)); break; case 5: setupdated_at(*reinterpret_cast< QDateTime*>(_v)); break; case 6: setlock_revision(*reinterpret_cast< int*>(_v)); break; } _id -= 7; } else if (_c == QMetaObject::ResetProperty) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 7; } #endif // QT_NO_PROPERTIES return _id; }
void init_graph(Agraph_t* g) { int i = 0; Agnode_t* n; weight = agattr(g, AGEDGE, "weight", "1.0"); pos = agattr(g, AGNODE, "pos", ""); color = agattr(g, AGNODE, "color", "black"); comment = agattr(g, AGRAPH, "cmd", ""); nodes = (Agnode_t**) malloc(sizeof(Agnode_t*)*agnnodes(g)); for(n = agfstnode(g); n; n = agnxtnode(g,n)) { agbindrec(n, (char*)"nodedata", sizeof(nodedata_t),1); setid(n,i); nodes[i] = n; i++; } }
/* * Default inputdevice config for SDL mouse */ int input_get_default_mouse (struct uae_input_device *uid, int i, int port, int af) { write_log("input_get_default_mouse\n"); /* SDL supports only one mouse */ setid (uid, i, ID_AXIS_OFFSET + 0, 0, port, port ? INPUTEVENT_MOUSE2_HORIZ : INPUTEVENT_MOUSE1_HORIZ); setid (uid, i, ID_AXIS_OFFSET + 1, 0, port, port ? INPUTEVENT_MOUSE2_VERT : INPUTEVENT_MOUSE1_VERT); setid (uid, i, ID_AXIS_OFFSET + 2, 0, port, port ? 0 : INPUTEVENT_MOUSE1_WHEEL); setid_af (uid, i, ID_BUTTON_OFFSET + 0, 0, port, port ? INPUTEVENT_JOY2_FIRE_BUTTON : INPUTEVENT_JOY1_FIRE_BUTTON, af); setid (uid, i, ID_BUTTON_OFFSET + 1, 0, port, port ? INPUTEVENT_JOY2_2ND_BUTTON : INPUTEVENT_JOY1_2ND_BUTTON); setid (uid, i, ID_BUTTON_OFFSET + 2, 0, port, port ? INPUTEVENT_JOY2_3RD_BUTTON : INPUTEVENT_JOY1_3RD_BUTTON); if (port == 0) { /* map back and forward to ALT+LCUR and ALT+RCUR */ // if (isrealbutton (did, 3)) { setid (uid, i, ID_BUTTON_OFFSET + 3, 0, port, INPUTEVENT_KEY_ALT_LEFT); setid (uid, i, ID_BUTTON_OFFSET + 3, 1, port, INPUTEVENT_KEY_CURSOR_LEFT); // if (isrealbutton (did, 4)) { setid (uid, i, ID_BUTTON_OFFSET + 4, 0, port, INPUTEVENT_KEY_ALT_LEFT); setid (uid, i, ID_BUTTON_OFFSET + 4, 1, port, INPUTEVENT_KEY_CURSOR_RIGHT); // } // } } if (i == 0) return 1; return 0; }
static int capwriteuse(uchar *a, int len) { int n; uchar digest[SHA1dlen]; char buf[128], *p, *users[3]; Caps *c, **l; if(len >= sizeof(buf)-1) return -1; memmove(buf, a, len); buf[len] = 0; p = strrchr(buf, '@'); if(p == nil) return -1; *p++ = 0; len = strlen(p); n = strlen(buf); if(len == 0 || n == 0) return -1; hmac_sha1((uchar*)buf, n, (uchar*)p, len, digest, nil); n = getfields(buf, users, nelem(users), 0, "@"); if(n == 1) users[1] = users[0]; else if(n != 2) return -1; if(*users[0] == 0 || *users[1] == 0) return -1; qlock(&allcaps.l); for(l = &allcaps.caps; (c = *l) != nil; l = &c->next) if(memcmp(c->hash, digest, sizeof(c->hash)) == 0){ *l = c->next; qunlock(&allcaps.l); free(c); if(n == 2 && strcmp(up->env->user, users[0]) != 0) return -1; setid(users[1], 0); /* could use users[2] to mean `host OS user' */ return 0; } qunlock(&allcaps.l); return -1; }
//compute bag affiliation for all vertices //store result in m_bagindex void ClusterAnalysis::computeBags() { const Graph &G = m_C->constGraph(); // Storage structure for results m_bagindex.init(G); // We use Union-Find for chunks and bags DisjointSets<> uf; NodeArray<int> setid(G); // Index mapping for union-find #if 0 node* nn = new node[G.numberOfNodes()]; // dito #endif // Every cluster gets its index ClusterArray<int> cind(*m_C); // We store the lists of cluster vertices List<node>* clists = new List<node>[m_C->numberOfClusters()]; int i = 0; // Store index and detect the current leaf clusters List<cluster> ccleafs; ClusterArray<int> unprocessedChildren(*m_C); //processing below: compute bags for(cluster c : m_C->clusters) { cind[c] = i++; if (c->cCount() == 0) ccleafs.pushBack(c); unprocessedChildren[c] = c->cCount(); } // Now we run through all vertices, storing them in the parent lists, // at the same time, we initialize m_bagindex for(node v : G.nodes) { // setid is constant in the following setid[v] = uf.makeSet(); // Each vertex v gets its own ClusterArray that stores v's bag index per cluster. // See comment on use of ClusterArrays above m_bagindex[v] = new ClusterArray<int>(*m_C,DefaultIndex, m_C->maxClusterIndex()+1);//m_C->numberOfClusters()); cluster c = m_C->clusterOf(v); // Push vertices in parent list clists[cind[c]].pushBack(v); } // Now each clist contains the direct vertex descendants // We process the clusters bottom-up, compute the chunks // of the leafs first. At each level, for a cluster the // vertex lists of all children are concatenated // (could improve this by having an array of size(#leafs) // and concatenating only at child1), then the bags are // updated as follows: chunks may be linked by exactly // the edges with lca(c) ie the ones in m_lcaEdges[c], // and bags may be built by direct child clusters that join chunks. // While concatenating the vertex lists, we can check // for the vertices in each child if the uf number is the same // as the one of a first initial vertex, otherwise we join. // First, lowest level clusters are processed: All chunks are bags OGDF_ASSERT(!ccleafs.empty()); while (!ccleafs.empty()){ const cluster c = ccleafs.popFrontRet(); Skiplist<int*> cbags; //Stores bag indexes ocurring in c auto storeResult = [&] { for (node v : clists[cind[c]]) { int theid = uf.find(setid[v]); (*m_bagindex[v])[c] = theid; if (!cbags.isElement(&theid)) { cbags.add(new int(theid)); } // push into list of outer active vertices if (m_storeoalists && isOuterActive(v, c)) { (*m_oalists)[c].pushBack(v); } } (*m_bags)[c] = cbags.size(); // store number of bags of c }; if (m_storeoalists){ //no outeractive vertices detected so far (*m_oalists)[c].clear(); } //process leafs separately if (c->cCount() == 0) { //Todo could use lcaEdges list here too, see below for (node u : c->nodes) { for(adjEntry adj : u->adjEntries) { node w = adj->twinNode(); if (m_C->clusterOf(w) == c) { uf.link(uf.find(setid[u]),uf.find(setid[w])); } } } // Now all chunks in the leaf cluster are computed // update for parent is done in the else case storeResult(); } else { // ?We construct the vertex list by concatenating // ?the lists of the children to the current list. // We need the lists for storing the results efficiently. // (Should be slightly faster than to call clusterNodes each time) // Bags are either links of chunks by edges with lca==c // or links of chunk by child clusters. // Edge links for(edge e : (*m_lcaEdges)[c]) { uf.link(uf.find(setid[e->source()]),uf.find(setid[e->target()])); } // Cluster links for(cluster cc : c->children) { //Initial id per child cluster cc: Use value of first //vertex, each time we encounter a different value in cc, //we link the chunks //add (*itcc)'s vertices to c's list ListConstIterator<node> itvc = clists[cind[cc]].begin(); int inid; if (itvc.valid()) inid = uf.find(setid[*itvc]); while (itvc.valid()) { int theid = uf.find(setid[*itvc]); if (theid != inid) uf.link(inid,theid); clists[cind[c]].pushBack(*itvc); ++itvc; } } storeResult(); } // Now we update the status of the parent cluster and, // in case all its children are processed, add it to // the process queue. if (c != m_C->rootCluster()) { OGDF_ASSERT(unprocessedChildren[c->parent()] > 0); unprocessedChildren[c->parent()]--; if (unprocessedChildren[c->parent()] == 0) ccleafs.pushBack(c->parent()); } } // clean up delete[] clists; }
static long conswrite(Chan *c, void *va, long n, vlong offset) { char buf[128], *a, ch; int x; if(c->qid.type & QTDIR) error(Eperm); switch((ulong)c->qid.path) { default: error(Egreg); case Qcons: if(canrlock(&kprintq.l)){ if(kprintq.q != nil){ if(waserror()){ runlock(&kprintq.l); nexterror(); } qwrite(kprintq.q, va, n); poperror(); runlock(&kprintq.l); return n; } runlock(&kprintq.l); } return write(1, va, n); case Qsysctl: return sysconwrite(va, n); case Qconsctl: if(n >= sizeof(buf)) n = sizeof(buf)-1; strncpy(buf, va, n); buf[n] = 0; for(a = buf; a;){ if(strncmp(a, "rawon", 5) == 0){ kbd.raw = 1; /* clumsy hack - wake up reader */ ch = 0; qwrite(kbdq, &ch, 1); } else if(strncmp(buf, "rawoff", 6) == 0){ kbd.raw = 0; } if((a = strchr(a, ' ')) != nil) a++; } break; case Qkeyboard: for(x=0; x<n; ) { Rune r; x += chartorune(&r, &((char*)va)[x]); gkbdputc(gkbdq, r); } break; case Qnull: break; case Qtime: if(n >= sizeof(buf)) n = sizeof(buf)-1; strncpy(buf, va, n); buf[n] = '\0'; timeoffset = strtoll(buf, 0, 0)-osusectime(); break; case Qhostowner: if(!iseve()) error(Eperm); if(offset != 0 || n >= sizeof(buf)) error(Ebadarg); memmove(buf, va, n); buf[n] = '\0'; if(n > 0 && buf[n-1] == '\n') buf[--n] = '\0'; if(n == 0) error(Ebadarg); /* renameuser(eve, buf); */ /* renameproguser(eve, buf); */ kstrdup(&eve, buf); kstrdup(&up->env->user, buf); break; case Quser: if(!iseve()) error(Eperm); if(offset != 0) error(Ebadarg); if(n <= 0 || n >= sizeof(buf)) error(Ebadarg); strncpy(buf, va, n); buf[n] = '\0'; if(n > 0 && buf[n-1] == '\n') buf[--n] = '\0'; if(n == 0) error(Ebadarg); setid(buf, 0); break; case Qhoststdout: return write(1, va, n); case Qhoststderr: return write(2, va, n); case Qjit: if(n >= sizeof(buf)) n = sizeof(buf)-1; strncpy(buf, va, n); buf[n] = '\0'; x = atoi(buf); if(x < 0 || x > 9) error(Ebadarg); cflag = x; break; case Qsysname: if(offset != 0) error(Ebadarg); if(n < 0 || n >= sizeof(buf)) error(Ebadarg); strncpy(buf, va, n); buf[n] = '\0'; if(buf[n-1] == '\n') buf[n-1] = 0; kstrdup(&ossysname, buf); break; } return n; }
int input_get_default_joystick (struct uae_input_device *uid, int i, int port, int af, int mode, bool gp, bool joymouseswap) { struct pidata *pid = NULL; int h, v; if (joymouseswap) { if (i >= num_mouse) return 0; pid = &pi_mouse[i]; } else { if (i >= num_joystick) return 0; pid = &pi_joystick[i]; } if (port >= 2) { h = port == 3 ? INPUTEVENT_PAR_JOY2_HORIZ : INPUTEVENT_PAR_JOY1_HORIZ; v = port == 3 ? INPUTEVENT_PAR_JOY2_VERT : INPUTEVENT_PAR_JOY1_VERT; } else { h = port ? INPUTEVENT_JOY2_HORIZ : INPUTEVENT_JOY1_HORIZ; v = port ? INPUTEVENT_JOY2_VERT : INPUTEVENT_JOY1_VERT; } setid (uid, i, ID_AXIS_OFFSET + 0, 0, port, h, gp); setid (uid, i, ID_AXIS_OFFSET + 1, 0, port, v, gp); if (port >= 2) { setid (uid, i, ID_BUTTON_OFFSET + 0, 0, port, port == 3 ? INPUTEVENT_PAR_JOY2_FIRE_BUTTON : INPUTEVENT_PAR_JOY1_FIRE_BUTTON, af, gp); } else { setid (uid, i, ID_BUTTON_OFFSET + 0, 0, port, port ? INPUTEVENT_JOY2_FIRE_BUTTON : INPUTEVENT_JOY1_FIRE_BUTTON, af, gp); if (isrealbutton (pid, 1)) setid (uid, i, ID_BUTTON_OFFSET + 1, 0, port, port ? INPUTEVENT_JOY2_2ND_BUTTON : INPUTEVENT_JOY1_2ND_BUTTON, gp); if (mode != JSEM_MODE_JOYSTICK) { if (isrealbutton (pid, 2)) setid (uid, i, ID_BUTTON_OFFSET + 2, 0, port, port ? INPUTEVENT_JOY2_3RD_BUTTON : INPUTEVENT_JOY1_3RD_BUTTON, gp); } } if (mode == JSEM_MODE_JOYSTICK_CD32) { setid (uid, i, ID_BUTTON_OFFSET + 0, 0, port, port ? INPUTEVENT_JOY2_CD32_RED : INPUTEVENT_JOY1_CD32_RED, af, gp); if (isrealbutton (pid, 1)) { setid (uid, i, ID_BUTTON_OFFSET + 1, 0, port, port ? INPUTEVENT_JOY2_CD32_BLUE : INPUTEVENT_JOY1_CD32_BLUE, gp); } if (isrealbutton (pid, 2)) setid (uid, i, ID_BUTTON_OFFSET + 2, 0, port, port ? INPUTEVENT_JOY2_CD32_GREEN : INPUTEVENT_JOY1_CD32_GREEN, gp); if (isrealbutton (pid, 3)) setid (uid, i, ID_BUTTON_OFFSET + 3, 0, port, port ? INPUTEVENT_JOY2_CD32_YELLOW : INPUTEVENT_JOY1_CD32_YELLOW, gp); if (isrealbutton (pid, 4)) setid (uid, i, ID_BUTTON_OFFSET + 4, 0, port, port ? INPUTEVENT_JOY2_CD32_RWD : INPUTEVENT_JOY1_CD32_RWD, gp); if (isrealbutton (pid, 5)) setid (uid, i, ID_BUTTON_OFFSET + 5, 0, port, port ? INPUTEVENT_JOY2_CD32_FFW : INPUTEVENT_JOY1_CD32_FFW, gp); if (isrealbutton (pid, 6)) setid (uid, i, ID_BUTTON_OFFSET + 6, 0, port, port ? INPUTEVENT_JOY2_CD32_PLAY : INPUTEVENT_JOY1_CD32_PLAY, gp); } if (i == 0) { return 1; } return 0; }
/** * Construct a new id. */ ID(const Glib::ustring& data):lmaker_( new Sha1LabelMaker() ), label_( ){ if (data.size() > 0){ setid(data); } else { setid(CDAO::convert(serialno++)); } }
/* * Set default inputdevice config for SDL joysticks */ int32_t input_get_default_joystick (struct uae_input_device *uid, int32_t num, int32_t port, int32_t af, int32_t mode, bool gp, bool joymouseswap) { int32_t h,v; // uint32_t j; // struct didata *did; SDL_Joystick *joy; joy = joys[num].joy; if (num >= get_joystick_num ()) return 0; if (mode == JSEM_MODE_MOUSE_CDTV) { h = INPUTEVENT_MOUSE_CDTV_HORIZ; v = INPUTEVENT_MOUSE_CDTV_VERT; } else if (port >= 2) { h = port == 3 ? INPUTEVENT_PAR_JOY2_HORIZ : INPUTEVENT_PAR_JOY1_HORIZ; v = port == 3 ? INPUTEVENT_PAR_JOY2_VERT : INPUTEVENT_PAR_JOY1_VERT; } else { h = port ? INPUTEVENT_JOY2_HORIZ : INPUTEVENT_JOY1_HORIZ;; v = port ? INPUTEVENT_JOY2_VERT : INPUTEVENT_JOY1_VERT; } setid (uid, num, ID_AXIS_OFFSET + 0, 0, port, h); setid (uid, num, ID_AXIS_OFFSET + 1, 0, port, v); if (port >= 2) { setid_af (uid, num, ID_BUTTON_OFFSET + 0, 0, port, port == 3 ? INPUTEVENT_PAR_JOY2_FIRE_BUTTON : INPUTEVENT_PAR_JOY1_FIRE_BUTTON, af); } else { setid_af (uid, num, ID_BUTTON_OFFSET + 0, 0, port, port ? INPUTEVENT_JOY2_FIRE_BUTTON : INPUTEVENT_JOY1_FIRE_BUTTON, af); if (SDL_JoystickNumButtons(joy) > 0) setid (uid, num, ID_BUTTON_OFFSET + 1, 0, port, port ? INPUTEVENT_JOY2_2ND_BUTTON : INPUTEVENT_JOY1_2ND_BUTTON); if (SDL_JoystickNumButtons(joy) > 1) setid (uid, num, ID_BUTTON_OFFSET + 2, 0, port, port ? INPUTEVENT_JOY2_3RD_BUTTON : INPUTEVENT_JOY1_3RD_BUTTON); } #if 0 for (int32_t j = 2; j < MAX_MAPPINGS - 1; j++) { int32_t am = did->axismappings[j]; if (am == DIJOFS_POV(0) || am == DIJOFS_POV(1) || am == DIJOFS_POV(2) || am == DIJOFS_POV(3)) { setid (uid, num, ID_AXIS_OFFSET + j + 0, 0, port, h); setid (uid, num, ID_AXIS_OFFSET + j + 1, 0, port, v); j++; } } #endif if (mode == JSEM_MODE_JOYSTICK_CD32) { setid_af (uid, num, ID_BUTTON_OFFSET + 0, 0, port, port ? INPUTEVENT_JOY2_CD32_RED : INPUTEVENT_JOY1_CD32_RED, af); setid_af (uid, num, ID_BUTTON_OFFSET + 0, 1, port, port ? INPUTEVENT_JOY2_FIRE_BUTTON : INPUTEVENT_JOY1_FIRE_BUTTON, af); if (SDL_JoystickNumButtons(joy) > 0) { setid (uid, num, ID_BUTTON_OFFSET + 1, 0, port, port ? INPUTEVENT_JOY2_CD32_BLUE : INPUTEVENT_JOY1_CD32_BLUE); setid (uid, num, ID_BUTTON_OFFSET + 1, 1, port, port ? INPUTEVENT_JOY2_2ND_BUTTON : INPUTEVENT_JOY1_2ND_BUTTON); } if (SDL_JoystickNumButtons(joy) > 1) setid (uid, num, ID_BUTTON_OFFSET + 2, 0, port, port ? INPUTEVENT_JOY2_CD32_GREEN : INPUTEVENT_JOY1_CD32_GREEN); if (SDL_JoystickNumButtons(joy) > 2) setid (uid, num, ID_BUTTON_OFFSET + 3, 0, port, port ? INPUTEVENT_JOY2_CD32_YELLOW : INPUTEVENT_JOY1_CD32_YELLOW); if (SDL_JoystickNumButtons(joy) > 3) setid (uid, num, ID_BUTTON_OFFSET + 4, 0, port, port ? INPUTEVENT_JOY2_CD32_RWD : INPUTEVENT_JOY1_CD32_RWD); if (SDL_JoystickNumButtons(joy) > 4) setid (uid, num, ID_BUTTON_OFFSET + 5, 0, port, port ? INPUTEVENT_JOY2_CD32_FFW : INPUTEVENT_JOY1_CD32_FFW); if (SDL_JoystickNumButtons(joy) > 5) setid (uid, num, ID_BUTTON_OFFSET + 6, 0, port, port ? INPUTEVENT_JOY2_CD32_PLAY : INPUTEVENT_JOY1_CD32_PLAY); } if (num == 0) return 1; return 0; }
HealerAI::HealerAI() { animationMap = ReadWritePack::readAnimationMap("healer.am"); setAnimationFrames("down"); setid("HealerAI"); }
// assignment from stat (creates a new fileid) void assign(const char* fileid, struct stat& st) { setid(fileid); add(st); }
event_t(uint event, F fcptr) : type(evenfcptr<F>::type), ok(true), postuninstall(false), executing(false), filename(NULL), event(event), codestring(NULL), code(NULL), calls(0), fcptr((void*)fcptr) { setid(); }
void emuinit(void *imod) { Osenv *e; char *wdir; e = up->env; e->pgrp = newpgrp(); e->fgrp = newfgrp(nil); e->egrp = newegrp(); e->errstr = e->errbuf0; e->syserrstr = e->errbuf1; e->user = strdup(""); links(); chandevinit(); if(waserror()) panic("setting root and dot"); e->pgrp->slash = namec("#/", Atodir, 0, 0); cnameclose(e->pgrp->slash->name); e->pgrp->slash->name = newcname("/"); e->pgrp->dot = cclone(e->pgrp->slash); poperror(); strcpy(up->text, "main"); if(kopen("#c/cons", OREAD) != 0) fprint(2, "failed to make fd0 from #c/cons: %r\n"); kopen("#c/cons", OWRITE); kopen("#c/cons", OWRITE); /* the setid cannot precede the bind of #U */ kbind("#U", "/", MAFTER|MCREATE); setid(eve, 0); kbind("#^", "/dev", MBEFORE); /* snarf */ kbind("#^", "/chan", MBEFORE); kbind("#m", "/dev", MBEFORE); /* pointer */ kbind("#c", "/dev", MBEFORE); kbind("#p", "/prog", MREPL); kbind("#d", "/fd", MREPL); kbind("#I", "/net", MAFTER); /* will fail on Plan 9 */ /* BUG: we actually only need to do these on Plan 9 */ kbind("#U/dev", "/dev", MAFTER); kbind("#U/net", "/net", MAFTER); kbind("#U/net.alt", "/net.alt", MAFTER); if(cputype != nil) ksetenv("cputype", cputype, 1); putenvqv("emuargs", rebootargv, rebootargc, 1); putenvq("emuroot", rootdir, 1); ksetenv("emuhost", hosttype, 1); wdir = malloc(1024); if(wdir != nil){ if(getwd(wdir, 1024) != nil) putenvq("emuwdir", wdir, 1); free(wdir); } kproc("main", disinit, imod, KPDUPFDG|KPDUPPG|KPDUPENVG); for(;;) ospause(); }
int input_get_default_joystick (struct uae_input_device *uid, int num, int port, int af, int mode) { int h,v; unsigned int j; struct didata *did; //SDL_Joystick *joy; //joy = joys[i].joy; write_log("input_get_default_joystick num=%d port=%d af=%d mode=%d\n", num, port, af, mode); /* if (i >= get_joystick_num ()) return 0; */ if (mode == JSEM_MODE_MOUSE_CDTV) { h = INPUTEVENT_MOUSE_CDTV_HORIZ; v = INPUTEVENT_MOUSE_CDTV_VERT; } else if (port >= 2) { h = port == 3 ? INPUTEVENT_PAR_JOY2_HORIZ : INPUTEVENT_PAR_JOY1_HORIZ; v = port == 3 ? INPUTEVENT_PAR_JOY2_VERT : INPUTEVENT_PAR_JOY1_VERT; } else { h = port ? INPUTEVENT_JOY2_HORIZ : INPUTEVENT_JOY1_HORIZ;; v = port ? INPUTEVENT_JOY2_VERT : INPUTEVENT_JOY1_VERT; } setid (uid, num, ID_AXIS_OFFSET + 0, 0, port, h); setid (uid, num, ID_AXIS_OFFSET + 1, 0, port, v); if (port >= 2) { setid_af (uid, num, ID_BUTTON_OFFSET + 0, 0, port, port == 3 ? INPUTEVENT_PAR_JOY2_FIRE_BUTTON : INPUTEVENT_PAR_JOY1_FIRE_BUTTON, af); } else { setid_af (uid, num, ID_BUTTON_OFFSET + 0, 0, port, port ? INPUTEVENT_JOY2_FIRE_BUTTON : INPUTEVENT_JOY1_FIRE_BUTTON, af); setid (uid, num, ID_BUTTON_OFFSET + 1, 0, port, port ? INPUTEVENT_JOY2_2ND_BUTTON : INPUTEVENT_JOY1_2ND_BUTTON); setid (uid, num, ID_BUTTON_OFFSET + 2, 0, port, port ? INPUTEVENT_JOY2_3RD_BUTTON : INPUTEVENT_JOY1_3RD_BUTTON); } if (mode == JSEM_MODE_JOYSTICK_CD32) { setid_af (uid, num, ID_BUTTON_OFFSET + 0, 0, port, port ? INPUTEVENT_JOY2_CD32_RED : INPUTEVENT_JOY1_CD32_RED, af); setid_af (uid, num, ID_BUTTON_OFFSET + 0, 1, port, port ? INPUTEVENT_JOY2_FIRE_BUTTON : INPUTEVENT_JOY1_FIRE_BUTTON, af); setid (uid, num, ID_BUTTON_OFFSET + 1, 0, port, port ? INPUTEVENT_JOY2_CD32_BLUE : INPUTEVENT_JOY1_CD32_BLUE); setid (uid, num, ID_BUTTON_OFFSET + 1, 1, port, port ? INPUTEVENT_JOY2_2ND_BUTTON : INPUTEVENT_JOY1_2ND_BUTTON); setid (uid, num, ID_BUTTON_OFFSET + 2, 0, port, port ? INPUTEVENT_JOY2_CD32_GREEN : INPUTEVENT_JOY1_CD32_GREEN); setid (uid, num, ID_BUTTON_OFFSET + 3, 0, port, port ? INPUTEVENT_JOY2_CD32_YELLOW : INPUTEVENT_JOY1_CD32_YELLOW); setid (uid, num, ID_BUTTON_OFFSET + 4, 0, port, port ? INPUTEVENT_JOY2_CD32_RWD : INPUTEVENT_JOY1_CD32_RWD); setid (uid, num, ID_BUTTON_OFFSET + 5, 0, port, port ? INPUTEVENT_JOY2_CD32_FFW : INPUTEVENT_JOY1_CD32_FFW); setid (uid, num, ID_BUTTON_OFFSET + 6, 0, port, port ? INPUTEVENT_JOY2_CD32_PLAY : INPUTEVENT_JOY1_CD32_PLAY); } if (num == 0) { return 1; } return 0; }
long conswrite(Chan *c, void *va, long count, vlong offset) { char buf[128], *p; int x, y; USED(offset); if(c->qid.type & QTDIR) error(Eperm); switch((ulong)c->qid.path) { default: error(Egreg); case Qcons: if(canrlock(&kprintq.l)){ if(kprintq.q != nil){ if(waserror()){ runlock(&kprintq.l); nexterror(); } qwrite(kprintq.q, va, count); poperror(); runlock(&kprintq.l); return count; } runlock(&kprintq.l); } return write(1, va, count); case Qsysctl: return sysconwrite(va, count); case Qconsctl: if(count >= sizeof(buf)) count = sizeof(buf)-1; strncpy(buf, va, count); buf[count] = 0; if(strncmp(buf, "rawon", 5) == 0) { kbd.raw = 1; return count; } else if(strncmp(buf, "rawoff", 6) == 0) { kbd.raw = 0; return count; } error(Ebadctl); case Qkeyboard: for(x=0; x<count; ) { Rune r; x += chartorune(&r, &((char*)va)[x]); gkbdputc(gkbdq, r); } return count; case Qpointer: if(count > sizeof buf-1) count = sizeof buf -1; memmove(buf, va, count); buf[count] = 0; p = nil; x = strtoul(buf+1, &p, 0); if(p == nil || p == buf+1) error(Eshort); y = strtoul(p, 0, 0); setpointer(x, y); return count; case Qnull: return count; case Qpin: if(up->env->pgrp->pin != Nopin) error("pin already set"); if(count >= sizeof(buf)) count = sizeof(buf)-1; strncpy(buf, va, count); buf[count] = '\0'; up->env->pgrp->pin = atoi(buf); return count; case Qtime: if(count >= sizeof(buf)) count = sizeof(buf)-1; strncpy(buf, va, count); buf[count] = '\0'; timeoffset = strtoll(buf, 0, 0)-osusectime(); return count; case Quser: if(count >= sizeof(buf)) error(Ebadarg); strncpy(buf, va, count); buf[count] = '\0'; if(count > 0 && buf[count-1] == '\n') buf[--count] = '\0'; if(count == 0) error(Ebadarg); if(strcmp(up->env->user, eve) != 0) error(Eperm); setid(buf, 0); return count; case Qhostowner: if(count >= sizeof(buf)) error(Ebadarg); strncpy(buf, va, count); buf[count] = '\0'; if(count > 0 && buf[count-1] == '\n') buf[--count] = '\0'; if(count == 0) error(Ebadarg); if(strcmp(up->env->user, eve) != 0) error(Eperm); kstrdup(&eve, buf); return count; case Qhoststdout: return write(1, va, count); case Qhoststderr: return write(2, va, count); case Qjit: if(count >= sizeof(buf)) count = sizeof(buf)-1; strncpy(buf, va, count); buf[count] = '\0'; x = atoi(buf); if (x < 0 || x > 9) error(Ebadarg); cflag = x; return count; case Qsysname: if(count >= sizeof(buf)) count = sizeof(buf)-1; strncpy(buf, va, count); buf[count] = '\0'; kstrdup(&ossysname, buf); return count; case Qsnarf: if(offset+count >= SnarfSize) error(Etoobig); snarftab->qid.vers++; memmove((uchar*)(c->aux)+offset, va, count); return count; } return 0; }