Initial commit
This commit is contained in:
61
libazeron/internal.h
Normal file
61
libazeron/internal.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Azeron Linux Configuration Library - Internal Header
|
||||
* Copyright (C) 2024 Azeron Linux Project
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef AZERON_INTERNAL_H
|
||||
#define AZERON_INTERNAL_H
|
||||
|
||||
#include "azeron.h"
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#define AZERON_USB_TIMEOUT 1000
|
||||
#define AZERON_MAX_STRING_LENGTH 256
|
||||
|
||||
/* Debug logging */
|
||||
#ifdef AZERON_DEBUG
|
||||
#define AZERON_LOG(fmt, ...) fprintf(stderr, "[AZERON] " fmt "\n", ##__VA_ARGS__)
|
||||
#else
|
||||
#define AZERON_LOG(fmt, ...) do {} while (0)
|
||||
#endif
|
||||
|
||||
/* Error logging */
|
||||
#define AZERON_ERROR(fmt, ...) fprintf(stderr, "[AZERON ERROR] " fmt "\n", ##__VA_ARGS__)
|
||||
|
||||
/* Device structure */
|
||||
struct azeron_device {
|
||||
libusb_device_handle *handle;
|
||||
libusb_context *context;
|
||||
struct azeron_device_info info;
|
||||
pthread_mutex_t mutex;
|
||||
bool claimed;
|
||||
};
|
||||
|
||||
/* Protocol functions */
|
||||
int azeron_protocol_init(struct azeron_device *device);
|
||||
int azeron_protocol_read_config(struct azeron_device *device, uint8_t *data, size_t *size);
|
||||
int azeron_protocol_write_config(struct azeron_device *device, const uint8_t *data, size_t size);
|
||||
int azeron_protocol_get_button_mapping(struct azeron_device *device, uint8_t button_id, struct azeron_button_mapping *mapping);
|
||||
int azeron_protocol_set_button_mapping(struct azeron_device *device, const struct azeron_button_mapping *mapping);
|
||||
int azeron_protocol_get_stick_config(struct azeron_device *device, struct azeron_stick_config *config);
|
||||
int azeron_protocol_set_stick_config(struct azeron_device *device, const struct azeron_stick_config *config);
|
||||
int azeron_protocol_get_profile(struct azeron_device *device, uint8_t profile_id, struct azeron_profile *profile);
|
||||
int azeron_protocol_set_profile(struct azeron_device *device, const struct azeron_profile *profile);
|
||||
int azeron_protocol_save_to_device(struct azeron_device *device);
|
||||
|
||||
/* Device functions */
|
||||
int azeron_device_claim(struct azeron_device *device);
|
||||
int azeron_device_release(struct azeron_device *device);
|
||||
int azeron_device_read(struct azeron_device *device, uint8_t endpoint, uint8_t *data, size_t size, int timeout);
|
||||
int azeron_device_write(struct azeron_device *device, uint8_t endpoint, const uint8_t *data, size_t size, int timeout);
|
||||
int azeron_device_control_transfer(struct azeron_device *device, uint8_t request_type, uint8_t request, uint16_t value, uint16_t index, uint8_t *data, size_t size, int timeout);
|
||||
|
||||
/* Utility functions */
|
||||
const char *azeron_usb_error_string(int error);
|
||||
int azeron_libusb_to_azeron_error(int libusb_error);
|
||||
void azeron_device_info_from_libusb(struct azeron_device *device, libusb_device *libusb_dev);
|
||||
|
||||
#endif /* AZERON_INTERNAL_H */
|
||||
Reference in New Issue
Block a user