# Hi! # I started to write an answer to a question on list about using keyboard input in a patch. Then I realized that a patch which I written in Windows does not work well under Linux, to which I have switched weeks ago. # When I press and hold a key, after a short time [keyup] starts to output the number of that key repeatedly (before releasing it). In Windows it only outputs the key no when a key is released. Do you have any idea why there is a difference between two platforms? # I'm using canonical Pd version 0.40-2 under Ubuntu Feisty. -ugur guney-
ugur guney wrote:
# Hi! # I started to write an answer to a question on list about using keyboard input in a patch. Then I realized that a patch which I written in Windows does not work well under Linux, to which I have switched weeks ago. # When I press and hold a key, after a short time [keyup] starts to output the number of that key repeatedly (before releasing it). In Windows it only outputs the key no when a key is released. Do you have any idea why there is a difference between two platforms?
It's just the way X11 works, as far as I understand it. I did a test with GridFlow, and the same thing happens (console log from attached patch):
("y" key pressed and held) print: 10960 keypress 129 106 0 y print: 520 keyrelease 129 106 0 y print: 0 keypress 129 106 0 y print: 20 keyrelease 129 106 0 y print: 0 keypress 129 106 0 y print: 40 keyrelease 129 106 0 y print: 0 keypress 129 106 0 y print: 20 keyrelease 129 106 0 y print: 0 keypress 129 106 0 y print: 60 keyrelease 129 106 0 y print: 0 keypress 129 106 0 y print: 20 keyrelease 129 106 0 y print: 0 keypress 129 106 0 y print: 20 keyrelease 129 106 0 y print: 0 keypress 129 106 0 y print: 40 keyrelease 129 106 0 y print: 0 keypress 129 106 0 y print: 40 keyrelease 129 106 0 y print: 0 keypress 129 106 0 y print: 40 keyrelease 129 106 0 y print: 0 keypress 129 106 0 y print: 40 keyrelease 129 106 0 y print: 0 keypress 129 106 0 y print: 0 keyrelease 129 106 0 y ("y" key really released)
Here the first number is the elapsed time since the previous event (measured in Pd logical time). It would be possible to patch up something that would discard any "keyrelease immediately-followed-by keypress for the same key" pairs that occur with an elapsed time of 0 (hint: it would use [delay 0.1] or so, maybe even [delay 0] would work). The last keyrelease would be delayed a little, but it would either be unnoticeable with [delay 0.1] or at exactly the same logical time with [delay 0]
# I'm using canonical Pd version 0.40-2 under Ubuntu Feisty. -ugur guney-
Pd 0.40-2 under pure:dyne 2.3.57 here.
http://claudiusmaximus.goto10.org
#N canvas 594 349 450 300 10; #X obj 81 104 #out window; #X obj 81 223 print; #X obj 104 160 timer; #X obj 81 131 t a b b; #X obj 81 197 list prepend; #X connect 0 0 3 0; #X connect 2 0 4 1; #X connect 3 0 4 0; #X connect 3 1 2 0; #X connect 3 2 2 1; #X connect 4 0 1 0;
You can use [hid] to get the raw keyboard events, but it's not quite
as easy as [keyup]. Plus it doesn't work on Windows.
.hc
On May 28, 2007, at 11:05 PM, Claude Heiland-Allen wrote:
ugur guney wrote:
# Hi! # I started to write an answer to a question on list about using
keyboard input in a patch. Then I realized that a patch which I written in
Windows does not work well under Linux, to which I have switched weeks ago. # When I press and hold a key, after a short time [keyup] starts
to output the number of that key repeatedly (before releasing it). In
Windows it only outputs the key no when a key is released. Do you have any idea
why there is a difference between two platforms?It's just the way X11 works, as far as I understand it. I did a
test with GridFlow, and the same thing happens (console log from
attached patch):("y" key pressed and held) print: 10960 keypress 129 106 0 y print: 520 keyrelease 129 106 0 y print: 0 keypress 129 106 0 y print: 20 keyrelease 129 106 0 y print: 0 keypress 129 106 0 y print: 40 keyrelease 129 106 0 y print: 0 keypress 129 106 0 y print: 20 keyrelease 129 106 0 y print: 0 keypress 129 106 0 y print: 60 keyrelease 129 106 0 y print: 0 keypress 129 106 0 y print: 20 keyrelease 129 106 0 y print: 0 keypress 129 106 0 y print: 20 keyrelease 129 106 0 y print: 0 keypress 129 106 0 y print: 40 keyrelease 129 106 0 y print: 0 keypress 129 106 0 y print: 40 keyrelease 129 106 0 y print: 0 keypress 129 106 0 y print: 40 keyrelease 129 106 0 y print: 0 keypress 129 106 0 y print: 40 keyrelease 129 106 0 y print: 0 keypress 129 106 0 y print: 0 keyrelease 129 106 0 y ("y" key really released)
Here the first number is the elapsed time since the previous event
(measured in Pd logical time). It would be possible to patch up
something that would discard any "keyrelease immediately-followed- by keypress for the same key" pairs that occur with an elapsed time
of 0 (hint: it would use [delay 0.1] or so, maybe even [delay 0]
would work). The last keyrelease would be delayed a little, but it
would either be unnoticeable with [delay 0.1] or at exactly the
same logical time with [delay 0]# I'm using canonical Pd version 0.40-2 under Ubuntu Feisty. -ugur guney-
Pd 0.40-2 under pure:dyne 2.3.57 here.
Claude
http://claudiusmaximus.goto10.org
#N canvas 594 349 450 300 10; #X obj 81 104 #out window; #X obj 81 223 print; #X obj 104 160 timer; #X obj 81 131 t a b b; #X obj 81 197 list prepend; #X connect 0 0 3 0; #X connect 2 0 4 1; #X connect 3 0 4 0; #X connect 3 1 2 0; #X connect 3 2 2 1; #X connect 4 0 1 0; _______________________________________________ PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/ listinfo/pd-list
Man has survived hitherto because he was too ignorant to know how to
realize his wishes. Now that he can realize them, he must either
change them, or perish. -William Carlos Williams
# Adding a delay worked well. But something is surprising. The [delay] have to be longer than 0.1 to block this oscillating behavior. I'm attaching a patch (delaykey.pd) which shows the implementation. I think X11 gives the "key pressed" message in every 40 msec's or something. So 0.1 delay is not enough to block these messages. # and I'm attaching the abstracion I was using in Windows too. (keybin.pd, keybin-help.pd) -ugur-
On 5/29/07, Claude Heiland-Allen claudiusmaximus@goto10.org wrote:
ugur guney wrote:
# When I press and hold a key, after a short time [keyup] starts to
output
the number of that key repeatedly (before releasing it). In Windows it
only
outputs the key no when a key is released.
It's just the way X11 works, as far as I understand it. I did a test
with GridFlow, and the same thing happens (console log from attached patch):
Here the first number is the elapsed time since the previous event (measured in Pd logical time). It would be possible to patch up something that would discard any "keyrelease immediately-followed-by keypress for the same key" pairs that occur with an elapsed time of 0 (hint: it would use [delay 0.1] or so, maybe even [delay 0] would work). The last keyrelease would be delayed a little, but it would either be unnoticeable with [delay 0.1] or at exactly the same logical time with [delay 0]
If it's coming from the X, can't you switch off autorepeat in the X ? Granted, I cannot find the correct documentaiton as to how to do it at the shell level, but the XkeyboardControl structure contains a flag to set it off or on... So there must be a way... Like xset -r ?
...............
int auto_repeat_mode;/* AutoRepeatModeOff, AutoRepeatModeOn,
AutoRepeatModeDefault */
} XKeyboardControl;
Just a thought...
It does not work on the computer where I am sitting but that may be because I am logged in over the network using SSH on a PuTTy terminal from a Windows machien, so nobody can figure out who's responsible for the key repeats.
-----Original Message----- From: pd-list-bounces@iem.at [mailto:pd-list-bounces@iem.at] On Behalf Of ugur guney Sent: 29 May 2007 12:28 To: Claude Heiland-Allen Cc: pd-list Subject: Re: [PD] Behavoir of [keyup] in Linux
# Adding a delay worked well. But something is surprising. The [delay] have to be longer than 0.1 to block this oscillating behavior. I'm attaching a patch (delaykey.pd) which shows the implementation. I think X11 gives the "key pressed" message in every 40 msec's or something. So 0.1 delay is not enough to block these messages. # and I'm attaching the abstracion I was using in Windows too. (keybin.pd, keybin-help.pd) -ugur-
On 5/29/07, Claude Heiland-Allen claudiusmaximus@goto10.org wrote:
ugur guney wrote:
# When I press and hold a key, after a short time
[keyup] starts to output
the number of that key repeatedly (before releasing
it). In Windows it only
outputs the key no when a key is released.
It's just the way X11 works, as far as I understand it. I did a test with GridFlow, and the same thing happens (console log from attached patch):
Here the first number is the elapsed time since the previous event (measured in Pd logical time). It would be possible to patch up something that would discard any "keyrelease immediately-followed-by keypress for the same key" pairs that occur with an elapsed time of 0 (hint: it would use [delay 0.1] or so, maybe even [delay 0] would work). The last keyrelease would be delayed a little, but it would either be unnoticeable with [delay 0.1] or at exactly the same logical time with [delay 0]
I said:
It does not work on the computer where I am sitting
.. But actually it does work, i.e. X clients on that display no longer receive key repeats after an xset -r is issued on any session whose DISPLAY is the X server that I am looking at here. The PuTTy terminal window is not a X client so it's keyboard events are coming from somewhere else.
It seems to work for PD runnign on the Linux machine while I am logged in, in this way (looking at the behaviour of the right-click 'help' from the 'key' object found in lib/pd/doc/5.reference) and also 'keybin-help.pd' posted to the list. It's a property of the 'display', not the machine or the shell session, however.
I think you could not easily have another program running in which key repeates ARE active; unless it's on another display; also if the program bypasses the X and gets its keystrokes from the kernel directly, probably it would not work as expected.
Hallo, ugur guney hat gesagt: // ugur guney wrote:
# I started to write an answer to a question on list about using keyboard input in a patch. Then I realized that a patch which I written in Windows does not work well under Linux, to which I have switched weeks ago. # When I press and hold a key, after a short time [keyup] starts to output the number of that key repeatedly (before releasing it). In Windows it only outputs the key no when a key is released. Do you have any idea why there is a difference between two platforms?
Switch off autorepeat on Linux with "xset -r" and on again with "xset r".
Frank Barknecht _ ______footils.org_ __goto10.org__