Ich bräuchte eure Hilfe beim Konvertieren einer C-Header-Datei zu
PureBasic.
Die Konstanten am Anfang waren alle kein Problem. Aber jetzt kommen
Strukturen und Funktionen. Ich habe alles schon so weit wie ich auf Anhieb
konnte und wo ich mir sicher war umgesetzt.
Ich werde die einzelnen Teile auch einzeln posten und nummerieren, damit
es für mich übersichtlicher wird.
Aber vorher noch zum Verständnis für mich:
char = .b
int = .l
short = .w
long = .l
Wenn das falsch ist, dann auch Bescheid geben. Danke!
1
Code: Alles auswählen
; String descriptor
Structure USB_String_descriptor
bLength.b
bDescriptorType.b
; unsigned short wData[1];
EndStructure
Code: Alles auswählen
; Endpoint descriptor
#USB_MAXENDPOINTS = 32
Structure USB_Endpoint_Descriptor
bLength.b
bDescriptorType.b
bEndpointaddress.b
bmAttributes.b
; unsigned short wMaxPacketSize;
bInterval.b
bRefresh.b
bSynchAddress.b
; unsigned char *extra; /* Extra descriptors */
; int extralen;
EndStructure
Code: Alles auswählen
Structure USB_Interface_Descriptor
bLength.b
bDescriptorType.b
bInterfaceNumber.b
bAlternateSetting.b
bNumEndpoints.b
bInterfaceClass.b
bInterfaceSubClass.b
bInterfaceProtocol.b
iInterface.b
; struct usb_endpoint_descriptor *endpoint;
;
; unsigned char *extra; /* Extra descriptors */
; int extralen;
EndStructure
Code: Alles auswählen
Structure USB_Interface
; struct usb_interface_descriptor *altsetting;
; int num_altsetting;
EndStructure
Code: Alles auswählen
Structure USB_Config_Descriptor
bLength.b
bDescriptorType.b
; unsigned short wTotalLength;
bNumInterfaces.b
bConfigurationValue.b
iConfiguration.b
bmAttributes.b
MaxPower.b
; struct usb_interface *interface;
; unsigned char *extra; /* Extra descriptors */
; int extralen;
EndStructure
Code: Alles auswählen
; This is supposed to look weird. This file is generated from autoconf
; and I didn't want to make this too complicated.
; #define USB_LE16_TO_CPU(x)
;
; /* Data types */
; /* struct usb_device; */
; /* struct usb_bus; */
;
; struct usb_device {
; struct usb_device *next, *prev;
;
; char filename[LIBUSB_PATH_MAX];
;
; struct usb_bus *bus;
;
; struct usb_device_descriptor descriptor;
; struct usb_config_descriptor *config;
;
; void *dev; /* Darwin support */
;
; unsigned char devnum;
;
; unsigned char num_children;
; struct usb_device **children;
; };
;
; struct usb_bus {
; struct usb_bus *next, *prev;
;
; char dirname[LIBUSB_PATH_MAX];
;
; struct usb_device *devices;
; unsigned long location;
;
; struct usb_device *root_dev;
; };
;
; /* Version information, Windows specific */
; struct usb_version {
; struct {
; int major;
; int minor;
; int micro;
; int nano;
; } dll;
; struct {
; int major;
; int minor;
; int micro;
; int nano;
; } driver;
; };
;
;
; struct usb_dev_handle;
; typedef struct usb_dev_handle usb_dev_handle;
;
; /* Variables */
; #ifndef __USB_C__
; #define usb_busses usb_get_busses()
; #endif
;
;
;
; #include <poppack.h>
;
;
; #ifdef __cplusplus
; extern "C" {
; #endif
;
; /* Function prototypes */
;
; /* usb.c */
; usb_dev_handle *usb_open(struct usb_device *dev);
; int usb_close(usb_dev_handle *dev);
; int usb_get_string(usb_dev_handle *dev, int index, int langid, char *buf,
; size_t buflen);
; int usb_get_string_simple(usb_dev_handle *dev, int index, char *buf,
; size_t buflen);
;
; /* descriptors.c */
; int usb_get_descriptor_by_endpoint(usb_dev_handle *udev, int ep,
; unsigned char type, unsigned char index,
; void *buf, int size);
; int usb_get_descriptor(usb_dev_handle *udev, unsigned char type,
; unsigned char index, void *buf, int size);
;
; /* <arch>.c */
; int usb_bulk_write(usb_dev_handle *dev, int ep, char *bytes, int size,
; int timeout);
; int usb_bulk_read(usb_dev_handle *dev, int ep, char *bytes, int size,
; int timeout);
; int usb_interrupt_write(usb_dev_handle *dev, int ep, char *bytes, int size,
; int timeout);
; int usb_interrupt_read(usb_dev_handle *dev, int ep, char *bytes, int size,
; int timeout);
; int usb_control_msg(usb_dev_handle *dev, int requesttype, int request,
; int value, int index, char *bytes, int size,
; int timeout);
; int usb_set_configuration(usb_dev_handle *dev, int configuration);
; int usb_claim_interface(usb_dev_handle *dev, int interface);
; int usb_release_interface(usb_dev_handle *dev, int interface);
; int usb_set_altinterface(usb_dev_handle *dev, int alternate);
; int usb_resetep(usb_dev_handle *dev, unsigned int ep);
; int usb_clear_halt(usb_dev_handle *dev, unsigned int ep);
; int usb_reset(usb_dev_handle *dev);
;
; char *usb_strerror(void);
;
; void usb_init(void);
; void usb_set_debug(int level);
; int usb_find_busses(void);
; int usb_find_devices(void);
; struct usb_device *usb_device(usb_dev_handle *dev);
; struct usb_bus *usb_get_busses(void);
;
;
; /* Windows specific functions */
;
; #define LIBUSB_HAS_INSTALL_SERVICE_NP 1
; int usb_install_service_np(void);
; void CALLBACK usb_install_service_np_rundll(HWND wnd, HINSTANCE instance,
; LPSTR cmd_line, int cmd_show);
;
; #define LIBUSB_HAS_UNINSTALL_SERVICE_NP 1
; int usb_uninstall_service_np(void);
; void CALLBACK usb_uninstall_service_np_rundll(HWND wnd, HINSTANCE instance,
; LPSTR cmd_line, int cmd_show);
;
; #define LIBUSB_HAS_INSTALL_DRIVER_NP 1
; int usb_install_driver_np(const char *inf_file);
; void CALLBACK usb_install_driver_np_rundll(HWND wnd, HINSTANCE instance,
; LPSTR cmd_line, int cmd_show);
;
; #define LIBUSB_HAS_TOUCH_INF_FILE_NP 1
; int usb_touch_inf_file_np(const char *inf_file);
; void CALLBACK usb_touch_inf_file_np_rundll(HWND wnd, HINSTANCE instance,
; LPSTR cmd_line, int cmd_show);
;
; #define LIBUSB_HAS_INSTALL_NEEDS_RESTART_NP 1
; int usb_install_needs_restart_np(void);
;
; const struct usb_version *usb_get_version(void);
;
; int usb_isochronous_setup_async(usb_dev_handle *dev, void **context,
; unsigned char ep, int pktsize);
; int usb_bulk_setup_async(usb_dev_handle *dev, void **context,
; unsigned char ep);
; int usb_interrupt_setup_async(usb_dev_handle *dev, void **context,
; unsigned char ep);
;
; int usb_submit_async(void *context, char *bytes, int size);
; int usb_reap_async(void *context, int timeout);
; int usb_reap_async_nocancel(void *context, int timeout);
; int usb_cancel_async(void *context);
; int usb_free_async(void **context);
sicher genug bin, es einfach selbst zu machen. Nummer 6 ist die
eigentliche Herausforderung. Dabei kommt es mir vor allem auf die
Sternchen an und wie sie zu interpretieren sind.
Danke schonmal im Voraus an alle, die mir helfen können / wollen!
