signal11/hidapi — pull request #125 by nh2 (2013-06-17 14:15:42+00:00)
Title: hidraw: Implement hid_error()

Here is my first try at implementing error messages for the Linux/hidraw implementation.

* I used a thread-local variable for non-device error messages.
* Non-device errors can be obtained by passing `NULL` into `hid_error` as I suggested in #123.
* I **belive** to have covered all system calls that could fail; please check this.

A few extra questions:

* I am not sure why in `utf8_to_wchar_t` the input is called `utf8`. As far as I know, the encoding used in `mbstowcs` depends on the current locale, if if I haven't set my locale to use UTF8, then the input is not UTF8.
* The `register_error` equivalent in `windows/hid.c` doesn't use its argument `const char *op`. Is that intended?
* In the Windows implementation, do functions like [`HidD_GetPreparsedData`](http://msdn.microsoft.com/en-us/library/windows/hardware/ff539679%28v=vs.85%29.aspx) actually set the error code for `GetLastError()`?