Active Topics

 


Reply
Thread Tools
Posts: 875 | Thanked: 918 times | Joined on Sep 2010
#61
Originally Posted by Addison View Post
I wish that you just would have said that it's not possible instead.
This ability is actually planned for ASUI. I just need to figure out the best way to handle it. Probably unmap ASUI and open its blank window to grab all keys. Use a simple command language in asui-settings to map keys to dbus calls, ignore them or pass them through. The screen automatically comes on when a key is pressed so I'll probably have a configure the delay before turning it back off. That way it would only remain on for a few seconds instead of for your entire dim/blank timeout.

Thoughts?
 

The Following User Says Thank You to auouymous For This Useful Post:
Addison's Avatar
Posts: 3,811 | Thanked: 1,151 times | Joined on Oct 2007 @ East Lansing, MI
#62
Isn't the dim/blank timeout done in milliseconds?

Why not just set it at 1?

Maybe it won't even be noticeable.
 
Posts: 875 | Thanked: 918 times | Joined on Sep 2010
#63
Originally Posted by Addison View Post
Isn't the dim/blank timeout done in milliseconds?

Why not just set it at 1?

Maybe it won't even be noticeable.
What if you want to see the screen briefly while pressing the keys? Duration is not a problem since the user would be able to set it.
 

The Following User Says Thank You to auouymous For This Useful Post:
Posts: 235 | Thanked: 339 times | Joined on Nov 2010
#64
Originally Posted by Addison View Post
Hey, there's one other thing I wanted to ask.

I love Xmms.

I also love how you can use the zoom in and out keys to change tracks.

The thing is, this doesn't work with the tablet locked so that the screen is turned off to save on battery life.

Is there any possible trick around this?
I wrote a hack, but unfortunately it doesn't work correctly: Sometimes, when locking, this program picks up spurious input events making the program think the zoom keys have been pressed, even when they haven't.

