// Copyright 2007, Jesper Thomschutz <jesperht@yahoo.com>
// Licensed under GPLv2

#include <stdio.h>
#include <usb.h>

static struct usb_device *findKeyboard(uint16_t vendor, uint16_t product)
{
  struct usb_bus *bus;
  struct usb_device *dev;
  struct usb_bus *busses;

  usb_init();
  usb_find_busses();
  usb_find_devices();
  busses = usb_get_busses();

  for (bus = busses; bus; bus = bus->next)
    for (dev = bus->devices; dev; dev = dev->next)
      if ((dev->descriptor.idVendor == vendor) && (dev->descriptor.idProduct == product))
        return dev;

  return NULL;
}


int main (int argc,char **argv)
{
  printf("Trying to locate the Luxeed LED keyboard...\n");

  // Call the findKeyboard function and store the returned results.
  // The function takes the vendor id and product id of the desired keyboard as arguments
  // so that it knows what to look for
  struct usb_device *dev;
  dev = findKeyboard(0x534B,0x0600);

  //If the keyboard wasn't found the function will have returned NULL
  if (dev == NULL) {
    fprintf(stderr, "Not found!\n");
    return 1;
  }

  //If it gets this far, it means it found the keyboard
  printf("Found it! Now make me blink already!\n");
  return 0;
}

