SDLInputJoystick(int DeviceIndex) : DeviceIndex(DeviceIndex), Multiplier(1.0f) { Device = SDL_JoystickOpen(DeviceIndex); if(Device != NULL) { NumAxes = SDL_JoystickNumAxes(Device); NumHats = SDL_JoystickNumHats(Device); SetDefaultConfig(); } }
Keyboard::Keyboard() : ManMachineInterface() , modifier_bits(0) , modifier_only_bits(0) { //Disable repeated events when a key is kept down SDL_EnableKeyRepeat(0,0); SetDefaultConfig(); // Registring SDL event RegisterEvent(SDL_KEYDOWN); RegisterEvent(SDL_KEYUP); }
CameraMgr::CameraMgr() { // TODO Auto-generated constructor stub Cam = new Camera(); SetDefaultConfig(); }
int main(int argc, char **argv) { char text[256]; int i; #ifdef _WIN32 HMODULE hLib; WSADATA wsadata; WSAStartup(0x0202, &wsadata); InitUptimePerfCounter(); hLib = LoadLibrary("advapi32.dll"); if (hLib) lpfnRtlGenRandom = (_RtlGenRandom)GetProcAddress(hLib, "SystemFunction036"); #ifdef _DEBUG _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_CHECK_CRT_DF | _CRTDBG_ALLOC_MEM_DF); #endif #endif GetOS(text); printf("\n -- Phyros " BOT_VER " -- %s --\n\n", text); loadedtime = getuptime(); #ifndef _WIN32 SetPipeSignalHandler(); if (getuid() == 0) { printf("WARNING: should not be running as root!\n"); setuid(GetUidFromUsername("nobody")); } //////should set the group id instead so files can be modified at runtime #endif botpluser = malloc(sizeof(LUSER)); botpluser->access = 103; strcpy(botpluser->username, "the bot"); maintid = get_self_tid(); #ifndef _DEBUG SetSegvSignalHandler(); #endif tagbans[WCP_BACK] = RadixInit(); tagbans[WCP_FRONT] = RadixInit(); tagbans[WCP_BOTH] = RadixInit(); phrases = RadixInit(); cdkeys = VectorInit(8); //banqueue = malloc(BANQUEUE_INITIALSIZE * sizeof(char *)); //bqsize = BANQUEUE_INITIALSIZE; SetDefaultConfig(); LoadConfig(); LoadUsers(); LoadCDKeys(); GetRealms(); BlacklistLoad(); LoadPhrases(); CmdTreeInit(); LoadAccessModifications(); ParseCmdLine(argc, argv); for (i = 0; i != 3; i++) { if (!hashes[i][0]) { gstate |= GFS_USEBNLS; printf("WARNING: path for binary \'%s\' not set, falling back to BNLS checkrevision\n", hash_filenames[i]); break; } } if (gstate & GFS_CHECKUPDATES) { printf(" - checking %s%s for updates...\n", updatesite, updateverfile); printf("%s\n", updateresult[CheckUpdate(updatesite, updateverfile)]); } CreateAsyncTimer(); ptimertid = _CreateThread(PeriodicTimerWaitProc, NULL); AddPeriodicTimer(TIMER_NULLPKT, 10, NullPacketTimerProc); setjmp(jmpenv); ////////////////////////////////////////////TEST BATTERY////////////////////////////////////// /*ChatHandleChannel("Clan Blah", 0, 0); //ChatHandleJoin("loladfg", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladf1aaaaaaaaaa", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladf2bbbbbfffe", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladf3", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladf4", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladf5", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladf6", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladf7", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladf8", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladf9", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladfa", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladfb", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladfc", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladfd", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); */ /*printf("%x\n", FindTextInWildcards(tagbans, "asdfgdfg")); printf("%x\n", FindTextInWildcards(tagbans, "as[tg]gdfg")); printf("%x\n", FindTextInWildcards(tagbans, "asdfgdfg[tg]")); printf("%x\n", FindTextInWildcards(tagbans, "asdfgdfg")); printf("%x\n", FindPhraseban(phrases, "raiasdfdasdfzomgzasdfasdfasdfasdf")); printf("%x\n", FindPhraseban(phrases, "raiasdfgdfgbloop")); printf("%x\n", FindPhraseban(phrases, "bloo asfukdfgdfg zomg"));*/ ///////////////////////////////////////////////////////////////////////////////////////////// while (1) { fgets(text, sizeof(text), stdin); text[strlen(text) - 1] = 0; if (*(int16_t *)text == '//') CheckCommand(NULL, text, 0, 0); else QueueAdd(text, curbotinc()); } return 0; }
void LoadPADConfig() { FILE *fp; char buf[256]; int current, a, b, c; SetDefaultConfig(); fp = fopen(CONFIG_FILE, "r"); if (fp == NULL) { return; } current = 0; while (fgets(buf, 256, fp) != NULL) { if (strncmp(buf, "Threaded=", 9) == 0) { g.cfg.Threaded = atoi(&buf[9]); } else if (strncmp(buf, "HideCursor=", 11) == 0) { g.cfg.HideCursor = atoi(&buf[11]); } else if (strncmp(buf, "[PAD", 4) == 0) { current = atoi(&buf[4]) - 1; if (current < 0) { current = 0; } else if (current > 1) { current = 1; } } else if (strncmp(buf, "DevNum=", 7) == 0) { g.cfg.PadDef[current].DevNum = atoi(&buf[7]); } else if (strncmp(buf, "Type=", 5) == 0) { g.cfg.PadDef[current].Type = atoi(&buf[5]); } else if (strncmp(buf, "VisualVibration=", 16) == 0) { g.cfg.PadDef[current].VisualVibration = atoi(&buf[16]); } else if (strncmp(buf, "Select=", 7) == 0) { sscanf(buf, "Select=%d,%d,%d", &a, &b, &c); g.cfg.PadDef[current].KeyDef[DKEY_SELECT].Key = a; g.cfg.PadDef[current].KeyDef[DKEY_SELECT].JoyEvType = b; g.cfg.PadDef[current].KeyDef[DKEY_SELECT].J.d = c; } else if (strncmp(buf, "L3=", 3) == 0) { sscanf(buf, "L3=%d,%d,%d", &a, &b, &c); g.cfg.PadDef[current].KeyDef[DKEY_L3].Key = a; g.cfg.PadDef[current].KeyDef[DKEY_L3].JoyEvType = b; g.cfg.PadDef[current].KeyDef[DKEY_L3].J.d = c; } else if (strncmp(buf, "R3=", 3) == 0) { sscanf(buf, "R3=%d,%d,%d", &a, &b, &c); g.cfg.PadDef[current].KeyDef[DKEY_R3].Key = a; g.cfg.PadDef[current].KeyDef[DKEY_R3].JoyEvType = b; g.cfg.PadDef[current].KeyDef[DKEY_R3].J.d = c; } else if (strncmp(buf, "Analog=", 7) == 0) { sscanf(buf, "Analog=%d,%d,%d", &a, &b, &c); g.cfg.PadDef[current].KeyDef[DKEY_ANALOG].Key = a; g.cfg.PadDef[current].KeyDef[DKEY_ANALOG].JoyEvType = b; g.cfg.PadDef[current].KeyDef[DKEY_ANALOG].J.d = c; } else if (strncmp(buf, "Start=", 6) == 0) { sscanf(buf, "Start=%d,%d,%d", &a, &b, &c); g.cfg.PadDef[current].KeyDef[DKEY_START].Key = a; g.cfg.PadDef[current].KeyDef[DKEY_START].JoyEvType = b; g.cfg.PadDef[current].KeyDef[DKEY_START].J.d = c; } else if (strncmp(buf, "Up=", 3) == 0) { sscanf(buf, "Up=%d,%d,%d", &a, &b, &c); g.cfg.PadDef[current].KeyDef[DKEY_UP].Key = a; g.cfg.PadDef[current].KeyDef[DKEY_UP].JoyEvType = b; g.cfg.PadDef[current].KeyDef[DKEY_UP].J.d = c; } else if (strncmp(buf, "Right=", 6) == 0) { sscanf(buf, "Right=%d,%d,%d", &a, &b, &c); g.cfg.PadDef[current].KeyDef[DKEY_RIGHT].Key = a; g.cfg.PadDef[current].KeyDef[DKEY_RIGHT].JoyEvType = b; g.cfg.PadDef[current].KeyDef[DKEY_RIGHT].J.d = c; } else if (strncmp(buf, "Down=", 5) == 0) { sscanf(buf, "Down=%d,%d,%d", &a, &b, &c); g.cfg.PadDef[current].KeyDef[DKEY_DOWN].Key = a; g.cfg.PadDef[current].KeyDef[DKEY_DOWN].JoyEvType = b; g.cfg.PadDef[current].KeyDef[DKEY_DOWN].J.d = c; } else if (strncmp(buf, "Left=", 5) == 0) { sscanf(buf, "Left=%d,%d,%d", &a, &b, &c); g.cfg.PadDef[current].KeyDef[DKEY_LEFT].Key = a; g.cfg.PadDef[current].KeyDef[DKEY_LEFT].JoyEvType = b; g.cfg.PadDef[current].KeyDef[DKEY_LEFT].J.d = c; } else if (strncmp(buf, "L2=", 3) == 0) { sscanf(buf, "L2=%d,%d,%d", &a, &b, &c); g.cfg.PadDef[current].KeyDef[DKEY_L2].Key = a; g.cfg.PadDef[current].KeyDef[DKEY_L2].JoyEvType = b; g.cfg.PadDef[current].KeyDef[DKEY_L2].J.d = c; } else if (strncmp(buf, "R2=", 3) == 0) { sscanf(buf, "R2=%d,%d,%d", &a, &b, &c); g.cfg.PadDef[current].KeyDef[DKEY_R2].Key = a; g.cfg.PadDef[current].KeyDef[DKEY_R2].JoyEvType = b; g.cfg.PadDef[current].KeyDef[DKEY_R2].J.d = c; } else if (strncmp(buf, "L1=", 3) == 0) { sscanf(buf, "L1=%d,%d,%d", &a, &b, &c); g.cfg.PadDef[current].KeyDef[DKEY_L1].Key = a; g.cfg.PadDef[current].KeyDef[DKEY_L1].JoyEvType = b; g.cfg.PadDef[current].KeyDef[DKEY_L1].J.d = c; } else if (strncmp(buf, "R1=", 3) == 0) { sscanf(buf, "R1=%d,%d,%d", &a, &b, &c); g.cfg.PadDef[current].KeyDef[DKEY_R1].Key = a; g.cfg.PadDef[current].KeyDef[DKEY_R1].JoyEvType = b; g.cfg.PadDef[current].KeyDef[DKEY_R1].J.d = c; } else if (strncmp(buf, "Triangle=", 9) == 0) { sscanf(buf, "Triangle=%d,%d,%d", &a, &b, &c); g.cfg.PadDef[current].KeyDef[DKEY_TRIANGLE].Key = a; g.cfg.PadDef[current].KeyDef[DKEY_TRIANGLE].JoyEvType = b; g.cfg.PadDef[current].KeyDef[DKEY_TRIANGLE].J.d = c; } else if (strncmp(buf, "Circle=", 7) == 0) { sscanf(buf, "Circle=%d,%d,%d", &a, &b, &c); g.cfg.PadDef[current].KeyDef[DKEY_CIRCLE].Key = a; g.cfg.PadDef[current].KeyDef[DKEY_CIRCLE].JoyEvType = b; g.cfg.PadDef[current].KeyDef[DKEY_CIRCLE].J.d = c; } else if (strncmp(buf, "Cross=", 6) == 0) { sscanf(buf, "Cross=%d,%d,%d", &a, &b, &c); g.cfg.PadDef[current].KeyDef[DKEY_CROSS].Key = a; g.cfg.PadDef[current].KeyDef[DKEY_CROSS].JoyEvType = b; g.cfg.PadDef[current].KeyDef[DKEY_CROSS].J.d = c; } else if (strncmp(buf, "Square=", 7) == 0) { sscanf(buf, "Square=%d,%d,%d", &a, &b, &c); g.cfg.PadDef[current].KeyDef[DKEY_SQUARE].Key = a; g.cfg.PadDef[current].KeyDef[DKEY_SQUARE].JoyEvType = b; g.cfg.PadDef[current].KeyDef[DKEY_SQUARE].J.d = c; } else if (strncmp(buf, "LeftAnalogXP=", 13) == 0) { sscanf(buf, "LeftAnalogXP=%d,%d,%d", &a, &b, &c); g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XP].Key = a; g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XP].JoyEvType = b; g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XP].J.d = c; } else if (strncmp(buf, "LeftAnalogXM=", 13) == 0) { sscanf(buf, "LeftAnalogXM=%d,%d,%d", &a, &b, &c); g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XM].Key = a; g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XM].JoyEvType = b; g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XM].J.d = c; } else if (strncmp(buf, "LeftAnalogYP=", 13) == 0) { sscanf(buf, "LeftAnalogYP=%d,%d,%d", &a, &b, &c); g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YP].Key = a; g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YP].JoyEvType = b; g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YP].J.d = c; } else if (strncmp(buf, "LeftAnalogYM=", 13) == 0) { sscanf(buf, "LeftAnalogYM=%d,%d,%d", &a, &b, &c); g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YM].Key = a; g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YM].JoyEvType = b; g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YM].J.d = c; } else if (strncmp(buf, "RightAnalogXP=", 14) == 0) { sscanf(buf, "RightAnalogXP=%d,%d,%d", &a, &b, &c); g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XP].Key = a; g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XP].JoyEvType = b; g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XP].J.d = c; } else if (strncmp(buf, "RightAnalogXM=", 14) == 0) { sscanf(buf, "RightAnalogXM=%d,%d,%d", &a, &b, &c); g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XM].Key = a; g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XM].JoyEvType = b; g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XM].J.d = c; } else if (strncmp(buf, "RightAnalogYP=", 14) == 0) { sscanf(buf, "RightAnalogYP=%d,%d,%d", &a, &b, &c); g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YP].Key = a; g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YP].JoyEvType = b; g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YP].J.d = c; } else if (strncmp(buf, "RightAnalogYM=", 14) == 0) { sscanf(buf, "RightAnalogYM=%d,%d,%d", &a, &b, &c); g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YM].Key = a; g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YM].JoyEvType = b; g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YM].J.d = c; } } fclose(fp); }