[haiku-development] Re: [PATCH] get_modifier_key() in InputServer class

  • From: Stephan Aßmus <superstippi@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sat, 13 Dec 2008 12:31:44 +0100

Hi,

Am Samstag, den 13.12.2008, 10:55 +0100 schrieb Olivier Cortès:
> I've been hacking a little in Menu* and InputServer to fix #3176.
> The very first patch, initiated by Jerome (korli ?) touched Keymap.h and 
> Keymap.cpp in the input_server/devices/keyboard.
> 
> The current patch i'm proposing forwards the change done to Keymap to 
> the input server and the interface kit, making the new functionnality 
> accessible for apps.
> 
> I don't know if it is valuable or useful yet, i'm just hacking ;-)
> feel free to advise anything.

The patch looks nice, although it looks like it misses the place where
the IS_GET_MODIFIER_KEY message constant is defined. (Unless it was
already defined before.)


>  status_t
> +InputServer::HandleGetModifierKey(BMessage* message, BMessage* reply)
> +{
> +     int32 modifier;
> +     
> +     if (message->FindInt32("modifier", &modifier) == B_OK) {
> +             
> +             switch (modifier) {
> +                     case B_CAPS_LOCK:
> +                             return reply->AddInt32("key", fKeys.caps_key);
> +                     case B_NUM_LOCK:
> +                             return reply->AddInt32("key", fKeys.num_key);
> +                     case B_SCROLL_LOCK:
> +                             return reply->AddInt32("key", fKeys.scroll_key);
> +                     case B_LEFT_SHIFT_KEY:
> +                             return reply->AddInt32("key", 
> fKeys.left_shift_key);
> +                     case B_RIGHT_SHIFT_KEY:
> +                             return reply->AddInt32("key", 
> fKeys.right_shift_key);
> +                     case B_LEFT_COMMAND_KEY:
> +                             return reply->AddInt32("key", 
> fKeys.left_command_key);
> +                     case B_RIGHT_COMMAND_KEY:
> +                             return reply->AddInt32("key", 
> fKeys.right_command_key);
> +                     case B_LEFT_CONTROL_KEY:
> +                             return reply->AddInt32("key", 
> fKeys.left_control_key);
> +                     case B_RIGHT_CONTROL_KEY:
> +                             return reply->AddInt32("key", 
> fKeys.right_control_key);
> +                     case B_LEFT_OPTION_KEY:
> +                             return reply->AddInt32("key", 
> fKeys.left_option_key);
> +                     case B_RIGHT_OPTION_KEY:
> +                             return reply->AddInt32("key", 
> fKeys.right_option_key);
> +                     case B_MENU_KEY:
> +                             return reply->AddInt32("key", fKeys.menu_key);
> +                     default:
> +                             return B_ERROR;
> +             }
> +     }
> +
> +     return B_ERROR;

You could skip the closing "return B_ERROR;" here, since you already
handle this in the switch. Otherwise it all looks fine to me.

Thanks a lot!

Best regards,
-Stephan



Other related posts: