feat: Update symbol visibility

mouse-isometric-mode
nirenjan 2026-03-30 22:35:52 -07:00
parent 357ea96676
commit 667e8e2a7b
18 changed files with 146 additions and 72 deletions

View File

@ -19,6 +19,11 @@ LT_INIT
PKG_PROG_PKG_CONFIG
PKG_INSTALLDIR
AX_COMPILER_FLAGS
VISIBILITY_CFLAGS=
if test "x$GCC" = xyes; then
VISIBILITY_CFLAGS="-fvisibility=hidden"
fi
AC_SUBST([VISIBILITY_CFLAGS])
AC_CANONICAL_HOST
AX_GCC_FUNC_ATTRIBUTE([constructor])
AX_GCC_FUNC_ATTRIBUTE([destructor])

View File

@ -61,8 +61,11 @@ libx52dcomm_la_CFLAGS = \
-DLOCALEDIR=\"$(localedir)\" \
-DLOGDIR=\"$(localstatedir)/log\" \
-DRUNDIR=\"$(localstatedir)/run\" \
$(VISIBILITY_CFLAGS) \
$(WARN_CFLAGS)
libx52dcomm_la_LDFLAGS = $(WARN_LDFLAGS)
libx52dcomm_la_LDFLAGS = \
-export-symbols-regex '^x52d_(dial_command|dial_notify|format_command|send_command|recv_notification)$' \
$(WARN_LDFLAGS)
x52include_HEADERS += daemon/x52dcomm.h

View File

@ -11,6 +11,7 @@ install_headers('x52dcomm.h', subdir: meson.project_name())
lib_libx52dcomm = library('x52dcomm', libx52dcomm_sources,
dependencies: [dep_intl],
version: libx52dcomm_version,
c_args: sym_hidden_cargs,
install: true,
include_directories: includes)
@ -31,14 +32,15 @@ x52d_sources = [
]
dep_threads = dependency('threads')
x52d_linkwith = [lib_libx52, lib_libx52dcomm, lib_vkm, lib_libx52io]
# Comm sources are compiled into x52d (same as Autotools); libx52dcomm is only for x52ctl.
x52d_linkwith = [lib_libx52, lib_vkm, lib_libx52io]
x52d_deps = [dep_pinelog, dep_inih, dep_threads, dep_intl]
x52d_cflags = []
exe_x52d = executable('x52d', x52d_sources,
exe_x52d = executable('x52d', x52d_sources + libx52dcomm_sources,
install: true,
include_directories: includes,
c_args: x52d_cflags,
c_args: sym_hidden_cargs + x52d_cflags,
dependencies: x52d_deps,
link_with: x52d_linkwith)

View File

@ -22,6 +22,16 @@
#include <stddef.h>
#ifndef X52DCOMM_API
# if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
# define X52DCOMM_API __attribute__((visibility("default")))
# elif defined(_WIN32)
# define X52DCOMM_API __declspec(dllexport)
# else
# define X52DCOMM_API
# endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
@ -52,7 +62,7 @@ extern "C" {
*
* @exception E2BIG returned if the passed socket path is too big
*/
int x52d_dial_command(const char *sock_path);
X52DCOMM_API int x52d_dial_command(const char *sock_path);
/**
* @brief Open a connection to the daemon notify socket.
@ -73,7 +83,7 @@ int x52d_dial_command(const char *sock_path);
*
* @exception E2BIG returned if the passed socket path is too big
*/
int x52d_dial_notify(const char *sock_path);
X52DCOMM_API int x52d_dial_notify(const char *sock_path);
/**
* @brief Format a series of command strings into a buffer
@ -92,7 +102,7 @@ int x52d_dial_notify(const char *sock_path);
* @returns number of bytes in the formatted command
* @returns -1 on an error condition, and \c errno is set accordingly.
*/
int x52d_format_command(int argc, const char **argv, char *buffer, size_t buflen);
X52DCOMM_API int x52d_format_command(int argc, const char **argv, char *buffer, size_t buflen);
/**
* @brief Send a command to the daemon and retrieve the response.
@ -121,7 +131,7 @@ int x52d_format_command(int argc, const char **argv, char *buffer, size_t buflen
* @returns number of bytes returned from the server
* @returns -1 on an error condition, and \c errno is set accordingly.
*/
int x52d_send_command(int sock_fd, char *buffer, size_t bufin, size_t bufout);
X52DCOMM_API int x52d_send_command(int sock_fd, char *buffer, size_t bufin, size_t bufout);
/**
* @brief Notification callback function type
@ -147,7 +157,7 @@ typedef int (* x52d_notify_callback_fn)(int argc, char **argv);
* @returns return code of the callback function on success
* @returns -1 on an error condition, and \c errno is set accordingly.
*/
int x52d_recv_notification(int sock_fd, x52d_notify_callback_fn callback);
X52DCOMM_API int x52d_recv_notification(int sock_fd, x52d_notify_callback_fn callback);
/** @} */
#ifdef __cplusplus

View File

@ -24,6 +24,7 @@ libx52_la_CFLAGS = \
@LIBUSB_CFLAGS@ \
-DLOCALEDIR=\"$(localedir)\" \
-I $(top_srcdir) \
$(VISIBILITY_CFLAGS) \
$(WARN_CFLAGS)
libx52_la_LDFLAGS = \
-export-symbols-regex '^libx52_' \

View File

@ -24,6 +24,17 @@
#include <stdint.h>
#include <stdbool.h>
/** Applied to public library entry points (default visibility with hidden ELF default). */
#ifndef LIBX52_API
# if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
# define LIBX52_API __attribute__((visibility("default")))
# elif defined(_WIN32)
# define LIBX52_API __declspec(dllexport)
# else
# define LIBX52_API
# endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
@ -275,7 +286,7 @@ typedef enum {
*
* @returns \ref libx52_error_code indicating status
*/
int libx52_init(libx52_device ** dev);
LIBX52_API int libx52_init(libx52_device ** dev);
/**
* @brief Exit the library and free up any resources used
@ -286,7 +297,7 @@ int libx52_init(libx52_device ** dev);
*
* @param[in] dev Pointer to the device context
*/
void libx52_exit(libx52_device *dev);
LIBX52_API void libx52_exit(libx52_device *dev);
/** @} */
@ -316,7 +327,7 @@ void libx52_exit(libx52_device *dev);
*
* @returns \ref libx52_error_code indicating status
*/
int libx52_connect(libx52_device *dev);
LIBX52_API int libx52_connect(libx52_device *dev);
/**
* @brief Disconnect from the X52 device
@ -329,7 +340,7 @@ int libx52_connect(libx52_device *dev);
*
* @returns \ref libx52_error_code indicating status
*/
int libx52_disconnect(libx52_device *dev);
LIBX52_API int libx52_disconnect(libx52_device *dev);
/**
* @brief Check if joystick is connected
@ -350,7 +361,7 @@ int libx52_disconnect(libx52_device *dev);
*
* @returns Boolean indicating if the internal device handle is valid.
*/
bool libx52_is_connected(libx52_device *dev);
LIBX52_API bool libx52_is_connected(libx52_device *dev);
/** @} */
@ -390,7 +401,7 @@ bool libx52_is_connected(libx52_device *dev);
* - \ref LIBX52_ERROR_INVALID_PARAM if either \p x52 is invalid, or \p line is
* outside the accepted range.
*/
int libx52_set_text(libx52_device *x52, uint8_t line, const char *text, uint8_t length);
LIBX52_API int libx52_set_text(libx52_device *x52, uint8_t line, const char *text, uint8_t length);
/**
* @brief Set the LED state
@ -415,7 +426,7 @@ int libx52_set_text(libx52_device *x52, uint8_t line, const char *text, uint8_t
* not a supported one. The API also returns \ref LIBX52_ERROR_NOT_SUPPORTED
* if the probed joystick is not an X52 Pro, but the non-Pro X52 variant.
*/
int libx52_set_led_state(libx52_device *x52,
LIBX52_API int libx52_set_led_state(libx52_device *x52,
libx52_led_id led,
libx52_led_state state);
@ -455,7 +466,7 @@ int libx52_set_led_state(libx52_device *x52,
* - \ref LIBX52_ERROR_TRY_AGAIN if no change from previous time
* - \ref LIBX52_ERROR_INVALID_PARAM if \p x52 is not valid.
*/
int libx52_set_clock(libx52_device *x52, time_t time, int local);
LIBX52_API int libx52_set_clock(libx52_device *x52, time_t time, int local);
/**
* @brief Set the timezone for the secondary and tertiary clocks.
@ -487,7 +498,7 @@ int libx52_set_clock(libx52_device *x52, time_t time, int local);
* - \ref LIBX52_ERROR_NOT_SUPPORTED if \p clock is \ref LIBX52_CLOCK_1
* - \ref LIBX52_ERROR_OUT_OF_RANGE if \p offset is more than &plusmn; 24 hours.
*/
int libx52_set_clock_timezone(libx52_device *x52,
LIBX52_API int libx52_set_clock_timezone(libx52_device *x52,
libx52_clock_id clock,
int offset);
@ -511,7 +522,7 @@ int libx52_set_clock_timezone(libx52_device *x52,
* - \ref LIBX52_ERROR_INVALID_PARAM if \p x52 is not valid, or if either of \p
* clock or \p format are outside their respective ranges.
*/
int libx52_set_clock_format(libx52_device *x52,
LIBX52_API int libx52_set_clock_format(libx52_device *x52,
libx52_clock_id clock,
libx52_clock_format format);
@ -530,7 +541,7 @@ int libx52_set_clock_format(libx52_device *x52,
* - 0 on success
* - \ref LIBX52_ERROR_INVALID_PARAM if \p x52 is not valid
*/
int libx52_set_time(libx52_device *x52, uint8_t hour, uint8_t minute);
LIBX52_API int libx52_set_time(libx52_device *x52, uint8_t hour, uint8_t minute);
/**
* @brief Set the date
@ -547,7 +558,7 @@ int libx52_set_time(libx52_device *x52, uint8_t hour, uint8_t minute);
* - 0 on success
* - \ref LIBX52_ERROR_INVALID_PARAM if \p x52 is not valid
*/
int libx52_set_date(libx52_device *x52, uint8_t dd, uint8_t mm, uint8_t yy);
LIBX52_API int libx52_set_date(libx52_device *x52, uint8_t dd, uint8_t mm, uint8_t yy);
/**
* @brief Set the date format for the MFD date display
@ -561,7 +572,7 @@ int libx52_set_date(libx52_device *x52, uint8_t dd, uint8_t mm, uint8_t yy);
* - 0 on success
* - \ref LIBX52_ERROR_INVALID_PARAM if \p x52 is not valid
*/
int libx52_set_date_format(libx52_device *x52, libx52_date_format format);
LIBX52_API int libx52_set_date_format(libx52_device *x52, libx52_date_format format);
/** @} */
@ -586,7 +597,7 @@ int libx52_set_date_format(libx52_device *x52, libx52_date_format format);
* - 0 on success
* - \ref LIBX52_ERROR_INVALID_PARAM if \p x52 is not valid
*/
int libx52_set_brightness(libx52_device *x52, uint8_t mfd, uint16_t brightness);
LIBX52_API int libx52_set_brightness(libx52_device *x52, uint8_t mfd, uint16_t brightness);
/**
* @brief Set the state of the shift indicator
@ -601,7 +612,7 @@ int libx52_set_brightness(libx52_device *x52, uint8_t mfd, uint16_t brightness);
* - 0 on success
* - \ref LIBX52_ERROR_INVALID_PARAM if \p x52 is not valid
*/
int libx52_set_shift(libx52_device *x52, uint8_t state);
LIBX52_API int libx52_set_shift(libx52_device *x52, uint8_t state);
/**
* @brief Set the blinking state
@ -615,7 +626,7 @@ int libx52_set_shift(libx52_device *x52, uint8_t state);
* - 0 on success
* - \ref LIBX52_ERROR_INVALID_PARAM if \p x52 is not valid
*/
int libx52_set_blink(libx52_device *x52, uint8_t state);
LIBX52_API int libx52_set_blink(libx52_device *x52, uint8_t state);
/** @} */
@ -638,7 +649,7 @@ int libx52_set_blink(libx52_device *x52, uint8_t state);
*
* @returns \ref libx52_error_code indicating status
*/
int libx52_update(libx52_device *x52);
LIBX52_API int libx52_update(libx52_device *x52);
/**
* @brief Write a raw vendor control packet
@ -655,7 +666,7 @@ int libx52_update(libx52_device *x52);
*
* @returns \ref libx52_error_code indicating status
*/
int libx52_vendor_command(libx52_device *x52, uint16_t index, uint16_t value);
LIBX52_API int libx52_vendor_command(libx52_device *x52, uint16_t index, uint16_t value);
/**
* @brief Check if the device supports the given feature.
@ -670,7 +681,7 @@ int libx52_vendor_command(libx52_device *x52, uint16_t index, uint16_t value);
*
* @returns \ref libx52_error_code indicating status
*/
int libx52_check_feature(libx52_device *x52, libx52_feature feature);
LIBX52_API int libx52_check_feature(libx52_device *x52, libx52_feature feature);
/** @} */
@ -690,7 +701,7 @@ int libx52_check_feature(libx52_device *x52, libx52_feature feature);
* @returns Pointer to a NULL terminated string describing the error.
* Returned pointer must not be freed.
*/
const char * libx52_strerror(libx52_error_code error);
LIBX52_API const char *libx52_strerror(libx52_error_code error);
/**
* @brief Returns a string representation of the clock ID
@ -700,7 +711,7 @@ const char * libx52_strerror(libx52_error_code error);
* @returns Pointer to a NULL terminated string describing the clock ID.
* Returned pointer must not be freed.
*/
const char * libx52_clock_id_to_str(libx52_clock_id id);
LIBX52_API const char *libx52_clock_id_to_str(libx52_clock_id id);
/**
* @brief Returns a string representation of the clock format
@ -710,7 +721,7 @@ const char * libx52_clock_id_to_str(libx52_clock_id id);
* @returns Pointer to a NULL terminated string describing the clock format.
* Returned pointer must not be freed.
*/
const char * libx52_clock_format_to_str(libx52_clock_format format);
LIBX52_API const char *libx52_clock_format_to_str(libx52_clock_format format);
/**
* @brief Returns a string representation of the date format
@ -720,7 +731,7 @@ const char * libx52_clock_format_to_str(libx52_clock_format format);
* @returns Pointer to a NULL terminated string describing the date format.
* Returned pointer must not be freed.
*/
const char * libx52_date_format_to_str(libx52_date_format format);
LIBX52_API const char *libx52_date_format_to_str(libx52_date_format format);
/**
* @brief Returns a string representation of the LED
@ -730,7 +741,7 @@ const char * libx52_date_format_to_str(libx52_date_format format);
* @returns Pointer to a NULL terminated string describing the LED.
* Returned pointer must not be freed.
*/
const char * libx52_led_id_to_str(libx52_led_id id);
LIBX52_API const char *libx52_led_id_to_str(libx52_led_id id);
/**
* @brief Returns a string representation of the LED state
@ -740,7 +751,7 @@ const char * libx52_led_id_to_str(libx52_led_id id);
* @returns Pointer to a NULL terminated string describing the LED state.
* Returned pointer must not be freed.
*/
const char * libx52_led_state_to_str(libx52_led_state state);
LIBX52_API const char *libx52_led_state_to_str(libx52_led_state state);
/** @} */

View File

@ -12,6 +12,7 @@ libx52_files = files(
lib_libx52 = library('x52', libx52_files,
install: true,
version: libx52_version,
c_args: sym_hidden_cargs,
dependencies: [dep_libusb, dep_intl],
include_directories: [includes])

View File

@ -39,7 +39,7 @@ static const char *error_string[] = {
N_("System call interrupted"),
};
const char * libx52_strerror(libx52_error_code error)
LIBX52_API const char * libx52_strerror(libx52_error_code error)
{
switch (error) {
case LIBX52_SUCCESS:

View File

@ -16,7 +16,7 @@
#define _(str) dgettext(PACKAGE, str)
#define STRINGIFY(name, max_id, errstr, ...) \
const char * libx52_ ## name ## _to_str (libx52_ ## name param) { \
LIBX52_API const char * libx52_ ## name ## _to_str (libx52_ ## name param) { \
static char invalid[256]; \
static const char *desc[] = { __VA_ARGS__ }; \
if (param >= 0 && param <= max_id) { \
@ -51,7 +51,7 @@ STRINGIFY(led_state, LIBX52_LED_STATE_GREEN, N_("Unknown LED state %d"),
N_("green"),
)
const char * libx52_led_id_to_str(libx52_led_id id)
LIBX52_API const char * libx52_led_id_to_str(libx52_led_id id)
{
static char invalid[256];

View File

@ -19,7 +19,7 @@ libx52io_la_SOURCES = \
libx52io/io_parser.c \
libx52io/io_strings.c \
libx52io/io_device.c
libx52io_la_CFLAGS = @HIDAPI_CFLAGS@ -DLOCALEDIR=\"$(localedir)\" -I $(top_srcdir) $(WARN_CFLAGS)
libx52io_la_CFLAGS = @HIDAPI_CFLAGS@ -DLOCALEDIR=\"$(localedir)\" -I $(top_srcdir) $(VISIBILITY_CFLAGS) $(WARN_CFLAGS)
libx52io_la_LDFLAGS = \
-export-symbols-regex '^libx52io_' \
-version-info $(libx52io_v_CUR):$(libx52io_v_REV):$(libx52io_v_AGE) @HIDAPI_LIBS@ \

View File

@ -23,6 +23,16 @@
#include <stdint.h>
#include <stdbool.h>
#ifndef LIBX52IO_API
# if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
# define LIBX52IO_API __attribute__((visibility("default")))
# elif defined(_WIN32)
# define LIBX52IO_API __declspec(dllexport)
# else
# define LIBX52IO_API
# endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
@ -293,7 +303,7 @@ typedef struct libx52io_report libx52io_report;
*
* @returns \c libx52io_error_code indicating status
*/
int libx52io_init(libx52io_context **ctx);
LIBX52IO_API int libx52io_init(libx52io_context **ctx);
/**
* @brief Exit the library and free up any resources used
@ -304,7 +314,7 @@ int libx52io_init(libx52io_context **ctx);
*
* @param[in] ctx Pointer to the device context
*/
void libx52io_exit(libx52io_context *ctx);
LIBX52IO_API void libx52io_exit(libx52io_context *ctx);
/**
* @brief Open a connection to a supported joystick
@ -321,7 +331,7 @@ void libx52io_exit(libx52io_context *ctx);
* - \ref LIBX52IO_ERROR_NO_DEVICE if no supported joystick is found
* - \ref LIBX52IO_ERROR_CONN if the connection fails
*/
int libx52io_open(libx52io_context *ctx);
LIBX52IO_API int libx52io_open(libx52io_context *ctx);
/**
* @brief Close an existing connection to a supported joystick
@ -335,7 +345,7 @@ int libx52io_open(libx52io_context *ctx);
* - \ref LIBX52IO_SUCCESS on closing, or if the connection is already closed.
* - \ref LIBX52IO_ERROR_INVALID if the context pointer is not valid
*/
int libx52io_close(libx52io_context *ctx);
LIBX52IO_API int libx52io_close(libx52io_context *ctx);
/**
* @brief Read and parse a HID report
@ -356,7 +366,7 @@ int libx52io_close(libx52io_context *ctx);
* including if the device was disconnected during the read.
* - \ref LIBX52IO_ERROR_TIMEOUT if no report was read before timeout.
*/
int libx52io_read_timeout(libx52io_context *ctx, libx52io_report *report, int timeout);
LIBX52IO_API int libx52io_read_timeout(libx52io_context *ctx, libx52io_report *report, int timeout);
/**
* @brief Read and parse a HID report
@ -374,7 +384,7 @@ int libx52io_read_timeout(libx52io_context *ctx, libx52io_report *report, int ti
* - \ref LIBX52IO_ERROR_IO if there was an error reading from the device,
* including if the device was disconnected during the read.
*/
int libx52io_read(libx52io_context *ctx, libx52io_report *report);
LIBX52IO_API int libx52io_read(libx52io_context *ctx, libx52io_report *report);
/**
* @brief Retrieve the range of an axis
@ -393,7 +403,7 @@ int libx52io_read(libx52io_context *ctx, libx52io_report *report);
* valid, or the requested axis is not a valid axis identifier
* - \ref LIBX52IO_ERROR_NO_DEVICE if the device is disconnected
*/
int libx52io_get_axis_range(libx52io_context *ctx, libx52io_axis axis, int32_t *min, int32_t *max);
LIBX52IO_API int libx52io_get_axis_range(libx52io_context *ctx, libx52io_axis axis, int32_t *min, int32_t *max);
/**
* @brief Get the string representation of an error code
@ -402,7 +412,7 @@ int libx52io_get_axis_range(libx52io_context *ctx, libx52io_axis axis, int32_t *
*
* @returns String representation of the error. This pointer must not be freed.
*/
const char * libx52io_strerror(libx52io_error_code code);
LIBX52IO_API const char *libx52io_strerror(libx52io_error_code code);
/**
* @brief Get the string representation of an axis.
@ -412,7 +422,7 @@ const char * libx52io_strerror(libx52io_error_code code);
* @returns String representation of the axis. This pointer must not be freed.
* If axis is outside the defined range, then this returns NULL.
*/
const char * libx52io_axis_to_str(libx52io_axis axis);
LIBX52IO_API const char *libx52io_axis_to_str(libx52io_axis axis);
/**
* @brief Get the string representation of a button.
@ -422,7 +432,7 @@ const char * libx52io_axis_to_str(libx52io_axis axis);
* @returns String representation of the button. This pointer must not be freed.
* If button is outside the defined range, then this returns NULL.
*/
const char * libx52io_button_to_str(libx52io_button button);
LIBX52IO_API const char *libx52io_button_to_str(libx52io_button button);
/**
* @brief Get the vendor ID of the connected X52 device.
@ -431,7 +441,7 @@ const char * libx52io_button_to_str(libx52io_button button);
*
* @returns Vendor ID of the connected device. Returns 0 if no device is connected.
*/
uint16_t libx52io_get_vendor_id(libx52io_context *ctx);
LIBX52IO_API uint16_t libx52io_get_vendor_id(libx52io_context *ctx);
/**
* @brief Get the product ID of the connected X52 device.
@ -440,7 +450,7 @@ uint16_t libx52io_get_vendor_id(libx52io_context *ctx);
*
* @returns Product ID of the connected device. Returns 0 if no device is connected.
*/
uint16_t libx52io_get_product_id(libx52io_context *ctx);
LIBX52IO_API uint16_t libx52io_get_product_id(libx52io_context *ctx);
/**
* @brief Get the device version of the connected X52 device.
@ -449,7 +459,7 @@ uint16_t libx52io_get_product_id(libx52io_context *ctx);
*
* @returns Device version of the connected device. Returns 0 if no device is connected.
*/
uint16_t libx52io_get_device_version(libx52io_context *ctx);
LIBX52IO_API uint16_t libx52io_get_device_version(libx52io_context *ctx);
/**
* @brief Get the manufacturer string of the connected X52 device.
@ -462,7 +472,7 @@ uint16_t libx52io_get_device_version(libx52io_context *ctx);
* @returns Pointer to the manufacturer string, which may be NULL. Return value
* is always NULL if no device is connected.
*/
const char * libx52io_get_manufacturer_string(libx52io_context *ctx);
LIBX52IO_API const char *libx52io_get_manufacturer_string(libx52io_context *ctx);
/**
* @brief Get the product string of the connected X52 device.
@ -475,7 +485,7 @@ const char * libx52io_get_manufacturer_string(libx52io_context *ctx);
* @returns Pointer to the product string, which may be NULL. Return value
* is always NULL if no device is connected.
*/
const char * libx52io_get_product_string(libx52io_context *ctx);
LIBX52IO_API const char *libx52io_get_product_string(libx52io_context *ctx);
/**
* @brief Get the serial number of the connected X52 device.
@ -488,7 +498,7 @@ const char * libx52io_get_product_string(libx52io_context *ctx);
* @returns Pointer to the serial number string, which may be NULL. Return value
* is always NULL if no device is connected.
*/
const char * libx52io_get_serial_number_string(libx52io_context *ctx);
LIBX52IO_API const char *libx52io_get_serial_number_string(libx52io_context *ctx);
/** @} */

View File

@ -11,6 +11,7 @@ libx52io_files = files(
lib_libx52io = library('x52io', libx52io_files,
install: true,
version: libx52io_version,
c_args: sym_hidden_cargs,
dependencies: [dep_hidapi, dep_intl],
include_directories: [includes])

View File

@ -10,8 +10,11 @@ lib_LTLIBRARIES += libx52util.la
# This library provides extra utilities for ease of use
nodist_libx52util_la_SOURCES = libx52util/util_char_map.c
libx52util_la_SOURCES = libx52util/x52_char_map_lookup.c
libx52util_la_CFLAGS = -I $(top_srcdir)/libx52util $(WARN_CFLAGS)
libx52util_la_LDFLAGS = -version-info 1:1:0 $(WARN_LDFLAGS)
libx52util_la_CFLAGS = -I $(top_srcdir)/libx52util $(VISIBILITY_CFLAGS) $(WARN_CFLAGS)
libx52util_la_LDFLAGS = \
-export-symbols-regex '^libx52util_' \
-version-info 1:1:0 \
$(WARN_LDFLAGS)
# Header files that need to be copied
x52include_HEADERS += libx52util/libx52util.h

View File

@ -20,6 +20,17 @@
#define LIBX52UTIL_H
#include <stddef.h>
#include <stdint.h>
#ifndef LIBX52UTIL_API
# if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
# define LIBX52UTIL_API __attribute__((visibility("default")))
# elif defined(_WIN32)
# define LIBX52UTIL_API __declspec(dllexport)
# else
# define LIBX52UTIL_API
# endif
#endif
#ifdef __cplusplus
extern "C" {
@ -46,8 +57,8 @@ extern "C" {
* @returns 0 on success, -EINVAL on invalid parameters, -E2BIG if the buffer
* filled up before converting the entire string.
*/
int libx52util_convert_utf8_string(const uint8_t *input,
uint8_t *output, size_t *len);
LIBX52UTIL_API int libx52util_convert_utf8_string(const uint8_t *input,
uint8_t *output, size_t *len);
/** @} */

View File

@ -12,6 +12,7 @@ util_char_map = custom_target('util-char-map',
lib_libx52util = library('x52util', util_char_map, 'x52_char_map_lookup.c',
install: true,
version: libx52util_version,
c_args: sym_hidden_cargs,
include_directories: [includes],
)

View File

@ -39,6 +39,10 @@ assert(pyversion[1].to_int() >= 5, 'Require Python >= 3.5')
# config.h
#######################################################################
compiler = meson.get_compiler('c')
sym_hidden_cargs = []
if compiler.has_argument('-fvisibility=hidden')
sym_hidden_cargs = ['-fvisibility=hidden']
endif
cdata = configuration_data()
cdata.set_quoted('PACKAGE', meson.project_name())
cdata.set_quoted('PACKAGE_BUGREPORT', 'https://github.com/nirenjan/libx52/issues')

View File

@ -25,6 +25,7 @@ endif
lib_vkm = library('vkm', vkm_files + vkm_platform_files,
install: true,
version: vkm_version,
c_args: sym_hidden_cargs,
dependencies: [vkm_dep, dep_intl],
include_directories: [includes])

View File

@ -23,6 +23,16 @@
#include <stdint.h>
#include <stdbool.h>
#ifndef VKM_API
# if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
# define VKM_API __attribute__((visibility("default")))
# elif defined(_WIN32)
# define VKM_API __declspec(dllexport)
# else
# define VKM_API
# endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
@ -113,7 +123,7 @@ typedef enum {
*
* @returns Pointer to a NUL-terminated description string
*/
const char *vkm_strerror(vkm_result code);
VKM_API const char *vkm_strerror(vkm_result code);
/**
* @brief Option list
@ -413,7 +423,7 @@ typedef enum {
*
* @returns \ref vkm_error_code indicating status
*/
vkm_result vkm_init(vkm_context **ctx);
VKM_API vkm_result vkm_init(vkm_context **ctx);
/**
* @brief Exit the VKM library and free up any resources used
@ -424,7 +434,7 @@ vkm_result vkm_init(vkm_context **ctx);
*
* @param[in] ctx Context pointer
*/
void vkm_exit(vkm_context *ctx);
VKM_API void vkm_exit(vkm_context *ctx);
/**
* @brief Release all virtual keys and mouse buttons that are still down
@ -443,7 +453,7 @@ void vkm_exit(vkm_context *ctx);
* - \ref VKM_ERROR_INVALID_PARAM on bad pointer
* - \ref VKM_ERROR_EVENT if writing a release event failed
*/
vkm_result vkm_reset(vkm_context *ctx);
VKM_API vkm_result vkm_reset(vkm_context *ctx);
/**
* @brief Start any virtual keyboard/mouse devices on the platform
@ -458,7 +468,7 @@ vkm_result vkm_reset(vkm_context *ctx);
* - \ref VKM_ERROR_INVALID_PARAM on bad pointer
* - \ref VKM_ERROR_UNKNOWN on other errors
*/
vkm_result vkm_start(vkm_context *ctx);
VKM_API vkm_result vkm_start(vkm_context *ctx);
/**
* @brief check if VKM is started and ready
@ -467,7 +477,7 @@ vkm_result vkm_start(vkm_context *ctx);
*
* @returns boolean indicating if ready or not.
*/
bool vkm_is_ready(vkm_context *ctx);
VKM_API bool vkm_is_ready(vkm_context *ctx);
/**
* @brief Check if VKM is supported on this platform
@ -477,7 +487,7 @@ bool vkm_is_ready(vkm_context *ctx);
*
* @returns boolean indicating support.
*/
bool vkm_platform_supported(void);
VKM_API bool vkm_platform_supported(void);
/**
* @brief Check if a particular feature is enabled on this platform
@ -488,7 +498,7 @@ bool vkm_platform_supported(void);
*
* @returns boolean indicating if feature is supported or not.
*/
bool vkm_feature_supported(vkm_feature feat);
VKM_API bool vkm_feature_supported(vkm_feature feat);
/**
* @brief Set an option flag for VKM.
@ -505,7 +515,7 @@ bool vkm_feature_supported(vkm_feature feat);
* - \ref VKM_ERROR_INVALID_PARAM if the option or arguments are invalid
* - \ref VKM_ERROR_NOT_SUPPORTED if the option is valid but not supported on this platform
*/
vkm_result vkm_set_option(vkm_context *ctx, vkm_option option, ...);
VKM_API vkm_result vkm_set_option(vkm_context *ctx, vkm_option option, ...);
/**
* @brief Move the mouse by the specified amount
@ -523,7 +533,7 @@ vkm_result vkm_set_option(vkm_context *ctx, vkm_option option, ...);
* - \ref VKM_ERROR_NOT_SUPPORTED if the mouse move is not supported on this platform
* - \ref VKM_ERROR_NOT_READY if VKM is not started
*/
vkm_result vkm_mouse_move(vkm_context *ctx, int dx, int dy);
VKM_API vkm_result vkm_mouse_move(vkm_context *ctx, int dx, int dy);
/**
* @brief Click the mouse button
@ -540,7 +550,7 @@ vkm_result vkm_mouse_move(vkm_context *ctx, int dx, int dy);
* - \ref VKM_ERROR_NOT_SUPPORTED if the mouse button click is not supported on this platform
* - \ref VKM_ERROR_NOT_READY if VKM is not started
*/
vkm_result vkm_mouse_click(vkm_context *ctx, vkm_mouse_button button, vkm_button_state state);
VKM_API vkm_result vkm_mouse_click(vkm_context *ctx, vkm_mouse_button button, vkm_button_state state);
/**
* @brief Scroll the mouse wheel
@ -562,7 +572,7 @@ vkm_result vkm_mouse_click(vkm_context *ctx, vkm_mouse_button button, vkm_button
* - \ref VKM_ERROR_NOT_SUPPORTED if the mouse scrolling is not supported on this platform
* - \ref VKM_ERROR_NOT_READY if VKM is not started
*/
vkm_result vkm_mouse_scroll(vkm_context *ctx, vkm_mouse_scroll_direction dir);
VKM_API vkm_result vkm_mouse_scroll(vkm_context *ctx, vkm_mouse_scroll_direction dir);
/**
* @brief Send a single keyboard event
@ -583,7 +593,7 @@ vkm_result vkm_mouse_scroll(vkm_context *ctx, vkm_mouse_scroll_direction dir);
* supported on this platform
* - \ref VKM_ERROR_NOT_READY if VKM is not started
*/
vkm_result vkm_keyboard_send(vkm_context *ctx, vkm_key key, vkm_key_modifiers modifiers, vkm_key_state state);
VKM_API vkm_result vkm_keyboard_send(vkm_context *ctx, vkm_key key, vkm_key_modifiers modifiers, vkm_key_state state);
/**
* @brief Send a sync packet to the OS
@ -600,7 +610,7 @@ vkm_result vkm_keyboard_send(vkm_context *ctx, vkm_key key, vkm_key_modifiers mo
* - \ref VKM_ERROR_INVALID_PARAM if parameters are invalid
* - \ref VKM_ERROR_NOT_READY if VKM is not started
*/
vkm_result vkm_sync(vkm_context *ctx);
VKM_API vkm_result vkm_sync(vkm_context *ctx);
#ifdef __cplusplus
}