[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Mouse movements not identified as activity (sleep in 2.6.12)



On Sun, 30 Oct 2005 16:44:36 +0200
Eddy Petrişor <eddy.petrisor@gmail.com> wrote:

> Hello,
> 
> I have a little problem with the sleep functionality in 2.6.12. While
> i am browsing sometimes I see a warning from gtkpbbuttons-gtk that the
> laptop (PowerBook 5,2) will go to sleep (and the counting starts. This
> happens and does not stop when I click the USB mouse attached to the
> laptop, while is stops if I tap the touchpad or press a few keys.
> 
> Why is this happening? Does anybody else has this problem? (Notice
> that I almost never shutdown my laptop, but meerly lock it and put it
> to sleep, so it can reach an "uptime" of more than 4-5 days, but I met
> this behaviour even after a day up)

Do you use udev? If not there might be an event device missing for your
usb mouse in /dev/input/. With the attached program you could check, if
there is a proper device. (Compile with gcc -Wall -o cev cev.c, run as
root because access to the event devices is needed.)

If no event device is available you have multiple choices:
1. install and run udev
2. create missing devices by hand with mknod 

Pbbuttonsd will automatically recognize newly attached devices only if
it was configured with autorescan = yes. See the man page for all
details.

  Best Regards
    Matthias




#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <linux/input.h>

#define BITS_PER_LONG (sizeof(long) * 8)
#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
#define OFF(x) ((x)%BITS_PER_LONG)
#define LONG(x) ((x)/BITS_PER_LONG)
#define test_bit(bit, array) ((array[LONG(bit)] >> OFF(bit)) & 1)

char *events[EV_MAX + 1] = {"Reset", "Key", "Relative", "Absolute",
                             NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
			     NULL, NULL, "LED", "Sound", NULL, "Repeat", "ForceFeedback", NULL,
			     "ForceFeedbackStatus"};

int main(int argc, const char **argv)
{
        int eventfd = -1;
/*        struct input_event inp;*/
        short ids[4];
        char filename[20];
	char name[256];
	unsigned long bit[EV_MAX][NBITS(KEY_MAX)];

/*	int rep=0; */
	int i, j;

	for (i = 0; i < 32; i++) {
		sprintf(filename, "/dev/input/event%d", i);
		if (i == 32)
		    eventfd = open("/dev/input/mice", O_RDONLY);
		else
		    eventfd = open(filename, O_RDONLY);
		if (eventfd >= 0) {
			ioctl(eventfd, EVIOCGID, ids);
			printf("[%d] ids - %x %x %x %x", i, ids[0], ids[1], ids[2], ids[3]);
			ioctl(eventfd, EVIOCGNAME(sizeof(name)), name);
			printf("  Name: %s\n", name);
			ioctl(eventfd, EVIOCGBIT(0, EV_MAX), bit[0]);
			printf("  Supported Events:\n  ");
			for(j=0; j < EV_MAX; j++)
			    if (test_bit(j, bit[0]))
			        printf("%d (%s) ", j, events[j] ? events[j] : "?");
			printf("\n");	
			close(eventfd);
			eventfd = -1;
		} else {
			fprintf(stderr, "[%d] nil\n", i);
		}
	}
/*
	eventfd = open("/dev/input/event0", O_RDONLY);
	while (read(eventfd, &inp, sizeof(inp))) {
	    if (rep != ((inp.value << 8) + inp.code)) {
    	        rep = (inp.value << 8) + inp.code;
			printf("\tEvent: type=0x%02x (%d) code=0x%02x (%d) value=0x%02x (%d)\n",
			   inp.type, inp.type, inp.code, inp.code, inp.value, inp.value);
	    }
	}
	close(eventfd);
*/
	return 0;
}

Reply to: