Giter Site home page Giter Site logo

digimend / hidrd Goto Github PK

View Code? Open in Web Editor NEW
167.0 167.0 29.0 758 KB

HID report descriptor I/O library and conversion tool

License: GNU General Public License v2.0

Shell 1.38% C 73.78% C++ 2.11% Makefile 4.77% M4 17.74% Ruby 0.05% Python 0.18%

hidrd's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hidrd's Issues

It is confusing that usage elements are displayed in XML as unadorned hexadecimal

I must have stared at

<usage_minimum>01</usage_minimum>
<usage_maximum>12</usage_maximum>
<report_count>12</report_count>

a dozen (decimal; i.e, 0x0c) times before realizing, from looking at the C code equivalent, that it is broken. Does it really make sense for usage elements to be represented in hexadecimal in XML? If so, could they be written as 0x12 or 12h to make it clear to human readers that the values are hexadecimal? Or could there be a comment noting that fact?

For that matter, when reading XML, could numbers be self-describing? I.e., could 0x0c, 0Ch, and 12 all be considered equivalent representations of the same number? (Perhaps also 0b00001100.)

(I realize that it would be tricky to do this in a fully backwards-compatible way.)

Autotools cleanups

Hi Nikolai,

here are some autotools cleanups I had laying around: http://ao2.it/tmp/hidrd-autotools-cleanup.patch

You can apply the changes with git am.

There are still a few warnings with the current build files:

include/hidrd/usage/Makefile.am:22: warning: '%'-style pattern rules are a GNU make extension
lib/usage/Makefile.am:31: warning: '%'-style pattern rules are a GNU make extension

I am not sure if these are worth fixing.

Ciao,
Antonio

library is not found when execute the hid-convert in Ubuntu 14.04 and 16.04 after make install

After install the program:

 ./bootstrap
 ./configure
 make
 sudo make install

When I try to run the program, it can't find the libraries:
hidrd-convert: error while loading shared libraries: libhidrd_util.so.0: cannot open shared object file: No such file or directory

But I can verify the shared libraries is there:

$ find /usr/local/lib/* -name libhidrd_util.so*
/usr/local/lib/libhidrd_util.so
/usr/local/lib/libhidrd_util.so.0
/usr/local/lib/libhidrd_util.so.0.0.0

I have tested on Ubuntu 14.04 and 16.04:

$ uname -a
Linux hexiongjun-9020 4.4.0-96-generic #119~14.04.1-Ubuntu SMP Wed Sep 13 08:40:48 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

$uname -a
Linux hexiongjun-vm 4.4.0-53-generic #74-Ubuntu SMP Fri Dec 2 15:59:10 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

When I append the /usr/local/lib to the LD_LIBRARY_PATH env, the program would work fine.

Also, when running the make install, there're many warnings like this:

libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin" ldconfig -n /usr/local/lib
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Needs better error reporting

$ sudo cat /sys/kernel/debug/hid/0005:3820:0009.0008/rdesc | head -n1 | xxd -r -p | jhbuild run hidrd-convert -i natv -o xml
Failed to read input item at offset 86:
invalid item encountered

Not much that I can do with that though. I'll try adding some better error reporting in lib/item/any.c, see where it fails.

Add an hex dump input format

Hi,

what about adding a new input format to hidrd-convert so that it can read hex dumps of HID descriptors directly?

gHID (https://code.google.com/p/ghid/) calls this format "dat", it would make sense to import it directly considering that it is used in the hidrd-convert documentation too.

Thanks,
Antonio

Improve code output format

Hi, first of all thanks for hidrd-convert.

Would it be possible to add some more options to the code output format, so that it creates descriptors ready to be used in the linux kernel?

Some examples:

enclose the byte array into an actual variable declaration:

static __u8 rdesc[] = {
<TAB>value,
<TAB>value,
...
};

pre-pending one TAB to each line.

Indent the bytes too according to the descriptor structure, i.e. if the comment is indented then the value is indented too (maybe by only one or two spaces, just to give some visual clue about the descriptor structure):

static __u8 rdesc[] = {
<TAB>value,    /* usage page   */
<TAB>  value,  /*     Collection  */
...
};

Show values in both decimal and hex in the comments when this can be useful (for min and max).

Show bitfields more explicitly in the comments:

0x81, 0x03, /* Input 0x3 (Constant:1,Variable:1,Abs:0) */

These are things that other tools (like gHID: https://code.google.com/p/ghid/) do, but the comments produced by hidrd-convert are generally clearer than gHIDs.

Thanks,
Antonio

New release

Would it be possible to cut a new release?

Verify comparisons between enum variables and hardcoded constants

Hi,

I was playing with warning flags and other compilers, and clang -Wall gives some warnings:

../include/hidrd/item/pfx/size.h:60:35: warning: comparison of constant 4 with expression of type 'hidrd_item_pfx_size' (aka 'enum hidrd_item_pfx_size') is
      always false [-Wtautological-constant-out-of-range-compare]
    return (bytes <= 2) || (bytes == 4);

In enum hidrd_item_pfx_size you never set a value to 4.

There are other similar warnings.

How to build?

Can someone include a "how to build" section for NOOBS in the makefile?

I tried:
autoreconf
and it doesn't work. I get errors like:
configure.ac:47: error: required file 'auxdir/ar-lib' not found

missing obstack.h

Trying to build on Mac (10.14.4) and keep getting short on obstack.h

I've modified the makefile to include one (from another mac ports) - but I'm now failing on this error:

Making all in util
  CC       obstack.lo
obstack.c:301:5: error: arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension [-Werror,-Wnull-pointer-arithmetic]
    __INT_TO_PTR ((__PTR_TO_INT (new_chunk->contents) + h->alignment_mask)

I can try and disable the warning, but is it safe?

Breaks microcrap

While building a joystick I was having repeated errors even when using a copied report.

The conversion optimizing from A1 00 to A0 breaks microsoft it whines about having collection outside a collection.

Indent values according to the descriptor structure

It can be useful to indent the descriptor values according to the descriptor structure, i.e. if the comment is indented then the value is indented too in order give a more immediate visual clue about the the descriptor structure.

...
value,      /* usage page     */
value,      /* Collection     */
    value,  /*    Report ID   */
    ...
value,      /* End Collection */
...

Thanks,
Antonio

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.