project(libtouchmouse)
-# Set up output folder
+# Set up output folders
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
+set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
# Add include path to hidapi.h
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/hidapi/hidapi ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR})
# Build demo
add_executable(consoledemo examples/consoledemo.c)
if(WIN32)
+ target_link_libraries(touchmouse setupapi)
target_link_libraries(consoledemo touchmouse setupapi)
elseif(NOT APPLE)
target_link_libraries(consoledemo touchmouse usb-1.0 pthread rt)
#define __LIBTOUCHMOUSE_H__
#include <stdint.h>
+// Win32 needs symbols exported.
+#ifndef _WIN32
+ #define TOUCHMOUSEAPI
+#else
+ #ifdef __cplusplus
+ #define TOUCHMOUSEAPI extern "C" __declspec(dllexport)
+ #else
+ #define TOUCHMOUSEAPI __declspec(dllexport)
+ #endif
+#endif
+
// Types:
struct touchmouse_device_;
typedef struct touchmouse_device_ touchmouse_device;
} touchmouse_mode;
// Library initialization/destruction
-int touchmouse_init(void);
-int touchmouse_shutdown(void);
+TOUCHMOUSEAPI int touchmouse_init(void);
+TOUCHMOUSEAPI int touchmouse_shutdown(void);
// Device enumeration/open/close/free
-touchmouse_device_info* touchmouse_enumerate_devices(void);
-void touchmouse_free_enumeration(touchmouse_device_info *devs);
-int touchmouse_open(touchmouse_device **dev, touchmouse_device_info *dev_info);
-int touchmouse_close(touchmouse_device *dev);
+TOUCHMOUSEAPI touchmouse_device_info* touchmouse_enumerate_devices(void);
+TOUCHMOUSEAPI void touchmouse_free_enumeration(touchmouse_device_info *devs);
+TOUCHMOUSEAPI int touchmouse_open(touchmouse_device **dev, touchmouse_device_info *dev_info);
+TOUCHMOUSEAPI int touchmouse_close(touchmouse_device *dev);
// Set mouse mode.
-int touchmouse_set_device_mode(touchmouse_device *dev, touchmouse_mode mode);
+TOUCHMOUSEAPI int touchmouse_set_device_mode(touchmouse_device *dev, touchmouse_mode mode);
// Register callback for touch image updates
-int touchmouse_set_image_update_callback(touchmouse_device *dev, touchmouse_image_callback callback);
+TOUCHMOUSEAPI int touchmouse_set_image_update_callback(touchmouse_device *dev, touchmouse_image_callback callback);
// Allow for setting a piece of user-defined data to be provided in the callback.
-int touchmouse_set_device_userdata(touchmouse_device *dev, void *userdata);
+TOUCHMOUSEAPI int touchmouse_set_device_userdata(touchmouse_device *dev, void *userdata);
// Process events for a device.
// milliseconds < 0 means "block until you have new data and trigger the callback, then return."
// milliseconds = 0 means "trigger the callback if you have the data waiting, otherwise request data async and return immediately"
// milliseconds > 0 means "fetch data. Trigger a callback if the data arrives within <arg> milliseconds, otherwise return."
-int touchmouse_process_events_timeout(touchmouse_device *dev, int milliseconds);
+TOUCHMOUSEAPI int touchmouse_process_events_timeout(touchmouse_device *dev, int milliseconds);
#endif /* __LIBTOUCHMOUSE_H__ */