add support for acpi events like:

video/tabletmode TBLT on K
video/tabletmode TBLT off K
This commit is contained in:
Carsten Haitzler 2013-06-16 10:31:11 +09:00
parent 3640009202
commit 4d68c30127
3 changed files with 48 additions and 5 deletions

View File

@ -13,6 +13,7 @@
/* local structures */
/* for simple acpi device mapping */
typedef struct _E_ACPI_Device_Simple E_ACPI_Device_Simple;
typedef struct _E_ACPI_Device_Simple_State E_ACPI_Device_Simple_State;
typedef struct _E_ACPI_Device_Multiplexed E_ACPI_Device_Multiplexed;
struct _E_ACPI_Device_Simple
@ -22,6 +23,15 @@ struct _E_ACPI_Device_Simple
int type;
};
struct _E_ACPI_Device_Simple_State
{
const char *name;
const char *bus;
const char *state;
// ->
int type;
};
struct _E_ACPI_Device_Multiplexed
{
const char *name;
@ -67,6 +77,15 @@ static E_ACPI_Device_Simple _devices_simple[] =
{NULL, E_ACPI_TYPE_UNKNOWN}
};
static E_ACPI_Device_Simple_State _devices_simple_state[] =
{
/* NB: DO NOT TRANSLATE THESE. */
{"video/tabletmode", "TBLT", "on", E_ACPI_TYPE_TABLET_ON},
{"video/tabletmode", "TBLT", "off", E_ACPI_TYPE_TABLET_OFF},
{NULL, NULL, NULL, E_ACPI_TYPE_UNKNOWN}
};
static E_ACPI_Device_Multiplexed _devices_multiplexed[] =
{
/* NB: DO NOT TRANSLATE THESE. */
@ -193,7 +212,7 @@ _e_acpi_cb_server_data(void *data __UNUSED__, int type __UNUSED__, void *event)
Ecore_Con_Event_Server_Data *ev;
E_Event_Acpi *acpi_event;
int sig, status, i, done = 0;
char device[1024], bus[1024], *sdata;
char device[1024], bus[1024], state[1024], *sdata;
const char *str, *p;
ev = event;
@ -213,6 +232,7 @@ _e_acpi_cb_server_data(void *data __UNUSED__, int type __UNUSED__, void *event)
if (!p) return ECORE_CALLBACK_PASS_ON;
while (p)
{
device[0] = bus[0] = state[0] = 0;
sdata = alloca(p - str + 1);
strncpy(sdata, str, (int)(p - str));
sdata[p - str] = 0;
@ -223,8 +243,11 @@ _e_acpi_cb_server_data(void *data __UNUSED__, int type __UNUSED__, void *event)
sig = -1;
status = -1;
if (sscanf(sdata, "%1023s %1023s", device, bus) != 2)
{
if (sscanf(sdata, "%1023s %1023s %1023s", device, bus, state) != 3)
goto done_event;
}
}
/* create new event structure to raise */
acpi_event = E_NEW(E_Event_Acpi, 1);
@ -252,6 +275,20 @@ _e_acpi_cb_server_data(void *data __UNUSED__, int type __UNUSED__, void *event)
}
}
}
if ((!done) && (state[0]))
{
for (i = 0; _devices_simple_state[i].name; i++)
{
if ((!strcmp(device, _devices_simple_state[i].name)) &&
((!_devices_simple_state[i].bus) || (!strcmp(bus, _devices_simple_state[i].bus))) &&
(!strcmp(state, _devices_simple_state[i].state)))
{
acpi_event->type = _devices_simple_state[i].type;
done = 1;
break;
}
}
}
if (!done)
{
// if device name matches

View File

@ -28,7 +28,9 @@ typedef enum _E_Acpi_Type
E_ACPI_TYPE_VOLUME, // 21
E_ACPI_TYPE_BRIGHTNESS, // 22
E_ACPI_TYPE_VOLUME_DOWN, // 23
E_ACPI_TYPE_VOLUME_UP // 24
E_ACPI_TYPE_VOLUME_UP, // 24
E_ACPI_TYPE_TABLET_ON, // 25
E_ACPI_TYPE_TABLET_OFF // 26
} E_Acpi_Type;
/* enum for acpi signals */

View File

@ -395,6 +395,10 @@ _binding_label_get(E_Config_Binding_Acpi *binding)
return _("Volume Down");
if (binding->type == E_ACPI_TYPE_VOLUME_UP)
return _("Volume Up");
if (binding->type == E_ACPI_TYPE_TABLET_ON)
return _("Tablet On");
if (binding->type == E_ACPI_TYPE_TABLET_OFF)
return _("Tablet Off");
return _("Unknown");
}