/* * Azeron Linux Configuration Library * Copyright (C) 2024 Azeron Linux Project * * SPDX-License-Identifier: MIT */ #ifndef AZERON_H #define AZERON_H #include #include #include #ifdef __cplusplus extern "C" { #endif #define AZERON_VENDOR_ID 0x16d0 #define AZERON_PRODUCT_ID 0x113c #define AZERON_MAX_BUTTONS 32 #define AZERON_MAX_PROFILES 3 /* Error codes */ enum azeron_error { AZERON_SUCCESS = 0, AZERON_ERROR_INIT = -1, AZERON_ERROR_NOT_FOUND = -2, AZERON_ERROR_ACCESS = -3, AZERON_ERROR_IO = -4, AZERON_ERROR_PROTOCOL = -5, AZERON_ERROR_INVALID_PARAM = -6, AZERON_ERROR_NO_MEM = -7, AZERON_ERROR_UNSUPPORTED = -8, }; /* Button types that can be mapped */ enum azeron_button_type { AZERON_BTN_KEYBOARD = 0, AZERON_BTN_MOUSE, AZERON_BTN_GAMEPAD, AZERON_BTN_MACRO, AZERON_BTN_LAYER_SWITCH, }; /* Analog stick modes */ enum azeron_stick_mode { AZERON_STICK_ANALOG = 0, AZERON_STICK_DIGITAL_4, AZERON_STICK_DIGITAL_8, AZERON_STICK_MOUSE, }; /* Device information */ struct azeron_device_info { uint16_t vendor_id; uint16_t product_id; char serial_number[64]; char manufacturer[128]; char product[128]; uint8_t firmware_version; uint8_t num_profiles; uint8_t active_profile; }; /* Button mapping */ struct azeron_button_mapping { uint8_t button_id; enum azeron_button_type type; uint16_t key_code; /* Linux input event code */ char *macro; /* For macro type */ uint8_t layer_target; /* For layer switch type */ }; /* Analog stick configuration */ struct azeron_stick_config { enum azeron_stick_mode mode; uint8_t deadzone; /* 0-100 */ uint8_t sensitivity; /* 0-100 */ bool invert_x; bool invert_y; uint8_t response_curve; /* 0=linear, 1=exponential, etc. */ }; /* Profile configuration */ struct azeron_profile { uint8_t profile_id; char name[64]; struct azeron_button_mapping buttons[AZERON_MAX_BUTTONS]; uint8_t num_buttons; struct azeron_stick_config stick_config; }; /* Opaque device handle */ struct azeron_device; /* Library initialization */ int azeron_init(void); void azeron_exit(void); const char *azeron_error_string(int error); /* Device management */ int azeron_device_list(struct azeron_device_info **devices, size_t *count); void azeron_device_list_free(struct azeron_device_info *devices, size_t count); int azeron_device_open(struct azeron_device **device, uint16_t vendor_id, uint16_t product_id); int azeron_device_open_index(struct azeron_device **device, size_t index); void azeron_device_close(struct azeron_device *device); int azeron_device_get_info(struct azeron_device *device, struct azeron_device_info *info); /* Button mapping */ int azeron_device_get_button_mapping(struct azeron_device *device, uint8_t button_id, struct azeron_button_mapping *mapping); int azeron_device_set_button_mapping(struct azeron_device *device, const struct azeron_button_mapping *mapping); /* Analog stick configuration */ int azeron_device_get_stick_config(struct azeron_device *device, struct azeron_stick_config *config); int azeron_device_set_stick_config(struct azeron_device *device, const struct azeron_stick_config *config); /* Profile management */ int azeron_device_get_active_profile(struct azeron_device *device, uint8_t *profile_id); int azeron_device_set_active_profile(struct azeron_device *device, uint8_t profile_id); int azeron_device_get_profile(struct azeron_device *device, uint8_t profile_id, struct azeron_profile *profile); int azeron_device_set_profile(struct azeron_device *device, const struct azeron_profile *profile); /* Configuration import/export */ int azeron_device_export_config(struct azeron_device *device, const char *filename); int azeron_device_import_config(struct azeron_device *device, const char *filename); int azeron_device_export_config_json(struct azeron_device *device, struct json_object **json); int azeron_device_import_config_json(struct azeron_device *device, struct json_object *json); /* Utility functions */ const char *azeron_button_type_string(enum azeron_button_type type); const char *azeron_stick_mode_string(enum azeron_stick_mode mode); int azeron_keycode_from_string(const char *key_name); const char *azeron_keycode_to_string(int keycode); #ifdef __cplusplus } #endif #endif /* AZERON_H */