[openbeos] Re: broken struct mouse_map in InterfaceDefs.h

  • From: "Andrew Bachmann" <shatty@xxxxxxxxxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Mon, 12 Jan 2004 01:52:26 -0800 PST

Jérôme Duval <korli@xxxxxxxx> wrote:
> Could binary compatibility happen ? 
> For example, sizeof(struct mouse_map) won't be equal in R5 and OBOS R1 with 
> this.
> 
> I think the best you can get is source compat. 
> 
> Cheers,
> Jerome

Well, we can still have a one struct solution I think, this one: [in 
InterfaceDefs.h]

struct mouse_map {
  uint32 left;
  uint32 middle;
  uint32 right;
  uint32 more_buttons[B_MORE_BUTTONS_COUNT];
};

Combined with axel's: [in InterfaceDefs.h]

#define get_mouse_map(map) _get_mouse_map(map, sizeof(mouse_map))
extern status_t _get_mouse_map(mouse_map *map, size_t mapSize);

And the obligatory: [in someplace else that eventually gets linked into our
equivalent of libbe.so]

#undef get_mouse_map
status_t
get_mouse_map(mouse_map * map)
{
        _get_mouse_map(map,3);
}

This seems to give us R5->OBOS compatibility in binary and source, but I
do find the mouse_map struct quite ugly this way.  If we want to do this
patch I'll let someone else get their name stuck in the commit log with it, 
rather than me. :-D

The other alternative is to use a separate mouse map struct based only on
the buttons array, and then simply to interpret whatever you get passed
in as that kind of struct.  This suffers from the same kind of "evil" as the
anonymous union earlier, with respect to interpreting the same bytes in
a different way.  Okay, so maybe the ugly more_buttons is the best option.

Andrew


Other related posts: