diff options
| author | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-03-26 10:14:52 +0100 | 
|---|---|---|
| committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-03-26 10:14:52 +0100 | 
| commit | 257c0d9b563f91d6613a8dd8c6bb4be0a1366036 (patch) | |
| tree | c50e75a48654dad22bcb25000691f0b976523019 /test | |
Initial import
Diffstat (limited to 'test')
| -rw-r--r-- | test/test.cc | 44 | ||||
| -rw-r--r-- | test/test.vcxproj | 90 | 
2 files changed, 134 insertions, 0 deletions
diff --git a/test/test.cc b/test/test.cc new file mode 100644 index 0000000..4a6e3ee --- /dev/null +++ b/test/test.cc @@ -0,0 +1,44 @@ +#include <stdio.h> +#include <time.h> + +#include <libusbhp.h> + +static void attach_fn(struct libusbhp_device_t *device, void *user_data) +{ +  printf("attach\n"); +  if(device) printf("  (%04x/%04x)\n", device->idVendor, device->idProduct); +} + +static void detach_fn(struct libusbhp_device_t *device, void *user_data) +{ +  printf("detach\n"); +  if(device) printf("  (%04x/%04x)\n", device->idVendor, device->idProduct); +} + +int main(int args, char* argv[]) +{ +  struct libusbhp_t *handle; + +  int ret = libusbhp_init(&handle); +  if(ret != 0) { +    printf("Could not initialise handle.\n"); +    return 1; +  } + +  libusbhp_register_hotplug_listeners(handle, attach_fn, detach_fn, NULL); + +  // 100ms timeout +  struct timeval tv; +  tv.tv_sec = 0; +  tv.tv_usec = 100000; + +  while(1) { +    int ret = libusbhp_handle_events_timeout(handle, &tv); +    if(ret) printf("handle_events failed [%d]...\n", ret); +    printf("loop\n"); +  } + +  libusbhp_exit(handle); + +  return 0; +} diff --git a/test/test.vcxproj b/test/test.vcxproj new file mode 100644 index 0000000..be61eef --- /dev/null +++ b/test/test.vcxproj @@ -0,0 +1,90 @@ +<?xml version="1.0" encoding="utf-8"?>
 +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 +  <ItemGroup Label="ProjectConfigurations">
 +    <ProjectConfiguration Include="Debug|Win32">
 +      <Configuration>Debug</Configuration>
 +      <Platform>Win32</Platform>
 +    </ProjectConfiguration>
 +    <ProjectConfiguration Include="Release|Win32">
 +      <Configuration>Release</Configuration>
 +      <Platform>Win32</Platform>
 +    </ProjectConfiguration>
 +  </ItemGroup>
 +  <ItemGroup>
 +    <ClCompile Include="test.cc" />
 +  </ItemGroup>
 +  <ItemGroup>
 +    <ProjectReference Include="..\libusbhp\libusbhp.vcxproj">
 +      <Project>{1b43450c-2534-451f-985c-2d0ba0ef5a43}</Project>
 +    </ProjectReference>
 +  </ItemGroup>
 +  <PropertyGroup Label="Globals">
 +    <ProjectGuid>{285305E3-918A-458B-BD54-F2D09953F2D2}</ProjectGuid>
 +    <Keyword>Win32Proj</Keyword>
 +    <RootNamespace>test</RootNamespace>
 +  </PropertyGroup>
 +  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
 +  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
 +    <ConfigurationType>Application</ConfigurationType>
 +    <UseDebugLibraries>true</UseDebugLibraries>
 +    <PlatformToolset>v110</PlatformToolset>
 +    <CharacterSet>Unicode</CharacterSet>
 +  </PropertyGroup>
 +  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
 +    <ConfigurationType>Application</ConfigurationType>
 +    <UseDebugLibraries>false</UseDebugLibraries>
 +    <PlatformToolset>v110</PlatformToolset>
 +    <WholeProgramOptimization>true</WholeProgramOptimization>
 +    <CharacterSet>Unicode</CharacterSet>
 +  </PropertyGroup>
 +  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
 +  <ImportGroup Label="ExtensionSettings">
 +  </ImportGroup>
 +  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
 +    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
 +  </ImportGroup>
 +  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
 +    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
 +  </ImportGroup>
 +  <PropertyGroup Label="UserMacros" />
 +  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
 +    <LinkIncremental>true</LinkIncremental>
 +  </PropertyGroup>
 +  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
 +    <LinkIncremental>false</LinkIncremental>
 +  </PropertyGroup>
 +  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
 +    <ClCompile>
 +      <PrecompiledHeader>
 +      </PrecompiledHeader>
 +      <WarningLevel>Level3</WarningLevel>
 +      <Optimization>Disabled</Optimization>
 +      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
 +      <AdditionalIncludeDirectories>..\libusbhp;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
 +    </ClCompile>
 +    <Link>
 +      <SubSystem>Console</SubSystem>
 +      <GenerateDebugInformation>true</GenerateDebugInformation>
 +    </Link>
 +  </ItemDefinitionGroup>
 +  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
 +    <ClCompile>
 +      <WarningLevel>Level3</WarningLevel>
 +      <PrecompiledHeader>
 +      </PrecompiledHeader>
 +      <Optimization>MaxSpeed</Optimization>
 +      <FunctionLevelLinking>true</FunctionLevelLinking>
 +      <IntrinsicFunctions>true</IntrinsicFunctions>
 +      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
 +    </ClCompile>
 +    <Link>
 +      <SubSystem>Console</SubSystem>
 +      <GenerateDebugInformation>true</GenerateDebugInformation>
 +      <EnableCOMDATFolding>true</EnableCOMDATFolding>
 +      <OptimizeReferences>true</OptimizeReferences>
 +    </Link>
 +  </ItemDefinitionGroup>
 +  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
 +  <ImportGroup Label="ExtensionTargets">
 +  </ImportGroup>
 +</Project>
\ No newline at end of file  | 
