Skip to content

Instantly share code, notes, and snippets.

@Sapd
Created June 24, 2017 17:58
Show Gist options
  • Save Sapd/c92139fb9a29b4c4d5c025bfcc5d5c08 to your computer and use it in GitHub Desktop.
Save Sapd/c92139fb9a29b4c4d5c025bfcc5d5c08 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include "hidapi.h"
#define MAX_STR 255
int main(int argc, char* argv[])
{
int res;
unsigned char buf[65];
hid_device *handle;
int i;
res = hid_init();
for (int i = 0; i < sizeof(buf)/sizeof(buf[0]); i++) buf[i] = 0;
// Write the vendor ID and the product id here
handle = hid_open(0x1b1c, 0x1b27, NULL);
/*
Doesn't seem to do anything on void
buf[0] = 0xcb;
buf[1] = 0x01;
buf[2] = 0x01;
buf[3] = 0x15;
for (int i = 0; i < 3; i++)
res = hid_write(handle, buf, 20);*/
printf("Waiting for read\n");
res = hid_read(handle, buf, 32);
// Print out the returned buffer.
for (i = 0; i < 32; i++)
printf("buf[%d]: %d\n", i, buf[i]);
// Finalize the hidapi library
res = hid_exit();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment