View previous topic :: View next topic |
Author |
Message |
robbyjo Guru
Joined: 06 Apr 2003 Posts: 462
|
Posted: Wed Jun 22, 2005 10:25 pm Post subject: |
|
|
Perhaps we can set the duplication to 3 or 4. But I can hardly think of words that has 3 identical letters in a row, except perhaps Kashyyyk. Hmm... |
|
Back to top |
|
|
alinv Guru
Joined: 19 Nov 2002 Posts: 395 Location: Bucharest
|
Posted: Wed Jun 22, 2005 10:31 pm Post subject: |
|
|
robbyjo wrote: | Perhaps we can set the duplication to 3 or 4. But I can hardly think of words that has 3 identical letters in a row, except perhaps Kashyyyk. Hmm... |
What about numbers like 1000000 or hex AAAABBBB1111...? _________________ Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better.
S.B. |
|
Back to top |
|
|
mirko_3 l33t
Joined: 02 Nov 2003 Posts: 605 Location: Birreria
|
Posted: Thu Jun 23, 2005 2:23 pm Post subject: |
|
|
I mean... do you really need it to be that precise? _________________ Non fa male! Non fa male! |
|
Back to top |
|
|
Redeeman l33t
Joined: 25 Sep 2003 Posts: 958 Location: Portugal
|
Posted: Thu Jun 23, 2005 2:37 pm Post subject: |
|
|
isnt it possible to catch a keypress event so that you just increment each time a key is pressed, and ignore the repeat thing? |
|
Back to top |
|
|
dsf n00b
Joined: 16 Nov 2004 Posts: 21
|
Posted: Fri Jun 24, 2005 1:10 am Post subject: |
|
|
People are indeed correct about the bug with repeats -- good eye and catch.
Right now, the code assumes that if it has seen the same character before, that it is a repeat. This was required because of the way the code is written to ignore the actual keypress repeat events.
It could probably be restructured differently in some way, along with an additional check or two, and perhaps adding an additional variable or two to track this stuff.
So I will leave this as an exercise in code modification for anyone that may be interested in fixing it. Shouldn't be too hard. |
|
Back to top |
|
|
rihteri n00b
Joined: 01 Jun 2003 Posts: 36 Location: Seinäjoki, Finland
|
Posted: Thu Oct 13, 2005 12:31 pm Post subject: |
|
|
Nice hacks, but if you really only want to count the keystrokes, try this little python script I wrote inspired by dsf:s comment about doing this in userspace. Seems the problem is really simple.
Code: |
i=0
event=file('/dev/input/event0','r')
while (1):
event.read(96)
i=i+1
print i
|
Of course this only starts counting when it is started. Output could be better as well. But I think it counts right. You might have to alter the read size if you have non-i386-32bit processor, I think. And change the device if needed.
EDIT:
Seems like the event interface also outputs the time an event occurs.
Code: |
struct input_event {
struct timeval time;
__u16 type;
__u16 code;
__s32 value;
};
|
Who wants to write a script to draw a graph of keystrokes relative to time? =) _________________ I do speak more freely if I get free beer... |
|
Back to top |
|
|
zojas Veteran
Joined: 22 Apr 2002 Posts: 1138 Location: Phoenix, AZ
|
Posted: Thu Oct 13, 2005 5:38 pm Post subject: |
|
|
where are these /dev/input/event* files documented? how did you know event0 was the keyboard? _________________ http://www.desertsol.com/~kevin/ppc |
|
Back to top |
|
|
rihteri n00b
Joined: 01 Jun 2003 Posts: 36 Location: Seinäjoki, Finland
|
Posted: Thu Oct 13, 2005 5:59 pm Post subject: |
|
|
zojas wrote: | where are these /dev/input/event* files documented? how did you know event0 was the keyboard? |
http://www.frogmouth.net/hid-doco/p13.html has something. http://www.charmed.com/txt/input-programming.txt has some more.
About making the script... I tried 'cat /dev/input/event0' etc, noticed event0 is my keyboard, event1 is mouse etc. I was actually trying to get my synaptics touchpad working, thats why I came across this thred as well.
When you open up /usr/src/linux/include/input.h you can start guessing the format of an input event - seems I got the size right eventually, at least on my system. I'm really pretty clueless about this thing, I'm not even sure about anything I said before
EDIT:
My script counts repeats wrong. It really needs some tuning. _________________ I do speak more freely if I get free beer... |
|
Back to top |
|
|
mephist0 Tux's lil' helper
Joined: 19 Sep 2005 Posts: 94 Location: Germany, Frankfurt/Main
|
Posted: Sat Oct 15, 2005 7:07 pm Post subject: Re: Linux Kernel Keystroke Counter |
|
|
zojas wrote: | I hacked the keyboard driver in the kernel so it counts every keystroke and reports it through /proc/keystrokes.
You can go to http://www.desertsol.com/~kevin/keystroke_patch
to get a patch for 2.4.18 or 2.4.19-gentoo-r7.
Just patch, recompile, install, reboot, then
Code: | cat /proc/keystrokes |
|
really cool, thanks alot !! _________________ There is only one God, and his name is Death. And there is only one thing we say to Death: 'Not today!'
Photography portfolio |
|
Back to top |
|
|
rihteri n00b
Joined: 01 Jun 2003 Posts: 36 Location: Seinäjoki, Finland
|
Posted: Fri Oct 21, 2005 8:49 pm Post subject: |
|
|
I got interested in this thing, so heres a little improved version of the userspace keypress counter. Compile with 'g++ -o key key.cc'. Mostly ripped of from http://www.frogmouth.net/hid-doco/c193.html. Should work fine, ignores repeats and makes no (?) errors =)
key.cc:
Code: | #include <fstream>
#include <linux/input.h>
#include <iostream>
using namespace std;
int main() {
struct input_event ev;
int i = 0;
//Open /dev/input/event0
ifstream fd ("/dev/input/event0", ios::binary);
if(! fd.good()) {
cout << "failed to open /dev/input/event0, you are propably not root" << endl;
exit(1);
}
while (1) {
fd.read( reinterpret_cast<char *> (&ev), sizeof(struct input_event) );
if (ev.value == 1) {
i++;
cout << i << " keys pressed." << endl;
}
}
}
|
_________________ I do speak more freely if I get free beer... |
|
Back to top |
|
|
|