[Core] Change the alsa state on jack in/out
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Wed, 6 May 2009 00:57:18 +0000 (02:57 +0200)
committerMarco Trevisan (Treviño) <mail@3v1n0.net>
Wed, 6 May 2009 00:57:18 +0000 (02:57 +0200)
Actually it supports only the alsa state files for standby.
I've to support also the call state files.

devices/ficgta01/server/fichardware.cpp

index faf12e3..a9e5f54 100644 (file)
@@ -164,18 +164,27 @@ void Ficgta01Hardware::inputEvent(struct input_event& event)
     if(event.type != EV_SW)
         return;
 
-    qWarning("keypressed: type=%03d, code=%03d, value=%03d (%s)",
-              event.type, event.code,event.value,((event.value)!=0) ? "Down":"Up");
+    //qWarning("keypressed: type=%03d, code=%03d, value=%03d (%s)",
+    //          event.type, event.code,event.value,((event.value)!=0) ? "Down":"Up");
 
     // Only handle the headphone insert. value=0 (Up,Insert), value=1 (Down,Remove)
-    switch(event.code) {
-    case SW_HEADPHONE_INSERT:
-        m_vsoPortableHandsfree.setAttribute("Present", event.value != 0x01);
-        m_vsoPortableHandsfree.sync();
-        break;
-    default:
-        break;
-    };
+    if (event.type ==0x05 && event.code == 0x02) {
+        QString confDir, cmd;
+
+        if (QDir("/usr/share/openmoko/scenarios").exists())
+            confDir = "/usr/share/openmoko/scenarios/";
+        else if (QDir("/etc/alsa").exists())
+            confDir = "/etc/alsa/";
+        else
+            confDir = "/etc/";
+
+        if (event.value == 0x00)
+            cmd = "/usr/sbin/alsactl -f " + confDir + "stereoout.state restore";
+        else if (event.value == 0x01)
+            cmd = "/usr/sbin/alsactl -f " + confDir +  "headset.state restore";
+
+        int result = system(cmd.toLocal8Bit());
+    }
 }
 
 #endif // QT_QWS_Ficgta01