From: Drew Fisher Date: Sat, 29 Oct 2011 20:14:03 +0000 (-0700) Subject: Windows is annoying. X-Git-Url: http://git.zarvox.org/%7Bgravatar%7D?a=commitdiff_plain;h=8dc658a8597e3e8f94c63804f9f3e9ad9f3b1108;p=libtouchmouse.git Windows is annoying. Declare all the things in libtouchmouse.h with dllexport. Also put output library in a lib folder Signed-off-by: Drew Fisher --- diff --git a/CMakeLists.txt b/CMakeLists.txt index d1ff373..28df86d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,8 +4,9 @@ cmake_minimum_required(VERSION 2.6) 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}) @@ -36,6 +37,7 @@ add_library(touchmouse SHARED ${LIBSRC}) # 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) diff --git a/libtouchmouse/libtouchmouse.h b/libtouchmouse/libtouchmouse.h index dc57fcf..1d38ea1 100644 --- a/libtouchmouse/libtouchmouse.h +++ b/libtouchmouse/libtouchmouse.h @@ -2,6 +2,17 @@ #define __LIBTOUCHMOUSE_H__ #include +// 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; @@ -30,28 +41,28 @@ typedef enum { } 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 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__ */