Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Device Enumerating is Done Odd #69

Open
Karutoh opened this issue Nov 11, 2023 · 3 comments
Open

Device Enumerating is Done Odd #69

Karutoh opened this issue Nov 11, 2023 · 3 comments

Comments

@Karutoh
Copy link

Karutoh commented Nov 11, 2023

So this is an odd way to enumerate devices at runtime as shown below.

WootingAnalog_DeviceInfo_FFI* buffer = nullptr;

int len = wooting_analog_get_connected_devices_info(nullptr, 0xFFFFFFFF);

buffer = new WootingAnalog_DeviceInfo_FFI[len];

wooting_analog_get_connected_devices_info(&buffer, len);

It should be done this way so there's no mistake on how it's done. As this method is typically common.

WootingAnalog_DeviceInfo_FFI* buffer = nullptr;
unsigned int size = 0;

wooting_analog_get_connected_devices_info(nullptr, &size); // Given buffer is a "nullptr" which will set the "size" variable.

buffer = new WootingAnalog_DeviceInfo_FFI[size];

wooting_analog_get_connected_devices_info(&buffer, &size); // Here the array is actually set.
@Sainan
Copy link
Contributor

Sainan commented Nov 11, 2023

This would be a breaking change. Instead, maybe something like wooting_analog_get_num_connected_devices so you can do your dynamic allocation.

@Karutoh
Copy link
Author

Karutoh commented Nov 11, 2023

This would be a breaking change. Instead, maybe something like wooting_analog_get_num_connected_devices so you can do your dynamic allocation.

I think that would be a good compromise.

@Sainan
Copy link
Contributor

Sainan commented Aug 31, 2024

One thing to note is that wooting_analog_initialise actually already returns the number of devices (at init time), which may be useful for whatever your use-case is/was.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants