Archive for the programming Category

Note: usage repo tips

Posted in programming, repo, SCM(Software Configuration Management) on 2017 年 07 月 26 日 by Kun-Yi
repo sync –no-tags –no-clone-bundle -jN -c
 
這就只會拉你要的那個 (repo init -u URI -b branch)branch or tags
N: integer for parallel process
repo init 時加上 –reference local_path 可以把使用自己已經先 mirror repositories
這是透過git clone 的 –reference 作到的
例如 先參考 https://source.android.com/source/downloading#using-a-local-mirror
做出一個 local mirror
搭配適當的指令可以快速repo sync

Note: using SetupAPI to find a special device on Windows system,

Posted in programming, WINDOWS with tags on 2015 年 01 月 19 日 by Kun-Yi
// EnumHIDDevice.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#pragma comment(lib, "setupapi")

bool chkDigitizer(void)
{
    HDEVINFO hDevInfo = INVALID_HANDLE_VALUE;
    bool bFind = false;
    hDevInfo = SetupDiGetClassDevs(
        &GUID_DEVCLASS_HIDCLASS,
        NULL,
        NULL,
        DIGCF_PRESENT);
#if 0
    // get special device instance
    hDevInfo = SetupDiGetClassDevs(
        &GUID_DEVCLASS_HIDCLASS,
        TEXT("HID\\VID_0458&PID_501E&COL05\\7&198536FE&0&0004"),
        NULL,
        DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
#endif

    if (INVALID_HANDLE_VALUE == hDevInfo)
        return false;

    SP_DEVINFO_DATA DeviceInfoData;
    ULONG DeviceIndex;

    ZeroMemory(&DeviceInfoData, sizeof(SP_DEVINFO_DATA));
    DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
    DeviceIndex = 0;
    while (SetupDiEnumDeviceInfo(hDevInfo, DeviceIndex, &DeviceInfoData))
    {
        DeviceIndex++;

        TCHAR InstanceID[MAX_PATH + 1];
        DWORD reqSize = 0;
        TCHAR CheckLists[][MAX_PATH + 1] = {
            TEXT("HID\\VID_0458&PID_5020&COL05"), // new
            TEXT("HID\\VID_0458&PID_501E&COL05"), // older
        };

        SetupDiGetDeviceInstanceId(hDevInfo, &DeviceInfoData, InstanceID, sizeof(InstanceID), &reqSize);
        for (ULONG i = 0; i < 2; i++)
            if (NULL != _tcsstr(InstanceID, CheckLists[i]))
            {
                bFind = true;
                break;
            }
    }
    if (INVALID_HANDLE_VALUE != hDevInfo)
        SetupDiDestroyDeviceInfoList(hDevInfo);

    return bFind;
}

int _tmain(int argc, _TCHAR* argv[])
{

    if (chkDigitizer())
        _tprintf(TEXT("Find out a digitizer device on system\n"));
    else
        _tprintf(TEXT("no digitizer on system\n"));

	return 0;
}