raster pushed a commit to branch master.

commit 4d68c301276830321507312b13103fec0311ab8b
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date:   Sun Jun 16 10:31:11 2013 +0900

    add support for acpi events like:
    
    video/tabletmode TBLT on K
    video/tabletmode TBLT off K
---
 src/bin/e_acpi.c                                   | 45 ++++++++++++++++++++--
 src/bin/e_acpi.h                                   |  4 +-
 .../conf_bindings/e_int_config_acpibindings.c      |  4 ++
 3 files changed, 48 insertions(+), 5 deletions(-)

diff --git a/src/bin/e_acpi.c b/src/bin/e_acpi.c
index e6c2f2b..470e3ca 100644
--- a/src/bin/e_acpi.c
+++ b/src/bin/e_acpi.c
@@ -12,8 +12,9 @@
 
 /* local structures */
 /* for simple acpi device mapping */
-typedef struct _E_ACPI_Device_Simple      E_ACPI_Device_Simple;
-typedef struct _E_ACPI_Device_Multiplexed E_ACPI_Device_Multiplexed;
+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,7 +243,10 @@ _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)
-               goto done_event;
+               {
+                  if (sscanf(sdata, "%1023s %1023s %1023s", device, bus, 
state) != 3)
+                    goto done_event;
+               }
           }
 
         /* create new event structure to raise */
@@ -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
diff --git a/src/bin/e_acpi.h b/src/bin/e_acpi.h
index cfaa037..743f47e 100644
--- a/src/bin/e_acpi.h
+++ b/src/bin/e_acpi.h
@@ -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 */
diff --git a/src/modules/conf_bindings/e_int_config_acpibindings.c 
b/src/modules/conf_bindings/e_int_config_acpibindings.c
index 17da063..cb47a45 100644
--- a/src/modules/conf_bindings/e_int_config_acpibindings.c
+++ b/src/modules/conf_bindings/e_int_config_acpibindings.c
@@ -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");
 }

-- 

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev

Reply via email to