Merge lp://staging/~dandrader/frame/backend into lp://staging/frame

Proposed by Daniel d'Andrada
Status: Merged
Merged at revision: 90
Proposed branch: lp://staging/~dandrader/frame/backend
Merge into: lp://staging/frame
Diff against target: 1092 lines (+817/-28)
13 files modified
include/oif/frame_backend.h (+254/-0)
src/device.cpp (+93/-6)
src/device.h (+7/-1)
src/event.cpp (+37/-0)
src/event.h (+1/-0)
src/frame.cpp (+82/-16)
src/frame.h (+9/-0)
src/libframe.ver (+34/-0)
src/touch.cpp (+80/-0)
src/touch.h (+13/-2)
src/x11/device_x11.cpp (+0/-3)
test/regular/Makefile.am (+1/-0)
test/regular/backend.cpp (+206/-0)
To merge this branch: bzr merge lp://staging/~dandrader/frame/backend
Reviewer Review Type Date Requested Status
Chase Douglas (community) Approve
Review via email: mp+121230@code.staging.launchpad.net

Commit message

Adds a backend API.

So that any client can adapt frame+grail to work on top of their input system, without relying on frame to provide a suitable backend implementation.

This API also removes the need to mock libframe when writing grail tests.

Description of the change

Adds a backend API.

So that any client can adapt frame+grail to work on top of their input system, without relying on frame to provide a suitable backend implementation.

This API also removes the need to mock libframe when writing grail tests.

To post a comment you must log in.
Revision history for this message
Chase Douglas (chasedouglas) wrote :

This is a great start! With a few changes we will hopefully be good to go :).

* The Doxygen comments for functions should have an extra newline between the summary and the extra description. The following function comments should be updated:
  frame_event_set_device()
  frame_device_add_axis()

* I would rather namespace the backend functions so they are clearly distinct from the frontend functions. For example, frame_device_new() should be frame_backend_device_new(), and frame_device_get_frontend() could be frame_backend_device_get_device().

* UFBackendDevice_ isn't an invariant because it is not fully initialized after the constructor returns. The constructor could be UFBackendDevice_(oif::frame::UFDevice* device), where the shared_ptr is initialized with the value of device. Then frame_backend_device_new() could simply be:

UFBackendDevice frame_device_new()
{
  return new UFBackendDevice_(new oif::frame::UFDevice);
}

This holds for UFBackendFrame and UFBackendTouch as well.

* Why can't we infer the number of axes from the number of added axes, rather than by having to manually set the value. The same for number of touches in the frame.

The simple fix would be to get the current value, increment it, then reinsert it into the device or frame when an axis or touch is added. The number of active touches would be set to the same value as the number of touches in the frame. The caller would need to set the total number of active touches *after* all frame touches have been added. A sanity check that the number of active touches is greater than or equal to the number of frame touches would be good.

* I understand how events are created, but how are they enqueued to a frame instance? How are devices added to a frame instance?

review: Needs Fixing
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> * Why can't we infer the number of axes from the number of added axes, rather
> than by having to manually set the value. The same for number of touches in
> the frame.

Because it's inefficient. If you add 10 items you will redefine the counter property 10 times.

It also hides the fact that number_of_foo is just a property that can be set independently from the entities they refer to. Besides, the idea of the backend interface is to enable the user to manually and directly build frame data as they will, to feed grail. No real logic expected here. All responsibility is in the hands of the user. The equivalent of a header defining some structs.

> * I understand how events are created, but how are they enqueued to a frame
> instance? How are devices added to a frame instance?

There's no need for a frame instance if you're using the backend interface. The whole point is that you manually create frame events to feed them to grail (through grail_process_frame_event). In that sense, libframe is reduced to being just a header defining some data containers that grail understands.

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> * I would rather namespace the backend functions so they are clearly distinct
> from the frontend functions. For example, frame_device_new() should be
> frame_backend_device_new(), and frame_device_get_frontend() could be
> frame_backend_device_get_device().

Makes all the sense.
I was striving for shorter function names. :)

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Updated according to comments (expect for auto-setting "count" properties)

Revision history for this message
Chase Douglas (chasedouglas) wrote :

* The frame_backend_device_delete() doxygen comment is a bit wonky, since it's one sentence split up for the summary and extended detail. It just needs to be slightly fixed up wording-wise.

* Daniel and I chatted on IRC about fixing up how the number of device axes and number of touches in a frame are calculated and reported. Those will be fixed in this proposal as well.

review: Needs Fixing
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> * The frame_backend_device_delete() doxygen comment is a bit wonky, since it's
> one sentence split up for the summary and extended detail. It just needs to be
> slightly fixed up wording-wise.

Yeah, that was a mistake. Autopilot was on when that happened.

>
> * Daniel and I chatted on IRC about fixing up how the number of device axes
> and number of touches in a frame are calculated and reported. Those will be
> fixed in this proposal as well.

Done.

Revision history for this message
Chase Douglas (chasedouglas) wrote :

* In frame_device_get_property(), the value parameter should be reinterpret_cast'd instead of static_cast'd. The same is true for frame_frame_get_property(). Casts from void* to a concrete pointer should always be reinterpret casted (according to thumper).

* frame_frame_get_property_unsigned_int_() has an erroneously added empty line at the top.

Everything else looks good. I'm approving based on these changes. Great stuff!

review: Approve
90. By Daniel d'Andrada

Adds a backend API.

So that any client can adapt frame+grail to work on top of their input system
without relying on frame to provide a suitable backend implementation.

This API also removes the need to mock libframe when writing grail tests.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches