--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore Wed Aug 14 16:16:58 2019 +0200
@@ -0,0 +1,13 @@
+syntax: glob
+
+*~
+CMakeLists.txt.user
+
+syntax: regexp
+
+^temp/
+
+^\.dep\.inc
+^dist/
+^build/
+^nbproject/private/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/CMakeLists.txt Wed Aug 14 16:16:58 2019 +0200
@@ -0,0 +1,3 @@
+project (cadMousePro)
+cmake_minimum_required(VERSION 2.8)
+add_subdirectory (src)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nbproject/configurations.xml Wed Aug 14 16:16:58 2019 +0200
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+
+Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved.
+
+Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+Other names may be trademarks of their respective owners.
+
+The contents of this file are subject to the terms of either the GNU
+General Public License Version 2 only ("GPL") or the Common
+Development and Distribution License("CDDL") (collectively, the
+"License"). You may not use this file except in compliance with the
+License. You can obtain a copy of the License at
+http://www.netbeans.org/cddl-gplv2.html
+or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+specific language governing permissions and limitations under the
+License. When distributing the software, include this License Header
+Notice in each file and include the License file at
+nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
+particular file as subject to the "Classpath" exception as provided
+by Oracle in the GPL Version 2 section of the License file that
+accompanied this code. If applicable, add the following below the
+License Header, with the fields enclosed by brackets [] replaced by
+your own identifying information:
+"Portions Copyrighted [year] [name of copyright owner]"
+
+If you wish your version of this file to be governed by only the CDDL
+or only the GPL Version 2, indicate your decision by adding
+"[Contributor] elects to include this software in this distribution
+under the [CDDL or GPL Version 2] license." If you do not indicate a
+single choice of license, a recipient has the option to distribute
+your version of this file under either the CDDL, the GPL Version 2 or
+to extend the choice of license to its licensees as provided above.
+However, if you add GPL Version 2 code and therefore, elected the GPL
+Version 2 license, then the option applies only if the new code is
+made subject to such option by the copyright holder.
+
+Contributor(s):
+-->
+<configurationDescriptor version="100">
+ <logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">
+ <df root="." name="0">
+ <df name="src">
+ <in>cadMousePro.cpp</in>
+ </df>
+ </df>
+ <logicalFolder name="ExternalFiles"
+ displayName="Important Files"
+ projectFiles="false"
+ kind="IMPORTANT_FILES_FOLDER">
+ <itemPath>CMakeLists.txt</itemPath>
+ <itemPath>build/Debug/Makefile</itemPath>
+ <itemPath>build/Release/Makefile</itemPath>
+ </logicalFolder>
+ </logicalFolder>
+ <sourceFolderFilter>^(nbproject|build)$</sourceFolderFilter>
+ <sourceRootList>
+ <Elem>.</Elem>
+ </sourceRootList>
+ <projectmakefile>build/Debug/Makefile</projectmakefile>
+ <confs>
+ <conf name="Debug" type="0">
+ <toolsSet>
+ <compilerSet>default</compilerSet>
+ <dependencyChecking>false</dependencyChecking>
+ <rebuildPropChanged>false</rebuildPropChanged>
+ </toolsSet>
+ <flagsDictionary>
+ <element flagsID="0" commonFlags="-fsanitize=address"/>
+ </flagsDictionary>
+ <codeAssistance>
+ </codeAssistance>
+ <makefileType>
+ <makeTool>
+ <buildCommandWorkingDir>build/Debug</buildCommandWorkingDir>
+ <buildCommand>${MAKE} -f Makefile</buildCommand>
+ <cleanCommand>${MAKE} -f Makefile clean</cleanCommand>
+ <executablePath>build/Debug/src/welcome</executablePath>
+ <ccTool>
+ <incDir>
+ <pElem>/usr/include/hidapi</pElem>
+ <pElem>build/Debug/src</pElem>
+ </incDir>
+ </ccTool>
+ </makeTool>
+ <preBuild>
+ <preBuildCommandWorkingDir>build/Debug</preBuildCommandWorkingDir>
+ <preBuildCommand>${CMAKE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=${IDE_CC} -DCMAKE_CXX_COMPILER=${IDE_CXX} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../..</preBuildCommand>
+ <preBuildFirst>true</preBuildFirst>
+ </preBuild>
+ </makefileType>
+ <item path="src/cadMousePro.cpp" ex="false" tool="1" flavor2="0">
+ <ccTool flags="0">
+ </ccTool>
+ </item>
+ </conf>
+ <conf name="Release" type="0">
+ <toolsSet>
+ <compilerSet>default</compilerSet>
+ <dependencyChecking>false</dependencyChecking>
+ <rebuildPropChanged>false</rebuildPropChanged>
+ </toolsSet>
+ <flagsDictionary>
+ <element flagsID="0" commonFlags="-O3"/>
+ </flagsDictionary>
+ <codeAssistance>
+ </codeAssistance>
+ <makefileType>
+ <makeTool>
+ <buildCommandWorkingDir>build/Release</buildCommandWorkingDir>
+ <buildCommand>${MAKE} -f Makefile</buildCommand>
+ <cleanCommand>${MAKE} -f Makefile clean</cleanCommand>
+ <executablePath>build/Release/src/welcome</executablePath>
+ <ccTool>
+ <incDir>
+ <pElem>build/Release/src</pElem>
+ </incDir>
+ <preprocessorList>
+ <Elem>NDEBUG</Elem>
+ </preprocessorList>
+ </ccTool>
+ </makeTool>
+ <preBuild>
+ <preBuildCommandWorkingDir>build/Release</preBuildCommandWorkingDir>
+ <preBuildCommand>${CMAKE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=${IDE_CC} -DCMAKE_CXX_COMPILER=${IDE_CXX} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../..</preBuildCommand>
+ <preBuildFirst>true</preBuildFirst>
+ </preBuild>
+ </makefileType>
+ <item path="src/cadMousePro.cpp" ex="false" tool="1" flavor2="0">
+ <ccTool flags="0">
+ </ccTool>
+ </item>
+ </conf>
+ </confs>
+</configurationDescriptor>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nbproject/project.xml Wed Aug 14 16:16:58 2019 +0200
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+
+Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved.
+
+Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+Other names may be trademarks of their respective owners.
+
+The contents of this file are subject to the terms of either the GNU
+General Public License Version 2 only ("GPL") or the Common
+Development and Distribution License("CDDL") (collectively, the
+"License"). You may not use this file except in compliance with the
+License. You can obtain a copy of the License at
+http://www.netbeans.org/cddl-gplv2.html
+or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+specific language governing permissions and limitations under the
+License. When distributing the software, include this License Header
+Notice in each file and include the License file at
+nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
+particular file as subject to the "Classpath" exception as provided
+by Oracle in the GPL Version 2 section of the License file that
+accompanied this code. If applicable, add the following below the
+License Header, with the fields enclosed by brackets [] replaced by
+your own identifying information:
+"Portions Copyrighted [year] [name of copyright owner]"
+
+If you wish your version of this file to be governed by only the CDDL
+or only the GPL Version 2, indicate your decision by adding
+"[Contributor] elects to include this software in this distribution
+under the [CDDL or GPL Version 2] license." If you do not indicate a
+single choice of license, a recipient has the option to distribute
+your version of this file under either the CDDL, the GPL Version 2 or
+to extend the choice of license to its licensees as provided above.
+However, if you add GPL Version 2 code and therefore, elected the GPL
+Version 2 license, then the option applies only if the new code is
+made subject to such option by the copyright holder.
+
+Contributor(s):
+-->
+<project xmlns="http://www.netbeans.org/ns/project/1">
+ <type>org.netbeans.modules.cnd.makeproject</type>
+ <configuration>
+ <data xmlns="http://www.netbeans.org/ns/make-project/1">
+ <name>cadMousePro</name>
+ <c-extensions/>
+ <cpp-extensions>cpp</cpp-extensions>
+ <header-extensions/>
+ <sourceEncoding>UTF-8</sourceEncoding>
+ <sourceRootList>
+ <sourceRootElem>.</sourceRootElem>
+ </sourceRootList>
+ <make-dep-projects/>
+ <sourceRootList>
+ <sourceRootElem>.</sourceRootElem>
+ </sourceRootList>
+ <confList>
+ <confElem>
+ <name>Debug</name>
+ <type>0</type>
+ </confElem>
+ <confElem>
+ <name>Release</name>
+ <type>0</type>
+ </confElem>
+ </confList>
+ <formatting>
+ <project-formatting-style>false</project-formatting-style>
+ </formatting>
+ </data>
+ </configuration>
+</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/CMakeLists.txt Wed Aug 14 16:16:58 2019 +0200
@@ -0,0 +1,21 @@
+set(EXECUTABLE_FILE "cadMousePro")
+
+# USB libraries:
+INCLUDE(FindPkgConfig)
+pkg_check_modules (USB_LIBS hidapi-hidraw)
+include_directories(${USB_LIBS_INCLUDE_DIRS})
+link_directories(${USB_LIBS_LIBRARY_DIRS})
+
+# Add ASan AddressSanitizer
+set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
+set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
+
+# Executable output:
+add_executable(
+ ${EXECUTABLE_FILE}
+ cadMousePro.cpp
+)
+
+# Link libraries:
+target_link_libraries(${EXECUTABLE_FILE} ${USB_LIBS_LIBRARIES})
+set_property(TARGET ${EXECUTABLE_FILE} PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cadMousePro.cpp Wed Aug 14 16:16:58 2019 +0200
@@ -0,0 +1,49 @@
+#include <iostream>
+
+#include <hidapi/hidapi.h>
+
+class HIDException {
+private:
+ std::wstring message;
+public:
+
+ HIDException(std::wstring message) : message(message) {
+ }
+
+ virtual ~HIDException() {
+ }
+
+ const std::wstring getMessage() const {
+ return message;
+ }
+
+};
+
+class HIDDevice {
+private:
+ hid_device* handle;
+public:
+
+ HIDDevice(unsigned short vendorId, unsigned short productId, const wchar_t *serialNumber) {
+ handle = hid_open(vendorId, productId, serialNumber);
+ if (handle == nullptr) throw HIDException(L"Unable to open HID device. Are you root? Is mouse present?");
+ }
+
+ virtual ~HIDDevice() {
+ hid_close(handle);
+ }
+
+
+};
+
+int main(int argc, char** argv) {
+ try {
+
+ std::wcout << L"cadMousePro" << std::endl;
+ HIDDevice mouse(0x256f, 0xc652, nullptr);
+ std::wcout << L"mouse opened" << std::endl;
+ } catch (const HIDException& e) {
+ std::wcout << L"HIDException: " << e.getMessage() << std::endl;
+
+ }
+}
\ No newline at end of file