Ejemplo n.º 1
0
// デストラクタ
KinectV2::~KinectV2()
{
  if (getActivated() > 0)
  {
    // データ変換用のメモリを削除する
    delete[] position;
    delete[] color;

    // センサを開放する
    colorReader->Release();
    depthReader->Release();
    coordinateMapper->Release();
    sensor->Close();
    sensor->Release();

    // センサを開放したことを記録する
    sensor = NULL;
  }
}
Ejemplo n.º 2
0
//创建一则消息,包括将其加入MsgTable和MsgQueue中
void createMsg(int msg_type, int pos_x, int pos_y, char key)
{
    int x = pos_x;
    int y = pos_y;
    //if(msg_type != 0) cprintf("msg type: %d\n", msg_type);
    /*if(msg_type == MSG_LPRESS || msg_type == MSG_RPRESS || msg_type == MSG_DOUBLECLICK
        || msg_type == MSG_KEYDOWN || msg_type == MSG_DRAG)
        cprintf("msg type: %d\n", msg_type);*/
	int pid;
    int msg_index;
	if(msg_type == MSG_KEYDOWN)//键盘事件
	{
		pid = getActivated()->pid;
        msg_index = requireMsg(msg_type, x, y, key, 0);
	    if (msg_index == -1) return;
        dispatch(pid, msg_index);
	}
	else//鼠标事件
	{
        if(mouse_x == -1) mouse_x = pos_x;
        if(mouse_y == -1) mouse_y = pos_y;

        struct Window* win_ptr = getWindowByPoint(pos_x, pos_y);
        //cprintf("%d\n", win_ptr);
        pid = win_ptr->pid;

        x = pos_x - win_ptr->window_position.left_x;//relative x
        y = pos_y - win_ptr->window_position.left_y;//relative y

        if(msg_type == MSG_LPRESS || msg_type == MSG_RPRESS || msg_type == MSG_DOUBLECLICK)
        {
            if (win_ptr->next_window != 0)
                setActivated(win_ptr);
            msg_index = requireMsg(msg_type, x, y, key, 0);
	        if (msg_index == -1) return;
            dispatch(pid, msg_index);
        }

        if(msg_type == MSG_DRAG)
        {
            if (win_ptr->next_window != 0)
              setActivated(win_ptr);
        	if(win_ptr->prior_window == 0)//desktop
            {
                mouse_x = pos_x;
                mouse_y = pos_y;
		        drawMouse(pos_x, pos_y);
             	return;
            }

            int dx = pos_x - mouse_x;
            int dy = pos_y - mouse_y;

            int win_left_x = win_ptr->window_position.left_x;
            int win_left_y = win_ptr->window_position.left_y;
            int win_right_x = win_ptr->window_position.right_x;
            int win_right_y = win_ptr->window_position.right_y;

            int x1 = (dx > 0) ? win_left_x : (win_left_x + dx);
            int y1 = (dy > 0) ? win_left_y : (win_left_y + dy);
            int x2 = (dx > 0) ? (win_right_x + dx) : win_right_x;
            int y2 = (dy > 0) ? (win_right_y + dy) : win_right_y;

            /*if( (dx > -10 && dx < 10)|| (dy > -10 && dy < 10))
            {
                //cprintf("one tiny drag!\n");
                return;
            }*/
            if(win_left_x + dx >= 0 && win_left_y + dy >= 0
                && win_right_x + dx < SCREEN_WIDTH
                && win_right_y + dy < SCREEN_HEIGHT)//判断合法位移
            {
                win_ptr->window_position.left_x += dx;
                win_ptr->window_position.left_y += dy;
                win_ptr->window_position.right_x += dx;
                win_ptr->window_position.right_y += dy;
            }
            else
            {
                mouse_x = pos_x;
                mouse_y = pos_y;
		        drawMouse(pos_x, pos_y);
                return;
            }
            /*
	        if (msg_index == -1) return;*/
            //dispatch(pid, msg_index);
            cprintf("update area: x1: %d, y1: %d, x2: %d, y2:%d.\n", x1, y1, x2, y2);
            //drawScreenArea(x1, y1, x2, y2);
            drawScreen();
            mouse_x = pos_x;
            mouse_y = pos_y;
            setMouse(mouse_x, mouse_y);
            return;
        }

        mouse_x = pos_x;
        mouse_y = pos_y;
		drawMouse(pos_x, pos_y);
	}
}