On Nov 1, 2012, at 8:05 PM, Tarl Neustaedter wrote:

On 2012-Nov-1 18:56 , Programmingkid wrote:
How would I add a device to the device tree, and be able to open that device using open-dev? I am trying to add "/pseudo-hid/keyboard" to the device tree. I need to test out a new keyboard word that I am adding.

Assuming "/pseudo-hid" already exists and is openable, it would be something like:

ok select /pseudo-hid
ok new-device
ok 0 0 0 0 set-args \ This assumes that encode-unit and decode-unit in psuedo-hid don't expect a unit address
ok " keyboard" name
ok : open true ;
ok finish-device

That should be the absolute minimum for where you can then do a "select" of /pseudo-hid/keyboard

For putting in the sources later on, it gets more complicated, but for debug, the above should work.


What is the C way of doing this? I have looked at the DECLARE_NODE function. I think it is what I need, but I could not figure out how to make it work. I found this snippet in mac-parts.c. 

DECLARE_NODE( macparts, INSTALL_OPEN, sizeof(macparts_info_t), "+/packages/mac-parts" );

What I tried was this:

DECLARE_NODE( keyboard, INSTALL_OPEN, sizeof(int), "+/pseudo-hid/keyboard" );

It didn't work. I am working with the file adb_kbd.c.