The idea behind this program (was supposed to be) is simple: If the zoom in/out keys are pressed are pressed while the tablet is locked and the display is dimmed/off, it will run /home/user/xmmskey and pass which zoom key was pressed by passing it as argv[1] (in a script, you can check if $1 = "in") and you could run xmmsctrl (available from free's debfarm repository) from this script.

If a resident Maemo 4 programmer (I don't know what I'm doing!) knows where I've messed up, I'll fix it, but it seems like auouymous is working on something anyway.

PHP Code:
/* Code taken from Austin Che's powerlaunch and fanoush's evkey */
/* gcc xmmskey.c  $(pkg-config --cflags --libs glib-2.0 dbus-glib-1) -Wall -O2 -o xmmskey */

#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <signal.h>
#include <linux/input.h>
#include <glib.h>
#include <glib/gstdio.h>
#include <dbus/dbus-glib.h>
#include <mce/dbus-names.h>
#include <mce/mode-names.h>

#define INPUT_DEV "/dev/input/event2"
#define KP_PATH "/sys/devices/platform/omap2_mcspi.1/spi1.0/disable_kp"
#define ZOOMIN_KC 65
#define ZOOMOUT_KC 66
#define SCRIPT_TO_RUN "/home/user/xmmskey"

static GMainLoop *loopy NULL;

static 
gint inputfd = -1;
static 
GIOChannel *inputfdchannel NULL;

static 
DBusGConnection *systembus NULL;
static 
DBusGProxy *mceproxy NULL;

static 
void sighandler (gint signo G_GNUC_UNUSED)
{
    if (!
inputfdchannel)
    {
        
g_io_channel_shutdown (inputfdchannelFALSENULL);
        
g_io_channel_unref (inputfdchannel);
        
inputfdchannel NULL;
    }

    if (
inputfd != -1)
    {
        
close (inputfd);
        
inputfd = -1;
    }
    
    if (
mceproxy)
    {
        
g_object_unref (mceproxy);
        
mceproxy NULL;
    }

    if (
loopy)
    {
        
g_main_loop_quit (loopy);
        
g_main_loop_unref (loopy);
        
loopy NULL;
    }
}

static 
void disable_kplock (void)
{
    
FILE *kp g_fopen (KP_PATH"w");
    if (
kp)
    {
        
fputc (0kp);
        
fclose (kp);
    }
}

static 
inline DBusGProxyget_mce_request_proxy (void)
{
    return 
dbus_g_proxy_new_for_name (systembusMCE_SERVICEMCE_REQUEST_PATHMCE_REQUEST_IF);
}

static 
gboolean is_tablet_locked (void)
{
    
gchar *lockmode NULL;
    
gboolean retval FALSE;
    
DBusGProxy *mcereqproxy get_mce_request_proxy();

    
dbus_g_proxy_call (mcereqproxyMCE_TKLOCK_MODE_GETNULLG_TYPE_INVALIDG_TYPE_STRING, &lockmodeG_TYPE_INVALID);
    
g_object_unref (mcereqproxy);
    if (!
lockmode)
        return 
FALSE;

    
retval g_strrstr (lockmodeMCE_TK_UNLOCKED) == NULL;
    
g_free (lockmode);

    return 
retval;
}

static 
void blank_screen (void)
{
    
DBusGProxy *mcereqproxy get_mce_request_proxy();

    
dbus_g_proxy_call_no_reply (mcereqproxyMCE_DISPLAY_OFF_REQG_TYPE_INVALID);
    
g_object_unref (mcereqproxy);
}

static 
void begin_work (gboolean zoomin)
{
    
gchar cmdline[sizeof (SCRIPT_TO_RUN) + 10];
    
g_snprintf (cmdlinesizeof (cmdline), "%s %s"SCRIPT_TO_RUNzoomin "in" "out");
    
g_spawn_command_line_sync (cmdlineNULLNULLNULLNULL);
    
blank_screen();
}

static 
gboolean input_cb (GIOChannel *sourceGIOCondition conditiongpointer data G_GNUC_UNUSED)
{
    if(
condition & (G_IO_IN G_IO_PRI))
    {
        
struct input_event ev;
        
gsize bytes_read;
        
        if (!
is_tablet_locked())
            return 
FALSE;

        if (
g_io_channel_read_chars (source, (gchar*) &evsizeof (struct input_event), &bytes_readNULL) == G_IO_STATUS_NORMAL)
        {
            if (
bytes_read != sizeof (struct input_event))
                goto 
getmeout;

            if (
ev.type != EV_KEY)
                goto 
getmeout;

            if (
ev.value != 0/* Act only on key release */
                
goto getmeout;

            if (
ev.code == ZOOMIN_KC)
                
begin_work (TRUE);
            else if (
ev.code == ZOOMOUT_KC)
                
begin_work (FALSE);
        }
    }

getmeout:
    return 
TRUE;
}

static 
void display_cb (DBusGProxy *proxy G_GNUC_UNUSED, const gchar *dispstategpointer data G_GNUC_UNUSED)
{
    if (!
g_str_equal (dispstateMCE_DISPLAY_ON_STRING) && is_tablet_locked())
    {
        
disable_kplock();
        
g_io_add_watch (inputfdchannelG_IO_IN G_IO_PRIinput_cbinputfdchannel);
    }
}

static 
void tklock_cb (DBusGProxy *proxy G_GNUC_UNUSED, const gchar *modegpointer data G_GNUC_UNUSED)
{
    if (
g_strrstr (modeMCE_TK_UNLOCKED))
    {
        
dbus_g_proxy_disconnect_signal (mceproxyMCE_DISPLAY_SIGG_CALLBACK (display_cb), NULL);
        
GSource *inputfd_watch g_main_context_find_source_by_user_data (NULLinputfdchannel);
        if (
inputfd_watch)
            
g_source_destroy (inputfd_watch);
    }
    else
    {
        
dbus_g_proxy_connect_signal (mceproxyMCE_DISPLAY_SIGG_CALLBACK (display_cb), NULLNULL);
    }
}

int main (void)
{
    
inputfd open (INPUT_DEVO_RDONLY O_NONBLOCK);
    if (
inputfd == -1)
        return 
EXIT_FAILURE;
    
    
signal (SIGTERMsighandler);
    
signal (SIGINTsighandler);
    
signal (SIGQUITsighandler);

    
g_type_init();    
    
systembus dbus_g_bus_get (DBUS_BUS_SYSTEMNULL);
    if (!
systembus)
    {
        
sighandler(0);
        return 
EXIT_FAILURE;
    }

    
inputfdchannel g_io_channel_unix_new (inputfd);
    if (!
inputfdchannel)
    {
        
sighandler(0);
        return 
EXIT_FAILURE;
    }
    
    
g_io_channel_set_flags (inputfdchannelG_IO_FLAG_NONBLOCKNULL);
    
g_io_channel_set_encoding (inputfdchannelNULLNULL);

    
mceproxy dbus_g_proxy_new_for_name (systembusMCE_SERVICEMCE_SIGNAL_PATHMCE_SIGNAL_IF);
    
dbus_g_proxy_add_signal (mceproxyMCE_DISPLAY_SIGG_TYPE_STRINGG_TYPE_INVALID);
    
dbus_g_proxy_add_signal (mceproxyMCE_TKLOCK_MODE_SIGG_TYPE_STRINGG_TYPE_INVALID);
    
dbus_g_proxy_connect_signal (mceproxyMCE_TKLOCK_MODE_SIGG_CALLBACK (tklock_cb), NULLNULL);
    
    
loopy g_main_loop_new (NULLFALSE);
    
g_main_loop_run (loopy);

    return 
EXIT_SUCCESS;

 

The Following User Says Thank You to jstokes For This Useful Post:
Addison's Avatar
Posts: 3,811 | Thanked: 1,151 times | Joined on Oct 2007 @ East Lansing, MI
#65
Originally Posted by auouymous View Post
What if you want to see the screen briefly while pressing the keys? Duration is not a problem since the user would be able to set it.
Okay. So perhaps just have that customizable on the user's side then?
 
Posts: 875 | Thanked: 918 times | Joined on Sep 2010
#66
Originally Posted by jstokes View Post
If a resident Maemo 4 programmer (I don't know what I'm doing!) knows where I've messed up, I'll fix it, but it seems like auouymous is working on something anyway.
Your KP_PATH only works on n800. Need to detect device type and change KP_PATH if you want it to also work on n810.

The key handling code looks correct, ASUI uses similar code to read the power button but not glib, maybe a problem with glib. Have you tried
Code:
printf("event: time=%f, type=%u, code=%u, value=%d\n", (float)ev.time.tv_sec + (float)ev.time.tv_usec / 1000000.0, ev.type, ev.code, ev.value);
after the ev.value condition? You can then see the time each event occured and its parameters.
 

The Following 2 Users Say Thank You to auouymous For This Useful Post:
Addison's Avatar
Posts: 3,811 | Thanked: 1,151 times | Joined on Oct 2007 @ East Lansing, MI
#67
Ooh! Hey!

I finally got around to using the built in Email with my Gmail POP account after all these years.

I love how I can now receive LED notifications.

Is there any hack to have it scan for new messages every minute though?

The lowest setting is only at every 5 minutes.
 
n9ots's Avatar
Posts: 139 | Thanked: 38 times | Joined on Nov 2007 @ mid gulf coast florida
#68
Originally Posted by Addison View Post
Is there any hack to have it scan for new messages every minute though?

The lowest setting is only at every 5 minutes.
not sure but you could try setting the 'update interval' with gconf-editor. (apps > modest)
 

The Following User Says Thank You to n9ots For This Useful Post:
Posts: 1,101 | Thanked: 1,184 times | Joined on Aug 2008 @ Spain
#69
Originally Posted by Addison View Post
Ooh! Hey!

I finally got around to using the built in Email with my Gmail POP account after all these years.

I love how I can now receive LED notifications.

Is there any hack to have it scan for new messages every minute though?

The lowest setting is only at every 5 minutes.
Isn't it a bit of abuse to scan every minute?
If it comes by email, sure it can wait 5 minutes, can't it?
 

The Following User Says Thank You to maacruz For This Useful Post:
Addison's Avatar
Posts: 3,811 | Thanked: 1,151 times | Joined on Oct 2007 @ East Lansing, MI
#70
I only ask because LED notification for Dial Central is still broke with it's latest build.

This would be a simple alternative instead.
 
Reply

Tags
nokia n800, volume


 
Forum Jump


All times are GMT. The time now is 06:31.