You are not logged in.

#1 2010-05-05 17:42:42

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

syndaemon's poor brother for Sentelic touchpads

I have set my touchpad on MSI Wind to middle-click in the bottom corner and accidental pasting was ticking me off. I scratched my itch a bit by hacking together the following (your touchpad has to be using evdev or somesuch):

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

int are_interrupts_idle(void) {
    static unsigned long nr_of_irqs;
    long new_nr_of_irqs = 0;
    int changed = 0;
    char buf[256];
    FILE* f;    

    if ( !(f = fopen("/proc/interrupts", "r")) ) 
        perror("Failed to open /proc/interrupts");

    // irq 1 should be used by the keyboard on msi wind, check for its activity
    while(fgets(buf, 256, f)) {
        if(sscanf(buf, "%*[ ]1: %ld", &new_nr_of_irqs))
            break;
    }

    fclose(f);

    if(nr_of_irqs != new_nr_of_irqs) {
        changed = 1;
    }
    nr_of_irqs = new_nr_of_irqs;

    return changed;
}

int main(int argc, char** argv) {
    
   int was_active = 0;
    while(1) {
        int is_active = are_interrupts_idle();
        if(is_active) {
            if(!was_active) {
              // run comand when keyboard is active
              // disable middle-click in the bottom left corner
              system("xinput set-button-map 'FSPPS/2 Sentelic FingerSensingPad' 1 2 3 4 5 6 7 8 9 10 11");
              //system("xinput set-prop 'FSPPS/2 Sentelic FingerSensingPad' 134 0"); // disable touchpad
              //printf("XXX System is active...\n");
              sleep(1); // increment if you want it disabled for longer
            }
            was_active = 1;
        } else {
            if(was_active) {
              // run command when keyboard is idle
              // enable middle-click in the bottom left corner
              system("xinput set-button-map 'FSPPS/2 Sentelic FingerSensingPad' 1 6 3 4 5 2 7 8 9 10 11");
              //system("xinput set-prop 'FSPPS/2 Sentelic FingerSensingPad' 134 1"); // enable touchpad
              //printf("OOO System is idle...\n");
            }
            was_active = 0;;
        }
    sleep(1); //adjust rate of polling
    }
}

Offline

Board footer

Powered by FluxBB