#!/usr/bin/python #Created by Kris Occhipinti #filmsbykris.com #Dec. 28 2008 #Copyright 2008 Kris Occhipinti #program is distributed under the terms of the GNU GPL # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . import struct from math import sqrt import os import time button = "/dev/input/event0" keyboard=0 #int, int, short, short, int fmt = 'iihhi' #Read button input in_file = open(button,"rb") event = in_file.read(16) while event: (time1,time2, type, code, value) = \ struct.unpack(fmt,event) if type == 1 & code == 169 & value == 1: keyboard=keyboard+1 print keyboard # if keyboard == 1: a = os.popen("ko-keypad") # a = os.popen("killall matchbox-keyboard;matchbox-keyboard") # elif keyboard == 2: # a = os.popen("killall matchbox-keyboard","w") # keyboard=0 event = in_file.read(16) in_file.close()