Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Added return value to sendState() #86

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

Open
virtmedia wants to merge 1 commit into MHeironimus:master
base: master
Choose a base branch
Loading
from virtmedia:master

Conversation

@virtmedia
Copy link

@virtmedia virtmedia commented May 7, 2018

The return value can be useful to detect, if USB host is active, or if
it only supply power to the device.

Fixes # or Enhancement #

Changes proposed in this pull request:

Contributors:

The return value can be useful to detect, if USB host is active, or if
it only supply power to the device.
Copy link
Owner

I like the idea!

In reviewing the USB_Send function defined in the USBCore.cpp module, it appears it returns the following:

  • -1 if an error occurs
  • length of the buffer if the buffer was successfully sent

Having the Joystick.sendState() function return the length of the internal _hidReportSize variable exposes some implementation details I might want to modify in a future version, but I do like the idea of the function returning a bool to indicate if the function worked correctly or not.

If we modify Joystick.sendState() function, should we modify the other functions that call sendState() internally as well? For example, if initAutoSendState is set to true, functions like setXAxis, pressButton, etc. all call sendState. These functions could be modified to return the result of the sendState() (or true if initAutoSendState is set to false). Thoughts?

Do you want to modify your Pull Request as indicated above (and also update the README.md documentation accordingly) or you would prefer for me to make the change (after I decide what should be done with all of the functions that call sendState)?

Thanks again for your contribution,
Matt

Copy link
Author

virtmedia commented May 9, 2018 via email

Hello, Thank you for the email! It is a good question about return values from other methods. My opinion is that is not necessarily. This is I think more advanced usage of the library, and the programmer who needs that feature can initialize the object with "false" parameter and call the sendState() when he needs it - and then check the return value. Also, it is possible that in the future other methods will need functionality to return different parameters, so the status of the USB communication will be not specific to them. I have small experience with the Github, so it would be better if you could make that commit, especially that you make better implementation. Best Regards, Aleksander Kawęczyński tel. +48 508 076 187 śr., 9 maj 2018, 03:49 użytkownik Matthew Heironimus < notifications@github.com> napisał:
...
I like the idea! In reviewing the USB_Send function defined in the USBCore.cpp <https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/USBCore.cpp> module, it appears it returns the following: - -1 if an error occurs - length of the buffer if the buffer was successfully sent Having the Joystick.sendState() function return the length of the internal _hidReportSize variable exposes some implementation details I might want to modify in a future version, but I do like the idea of the function returning a bool to indicate if the function worked correctly or not. If we modify Joystick.sendState() function, should we modify the other functions that call sendState() internally as well? For example, if initAutoSendState is set to true, functions like setXAxis, pressButton, etc. all call sendState. These functions could be modified to return the result of the sendState() (or true if initAutoSendState is set to false). Thoughts? Do you want to modify your Pull Request as indicated above (and also update the README.md documentation accordingly) or you would prefer for me to make the change (after I decide what should be done with all of the functions that call sendState)? Thanks again for your contribution, Matt — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#86 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AD4U2UZJPi42g_g-xa1MObNOytoMyWIfks5twksggaJpZM4T0i0k> .

Copy link
Owner

I agree with your reasoning on only updating the sendState. I am going to keep the PR open until I have had a chance to update the code with your change. I will let you know when the update has been made.

Thanks again for your contribution,
Matt

Dummiesman reacted with thumbs up emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /