Esempio n. 1
0
static NEINT32 reg_map_server(NEUINT16 sessionid, ne_handle listener)
{
	ne_usermsgbuf_t buf;
	NEINT32 ret = -1;
	reg_mapserver_t *data = (reg_mapserver_t *)buf.data;
	
	data->id = get_mapid();
	data->box = get_mapbox();

	NE_USERMSG_MAXID(&buf) = MAXID_SERVER_SERVER ;
	NE_USERMSG_MINID(&buf) = MSG_SERVER_REG;
	NE_USERMSG_LEN(&buf) = NE_USERMSG_HDRLEN + sizeof(reg_mapserver_t);
	NE_USERMSG_PARAM(&buf) = 0;
	NE_USERMSG_ENCRYPT(&buf) = 0;
	ret = NE_SENDEX(sessionid, (ne_usermsghdr_t *)&buf, ESF_URGENCY, listener);
	if (ret == NE_USERMSG_LEN(&buf)) {
		ret = 0;
	}
	return (ret);
}
Esempio n. 2
0
bool create_joymap_from_string(int player,char *jconf) {
	char *v;
	char butid[32]={0,};
	char jevt;
	int code;
	int jid;
	int rc;
	char type;
	//printf("Jconf=%s\n",jconf);
	if (jconf==NULL) return 0;
	v=strdup(jconf);
	v=strtok(v,",");
	//printf("V1=%s\n",v);
	while(v) {
		rc=sscanf(v,"%[A-Z1-4]=%c%d%c%d",butid,&type,&jid,&jevt,&code);
		if (rc==3 && type=='K') { /* Keyboard */
			//printf("%s | keycode %d\n",butid,jid);
			code=jid;
			if (code<SDLK_LAST) {
				jmap->key[code].player=player;
				jmap->key[code].map=get_mapid(butid);
			}
			//printf("%d\n",get_mapid(butid));
		}
		if (rc==5 && type=='J') {
			printf("%d, %s | joy no %d | evt %c | %d\n",
			rc,butid,jid,jevt,code);
			if (jid<conf.nb_joy) {
				switch(jevt) {
				case 'A':
					if (code<SDL_JoystickNumAxes(conf.joy[jid])) {
						jmap->jaxe[jid][code].player=player;
						jmap->jaxe[jid][code].map=get_mapid(butid);
						jmap->jaxe[jid][code].dir=1;
					}
					break;
				case 'a': /* Inverted axis */
					if (code<SDL_JoystickNumAxes(conf.joy[jid])) {
						jmap->jaxe[jid][code].player=player;
						jmap->jaxe[jid][code].map=get_mapid(butid);
						jmap->jaxe[jid][code].dir=-1;
					}
					break;
				case 'H':
					if (code<SDL_JoystickNumHats(conf.joy[jid])) {
						jmap->jhat[jid][code].player=player;
						jmap->jhat[jid][code].map=get_mapid(butid);
					}
					break;
				case 'B':
					if (code<SDL_JoystickNumButtons(conf.joy[jid])) {
						jmap->jbutton[jid][code].player=player;
						jmap->jbutton[jid][code].map=get_mapid(butid);
					}
					break;
				}
			}
		}

		v=strtok(NULL,",");
	}
  
	return true;
}