Exemple #1
0
static void PushKeyTask (void* pdata)
{
	INT8U err;

	while (1)
	{
		OSSemPend (os_sem_push, PUSH_TIME, &err);
		if (err == OS_TIMEOUT)
		{	
			key_hook (TYPE_KEY_PUSH<<24 | change);
			OSQPost (os_q_key_msg, (void*)(TYPE_KEY_PUSH<<24 | change));
		#if KEY_CONTINUOUS_PUSH_EN == 1
			while (1)	
			{
				key_hook (TYPE_KEY_DOWN<<24 | change);
			    OSQPost (os_q_key_msg, (void*)(TYPE_KEY_PUSH<<24 | change));
				OSTimeDly (PUSH_EXECUTE_INTERVAL);
				if (OSSemAccept(os_sem_push))
				{
					OSSemPost (os_sem_push);
					break;
				}
			}
		#else
			OSTaskDel (KEY_PUSH_TASK_PRIO);
		#endif
		}
		else
		{
			OSTaskDel (KEY_PUSH_TASK_PRIO);
		}
	}
}
Exemple #2
0
INT8S key_msg_post (INT32U msg)
{
    #if KEY_HOOK_EN == 1
        key_hook (msg);
    #endif
    
    return OSQPost (os_q_key_msg, (void*)msg) == OS_NO_ERR ? 0 : -1;
}
Exemple #3
0
void		content(t_env *env)
{
	glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0.0f, WIDTH, HEIGHT, 0.0f, 0.0f, 1.0f);
	key_hook(env);
	move_ball(env);
	draw(env);
	score(env);
}
Exemple #4
0
int		loop_hook(t_mega *all)
{
	open_door(all);
	if (all->e.refresh == 1)
	{
		ft_bzero(all->img.data, WWIN * HWIN * 4);
		raycasting_calcul(all);
		mlx_put_image_to_window(all->e.mlx, all->e.wmlx, all->img.img,
			(WWIN_HUD / 2) - (WWIN / 2), 20);
		loot_ammo(all->sprites, &all->player, &all->cam);
		display_weapon(all);
		display_hud(all);
		all->e.refresh = 0;
	}
	key_hook(all);
	return (1);
}
Exemple #5
0
static void DoubleKeyTask (void* pdata)
{
	INT8U err;

	while (1)
	{
		OSSemPend (os_sem_double, DOUBLE_INTERVAL, &err);
		if (err == OS_TIMEOUT)
		{	
			OSTaskDel (KEY_DOUBLE_TASK_PRIO);
		}
		else
		{
			key_hook (TYPE_KEY_DOUBLE<<24 | change);
			OSQPost (os_q_key_msg, (void*)(TYPE_KEY_DOUBLE<<24 | change));
			OSTaskDel (KEY_DOUBLE_TASK_PRIO);
		}
	}	
}
Exemple #6
0
void	main_loop(t_dlist *list, t_all *all)
{
	int			skip;
	Uint32 		ticks;
	SDL_Event	event;

	printf("Go : \n");
	skip = FALSE;
	all->pos.x = 0;
	all->pos.y = 0;
	while (skip == FALSE)
	{
		skip = fps_system(all, list);
		while (SDL_PollEvent(&event))
			skip = key_hook(event);
		display_all(all, list);
		SDL_Flip(all->win);
	}
}
Exemple #7
0
int	core_run_termcap(t_core *core)
{
  int	ret;
  char	buffer[BUF_CAPS_SIZE];

  put_str(PROMPT_1(core->prompt));
  while (!core->shutdown && (ret = read(0, buffer, 3)) > 0)
    {
      clear_buffer_caps(buffer, ret);
      if (key_hook(core, buffer) == FALSE)
	core->buf_caps = str_cat(core->buf_caps, buffer, FREE_LEFT);
      clear_buffer_caps(buffer, BUF_CAPS_SIZE);
      if (!core->shutdown && !reset_cursor(core, 0))
	return (ERROR);
      core->prompt = get_prompt(core);
      if (!core->shutdown)
	put_str(PROMPT_1(core->prompt));
      put_str(core->buf_caps);
    }
  free(core->buf_caps);
  free(core->prompt);
  module_free(core);
  return (NO_ERR);
}
Exemple #8
0
static void KeyScan (void* pdata)
{	
	static INT32U backup_read = 0;
	static INT8U judge_flag = 0;
	static INT8U refresh_flag = 0;	
	static INT32U front_read = KEY_DEFAULT_STATE;
    static INT32U current_read = KEY_DEFAULT_STATE;
	INT32U new_read;

#if KEY_PUSH_EN == 1 || KEY_DOUBLE_EN == 1
	static OS_TCB task_data;
#endif
	
	while (1)
	{			
		new_read = key_phy_read () & 0x00ffffff;
			
		if (new_read == backup_read)
		{
			if (refresh_flag == 0)
			{
				front_read = current_read;
				current_read = new_read;				
				
				refresh_flag = 1;
				judge_flag = 1;
			}
		}	
		else
		{
			backup_read = new_read;
			refresh_flag = 0;
		}

		if (judge_flag == 1)
		{		    
			change = front_read ^ current_read;
						
			if (change)
           	{
            	if ((change & current_read) != 0)	
            	{
            	    key_hook (TYPE_KEY_UP<<24 | change);
            	    OSQPost (os_q_key_msg, (void*)(TYPE_KEY_UP<<24 | change));
            	    
            	    #if KEY_PUSH_EN == 1		
                		if (OSTaskQuery (KEY_PUSH_TASK_PRIO, &task_data) == OS_NO_ERR)
                		{
                			OSSemPost (os_sem_push);
                		}
            		#endif
            	}
            	else
            	{
            		key_hook (TYPE_KEY_DOWN<<24 | change);
            		OSQPost (os_q_key_msg, (void*)(TYPE_KEY_DOWN<<24 | change));
            		
            	    #if KEY_PUSH_EN == 1
                		OSTaskCreate (PushKeyTask, (void*)0, &key_push_task_stk[KEY_PUSH_TASK_STK_SIZE - 1], KEY_PUSH_TASK_PRIO);
            		#endif
            		
            		#if KEY_DOUBLE_EN == 1
                   		if (OSTaskQuery (KEY_DOUBLE_TASK_PRIO, &task_data) == OS_NO_ERR)
                		{
                			OSSemPost (os_sem_double);
                		}
                		else
                		{
                		    OSTaskCreate (DoubleKeyTask, (void*)0, &key_double_task_stk[KEY_DOUBLE_TASK_STK_SIZE - 1], KEY_DOUBLE_TASK_PRIO);	
                		}
            		#endif
            	}
		    }
		    		
			judge_flag = 0;
		}

		OSTimeDly (KEY_SCAN_INTERVAL);
	}
}