summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-06-16 10:31:11 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-06-16 10:31:11 +0900
commit4d68c301276830321507312b13103fec0311ab8b (patch)
tree105eb4e926e74154f39b5876a60528236d84b9c1 /src
parent3640009202e6c0047ba5d62835a8dd86062e692f (diff)
add support for acpi events like:
video/tabletmode TBLT on K video/tabletmode TBLT off K
Diffstat (limited to 'src')
-rw-r--r--src/bin/e_acpi.c45
-rw-r--r--src/bin/e_acpi.h4
-rw-r--r--src/modules/conf_bindings/e_int_config_acpibindings.c4
3 files changed, 48 insertions, 5 deletions
diff --git a/src/bin/e_acpi.c b/src/bin/e_acpi.c
index e6c2f2bc4..470e3ca49 100644
--- a/src/bin/e_acpi.c
+++ b/src/bin/e_acpi.c
@@ -12,8 +12,9 @@
12 12
13/* local structures */ 13/* local structures */
14/* for simple acpi device mapping */ 14/* for simple acpi device mapping */
15typedef struct _E_ACPI_Device_Simple E_ACPI_Device_Simple; 15typedef struct _E_ACPI_Device_Simple E_ACPI_Device_Simple;
16typedef struct _E_ACPI_Device_Multiplexed E_ACPI_Device_Multiplexed; 16typedef struct _E_ACPI_Device_Simple_State E_ACPI_Device_Simple_State;
17typedef struct _E_ACPI_Device_Multiplexed E_ACPI_Device_Multiplexed;
17 18
18struct _E_ACPI_Device_Simple 19struct _E_ACPI_Device_Simple
19{ 20{
@@ -22,6 +23,15 @@ struct _E_ACPI_Device_Simple
22 int type; 23 int type;
23}; 24};
24 25
26struct _E_ACPI_Device_Simple_State
27{
28 const char *name;
29 const char *bus;
30 const char *state;
31 // ->
32 int type;
33};
34
25struct _E_ACPI_Device_Multiplexed 35struct _E_ACPI_Device_Multiplexed
26{ 36{
27 const char *name; 37 const char *name;
@@ -67,6 +77,15 @@ static E_ACPI_Device_Simple _devices_simple[] =
67 {NULL, E_ACPI_TYPE_UNKNOWN} 77 {NULL, E_ACPI_TYPE_UNKNOWN}
68}; 78};
69 79
80static E_ACPI_Device_Simple_State _devices_simple_state[] =
81{
82 /* NB: DO NOT TRANSLATE THESE. */
83 {"video/tabletmode", "TBLT", "on", E_ACPI_TYPE_TABLET_ON},
84 {"video/tabletmode", "TBLT", "off", E_ACPI_TYPE_TABLET_OFF},
85
86 {NULL, NULL, NULL, E_ACPI_TYPE_UNKNOWN}
87};
88
70static E_ACPI_Device_Multiplexed _devices_multiplexed[] = 89static E_ACPI_Device_Multiplexed _devices_multiplexed[] =
71{ 90{
72 /* NB: DO NOT TRANSLATE THESE. */ 91 /* NB: DO NOT TRANSLATE THESE. */
@@ -193,7 +212,7 @@ _e_acpi_cb_server_data(void *data __UNUSED__, int type __UNUSED__, void *event)
193 Ecore_Con_Event_Server_Data *ev; 212 Ecore_Con_Event_Server_Data *ev;
194 E_Event_Acpi *acpi_event; 213 E_Event_Acpi *acpi_event;
195 int sig, status, i, done = 0; 214 int sig, status, i, done = 0;
196 char device[1024], bus[1024], *sdata; 215 char device[1024], bus[1024], state[1024], *sdata;
197 const char *str, *p; 216 const char *str, *p;
198 217
199 ev = event; 218 ev = event;
@@ -213,6 +232,7 @@ _e_acpi_cb_server_data(void *data __UNUSED__, int type __UNUSED__, void *event)
213 if (!p) return ECORE_CALLBACK_PASS_ON; 232 if (!p) return ECORE_CALLBACK_PASS_ON;
214 while (p) 233 while (p)
215 { 234 {
235 device[0] = bus[0] = state[0] = 0;
216 sdata = alloca(p - str + 1); 236 sdata = alloca(p - str + 1);
217 strncpy(sdata, str, (int)(p - str)); 237 strncpy(sdata, str, (int)(p - str));
218 sdata[p - str] = 0; 238 sdata[p - str] = 0;
@@ -223,7 +243,10 @@ _e_acpi_cb_server_data(void *data __UNUSED__, int type __UNUSED__, void *event)
223 sig = -1; 243 sig = -1;
224 status = -1; 244 status = -1;
225 if (sscanf(sdata, "%1023s %1023s", device, bus) != 2) 245 if (sscanf(sdata, "%1023s %1023s", device, bus) != 2)
226 goto done_event; 246 {
247 if (sscanf(sdata, "%1023s %1023s %1023s", device, bus, state) != 3)
248 goto done_event;
249 }
227 } 250 }
228 251
229 /* create new event structure to raise */ 252 /* create new event structure to raise */
@@ -252,6 +275,20 @@ _e_acpi_cb_server_data(void *data __UNUSED__, int type __UNUSED__, void *event)
252 } 275 }
253 } 276 }
254 } 277 }
278 if ((!done) && (state[0]))
279 {
280 for (i = 0; _devices_simple_state[i].name; i++)
281 {
282 if ((!strcmp(device, _devices_simple_state[i].name)) &&
283 ((!_devices_simple_state[i].bus) || (!strcmp(bus, _devices_simple_state[i].bus))) &&
284 (!strcmp(state, _devices_simple_state[i].state)))
285 {
286 acpi_event->type = _devices_simple_state[i].type;
287 done = 1;
288 break;
289 }
290 }
291 }
255 if (!done) 292 if (!done)
256 { 293 {
257 // if device name matches 294 // if device name matches
diff --git a/src/bin/e_acpi.h b/src/bin/e_acpi.h
index cfaa0377c..743f47e84 100644
--- a/src/bin/e_acpi.h
+++ b/src/bin/e_acpi.h
@@ -28,7 +28,9 @@ typedef enum _E_Acpi_Type
28 E_ACPI_TYPE_VOLUME, // 21 28 E_ACPI_TYPE_VOLUME, // 21
29 E_ACPI_TYPE_BRIGHTNESS, // 22 29 E_ACPI_TYPE_BRIGHTNESS, // 22
30 E_ACPI_TYPE_VOLUME_DOWN, // 23 30 E_ACPI_TYPE_VOLUME_DOWN, // 23
31 E_ACPI_TYPE_VOLUME_UP // 24 31 E_ACPI_TYPE_VOLUME_UP, // 24
32 E_ACPI_TYPE_TABLET_ON, // 25
33 E_ACPI_TYPE_TABLET_OFF // 26
32} E_Acpi_Type; 34} E_Acpi_Type;
33 35
34/* enum for acpi signals */ 36/* 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 17da0636c..cb47a4573 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)
395 return _("Volume Down"); 395 return _("Volume Down");
396 if (binding->type == E_ACPI_TYPE_VOLUME_UP) 396 if (binding->type == E_ACPI_TYPE_VOLUME_UP)
397 return _("Volume Up"); 397 return _("Volume Up");
398 if (binding->type == E_ACPI_TYPE_TABLET_ON)
399 return _("Tablet On");
400 if (binding->type == E_ACPI_TYPE_TABLET_OFF)
401 return _("Tablet Off");
398 402
399 return _("Unknown"); 403 return _("Unknown");
400} 404}