Skip to content

Instantly share code, notes, and snippets.

@cactrot
cactrot / main.c
Last active May 27, 2018 10:38
Attempt at an octave generator for AVR
//https://hackaday.com/2018/05/24/ask-hackaday-diy-top-octave-generator/
// I thought it would be interesting to see if some kind of time/space trade off could be done with this problem.
// It compiles but you probably need an ATMEGA1284 or better to run since it needs a little over 8k ram
// It should run in constant time.
// Don't have anything to test this on.
void setup() {
// put your setup code here, to run once:
@cactrot
cactrot / handle_error.diff
Last active December 27, 2015 01:08
HID api Windows: Retry open_device if it fails with ERROR_ACCESS_DENIED or ERROR_SHARING_VIOLATION
@@ -523,7 +523,15 @@ HID_API_EXPORT hid_device * HID_API_CALL hid_open_path(const char *path)
dev = new_hid_device();
// Open a handle to the device
dev->device_handle = open_device(path, FALSE);
+
+ // If the device is a system keyboard/mouse, Windows (2k+) takes exclusive
+ // read/write access. Feature reports can still be sent, but only if
+ // neither read nor write access is requested.
+ if (dev->device_handle == INVALID_HANDLE_VALUE &&