Пример #1
0
int main_menu()
{
	continue_condition = true;
	fade_condition = false;
	function_to_call = NULL;
	darken = 127;
	int failure = 0;
	initialize_main_menu_buttons();
	int ipc_status;
	message msg;
	int r;
	char * display_name = (char*)malloc(sizeof(char) * strlen("Player name: ")+MAX_PLAYER_NAME_LENGTH);
	strcpy(display_name, "Player name: ");
	display_name = strcat(display_name, get_program_playername());
	if(!failure){
		do{
			/* Get a request message. */
			if ( (r = driver_receive(ANY, &msg, &ipc_status)) != 0 ) {
				printf("driver_receive failed with: %d", r);
				continue;
			}
			if (is_ipc_notify(ipc_status)) { /* received notification */
				switch (_ENDPOINT_P(msg.m_source)) {
				case HARDWARE: /* hardware interrupt notification */
					if (msg.NOTIFY_ARG & get_kbd_irq_set()){  /* subscribed kbd interrupt */
						kbd_int_handler();
					}
					if (msg.NOTIFY_ARG & get_rtc_irq_set()) { /* subscribed timer interrupt */
						if(rtc_ih())
							failure = 1;
						getDateString(get_date_str_ptr());
					}
					if(msg.NOTIFY_ARG & get_timer_irq_set()){
						timer_int_handler();
						main_menu_render();
					}
					if (msg.NOTIFY_ARG & get_mouse_irq_set()) { /* subscribed timer interrupt */
						mouse_int_handler();
				}
					break;
				default:
					break; /* no other notifications expected: do nothing */
				}
			} else {/* received a standard message, not a notification */
				/* no standard messages expected: do nothing */
			}
			if(mouse_is_updated())
			{
				assign_mouse(get_previous_mouse(), get_mouse());
				assign_mouse(get_mouse(), get_mouse_state());
				main_menu_mouse_event(get_previous_mouse(), get_mouse());
				move_cursor(get_cursor(), get_mouse()->coords);
			}
		} while(continue_condition);
	}
	return failure;
}
Пример #2
0
void backup_info(EVENT_MSG *msg)
  {
  char *c;
  if (msg->msg==E_INIT) return ;
  if (msg->msg==E_DONE) return ;
  if (msg->msg==E_MOUSE)
     {
     MS_EVENT *ms;

     ms=get_mouse(msg);
     if (ms->tl1)
        {
        send_message(E_STATUS_LINE,E_DONE,E_IDLE,backup_info);
        send_message(E_DONE,E_MOUSE,backup_info);
        return;
        }
     return;
     }
  c=(char *)msg->data;
  strcpy(c,"Star� soubor byl ulo�en v adres��i backup\\...");
  c=strchr(c,'\0');
  msg->data=(void *)c;
  msg->msg=-1;
  return;
  }
Пример #3
0
Scroller*
USBMouseDriver::create_scroller(const FileReader& reader, Control* parent)
{
  if (reader.get_name() == "usbmouse:scroller")
    {
      std::string device;
      if (reader.read_string("device", device))
        {
          USBMouse* mouse = get_mouse(device);
          if (mouse)
            {
              Scroller* scroller = new Scroller(parent);
              mouse->add_listener(scroller);
              return scroller;
            }
          else
            {
              return 0;
            }
        }
      else
        {
          std::cout << "USBMouseDriver: 'device' entry is missing" << std::endl;
          return 0;
        }
    }
  else
    {
      return 0;
    }
}
Пример #4
0
void toggle_buttgui_on_event(EVENT_MSG *msg,OBJREC *o)
  {
  MS_EVENT *ms;
  static char toggle_exit=0;

  if (msg->msg==E_MOUSE)
     {
     ms=get_mouse(msg);
     if (ms->event_type & 0x06)
        {
        if (ms->tl1)
           {
           *(char *)o->data^=1;
           redraw_object(o);
           toggle_exit=1;
           }
        else if (toggle_exit)
              {
              set_change();
              toggle_exit=0;
              }
        }
        }

  if ((msg->msg==E_GET_FOCUS || msg->msg==E_LOST_FOCUS)&&toggle_exit)
     {
     *(char *)o->data^=1;
     redraw_object(o);
     toggle_exit=0;
     }
  }
Пример #5
0
void check_box_event(EVENT_MSG *msg,OBJREC *o)
  {
  MS_EVENT *ms;

  if (msg->msg==E_MOUSE)
     {
     ms=get_mouse(msg);
     if (ms->event_type & 0x06)
        {
        if (ms->tl1)
           {
           *(char *)o->data|=0x80;
           redraw_object(o);
           }
        else if (*(char *)o->data)
              {
               *(char *)o->data^=0x1;
               *(char *)o->data&=0x1;
               redraw_object(o);
               set_change();
              }
        }
        }

  if (msg->msg==E_GET_FOCUS || msg->msg==E_LOST_FOCUS)
     {
     *(char *)o->data&=0x1;
     redraw_object(o);
     }
  }
Пример #6
0
void buttgui_on_event(EVENT_MSG *msg,OBJREC *o)
  {
  MS_EVENT *ms;

  if (msg->msg==E_MOUSE)
     {
     ms=get_mouse(msg);
     if (ms->event_type & 0x06)
        {
        if (ms->tl1)
           {
           *(char *)o->data=1;
           redraw_object(o);
           }
        else if (*(char *)o->data)
              {
               *(char *)o->data=0;
               redraw_object(o);
               set_change();
              }
        }
        }

  if (msg->msg==E_GET_FOCUS || msg->msg==E_LOST_FOCUS)
     {
     *(char *)o->data=0;
     redraw_object(o);
     }
  }
void vid_mouse_off_deflt()
{
    interlock++;
    mouse_on--;
    if(mouse_on == 0)
        get_mouse();
    interlock--;
}
Пример #8
0
int main ()
{
   char vertex_shader[512];
   char fragment_shader[512];
   char geometry_shader[512];

   
   
   int terminate = 0;
   GLfloat cx, cy;
   bcm_host_init();

   // Clear application state
   memset( state, 0, sizeof( *state ) );
      
   // Start OGLES
   init_ogl(state);


   glm::vec3 resolution((float)state->screen_width,(float)state->screen_height,0.0f);


   cx = state->screen_width/2;
   cy = state->screen_height/2;
   state->verbose=1;

   Shader shader(vertex_shader, fragment_shader,geometry_shader);
   init_shaders(state);
   
   //glBindAttribLocation (shader.Program, 0 , "position");
   shader.linkProg();
   shader.Use();
   state->program=shader.Program;

   GLint resLoc = glGetUniformLocation(shader.Program, "iResolution");
   glUniform3f(resLoc,resolution.x,resolution.y,resolution.z);
   GLfloat currentTime = 0.0f;

   GLint timeLoc = glGetUniformLocation(shader.Program, "time");
   glUniform1f(timeLoc,currentTime);
   
   //draw_mandelbrot_to_texture(state, cx, cy, 0.003);
   while (!terminate)
   {
      int x, y, b;
      currentTime=currentTime+0.02;
      
      timeLoc = glGetUniformLocation(shader.Program, "time");
      glUniform1f(timeLoc,currentTime);
      
      b = get_mouse(state, &x, &y);
      if (b) break;
      draw_triangles(state, cx, cy, 0.003, x, y);
   }
   return 0;
}
Пример #9
0
void sample_event(EVENT_MSG *msg,OBJREC *o)
  {
  MS_EVENT *ms;

  (void)o;
  if (msg->msg==E_MOUSE)
      {
      ms=get_mouse(msg);
      if (ms->tl1) exit_wait=1;
      }
  }
Пример #10
0
void ms_draw_event(EVENT_MSG *info,void *user_data)
  {
  MS_EVENT *ms_ev;

  user_data;
  if (info->msg==E_MOUSE)
     {
     ms_ev=get_mouse(info);
     if (ms_ev->event_type & 1)
       if (!visible) move_ms_cursor(ms_ev->x-h_x,ms_ev->y-h_y,0);
     }
  }
Пример #11
0
//------------------------------------------------------------
void Control()
{
   do
    {
      _1.button_effect();_2.button_effect();_3.button_effect();
      _4.button_effect();_5.button_effect();_6.button_effect();
      _7.button_effect();_8.button_effect();_9.button_effect();
      _ER.button_effect();_1.higlt(curr);

      restrictmouse();     showmouse();
      get_mouse();         getmousepos();
      wait_mouse();        hide_mouse();
    }
    while(1);
}
Пример #12
0
void chozeni(EVENT_MSG *msg)
  {
  MS_EVENT *ms;

  if (msg->msg==E_MOUSE)
     {
     ms=get_mouse(msg);
     if (ms->event_type & 0x8)
        {
        int s;
        s=vals(o_aktual->id);
        jdi_na_sektor(s);
        }
     }
  }
static void put_mouse()
{
    if(mouse_on <= 0) return;
    if(mouse_is_on_screen) get_mouse();
    interlock++;

    int mx = video_drv->mouse_x - ms_hot_shift_x;
    int my = video_drv->mouse_y - ms_hot_shift_y;

    // TODO hardcoded mouse hot point
    scr_readblt_ms(screencopy->pixel, mx, my, mpointer->xsize, mpointer->ysize);
    scr_bitblt_ms(mpointer->pixel, mx, my, mpointer->xsize, mpointer->ysize);

    last_mouse_x = mx;
    last_mouse_y = my;
    mouse_is_on_screen = 1;
    interlock--;
}
Пример #14
0
static
void get_pointer(double *x, double *y, int *state)
{
  Point mouse;
  EventModifiers modifiers;
  Rect rect;
  int mousex, mousey;

  GetWindowPortBounds(p->win, &rect);

  GetMouse(&mouse);
  mousex = mouse.h;
  mousey = mouse.v;
  crosshair(mousex, mousey);

  *state = GKS_K_STATUS_OK;
  do
    {  
      get_mouse(&mouse, &modifiers);

      if (mousex != mouse.h || mousey != mouse.v)
	{
	  crosshair(mousex, mousey);
	  mousex = mouse.h;
	  mousey = mouse.v;
	  crosshair(mousex, mousey);
	}
      usleep(10000);

      if (!(modifiers & 0x80) && modifiers & 0xff00)
	{
	  *state = GKS_K_STATUS_NONE;
	  break;
	}
    }
  while (modifiers);

  crosshair(mousex, mousey);

  DC_to_NDC(mousex, mousey, *x, *y);
}
Пример #15
0
void radio_butts_event(EVENT_MSG *msg,OBJREC *o)
  {
  MS_EVENT *ms;
  int sel;

  if (msg->msg==E_MOUSE)
     {
     ms=get_mouse(msg);
     if (ms->event_type & 0x02)
        {
        sel=(ms->y-o->locy)/(o->ys/(*((long *)o->userptr+1)));
        if (sel>=*((long *)o->userptr+1)) sel=*((long *)o->userptr+1)-1;
        *(long *)o->data=sel;
        *(long *)o->userptr=0;
        redraw_object(o);
        *(long *)o->userptr=1;
        set_change();
        }
     }

  }
Пример #16
0
Button*
USBMouseDriver::create_button(const FileReader& reader, Control* parent)
{
  if (reader.get_name() == "usbmouse:button")
    {
      std::string device;
      if (reader.read_string("device", device))
        {
          int i;
          if (reader.read_int("button", i))
            {
              USBMouse* mouse = get_mouse(device);
              if (mouse)
                {
                  Button* button = new Button(parent);
                  mouse->add_listener(i, button);
                  return button;
                }
              else
                {
                  return 0;
                }
            }
          else
            {
              std::cout << "USBMouseDriver: 'button' entry is missing" << std::endl;
              return 0;
            }
        }
      else
        {
          std::cout << "USBMouseDriver: 'device' entry is missing" << std::endl;
          return 0;
        }
    }
  else
    {
      return 0;
    }
}
Пример #17
0
void input_line_event(EVENT_MSG *msg,OBJREC *o)
  {
   static int cursor=0;
   int *len,*start,slen;
   char *c;
   static char *save;
   static char clear_kontext;

   len=(int *)o->userptr;
   start=len+1;
   c=(char *)o->data;
   slen=strlen(c);
   switch (msg->msg)
     {
     case E_GET_FOCUS:cursor=0;save=(char *)getmem(*len+1);
                      strcpy(save,c);clear_kontext=1;break;
     case E_LOST_FOCUS:cursor=0;*start=0;free(save);redraw_object(o);break;
     case E_CURSOR_TICK:
        {
        int xpos,i,j=-1,d;

        do
           {
           xpos=0;j++;
           for (i=*start;i<cursor;i++)
              {
              if ((d=charsize(curfont,c[i]) & 0xff)==0) xpos+=1;
              else xpos+=d;
              }
           if (xpos>=o->xs) (*start)+=1;
           if (xpos==0) (*start)-=1;
           if (*start<0) *start=0;
           }
        while ((xpos==0 || xpos>=o->xs)&& cursor);
        if (j) redraw_object(o);
        xor_rectangle(o->locx+xpos,o->locy,1,o->ys);
        };break;
     case E_MOUSE:
        {
        MS_EVENT *ms;int msx;

        ms=get_mouse(msg);
        msx=ms->x-o->locx;
        if (ms->event_type & 2)
           {
           int xpos;

           xpos=0;
           for (cursor=*start;cursor<slen;cursor++)
              {
              xpos+=charsize(curfont,c[cursor]) & 0xff;
              if (xpos>msx) break;
              }
           redraw_object(o);
           }
        }
        break;
     case E_KEYBOARD:
        {
        char key;

        cancel_event();
        key=(*(int *)msg->data) & 0xff;
        if (!key)
        switch (*(int *)msg->data >> 8)
           {
           case 'M':if (cursor<slen)  cursor++;break;
           case 'K':if (cursor>0)  cursor--;break;
           case 'S':if (cursor<slen) strcpy(&c[cursor],&c[cursor+1]);slen--;break;
           case 'G':cursor=0;
           case 'O':cursor=slen;
           }
        else
        if (key)
           switch (key)
           {
           case 8:if (cursor>0) {strcpy(&c[cursor-1],&c[cursor]);cursor--;}break;
           case 0:break;
           case 13:break;
           case 27:strcpy(c,save);slen=strlen(c);if (cursor>slen) cursor=slen;break;
           default:if (key>=' ') if (slen<*len || clear_kontext)
             {
             int i;

              if (clear_kontext)
                 {*c='\0';cursor=0;slen=0;}
              for (i=slen+1;i>cursor;i--) c[i]=c[i-1];
              c[cursor++]=key;
             }
           }
        if (!cursor) *start=0;
        redraw_object(o);
        msg->msg=E_CURSOR_TICK;
        input_line_event(msg,o);
        clear_kontext=0;
        msg->msg=-1;
        }
     }
Пример #18
0
void string_list_event(EVENT_MSG *msg,OBJREC *o)
  {
  STRING_LIST_DATA *p;
  int y;
  int znh,i;
  TSTR_LIST ls;
  MS_EVENT *ms;
  static char clicked=0;

  p=o->userptr;
  ls=p->list;
  y=o->locy;

  switch (msg->msg)
     {
     case E_MOUSE:
        i=get_to_topline(ls,p->topline,NULL);
        ms=get_mouse(msg);
        curfont=o->font;
        if (ms->tl1 && clicked || ms->event_type & 0x2)
           {
		   if (ls)
              do
              {
              char *c;

              clicked=1;
              c=ls[i];
              if (i>=p->maxitems) return;
              if (c!=NULL) znh=text_height(c); else znh=0;
              if (y+znh>o->locy+o->ys) return;
              if (ms->y>=y && ms->y<y+znh)
                 {
                 if (ls[i]!=NULL) c_set_value(0,o->id,i);else clicked=0;
                 return;
                 }
              i++;
              y+=znh;
              }
           while (1);
           }
        if (ms->event_type & 0x4 && clicked)
           {
            clicked=0;set_change();
           }
        return;
	 case E_KEYBOARD:
	   {
		 int pos=*(int *)(o->data);
		 int  key=(*(int *)msg->data) & 0xff;
		 if (!key)
		 {
		   int save;
		   int curLine;
		   key=*(int *)msg->data >> 8;
		   {
			 do
			 {
			   save=pos;
			   switch (key)
			   {
			   case 'H':pos--;break;
			   case 'P':pos++;break;
			   case 'I':pos-=p->maxview;break;
			   case 'Q':pos+=p->maxview;break;
			   }
			   if (pos<0) pos=0;
			   if (pos>=p->maxitems) pos=p->maxitems-1;
			   curLine=set_line_back(p->list,pos);
			   if (curLine>=p->topline+p->maxview) p->topline=curLine-p->maxview+1;
			   if (curLine<p->topline) p->topline=curLine;
			 }
			 while (save!=pos && p->list[pos]==NULL);
			 c_set_value(0,o->id,pos);
		   }
		 }
		break;
	   }
	   
     case E_CONTROL:
        {
        int *q;

        q=msg->data;
        switch (*q++)
           {
           case 1:p->list=(TSTR_LIST)*q;
                  redraw_object(o);
                  break;
           case 0:*(void **)*q=p->list;
                  break;
           case 2:
                  i=get_to_topline(ls,p->topline,NULL);
                  if (*(int *)o->data<i) p->topline=set_line_back(ls,*(int *)o->data);
                  if (*(int *)o->data>=i+p->maxview) p->topline=set_line_back(ls,*(int *)o->data);
                  break;
           }
        }
     case E_LOST_FOCUS:clicked=0;
     }
Пример #19
0
void win_label_move(EVENT_MSG *msg,OBJREC *o)
  {
  MS_EVENT *ms;
  static char run=0;
  static word xref,yref;
  static WINDOW w;
  static int moved=0;
  static int drawed=0;

  (void)o;
  if (msg->msg==E_INIT) return;
  if (msg->msg==E_TIMER)
     {
     send_message(E_TIMER);
     if (!drawed) {
     if (!moved)
     {
     drawed=1;
     redraw_desktop();
     moved=0;
     }
     else
     {
     drawed=0;
     moved=0;
     }
     }
     }
  if (msg->msg==E_MOUSE)
     {
        ms=get_mouse(msg);
        if (run)
           {
           //xor_rectangle(w.x,w.y,w.xs,w.ys);
           if (ms->event_type & 4)
              {
              run=0;
              redraw_desktop();
              send_message(E_DONE,E_MOUSE,win_label_move);
              msg->msg=-1;
              return;
              }
           w.x=ms->x-xref;
           w.y=ms->y-yref;
           check_window(&w);
           //xor_rectangle(w.x,w.y,w.xs,w.ys);
           waktual->x=w.x;
           waktual->y=w.y;
           waktual->xs=w.xs;
           waktual->ys=w.ys;
           moved=1;drawed=0;
           redraw_window();
           redraw_desktop();
           }
        else
           if (ms->event_type & 2)
           {
           run=1;
           memcpy(&w,waktual,sizeof(WINDOW));
           //xor_rectangle(w.x,w.y,w.xs,w.ys);
           xref=ms->x-waktual->x;
           yref=ms->y-waktual->y;
           send_message(E_ADD,E_MOUSE,win_label_move);
           freeze_gui_on_exit=1;
           }
     }
  if (msg->msg==E_LOST_FOCUS && run)
     {
              run=0;
              redraw_desktop();
              send_message(E_DONE,E_MOUSE,win_label_move);
              msg->msg=-1;
              return;
     }
msg->msg=-1;
return;
  }
Пример #20
0
int mp_lobby()
{
	int failure = 0;
	if((set_com1_irq_set(generic_ser_subscribe_int_tx_rx(COM1))) < 0)
	{//subscribe interrupts
		printf("mp_lobby(): generic_ser_subscribe_int_tx_rx() failed \n");
		failure = 1;
	}
	if(SET_COMMUNICATION_PARAM())
	{
		printf("ser_set() failed\n");
		return 1;
	}
	initialize_lobby_buttons();
	set_role(SEARCHING);
	lobby_state = NOT_READY;
	enable_per_second_alarm(on_rtc_alarm_int_transmission);
	if(im_message_log != NULL)
		{
			size_t del_i;
			for(del_i = 0 ; del_i < size(im_message_log); del_i++)
			{
				free(*(char**)at(im_message_log, del_i));
			}
			delete_vector_t(im_message_log);
		}
	im_message_log = new_vector_t(sizeof(char*));
	memset(current_im, 0, sizeof(char)*IM_MESSAGE_MAX);
	current_im_index = 0;
	draw_im_index = 0;
	int wait = 0;
	function_to_call = NULL;
	continue_condition = true;
	fade_condition = false;
	darken = FADE_MAX;
	int ipc_status;
	message msg;
	int r;
	set_program_player2name((char*)malloc(sizeof(char)*MAX_PLAYER_NAME_LENGTH+1));
	if(get_program_playername2() == NULL)
		return 1;
	memset(get_program_playername2(),0,sizeof(char)*MAX_PLAYER_NAME_LENGTH+1);
	size_t next_char_index = 0;
	char last_char = 0;
	if(!failure){
		do{
			/* Get a request message. */
			if ( (r = driver_receive(ANY, &msg, &ipc_status)) != 0 ) {
				printf("driver_receive failed with: %d", r);
				continue;
			}
			if (is_ipc_notify(ipc_status)) { /* received notification */
				switch (_ENDPOINT_P(msg.m_source)) {
				case HARDWARE: /* hardware interrupt notification */
					if (msg.NOTIFY_ARG & get_com1_irq_set()) { /* subscribed interrupt */
						if(ser_ih(COM1))
							failure = 1;
					}
					if (msg.NOTIFY_ARG & get_kbd_irq_set()){  /* subscribed kbd interrupt */
						kbd_int_handler();
						if(get_scancode() == ESC_BREAK)
						{
							lobby_state = NOT_READY;
							fade_condition = true;
							transmit_message(MES_BYE);
						}
						if(get_role() == SERVER || get_role() == CLIENT)
						{
							if(get_scancode() == ENTER_MAKE && current_im_index != 0)
							{


								current_im_index = 0;
								transmit_protocol(current_im, TYPE_STRING, strlen(current_im)+1);
								char* temp = (char*) calloc(IM_MESSAGE_MAX + 4,1);
								strcpy(temp, "me: ");
								strcat(temp,current_im);

								push_back(im_message_log, &temp);

								memset(current_im, 0, IM_MESSAGE_MAX);
								memset(transmission_message,0,IM_MESSAGE_MAX+4);

							}
							else
							{
								int action;
								action = process_input(get_scancode(), &last_char);
								if(action == CHAR_RECEIVED)
								{
									if(current_im_index < IM_MESSAGE_MAX -1)
									{
										current_im[current_im_index] = last_char;
										current_im_index++;
									}
								}
								else if(action == BACKSPACE_MAKE)
								{
									if(current_im_index > 0)
									{
										current_im_index--;
										current_im[current_im_index] = '\0';
									}
								}
							}
						}
					}
					if (msg.NOTIFY_ARG & get_rtc_irq_set()) { /* subscribed timer interrupt */
						if(rtc_ih())
							failure = 1;
						getDateString(get_date_str_ptr());
					}
					if(msg.NOTIFY_ARG & get_timer_irq_set()){
						timer_int_handler();
						mp_lobby_render();
						//establish_connection_transmission();
					}
					if (msg.NOTIFY_ARG & get_mouse_irq_set()) { /* subscribed timer interrupt */
						mouse_int_handler();
					}
					break;
				default:
					break; /* no other notifications expected: do nothing */
				}
			} else {
			}
			establish_connection_reception();
			if(mouse_is_updated())
			{
				assign_mouse(get_previous_mouse(), get_mouse());
				assign_mouse(get_mouse(), get_mouse_state());
				if(get_role() == SERVER || get_role() == CLIENT)
					lobby_mouse_event(get_previous_mouse(), get_mouse());
				move_cursor(get_cursor(), get_mouse()->coords);
			}

		} while(continue_condition);
	}
	if(im_message_log != NULL)
	{
		size_t del_i;
		for(del_i = 0 ; del_i < size(im_message_log); del_i++)
		{
			free(*(char**)at(im_message_log, del_i));
		}
		delete_vector_t(im_message_log);
		im_message_log = NULL;
	}
	if(generic_ser_unsubscribe_int_tx_rx(COM1))
	{//unsubscribe interrupts
		printf("ser_int_receive(): generic_ser_unsubscribe_int() failed \n");
		failure = 1;
	}
	disable_per_second_alarm();
	continue_condition = true;
	fade_condition = false;
	darken = FADE_MAX;
	return 0;
}