示例#1
0
文件: mtdev-test.c 项目: jiixyj/mtdev
static void loop_device(int fd)
{
	struct mtdev dev;
	struct input_event ev;
	int ret = mtdev_open(&dev, fd);
	if (ret) {
		fprintf(stderr, "error: could not open device: %d\n", ret);
		return;
	}
	show_props(&dev);
	/* while the device has not been inactive for five seconds */
	while (!mtdev_idle(&dev, fd, 5000)) {
		/* extract all available processed events */
		while (mtdev_get(&dev, fd, &ev, 1) > 0) {
			if (use_event(&ev))
				print_event(&ev);
		}
	}
	mtdev_close(&dev);
}
示例#2
0
//====================
void CommandItem::Invoke(int button)
{
    LPCITEMIDLIST pidl = GetPidl();
    if (INVOKE_PROP & button)
    {
        show_props(pidl);
        return;
    }
		/*BlackboxZero 1.7.2012 */
        char szPath[MAX_PATH];
		szPath[0] = '\0';

    if (INVOKE_LEFT & button)
    {

        m_pMenu->hide_on_click();
        if (m_pszCommand) {
			/*BlackboxZero 1.7.2012 */
			//if (const char *p = strstr(m_pszCommand, "%b")) {
            //    post_command_fmt(m_pszCommand, false == m_bChecked);
			if (const char *p = stristr(m_pszCommand, "@BBCore.exec ")) {
                _strcpy(szPath, p+13);
				post_command(m_pszCommand);
			} else
                post_command(m_pszCommand);
		} else if (pidl) {
			char buf[MAX_PATH];
		/*BlackboxZero 1.7.2012 */
			char szMenuPath[MAX_PATH];
			szMenuPath[0] = '\0';
			if (SHGetPathFromIDList(pidl, buf))
				sprintf(szPath, "\"%s\"", buf);
			/*BlackboxZero 1.7.2012 */

            BBExecute_pidl(NULL, pidl);

			/*BlackboxZero 1.7.2012 */
			strcpy(szMenuPath, unquote(Settings_recentMenu));
			int nKeep = Settings_recentItemKeepSize;
			int nSort = Settings_recentItemSortSize;
			bool bBeginEnd = Settings_recentBeginEnd;

			if (szPath[0] && szMenuPath[0] && (nKeep || nSort))
				CreateRecentItemMenu(szMenuPath, szPath, m_pszTitle, m_pszIcon, nKeep, nSort, bBeginEnd);
			/*BlackboxZero 1.7.2012 */
		}
        return;
    }

    if (INVOKE_RIGHT & button)
    {
        if (m_pszRightCommand)
            post_command(m_pszRightCommand);
        else
        if (m_pRightmenu)
            m_pRightmenu->incref(), ShowRightMenu(m_pRightmenu);
        else
		if ((GetAsyncKeyState (VK_SHIFT) & 0x8000))
		{
			char buffer[MAX_PATH], param[MAX_PATH];
			char *tokens[1];
			tokens[0] = param;
			BBTokenize((const char*)m_pszCommand, tokens, 1, param);
			if (0 == _memicmp(m_pszCommand, "@BBCfg.plugin", 12)) 
			{
				if ((GetAsyncKeyState (VK_CONTROL) & 0x8000))
					sprintf(buffer, "@BBCfg.plugin.remove %s", param);
				else
					sprintf(buffer, "@BBCfg.plugin.edit %s", param);
				post_command(buffer);
			}
			else
				if (0 == _memicmp(m_pszCommand, "@BBCore.style", 12)) 
				{
					sprintf(buffer, "@BBCore.edit %s", param);
					post_command(buffer);
				}
		}
		else
            ShowContextMenu(m_pszCommand, pidl);
        return;
    }

    if (INVOKE_MID & button)
    {
		if (0 == _memicmp(m_pszCommand, "@BBCfg.plugin", 12)) 
		{
			char buffer[MAX_PATH], param[MAX_PATH];
			char *tokens[1];
			tokens[0] = param;
			BBTokenize((const char*)m_pszCommand, tokens, 1, param);
			sprintf(buffer, "@BBCfg.plugin.docs %s", param);
			post_command(buffer);
		}
		return;
	}

    if (INVOKE_DRAG & button)
    {
        m_pMenu->start_drag(m_pszCommand, pidl);
        return;
    }
}