Ejemplo n.º 1
0
Archivo: input.c Proyecto: UkCvs/ukcvs
static void quit_signal(int sig)
{
	put_instance(get_instance()-1);
	printf("input Version %.2f killed\n",I_VERSION);
	exit(1);
}
Ejemplo n.º 2
0
 // Utility method to add a category to the Logging singleton
 static void add_logging_category(std::string i_category) {
   get_instance().add_category(i_category);
 }
Ejemplo n.º 3
0
 BOOST_DLLEXPORT static const T & get_const_instance(){
     return get_instance();
 }
Ejemplo n.º 4
0
bool CL_SharedGCData::add_texture(CL_Texture &texture, const CL_String &filename, const CL_VirtualDirectory &virtual_directory, const CL_ImageImportDescription &import_desc)
{
	CL_SharedGCData *self = get_instance();
	return self->impl->add_texture(texture, filename, virtual_directory, import_desc);
}
Ejemplo n.º 5
0
void CL_SharedGCData::unload_all_textures()
{
	CL_SharedGCData *self = get_instance();
	self->impl->unload_all_textures();
}
Ejemplo n.º 6
0
void CL_SharedGCData::add_disposable(CL_DisposableObject *disposable)
{
	CL_SharedGCData *self = get_instance();
	self->impl->add_disposable(disposable);
}
Ejemplo n.º 7
0
CL_Signal_v0 &CL_SharedGCData::func_gc_destruction_imminent()
{
	CL_SharedGCData *self = get_instance();
	return self->impl->func_gc_destruction_imminent();
}
Ejemplo n.º 8
0
ALLEGRO_SAMPLE *Framework::sample(std::string identifier)
{
   return get_instance()->samples[identifier];
}
Ejemplo n.º 9
0
Model3D *Framework::model(std::string identifier)
{
   return get_instance()->models[identifier];
}
Ejemplo n.º 10
0
ALLEGRO_FONT *Framework::font(std::string identifier)
{
   return get_instance()->fonts[identifier];
}
Ejemplo n.º 11
0
ALLEGRO_BITMAP *Framework::bitmap(std::string identifier)
{
   return get_instance()->bitmaps[identifier];
}
Ejemplo n.º 12
0
void Framework::run_loop()
{
   al_start_timer(primary_timer);

   while(!shutdown_program || Display::displays.empty())
   {
      ALLEGRO_EVENT this_event, next_event;

      al_wait_for_event(event_queue, &this_event);

      current_event = &this_event;
      time_now = this_event.any.timestamp;
      get_instance()->motions.update(time_now);

      Screen::on_events(current_event);

      switch(this_event.type)
      {
      case ALLEGRO_EVENT_TIMER:
         if (this_event.timer.source == primary_timer)
            Screen::primary_timer_funcs();
         else
            Screen::timer_funcs();
         while (al_peek_next_event(event_queue, &next_event)
               && next_event.type == ALLEGRO_EVENT_TIMER
               && next_event.timer.source == this_event.timer.source)
            al_drop_next_event(event_queue);
         break;
      case ALLEGRO_EVENT_KEY_DOWN:
         if (Framework::current_event->keyboard.keycode == ALLEGRO_KEY_LSHIFT
               || Framework::current_event->keyboard.keycode == ALLEGRO_KEY_RSHIFT) Framework::key_shift++;
         if (Framework::current_event->keyboard.keycode == ALLEGRO_KEY_ALT
               || Framework::current_event->keyboard.keycode == ALLEGRO_KEY_ALTGR) Framework::key_alt++;
         if (Framework::current_event->keyboard.keycode == ALLEGRO_KEY_RCTRL
               || Framework::current_event->keyboard.keycode == ALLEGRO_KEY_LCTRL) Framework::key_ctrl++;
         if (current_event->keyboard.keycode == ALLEGRO_KEY_F1)
            drawing_profiler_graph = !drawing_profiler_graph; // toggle the profiler graph with F1
         Screen::key_down_funcs();
         break;
      case ALLEGRO_EVENT_KEY_UP:
         if (Framework::current_event->keyboard.keycode == ALLEGRO_KEY_LSHIFT
               || Framework::current_event->keyboard.keycode == ALLEGRO_KEY_RSHIFT) Framework::key_shift--;
         if (Framework::current_event->keyboard.keycode == ALLEGRO_KEY_ALT
               || Framework::current_event->keyboard.keycode == ALLEGRO_KEY_ALTGR) Framework::key_alt--;
         if (Framework::current_event->keyboard.keycode == ALLEGRO_KEY_RCTRL
               || Framework::current_event->keyboard.keycode == ALLEGRO_KEY_LCTRL) Framework::key_ctrl--;
         Screen::key_up_funcs();
         break;
      case ALLEGRO_EVENT_KEY_CHAR:
         Screen::key_char_funcs();
         break;
      case ALLEGRO_EVENT_MOUSE_BUTTON_UP:
         Screen::mouse_up_funcs();
         break;
      case ALLEGRO_EVENT_MOUSE_BUTTON_DOWN:
         Screen::mouse_down_funcs();
         break;
      case ALLEGRO_EVENT_MOUSE_WARPED:
         Screen::mouse_warp_funcs();
         break;
      case ALLEGRO_EVENT_MOUSE_AXES:
         Screen::mouse_axes_funcs();
         break;
      case ALLEGRO_EVENT_JOYSTICK_BUTTON_DOWN:
         Screen::joy_button_down_funcs();
         break;
      case ALLEGRO_EVENT_JOYSTICK_BUTTON_UP:
         Screen::joy_button_up_funcs();
         break;
      case ALLEGRO_EVENT_JOYSTICK_AXIS:
         Screen::joy_axis_funcs();
         break;
      case ALLEGRO_EVENT_MOUSE_ENTER_DISPLAY:
      case ALLEGRO_EVENT_MOUSE_LEAVE_DISPLAY:
         // currently ignored
         break;
      case ALLEGRO_EVENT_DISPLAY_SWITCH_OUT:
         Screen::display_switch_out_funcs();
         break;
      case ALLEGRO_EVENT_DISPLAY_SWITCH_IN:
         Screen::display_switch_in_funcs();
         break;
      case ALLEGRO_EVENT_NATIVE_DIALOG_CLOSE:
         //Screen::display_switch_in_funcs();
         if (textlog) close_log_window();
         break;
      case ALLEGRO_EVENT_JOYSTICK_CONFIGURATION:
         std::cout << "a joystick was added/removed" << std::endl;
         al_reconfigure_joysticks();
         // note: a bug in allegro causes a crash when al_get_joystick(0) if there
         // are 0 joysticks.  So this extra check has been added to prevent
         // the crash from occuring, though it should be corrected in future
         // versions when this bug in allegro is fixed.
         joystick = (al_get_num_joysticks() == 0) ? NULL : al_get_joystick(0);
         Screen::joy_config_funcs();
         break;
      case ALLEGRO_EVENT_MENU_CLICK:
         Screen::native_menu_click_funcs();
         break;
      case ALLEGRO_EVENT_DISPLAY_CLOSE:
         {
            Display *this_display = Display::find_display(this_event.display.source);
            if (this_display) this_display->display_close_func();
         }
         break;
      default:
         if (ALLEGRO_EVENT_TYPE_IS_USER(this_event.type)) Screen::user_event_funcs();
         else std::cout << "uncaught event [" << this_event.type << "]" << std::endl;
         break;
      }
   }
}
Ejemplo n.º 13
0
Config &Framework::get_config()
{
   return get_instance()->config;
}
Ejemplo n.º 14
0
ExprOpcode
ExprOpcodesMap::get_opcode(std::string expr_name) {
  ExprOpcodesMap *instance = get_instance();
  return instance->opcodes_map[expr_name];
}
Ejemplo n.º 15
0
std::vector<CL_GraphicContextProvider*> &CL_SharedGCData::get_gc_providers()
{
	CL_SharedGCData *self = get_instance();
	return self->impl->get_gc_providers();
}
Ejemplo n.º 16
0
Motion &Framework::motion()
{
   return get_instance()->motions;
}
Ejemplo n.º 17
0
void CL_SharedGCData::dispose_objects()
{
	CL_SharedGCData *self = get_instance();
	self->impl->dispose_objects();
}
Ejemplo n.º 18
0
 //! \brief Dump the part of the object graph reachable from root.
 static void dump_graph_beneath(Ref root) {
     if (auto impl = get_instance())
         impl->dump_graph_beneath(root);
 }
Ejemplo n.º 19
0
void CL_SharedGCData::remove_disposable(CL_DisposableObject *disposable)
{
	CL_SharedGCData *self = get_instance();
	if (self)
		self->impl->remove_disposable(disposable);
}
Ejemplo n.º 20
0
 /*! \brief Dump all of allocated memory as-is, in hexadecimal.
  *
  *  Also dumps the stack.
  */
 static void dump_memory_as_array() {
     if (auto impl = get_instance())
         impl->dump_memory_as_array();
 }
Ejemplo n.º 21
0
CL_Texture CL_SharedGCData::load_texture(CL_GraphicContext &gc, const CL_String &filename, const CL_VirtualDirectory &virtual_directory, const CL_ImageImportDescription &import_desc)
{
	CL_SharedGCData *self = get_instance();
	return self->impl->load_texture(gc, filename, virtual_directory, import_desc);
}
Ejemplo n.º 22
0
 //! \brief Print a human-readable version of the expression starting at root.
 static void print_expression(Ref root) {
     if (auto impl = get_instance())
         impl->print_expression(root);
 }
Ejemplo n.º 23
0
void CL_SharedGCData::unload_texture(const CL_String &filename, const CL_VirtualDirectory &virtual_directory, const CL_ImageImportDescription &import_desc)
{
	CL_SharedGCData *self = get_instance();
	self->impl->unload_texture(filename, virtual_directory, import_desc);
}
Ejemplo n.º 24
0
 /*! \brief Call this to indicate that a step has been taken.
  *
  *  Automatically decides what must be done based on the current configuration.
  */
 static void step() {
     if (auto impl = get_instance())
         impl->step();
 }
Ejemplo n.º 25
0
 // Utility method to set the logger of the Logging singleton
 static void init_logging(LoggerInterface & i_logger) {
   get_instance().set_logger(i_logger);
 }
Ejemplo n.º 26
0
 //! \brief Set the type of info to dump.
 static void set_dump_type(MemoryDumpType dump_type) {
     if (auto impl = get_instance())
         impl->dump_type = dump_type;
 }
Ejemplo n.º 27
0
 BOOST_DLLEXPORT static T & get_mutable_instance(){
     BOOST_ASSERT(! is_locked());
     return get_instance();
 }
Ejemplo n.º 28
0
 //! \brief Set the directory to dump debug output to.
 static void set_output_dir(std::string const& dir) {
     if (auto impl = get_instance())
         impl->set_output_dir(dir);
 }
Ejemplo n.º 29
0
	static C* extract(lua_State *l, int n)
	{
		return get_instance(l, n)->ref;
	}
Ejemplo n.º 30
0
Archivo: input.c Proyecto: UkCvs/ukcvs
int main (int argc, char **argv)
{
int tv,cols=25,debounce=25,tmo=0;
char ttl[]="Input";
int dloop=1,keys=0,frame=1,mask=0,bhelp=0;
char *title=NULL, *format=NULL, *defstr=NULL, *aptr, *rptr; 
unsigned int alpha;

		if(argc==1)
		{
			ShowUsage();
			return 0;
		}

		dloop=0;
		for(tv=1; !dloop && tv<argc; tv++)
		{
			aptr=argv[tv];
			if((rptr=strchr(aptr,'='))!=NULL)
			{
				rptr++;
				if(strstr(aptr,"l=")!=NULL)
				{
					format=rptr;
					dloop=Transform_Msg(format)==0;
				}
				else
				{
					if(strstr(aptr,"t=")!=NULL)
					{
						title=rptr;
						dloop=Transform_Msg(title)==0;
					}
					else
					{
						if(strstr(aptr,"d=")!=NULL)
						{
							defstr=rptr;
							dloop=Transform_Msg(defstr)==0;
						}
						else
						{
							if(strstr(aptr,"m=")!=NULL)
							{
								if(sscanf(rptr,"%d",&mask)!=1)
								{
									dloop=1;
								}
							}
							else
							{
								if(strstr(aptr,"f=")!=NULL)
								{
									if(sscanf(rptr,"%d",&frame)!=1)
									{
										dloop=1;
									}
								}
								else
								{
									if(strstr(aptr,"k=")!=NULL)
									{
										if(sscanf(rptr,"%d",&keys)!=1)
										{
											dloop=1;
										}
									}
									else
									{
										if(strstr(aptr,"h=")!=NULL)
										{
											if(sscanf(rptr,"%d",&bhelp)!=1)
											{
												dloop=1;
											}
										}
										else
										{
											if(strstr(aptr,"c=")!=NULL)
											{
												if(sscanf(rptr,"%d",&cols)!=1)
												{
													dloop=1;
												}
											}
											else
											{
												if(strstr(aptr,"o=")!=NULL)
												{
													if(sscanf(rptr,"%d",&tmo)!=1)
													{
														dloop=1;
													}
												}
												else
												{
													dloop=2;
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
			switch (dloop)
			{
				case 1:
					printf("input <param error: %s>\n",aptr);
					return 0;
					break;
				
				case 2:
					printf("input <unknown command: %s>\n\n",aptr);
					ShowUsage();
					return 0;
					break;
			}
		}
		if(!format)
		{
			printf("input <missing format string>\n");
			return 0;
    	}
		if(!title)
		{
			title=ttl;
		}

		if((buffer=calloc(BUFSIZE+1, sizeof(char)))==NULL)
		{
			printf(NOMEM);
			return 0;
		}

		if(((sx=Read_Neutrino_Cfg("screen_StartX"))<0)&&((sx=Read_Neutrino_Cfg("/enigma/plugins/needoffsets/left"))<0))
			sx=80;
		
		if(((ex=Read_Neutrino_Cfg("screen_EndX"))<0)&&((ex=Read_Neutrino_Cfg("/enigma/plugins/needoffsets/right"))<0))
			ex=620;

		if(((sy=Read_Neutrino_Cfg("screen_StartY"))<0)&&((sy=Read_Neutrino_Cfg("/enigma/plugins/needoffsets/top"))<0))
			sy=80;

		if(((ey=Read_Neutrino_Cfg("screen_EndY"))<0)&&((ey=Read_Neutrino_Cfg("/enigma/plugins/needoffsets/bottom"))<0))
			ey=505;

		if(Read_Neutrino_Cfg("rounded_corners")>0)
			radius=9;
		else
			radius=0;

		fb = open(FB_DEVICE, O_RDWR);
#ifdef HAVE_DBOX_HARDWARE
		ioctl(fb, AVIA_GT_GV_GET_BLEV, &alpha);
#endif
		InitRC();

	//init framebuffer

		if(ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1)
		{
			printf("input <FBIOGET_FSCREENINFO failed>\n");
			return 0;
		}
		if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1)
		{
			printf("input <FBIOGET_VSCREENINFO failed>\n");
			return 0;
		}
		
		if(!(lfb = (unsigned char*)mmap(0, fix_screeninfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0)))
		{
			printf("input <mapping of Framebuffer failed>\n");
			return 0;
		}
		
	//init fontlibrary

		if((error = FT_Init_FreeType(&library)))
		{
			printf("input <FT_Init_FreeType failed with Errorcode 0x%.2X>", error);
			munmap(lfb, fix_screeninfo.smem_len);
			return 0;
		}

		if((error = FTC_Manager_New(library, 1, 2, 0, &MyFaceRequester, NULL, &manager)))
		{
			printf("input <FTC_Manager_New failed with Errorcode 0x%.2X>\n", error);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return 0;
		}

		if((error = FTC_SBitCache_New(manager, &cache)))
		{
			printf("input <FTC_SBitCache_New failed with Errorcode 0x%.2X>\n", error);
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return 0;
		}

		if((error = FTC_Manager_Lookup_Face(manager, FONT, &face)))
		{
			printf("input <FTC_Manager_Lookup_Face failed with Errorcode 0x%.2X>\n", error);
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return 0;
		}

		use_kerning = FT_HAS_KERNING(face);
#ifdef FT_NEW_CACHE_API
	desc.face_id = (char*)FONT;
#else
		desc.font.face_id = FONT;
#endif
#if FREETYPE_MAJOR == 2 && FREETYPE_MINOR == 0
		desc.image_type = ftc_image_mono;
#else
		desc.flags = FT_LOAD_MONOCHROME;
#endif

	//init backbuffer

		if(!(lbb = malloc(var_screeninfo.xres*var_screeninfo.yres)))
		{
			printf("input <allocating of Backbuffer failed>\n");
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return 0;
		}

		if(!(obb = malloc(var_screeninfo.xres*var_screeninfo.yres)))
		{
			printf("input <allocating of Backbuffer failed>\n");
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			free(lbb);
			munmap(lfb, fix_screeninfo.smem_len);
			return 0;
		}

		memcpy(lbb, lfb, var_screeninfo.xres*var_screeninfo.yres);
		memcpy(obb, lfb, var_screeninfo.xres*var_screeninfo.yres);

		startx = sx /*+ (((ex-sx) - 620)/2)*/;
		starty = sy /* + (((ey-sy) - 505)/2)*/;



	signal(SIGINT, quit_signal);
	signal(SIGTERM, quit_signal);
	signal(SIGQUIT, quit_signal);

	//main loop
	put_instance(instance=get_instance()+1);
	printf("%s\n",inputd(format, title, defstr, keys, frame, mask, bhelp, cols, tmo, debounce));
	put_instance(get_instance()-1);

	memcpy(lfb, obb, var_screeninfo.xres*var_screeninfo.yres);

	free(buffer);

	FTC_Manager_Done(manager);
	FT_Done_FreeType(library);

	free(lbb);
	free(obb);
#ifdef HAVE_DBOX_HARDWARE
	ioctl(fb, AVIA_GT_GV_SET_BLEV, alpha);
#endif
	munmap(lfb, fix_screeninfo.smem_len);

	close(fb);
	CloseRC();

	return 1;
}