[haiku-development] Re: Keymap management backend.

  • From: Alexandre Deckner <alex@xxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 03 Sep 2008 18:09:17 +0200

Stephan Assmus wrote:
Alexandre Deckner wrote:
Hi devs,
I started adding a few extensions to the keymap management in the input server as it was suggested by Axel in the commit list discussion for r24924 . This greatly simplifies the code and allow fixing bugs and to further enhance the Keymap preflet , and has all kinds of nice implications like easy keymap switching and keymap change on readonly systems. Well everything is said in the aforementioned thread.

It's 50% done, but now comes my first implementation question: Since i'm creating a new api, wouldn't it be better to add these new calls in a new (small) c++ api, instead of extending InterfaceDefs.h ?

I tried to extend the C interface but it felt really ugly and time consuming (i pass on the details but i lost hours on c strings and tables). Besides it also add some uglyness in the client apps. Awkward, when you know that the client apps and the i.s are written in lovely Be-style c++ .

Now i've put the few static methods i need in a separate c++ api that talks directly with the i.s. It works well, allowed me to progress faster, and it really feels better :)

Should i pursue with this approach? If yes, how to integrate it nicely? For now i've just put a InputServerAPI.cpp/h in the same places as InterfaceDefs.h/cpp and it works so far.

If you feel that it's nicer I think you should definitely pursue it.
Ok, good!
Alternative to an "InputServerAPI", you could also make a class specifically for controlling keymaps. "BKeymapController" or "BKeymapManager" comes to mind, perhaps even "BKeymapRoster" depending on it's capabilities. This way the C++ API could be more fine grained and targeted at the specific need.
Ok, i'll go with BKeymapManager, sounds good, it can be changed anytime off course. Anyway it will surely need a few passes of adjustments before it fits nicely with the rest. And yes, it only deals with keymaps, if it ever goes further, we could reconsider the question anyway.
You just need to put it into the BPrivate namespace.
Hmm, i'm not really sure how the BPrivate namespace should be used throughout the project. I mean, even for a public API? I'm asking since Keymap preflet and 3rd party tools are the target audience. Or i miss something?

Thanks,
Alex



Other related posts: