static void m_help(struct Luser *lptr, struct NickInfo *nptr, int ac, char **av) { if (ac >= 2) { char str[MAXLINE]; struct Command *cptr; for (cptr = memocmds; cptr->cmd; cptr++) if (!irccmp(av[1], cptr->cmd)) break; if (cptr->cmd) if ((cptr->level == LVL_ADMIN) && !(IsValidAdmin(lptr))) { notice(n_MemoServ, lptr->nick, "No help available on \002%s\002", av[1]); return; } ircsprintf(str, "%s", av[1]); GiveHelp(n_MemoServ, lptr->nick, str, NODCC); } else GiveHelp(n_MemoServ, lptr->nick, NULL, NODCC); } /* m_help() */
static void ss_help(struct Luser *lptr, int ac, char **av) { if (ac >= 2) { char str[MAXLINE + 1]; struct Command *sptr; for (sptr = statcmds; sptr->cmd; sptr++) if (!irccmp(av[1], sptr->cmd)) break; if (sptr->cmd) if ((sptr->level == LVL_ADMIN) && !(IsValidAdmin(lptr))) { notice(n_StatServ, lptr->nick, "No help available on \002%s\002", av[1]); return; } ircsprintf(str, "%s", av[1]); GiveHelp(n_StatServ, lptr->nick, str, NODCC); } else GiveHelp(n_StatServ, lptr->nick, NULL, NODCC); } /* ss_help() */
void JOYSTICKGetNumButtons(int nlhs, mxArray *plhs[], int nrhs, CONSTmxArray *prhs[]) { ProjectTable *joystickTable=GetProjectTable(); int numSticks; CONSTmxArray *numArg; double stickNum; SDL_Joystick *pStick; prhs; if(joystickTable->giveHelp){GiveHelp(useGetNumButtons,synopsisGetNumButtons);return;} numArg = joystickTable->joystickNumberArgument; if(numArg == NULL || nlhs > 1 || nrhs > 0 || !mxIsDouble(numArg) || (mxGetM(numArg) * mxGetN(numArg) != 1)) GiveUsageExit(useGetNumButtons); numSticks = SDL_NumJoysticks(); stickNum = mxGetPr(numArg)[0]; if(stickNum > numSticks) PrintfExit("The joystick number %d passed to JOYSTICK 'GetNumButtons' exceeds the number of joysticks, %d",stickNum,numSticks); if(stickNum < 1) PrintfExit("The joystick number passed to JOYSTICK 'GetNumButtons' must be greater than 0"); pStick = GetJoystickObjFromNum((int)stickNum-1); if(pStick == NULL) PrintfExit("JOYSTICK 'GetNumButtons' can not open joystick number %d",stickNum); plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); mxGetPr(plhs[0])[0] = SDL_JoystickNumButtons(pStick); }
void JOYSTICKGetAxis(int nlhs, mxArray *plhs[], int nrhs, CONSTmxArray *prhs[]) { ProjectTable *joystickTable=GetProjectTable(); int numSticks, numAxes, fetchedAxis; CONSTmxArray *numArg; double stickNum; SDL_Joystick *pStick; if(joystickTable->giveHelp){GiveHelp(useGetAxis,synopsisGetAxis);return;} numArg = joystickTable->joystickNumberArgument; if(numArg == NULL || nlhs > 1 || nrhs > 1 || nrhs < 1 || !mxIsDouble(numArg) || (mxGetM(numArg) * mxGetN(numArg) != 1 || !mxIsDouble(prhs[0]) || mxGetM(prhs[0]) * mxGetN(prhs[0]) != 1)){ GiveUsageExit(useGetAxis); } numSticks = SDL_NumJoysticks(); stickNum = mxGetPr(numArg)[0]; if(stickNum > numSticks) PrintfExit("The joystick number %d passed to JOYSTICK 'GetAxis' exceeds the number of joysticks, %d",stickNum,numSticks); if(stickNum < 1) PrintfExit("The joystick number passed to JOYSTICK 'GetButton' must be greater than 0"); pStick = GetJoystickObjFromNum((int)stickNum-1); if(pStick == NULL) PrintfExit("JOYSTICK 'GetAxis' can not open joystick number %d",stickNum); numAxes = SDL_JoystickNumAxes(pStick); fetchedAxis = (int)mxGetPr(prhs[0])[0]; if(fetchedAxis > numAxes || fetchedAxis < 0) PrintfExit("The axis number %d passed to JOYSTICK 'GetAxis' is oustide the allowable range",fetchedAxis); plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); SDL_JoystickUpdate(); mxGetPr(plhs[0])[0] = SDL_JoystickGetAxis(pStick, fetchedAxis-1); }
void JOYSTICKGetNumJoysticks(int nlhs, mxArray *plhs[], int nrhs, CONSTmxArray *prhs[]) { ProjectTable *joystickTable=GetProjectTable(); int numJoysticks; plhs; prhs; if(joystickTable->giveHelp){GiveHelp(useGetNumJoysticks,synopsisGetNumJoysticks);return;} if (joystickTable->joystickNumberArgument != NULL || nlhs > 1 || nrhs > 0) GiveUsageExit(useGetNumJoysticks); plhs[0]=mxCreateDoubleMatrix(1,1,mxREAL); numJoysticks = SDL_NumJoysticks(); mxGetPr(plhs[0])[0]=(double)numJoysticks; }
void JOYSTICKGetHat(int nlhs, mxArray *plhs[], int nrhs, CONSTmxArray *prhs[]) { ProjectTable *joystickTable=GetProjectTable(); int numSticks, numHats, fetchedHat; CONSTmxArray *numArg; double stickNum; SDL_Joystick *pStick; Uint8 hatVal; if(joystickTable->giveHelp){GiveHelp(useGetHat,synopsisGetHat);return;} numArg = joystickTable->joystickNumberArgument; if(numArg == NULL || nlhs > 1 || nrhs > 1 || nrhs < 1 || !mxIsDouble(numArg) || (mxGetM(numArg) * mxGetN(numArg) != 1 || !mxIsDouble(prhs[0]) || (mxGetM(prhs[0]) * mxGetN(prhs[0])) != 1)){ GiveUsageExit(useGetHat); } numSticks = SDL_NumJoysticks(); stickNum = mxGetPr(numArg)[0]; if(stickNum > numSticks) PrintfExit("The joystick number %d passed to JOYSTICK 'GetHat' exceeds the number of joysticks, %d",stickNum,numSticks); if(stickNum < 1) PrintfExit("The joystick number passed to JOYSTICK 'GetHat' must be greater than 0"); pStick = GetJoystickObjFromNum((int)stickNum-1); if(pStick == NULL) PrintfExit("JOYSTICK 'GetHat' can not open joystick number %d",stickNum); numHats = SDL_JoystickNumHats(pStick); fetchedHat = (int)mxGetPr(prhs[0])[0]; if(fetchedHat > numHats || fetchedHat < 0) PrintfExit("The axis number %d passed to JOYSTICK 'GetHat' is oustide the allowable range",fetchedHat); SDL_JoystickUpdate(); hatVal = SDL_JoystickGetHat(pStick, fetchedHat-1); plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); switch(hatVal){ case SDL_HAT_CENTERED: mxGetPr(plhs[0])[0] = 0; break; case SDL_HAT_UP: mxGetPr(plhs[0])[0] = 1; break; case SDL_HAT_RIGHT: mxGetPr(plhs[0])[0] = 2; break; case SDL_HAT_DOWN: mxGetPr(plhs[0])[0] = 3; break; case SDL_HAT_LEFT: mxGetPr(plhs[0])[0] = 4; break; case SDL_HAT_RIGHTUP: mxGetPr(plhs[0])[0] = 5; break; case SDL_HAT_RIGHTDOWN: mxGetPr(plhs[0])[0] = 6; break; case SDL_HAT_LEFTUP: mxGetPr(plhs[0])[0] = 7; break; case SDL_HAT_LEFTDOWN: mxGetPr(plhs[0])[0] = 8; break; } }
static void hs_givehelp(struct Luser *lptr, int ac, char **av) { struct Luser *serviceptr; if (!irccmp(av[0], "HELP")) { if (ac >= 2) GiveHelp(n_HelpServ, lptr->nick, av[1], NODCC); else GiveHelp(n_HelpServ, lptr->nick, NULL, NODCC); } else { char str[MAXLINE + 1]; if (!(serviceptr = GetService(av[0]))) { /* * this shouldn't happen unless they entered a partial * service nick, and the abbreviation code allowed it * to go through */ notice(n_HelpServ, lptr->nick, "[\002%s\002] is an invalid service nickname", av[0]); return; } if (ac < 2) strlcpy(str, "HELP", sizeof(str)); else if (ac >= 3) { ircsprintf(str, "HELP %s %s", av[1], av[2]); } else { ircsprintf(str, "HELP %s", av[1]); } if (serviceptr == Me.osptr) os_process(lptr->nick, str, NODCC); #ifdef NICKSERVICES if (serviceptr == Me.nsptr) ns_process(lptr->nick, str); #ifdef CHANNELSERVICES if (serviceptr == Me.csptr) cs_process(lptr->nick, str); #endif #ifdef MEMOSERVICES if (serviceptr == Me.msptr) ms_process(lptr->nick, str); #endif #endif /* NICKSERVICES */ #ifdef STATSERVICES if (serviceptr == Me.ssptr) ss_process(lptr->nick, str); #endif /* STATSERVICES */ #ifdef SEENSERVICES if (serviceptr == Me.esptr) es_process(lptr->nick, str); #endif /* SEENSERVICES */ #ifdef GLOBALSERVICES if (serviceptr == Me.gsptr) gs_process(lptr->nick, str); #endif /* GLOBALSERVICES */ } /* else */ } /* hs_givehelp() */