r2164 - trunk/src/target/OM-2007/panel-plugins/openmoko-panel-mainmenu/src
mickey at sita.openmoko.org
mickey at sita.openmoko.org
Tue Jun 5 14:30:26 CEST 2007
Author: mickey
Date: 2007-06-05 14:30:26 +0200 (Tue, 05 Jun 2007)
New Revision: 2164
Modified:
trunk/src/target/OM-2007/panel-plugins/openmoko-panel-mainmenu/src/buttonactions.c
trunk/src/target/OM-2007/panel-plugins/openmoko-panel-mainmenu/src/buttonactions.h
Log:
openmoko-panel-mainmenu: add key clicks
NOTE: While we are developing this feature, to enable the power management functions,
you need to export the MOKO_POWERSAVE environment variable to "yes". Restart the matchbox-panel afterwards.
Modified: trunk/src/target/OM-2007/panel-plugins/openmoko-panel-mainmenu/src/buttonactions.c
===================================================================
--- trunk/src/target/OM-2007/panel-plugins/openmoko-panel-mainmenu/src/buttonactions.c 2007-06-05 12:25:25 UTC (rev 2163)
+++ trunk/src/target/OM-2007/panel-plugins/openmoko-panel-mainmenu/src/buttonactions.c 2007-06-05 12:30:26 UTC (rev 2164)
@@ -48,12 +48,14 @@
#define POWER_BUTTON_EVENT_PATH "/dev/input/event2"
#define POWER_BUTTON_KEYCODE 116
#define TOUCHSCREEN_EVENT_PATH "/dev/input/touchscreen0"
+ #define TOUCHSCREEN_BUTTON_KEYCODE 0x14a
#else
#define AUX_BUTTON_EVENT_PATH "/dev/input/event1"
#define AUX_BUTTON_KEYCODE 0x25
#define POWER_BUTTON_EVENT_PATH "/dev/input/event0"
#define POWER_BUTTON_KEYCODE 0x25
#define TOUCHSCREEN_EVENT_PATH "/dev/input/event2"
+ #define TOUCHSCREEN_BUTTON_KEYCODE 0x14a
#endif
GPollFD aux_fd;
@@ -147,18 +149,24 @@
g_source_add_poll( button_watcher, &power_fd );
g_source_attach( button_watcher, NULL );
- int tsfd = open( TOUCHSCREEN_EVENT_PATH, O_RDONLY );
- if ( tsfd < 0 )
+ if ( getenv( "MOKO_POWERSAVE" ) )
{
- g_debug( "can't open " TOUCHSCREEN_EVENT_PATH " (%s)", strerror( errno ) );
- return FALSE;
+
+ int tsfd = open( TOUCHSCREEN_EVENT_PATH, O_RDONLY );
+ if ( tsfd < 0 )
+ {
+ g_debug( "can't open " TOUCHSCREEN_EVENT_PATH " (%s)", strerror( errno ) );
+ return FALSE;
+ }
+ touchscreen_io = g_io_channel_unix_new( tsfd );
+ g_io_add_watch( touchscreen_io, G_IO_IN, panel_mainmenu_touchscreen_cb, NULL );
+
+ panel_mainmenu_powersave_reset();
+ panel_mainmenu_set_display( 100 );
}
- touchscreen_io = g_io_channel_unix_new( tsfd );
- g_io_add_watch( touchscreen_io, G_IO_IN, panel_mainmenu_touchscreen_cb, NULL );
+ else
+ g_debug( "MOKO_POWERSAVE set. Not enabling power management." );
- //panel_mainmenu_powersave_reset();
- //panel_mainmenu_set_display( 100 );
-
return TRUE;
}
@@ -353,14 +361,27 @@
struct input_event event;
int size = read( g_io_channel_unix_get_fd( source ), &event, sizeof( struct input_event ) );
- g_debug( "read %d bytes from power_fd %d", size, power_fd.fd );
+ g_debug( "read %d bytes from touchscreen_fd %d", size, g_io_channel_unix_get_fd( source ) );
g_debug( "input event = ( %0x, %0x, %0x )", event.type, event.code, event.value );
- panel_mainmenu_powersave_reset();
- if ( power_state != NORMAL )
+ if ( event.type == 1 && event.code == TOUCHSCREEN_BUTTON_KEYCODE )
{
- panel_mainmenu_set_display( 100 );
- power_state = NORMAL;
+ if ( event.value == 1 ) /* pressed */
+ {
+ g_debug( "stylus pressed" );
+ panel_mainmenu_play_stylus_click();
+ }
+ else if ( event.value == 0 ) /* released */
+ {
+ g_debug( "stylus released" );
+ }
+
+ panel_mainmenu_powersave_reset();
+ if ( power_state != NORMAL )
+ {
+ panel_mainmenu_set_display( 100 );
+ power_state = NORMAL;
+ }
}
return TRUE;
}
@@ -417,3 +438,11 @@
power_state = NORMAL;
return FALSE;
}
+
+void panel_mainmenu_play_stylus_click()
+{
+ g_debug( "mainmenu play stylus click" );
+ //TODO add function to libmokoui that talks alsa
+ //yes, this is hardcoded... it's just a proof of concept
+ system( "/usr/bin/aplay /usr/share/openmoko/touchscreen_click.wav &" );
+}
Modified: trunk/src/target/OM-2007/panel-plugins/openmoko-panel-mainmenu/src/buttonactions.h
===================================================================
--- trunk/src/target/OM-2007/panel-plugins/openmoko-panel-mainmenu/src/buttonactions.h 2007-06-05 12:25:25 UTC (rev 2163)
+++ trunk/src/target/OM-2007/panel-plugins/openmoko-panel-mainmenu/src/buttonactions.h 2007-06-05 12:30:26 UTC (rev 2164)
@@ -2,6 +2,7 @@
#define BUTTONACTIONS_H
#include <glib.h>
+#include <gdk/gdk.h>
gboolean panel_mainmenu_input_prepare( GSource* source, gint* timeout );
gboolean panel_mainmenu_input_check( GSource* source );
@@ -19,5 +20,6 @@
gboolean panel_mainmenu_powersave_timeout3( guint timeout );
void panel_mainmenu_set_display( int brightness );
+void panel_mainmenu_play_stylus_click();
#endif
More information about the commitlog
mailing list