Skip to content

Instantly share code, notes, and snippets.

@cheery
Created December 1, 2012 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cheery/4182978 to your computer and use it in GitHub Desktop.
Save cheery/4182978 to your computer and use it in GitHub Desktop.
simple openwf test
#!/bin/sh
CFLAGS="-I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads"
LDFLAGS="-L/opt/vc/lib/ -lWFC -lGLESv2 -lvcos"
gcc enum.c -o bin/enum $CFLAGS $LDFLAGS
#include "bcm_host.h"
#include "WF/wfc.h"
#include <stdio.h>
int main() {
bcm_host_init();
int dids[10];
int count = wfcEnumerateDevices(dids, 10, NULL);
int i;
printf("[\n");
for (i = 0; i < count; i++) {
int did = dids[i];
WFCDevice dev = wfcCreateDevice(did, NULL);
if (dev == 0) continue;
printf(" {\n");
printf(" \"id\": %i,\n", did);
int cls = wfcGetDeviceAttribi(dev, WFC_DEVICE_CLASS);
switch (cls) {
case WFC_DEVICE_CLASS_FULLY_CAPABLE:
printf(" \"class\": \"DEVICE_CLASS_FULLY_CAPABLE\",\n");
break;
case WFC_DEVICE_CLASS_OFF_SCREEN_ONLY:
printf(" \"class\": \"DEVICE_CLASS_OFF_SCREEN_ONLY\",\n");
break;
default:
printf(" \"class\": %i,\n", cls);
}
wfcDestroyDevice(dev);
printf(" }\n");
}
printf("]\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment