From: Tollef Fog Heen Date: Sun, 28 Dec 2008 19:40:46 +0000 (+0100) Subject: Add initial libhid framework X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b4f57dd6e60600d5973c7f94bc1d556b282f8b86;p=yubiyubo Add initial libhid framework --- diff --git a/src/yubiyubo.c b/src/yubiyubo.c new file mode 100644 index 0000000..e01e492 --- /dev/null +++ b/src/yubiyubo.c @@ -0,0 +1,72 @@ +/* + * Copyright 2008, Tollef Fog Heen + * + * Licensed under the Apache License, Version 2.0 (the "License"); you + * may not use this file except in compliance with the License. You + * may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. See the License for the specific language governing + * permissions and limitations under the License. + * + * Main functions for yubiyubo + */ + +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + HIDInterface* hid; + hid_return ret; + char buf[128]; + int path[2] = {0x00010006, 0xff000020}; + int i; + bool reset = false; + HIDInterfaceMatcher matcher = { 0x1050, 0x0010, NULL, NULL, 0 }; + + ret = hid_init(); + if (ret != HID_RET_SUCCESS) { + fprintf(stderr, "hid_init failed with return code %d\n", ret); + exit(1); + } + + hid = hid_new_HIDInterface(); + if (hid == NULL) { + fprintf(stderr, "hid_new_HIDInterface() failed, out of memory?\n"); + exit(1); + } + + ret = hid_force_open(hid, 0, &matcher, 3); + if (ret != HID_RET_SUCCESS) { + fprintf(stderr, "hid_force_open failed with return code %d\n", ret); + exit(1); + } + + /* Do stuff with hid here */ + + ret = hid_close(hid); + if (ret != HID_RET_SUCCESS) { + fprintf(stderr, "hid_close failed with return code %d\n", ret); + exit(1); + } + + hid_delete_HIDInterface(&hid); + + ret = hid_cleanup(); + if (ret != HID_RET_SUCCESS) { + fprintf(stderr, "hid_cleanup failed with return code %d\n", ret); + exit(1); + } + + return 0; +} + + +}