mapping single-key input devices to buttons
Richard Hughes
hughsient at gmail.com
Thu May 4 09:41:19 PDT 2006
On Mon, 2006-05-01 at 17:50 +0200, Johannes Berg wrote:
> Hi,
>
> > Yes, so, just to recap, the case is that the kernel, for each physical
> > button exports a single input device with a single key, yes?
>
> That's the question. I'm no longer sure this approach is good, because
> we end up with tons of input devices. I'd probably prefer in the kernel
> to have just a single one for the PMU.
This is what I put in g-p-m:
/** Use when we want to emit a ButtonPressed event and we know the udi
*
* @param monitor This monitor instance
* @param udi The HAL UDI
* @param details The event details, or "" for unknown or invalid
*
* We can get two different types of ButtonPressed condition
* 1. The old acpi hardware buttons
* udi="acpi_foo", details="";
* button.type="power"
* 2. The new keyboard buttons
* udi="foo_Kbd_Port_logicaldev_input", details="sleep"
* button.type=""
*/
static void
emit_button_pressed (GpmHalMonitor *monitor,
const char *udi,
const char *details)
{
char *button_name = NULL;
gboolean value;
if (strcmp (details, "") == 0) {
/* no details about the event, so we get more info
for type 1 buttons */
gpm_hal_device_get_string (udi, "button.type", &button_name);
} else {
button_name = g_strdup (details);
}
/* Buttons without state should default to true. */
value = TRUE;
/* we need to get the button state for lid buttons */
if (strcmp (button_name, "lid") == 0) {
gpm_hal_device_get_bool (udi, "button.state.value", &value);
}
/* we now emit all buttons, even the ones we don't know */
gpm_debug ("emitting button-pressed : %s (%i)", button_name, value);
g_signal_emit (monitor, signals [BUTTON_PRESSED], 0, button_name,
value);
g_free (button_name);
}
Does that help? Sorry I can't be more verbose, but I'm right in the
middle of exams.
Richard.
More information about the hal
mailing list