示例#1
0
static
void key (unsigned long keycode, int pressed)
{
    unsigned long keyval = keycode & 0xffff;

    switch (KEY_TYPE(keycode)) {
    case KEY_TYPE_MOUSE:
        if (glut_mouse_func)
            glut_mouse_func(keyval, pressed ? GLUT_DOWN : GLUT_UP, mouse_x, mouse_y);
        break;
    case KEY_TYPE_SPECIAL:
        if (glut_special_func[pressed])
            glut_special_func[pressed](keyval, mouse_x, mouse_y);
        break;
    case KEY_TYPE_ASCII:
        if (glut_keyboard_func[pressed])
            glut_keyboard_func[pressed](keyval, mouse_x, mouse_y);
    default:
        ;
    }
}
示例#2
0
static void test_keyboard()
{
	s32 k_x = 60, k_y = 80;
    while (TRUE)
    {
        if (get_tick_count() % 10)
            io_halt();

        mouse_read();

        u32 key = 0;	
        keyboard_read(&key);
        if (key == 0 || KEY_TYPE(key) != KT_ASCII)
            continue;

        draw_asc16((char)key, k_x, k_y, color);
        k_x += 8;
        if (k_x + 100 > 1000)
        {
            k_x  = 60;
            k_y += 20;
        }
    }
}
示例#3
0
void Covariance::setCovariance(Investment::ID_TYPE i1, Investment::ID_TYPE i2, double covariance)
{
   if ( i1 > i2 )
      std::swap(i1, i2);
   mData.insert(MAP_TYPE::value_type(KEY_TYPE(i1, i2), covariance));
}
static void key_handler(void *msg)
{
	key_t key_msg = (key_t)(uint32_t)msg;
	uint8_t key = KEY_VALUE(key_msg);
	
	if (KEY_TYPE(key_msg) == MASK_KEY_RELEASE)
	{
		return;
	}

	if (KEY_TYPE(key_msg) != MASK_KEY_PRESS && (key == KEY_OK || key == KEY_CANCEL))
	{
		return;
	}
	
	beeper_beep(BEEPER_VOL_LOW, 50, 50, 1);

	if (key == KEY_LEFT || key == KEY_UP)
	{
		if (s_edit_item == DIVIDE_MODE_NONE)
		{
			s_unfocus_fun_arr[s_focus_item]();
			
			s_focus_item += DIVIDE_MODE_COUNT - 1;
			s_focus_item %= DIVIDE_MODE_COUNT;
			
			s_focus_fun_arr[s_focus_item]();
		}
		else
		{
			s_edit_fun_arr[s_edit_item](key);
		}
		
		lcd_validate_cmd();
	}
	else if (key == KEY_RIGHT || key == KEY_DOWN)
	{
		if (s_edit_item == DIVIDE_MODE_NONE)
		{
			s_unfocus_fun_arr[s_focus_item]();
			
			s_focus_item++;
			s_focus_item %= DIVIDE_MODE_COUNT;
			
			s_focus_fun_arr[s_focus_item]();
		}
		else
		{
			s_edit_fun_arr[s_edit_item](key);
		}

		lcd_validate_cmd();
	}
	else if (key == KEY_OK)
	{
		if (s_edit_item == DIVIDE_MODE_NONE)
		{
			s_enter_edit_fun_arr[s_focus_item]();
		}
		else
		{
			s_confirm_edit_fun_arr[s_focus_item]();
			
			s_edit_item = DIVIDE_MODE_NONE;
		}
		
		lcd_validate_cmd();
	}
	else if (key == KEY_CANCEL)
	{
		if (s_edit_item == DIVIDE_MODE_NONE)
		{
			/* save */
			set_dp_dn_divide_mode_setting(&s_divide_mode_setting);
			
			switch_to_menu(MENU_ID_EMPTY_LOAD_SETTING);
		}
		else
		{
			s_focus_fun_arr[s_focus_item]();
			
			lcd_validate_cmd();
			
			s_edit_item = DIVIDE_MODE_NONE;
		}
	}
}
示例#5
0
static void key_handler(void *msg)
{
	key_t key_msg = (key_t)(uint32_t)msg;
	uint8_t key = KEY_VALUE(key_msg);

	if (KEY_TYPE(key_msg) != MASK_KEY_PRESS && (key == KEY_OK || key == KEY_CANCEL))
	{
		return;
	}
	
	if (KEY_TYPE(key_msg) != MASK_KEY_RELEASE)
	{
		beeper_beep(BEEPER_VOL_LOW, 50, 50, 1);
		
		if (key == KEY_UP)
		{
			if (s_cr_mode == CR_EDIT_MODE)
			{
				s_cur_resist += BIG_RESIST_STEP;
				if (s_cur_resist > MAX_RESIST)
				{
					s_cur_resist = MAX_RESIST;
				}	
				draw_edit_resist_val(s_cur_resist);
			
				lcd_validate_cmd();
			}
		}
		else if (key == KEY_DOWN)
		{
			if (s_cr_mode == CR_EDIT_MODE)
			{
				if (s_cur_resist > BIG_RESIST_STEP)
				{
					s_cur_resist -= BIG_RESIST_STEP;
				}
				else
				{
					s_cur_resist = SMALL_RESIST_STEP;
				}
				draw_edit_resist_val(s_cur_resist);
			
				lcd_validate_cmd();
			}
		}
		else if (key == KEY_LEFT)
		{
			if (s_cr_mode == CR_EDIT_MODE)
			{
				if (s_cur_resist > SMALL_RESIST_STEP)
				{
					s_cur_resist -= SMALL_RESIST_STEP;
				}
				draw_edit_resist_val(s_cur_resist);
			
				lcd_validate_cmd();
			}
		}
		else if (key == KEY_RIGHT)
		{
			if (s_cr_mode == CR_EDIT_MODE)
			{	
				s_cur_resist += SMALL_RESIST_STEP;
				if (s_cur_resist > MAX_RESIST)
				{
					s_cur_resist = MAX_RESIST;
				}
				draw_edit_resist_val(s_cur_resist);
			
				lcd_validate_cmd();
			}
		}
		else if (key == KEY_OK)
		{
			if (KEY_TYPE(key_msg) == MASK_KEY_PRESS)
			{
				TEST_CMD test_cmd;
				
				if (s_cr_mode == CR_FOCUS_MODE)
				{	
					s_cur_resist = s_cr_mode_resist_set;
					draw_edit_resist_val(s_cur_resist);
				
					lcd_validate_cmd();
				
					s_cr_mode = CR_EDIT_MODE;		
					
					/* notify to start test */
					test_cmd.channel   = SLAVE_PORT_0;
					test_cmd.test_type = TEST_TYPE_CR_MODE;
					test_cmd.test_config.cr_mode_config.resist_val = s_cur_resist;
					test_cmd_notify(&test_cmd);

					TRACE("start testing\n");

					all_pass_led_on();
				}
				else
				{
					s_cr_mode_resist_set = s_cur_resist;
					draw_focus_resist_val(s_cr_mode_resist_set);
				
					lcd_validate_cmd();

					save_parameter(STRUCT_OFFSET(PARAMETER, cr_mode_resist_set), &s_cr_mode_resist_set, sizeof(s_cr_mode_resist_set));
					
					s_cr_mode = CR_FOCUS_MODE;
					
					/* notify to stop test */
					test_cmd.channel   = SLAVE_PORT_0;
					test_cmd.test_type = TEST_TYPE_NONE;
					test_cmd_notify(&test_cmd);		

					TRACE("stop testing\n");

					all_pass_led_off();
				}
			}
		}
		else if (key == KEY_CANCEL)
		{
			if (s_cr_mode == CR_FOCUS_MODE)
			{
				switch_to_menu(MENU_ID_MAIN);
			}
			else
			{
				TEST_CMD test_cmd;
				
				draw_focus_resist_val(s_cr_mode_resist_set);
				
				lcd_validate_cmd();
				
				s_cr_mode = CR_FOCUS_MODE;

				/* notify to stop test */
				test_cmd.channel   = SLAVE_PORT_0;
				test_cmd.test_type = TEST_TYPE_NONE;
				test_cmd_notify(&test_cmd);	

				TRACE("stop testing\n");

				all_pass_led_off();	
			}
		}
	}
	else
	{
		/* release */
		if (key == KEY_UP || key == KEY_DOWN
			|| key == KEY_LEFT || key == KEY_RIGHT)
		{
			if (s_cr_mode == CR_EDIT_MODE)
			{
				TEST_CMD test_cmd;
					
				/* notify */
				test_cmd.channel   = SLAVE_PORT_0;
				test_cmd.test_type = TEST_TYPE_CR_MODE;
				test_cmd.test_config.cr_mode_config.resist_val = s_cur_resist;
				test_cmd_notify(&test_cmd);

				TRACE("start testing\n");
			}
		}
	}
}