std::shared_ptr<mi::InputManager> mir::DefaultServerConfiguration::the_input_manager() { return input_manager( [this]() -> std::shared_ptr<mi::InputManager> { auto const options = the_options(); bool input_opt = options->get<bool>(options::enable_input_opt); // TODO nested input handling (== host_socket) should fold into a platform if (!input_opt || options->is_set(options::host_socket_opt)) { return std::make_shared<mi::NullInputManager>(); } else { auto platforms = probe_input_platforms(*options, the_emergency_cleanup(), the_input_device_registry(), the_input_report(), *the_shared_library_prober_report()); if (platforms.empty()) BOOST_THROW_EXCEPTION(std::runtime_error("No input platforms found")); auto const ret = std::make_shared<mi::DefaultInputManager>(the_input_reading_multiplexer()); for (auto & platform : platforms) ret->add_platform(std::move(platform)); return ret; } } ); }
// determine the list of supported platforms. // void CLIENT_STATE::detect_platforms() { #if defined(_WIN32) && !defined(__CYGWIN32__) #if defined(_WIN64) && defined(_M_X64) add_platform("windows_x86_64"); add_platform("windows_intelx86"); #else // see if 32-bit client is running on 64-bit machine // BOOL bIsWow64 = FALSE; fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress( GetModuleHandle(TEXT("kernel32")),"IsWow64Process" ); if (fnIsWow64Process) { if (fnIsWow64Process(GetCurrentProcess(), &bIsWow64)) { if (bIsWow64) { add_platform("windows_x86_64"); } } } add_platform("windows_intelx86"); #endif #elif defined(__APPLE__) #if defined(__i386__) || defined(__x86_64__) OSStatus err = noErr; SInt32 version = 0; int response = 0; int retval = 0; size_t len = sizeof(response); err = Gestalt(gestaltSystemVersion, &version); retval = sysctlbyname("hw.optional.x86_64", &response, &len, NULL, 0); if ((err == noErr) && (version >= 0x1050) && response && (!retval)) { HOSTTYPE = "x86_64-apple-darwin"; add_platform("x86_64-apple-darwin"); } else { HOSTTYPE = "i686-apple-darwin"; } // Supported on both Mac Intel architectures add_platform("i686-apple-darwin"); #endif // Supported on all 3 Mac architectures add_platform("powerpc-apple-darwin"); #elif defined(__linux__) && ( defined(__i386__) || defined(__x86_64__) ) // Let's try to support both 32 and 64 bit applications in one client // regardless of whether it is a 32 or 64 bit client const char *uname[]={"/bin/uname","/usr/bin/uname",0}; int eno=0, support64=0, support32=0; FILE *f; char cmdline[256]; cmdline[0]=0; // find the 'uname' executable do { if (boinc_file_exists(uname[eno])) break; } while (uname[++eno] != 0); // run it and check the kernel machine architecture. if ( uname[eno] != 0 ) { strlcpy(cmdline,uname[eno],256); strlcat(cmdline," -m",256); if ((f=popen(cmdline,"r"))) { while (!std::feof(f)) { fgets(cmdline,256,f); if (strstr(cmdline,"x86_64")) support64=1; } pclose(f); } if (!support64) { // we're running on a 32 bit kernel, so we will assume // we are i686-pc-linux-gnu only. support32=1; } else { // we're running on a 64 bit kernel. // Now comes the hard part. How to tell whether we can run // 32-bit binaries. #if defined(__i386__) && !defined(__x86_64__) // If we're a 32 bit binary, then we obviously can. support32=1; #else // If we're a 64 bit binary, the check is a bit harder. // We'll use the file command to check installation of // 32 bit libraries or executables. const char *file[]={"/usr/bin/file","/bin/file",0}; const char *libdir[]={"/lib","/lib32","/lib/32","/usr/lib","/usr/lib32","/usr/lib/32"}; const int nlibdirs=sizeof(libdir)/sizeof(char *); // find 'file' eno=0; do { if (boinc_file_exists(file[eno])) break; } while (file[++eno] != 0); // now try to find a 32-bit C library. if (file[eno] != 0) { int i; for (i=0; i < nlibdirs; i++) { struct dirent *entry; DIR *a = opendir(libdir[i]); // if dir doesn't exist, do to the next one if (a == 0) continue; // dir exists. read each entry until you find a 32bit lib while ((support32 == 0) && ((entry=readdir(a)) != 0)) { strlcpy(cmdline, file[eno], 256); strlcat(cmdline, " -L ", 256); strlcat(cmdline, libdir[i], 256); strlcat(cmdline, "/", 256); strlcat(cmdline, entry->d_name, 256); f = popen(cmdline, "r"); if (f) { while (!std::feof(f)) { fgets(cmdline,256,f); // If the library is 32-bit ELF, then we're // golden. if (strstr(cmdline, "ELF") && strstr(cmdline, "32-bit")) support32=1; } pclose(f); } } closedir(a); if (support32) break; } } #endif } } if (support64) { add_platform("x86_64-pc-linux-gnu"); } if (support32) { add_platform("i686-pc-linux-gnu"); } if (!(support64 || support32)) { // Something went wrong. Assume HOSTTYPE and HOSTTYPEALT // are correct add_platform(HOSTTYPE); #ifdef HOSTTYPEALT add_platform(HOSTTYPEALT); #endif } #elif defined(sun) // Check if we can run 64-bit binaries... // this assumes there isn't a 64-bit only solaris. (Every 64-bit solaris can run 32 bit binaries) #if defined(__sparc) || defined(sparc) char *exe64=const_cast<char *>("/usr/bin/sparcv9/ls"); char *platform64=const_cast<char *>("sparc64-sun-solaris"); char *platform32=const_cast<char *>("sparc-sun-solaris"); #elif defined(__i386) || defined(i386) || defined(__amd64) || defined(__x86_64__) char *exe64=const_cast<char *>("/usr/bin/amd64/ls"); char *platform64=const_cast<char *>("x86_64-pc-solaris"); char *platform32=const_cast<char *>("i686-pc-solaris"); #else #define UNKNOWN_SOLARIS_PROCESSOR #endif #ifndef UNKNOWN_SOLARIS_PROCESSOR FILE *f=fopen(exe64,"r"); char *argv[3]; pid_t pid; int rv=0; argv[0]=exe64; argv[1]=argv[0]; argv[2]=NULL; if (f) { fclose(f); if (0==(pid=fork())) { // we are in child process freopen("/dev/null","a",stderr); freopen("/dev/null","a",stdout); rv=execv(argv[0],argv); exit(rv); } else { // we are in the parent process. time_t start=time(0); int done; // wait 5 seconds or until the process exits. do { done=waitpid(pid,&rv,WNOHANG); sleep(1); } while (!done && ((time(0)-start)<5)); // if we timed out, kill the process if ((time(0)-start)>=5) { kill(pid,SIGKILL); done=-1; } // if we exited with success add the 64 bit platform if ((done == pid) && (rv == 0)) { add_platform(platform64); } } } add_platform(platform32); // the following platform is obsolete, but we'll add it anyway. #if defined(__sparc) || defined(sparc) add_platform("sparc-sun-solaris2.7"); #endif #else // !defined(UNKNOWN_SOLARIS_PROCESSOR) add_platform(HOSTTYPE); #ifdef HOSTTYPEALT add_platform(HOSTTYPEALT); #endif #endif // !defined(UNKNOWN_SOLARIS_PROCESSOR) #else // Any other platform, fall back to the previous method add_platform(HOSTTYPE); #ifdef HOSTTYPEALT add_platform(HOSTTYPEALT); #endif #endif if (config.no_alt_platform) { PLATFORM p = platforms[0]; platforms.clear(); platforms.push_back(p); } // add platforms listed in cc_config.xml AFTER the above. // for (unsigned int i=0; i<config.alt_platforms.size(); i++) { add_platform(config.alt_platforms[i].c_str()); } }
void main() { allegro_init(); install_keyboard(); install_mouse(); install_timer(); set_color_depth(32); set_gfx_mode(MODE, WIDTH, HEIGHT, 0, 0); srand(time(NULL)+clock()); text_mode(-1); buffer = create_bitmap(WIDTH, HEIGHT); textprintf_centre(screen, font, 320, 200, WHITE, "-Endless Tower-"); textprintf_centre(screen, font, 320, 240, WHITE, "press enter to start"); while (!key[KEY_ENTER]) {} for(int i = 0; i < 13; i++) { land[i].y = rand() % HEIGHT; land[i].x = ((rand()%300)*2) + 20; land[i].w = (rand()%20) + 20; } land[13].y = y + 10; land[13].x = x; land[13].w = 45; rest(50); while (!key[KEY_ESC]) { start_time = clock(); /*game goes here*/ //move left if (key[KEY_LEFT]) x -= 10; //move right if (key[KEY_RIGHT]) x += 10; //jump if ((!jump)&&(key[KEY_SPACE])) { jump = true; jumpforce = 60; } if ((jump)&&(key[KEY_SPACE])) { jumpforce += 1; } //speed up! speed = 3 + (game_time/20000); //fall if (jump) { jumpforce -= 3; } if (!jump) jumpforce = -12; y -= jumpforce/4; //drop platforms down add_platform(); for (int i = 0; i < 14; i++) { land[i].y += speed; } //collision on_land = 0; for (int i = 0; i < 14; i++) { if ((y > land[i].y - 20)&&(y < land[i].y)) { if ((x < land[i].x + land[i].w)&&(x > land[i].x - land[i].w)) { if (jumpforce < 5) { jump = false; } jumpforce = -speed*3; on_land += 1; } } } if (on_land == 0) jump = true; //warp if (x < 0) x = 0; if (x > WIDTH) x = WIDTH; //die if (y > HEIGHT) return; /*drawing goes here*/ rectfill(buffer, 0, 0, WIDTH, HEIGHT, BLACK); circlefill(buffer, x, y, 10, WHITE); textprintf(buffer, font, 320, 20, WHITE, "%i'%i", game_time/60000, (game_time/1000)%60); for (int i = 0; i < 14; i++) { hline(buffer, land[i].x - land[i].w, land[i].y, land[i].x + land[i].w, WHITE); } blit(buffer, screen, 0, 0, 0, 0, WIDTH, HEIGHT); game_time += 20; while (clock() < start_time + 20) {} } destroy_bitmap(buffer); return; }