<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Thanks a lot Julien,<br>
<br>
I'm still trying to set up the keyboard events. I found
/dev/input/by-path/, which contains symlinks to /dev/input with
sensible names. I guess this is what you meant. One of them is
called "platform-i8042-serio-0-event-kbd", I assume that is the
keyboard. It links to /dev/input/event5, so I granted access
rights to the device to everyone and wrote the following little
script:<br>
<br>
Hid hid;<br>
HidMsg msg;<br>
if(!hid.openKeyboard(5)) me.exit();<br>
<<< hid.name(), "ready">>>;<br>
while(true)<br>
{<br>
hid => now;<br>
<<< "received event" >>>;<br>
while(hid.recv(msg))<br>
{<br>
<<< msg.ascii, " was used" >>>;<br>
}<br>
}<br>
<br>
The output of it is, surprisingly, "Sleep Button ready", and it
never comes to the point of "received event". Any ideas?<br>
<br>
Best, Manuel<br>
Am 06/12/13 09:57, schrieb Julien Saint-Martin:<br>
</div>
<blockquote
cite="mid:CAF8ijLWp_WaVwHmB2HepoGjkoebuEnH0ENhdziVScqmopkQ4ZA@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>Hi Manuel and <span name="Moisés Gabriel
Cachay Tello" class="">Moisés</span>,<br>
<br>
</div>
Sorry for confusion I checked my code and I
use Hid event not KBHit.<br>
<br>
</div>
I work on linux too (Debian). And I have to
modify a little my linux config to use KeyBoard
in Chuck.<br>
</div>
On linux distrubutions I tried, Chuck didn't
receives Kb event by default. But fortunately
there is a work around.<br>
</div>
I am not on my linux PC now so maybe the following
is not exactly right:<br>
</div>
Go to directory /dev/input and find which event
corresponds to your keyboard (there is a directory
with links name of hid but I didn't remember the name)
. For me it is usually event0. <br>
</div>
Then modify access rights to this event to give read
access to everyone.<br>
</div>
After that your chuck may catch keyboard events.<br>
<br>
</div>
Once ok, Chuck works great on linux and you can use
fantastic Jack server to connect it directly to other sound
tools. So I encourage you to don't give up with linux :-)<br>
<br>
</div>
have fun,<br>
</div>
Julien<br>
<div>
<div>
<div>
<div>
<div>
<div>
<div><br>
<div>
<div><br>
<br>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">2013/12/5 Moisés Gabriel Cachay Tello <span
dir="ltr"><<a moz-do-not-send="true"
href="mailto:xpktro@gmail.com" target="_blank">xpktro@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">I got some problems with the linux builds
also, and my final solution was using wine and the windows
version of miniAudicle (the windows ChucK standalone also
would work) and everythings just goes fine, In fact I
wrote and tested the above code with it :)<br>
</div>
<div class="HOEnZb">
<div class="h5">
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">2013/12/5 Manuel Bärenz <span
dir="ltr"><<a moz-do-not-send="true"
href="mailto:manuel@enigmage.de" target="_blank">manuel@enigmage.de</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<div>Hey Moisés,<br>
<br>
Thanks again for this more sophisticated
example. I'm having problems with HIDs, I
constantly get this error:<br>
<p
style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">HidIn:
couldn't open keyboard 0...<br>
I get the error for all values from 0 to 5.
I'm using Gentoo Linux. For tonight's
presentation, I'm going to stick with KBHit
probably.<br>
</p>
<p
style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><br>
Best, Manuel<br>
</p>
<br>
<br>
Am 05/12/13 17:43, schrieb Moisés Gabriel
Cachay Tello:<br>
</div>
<div>
<div>
<blockquote type="cite">
<div dir="ltr">Hi, I'm a coursera's ChucK
course student, in the lectures, Ge used
HIDs to handle keyboard input, so this
snippet should help (I'm commenting the
code for clarity).<br>
<br>
// HID stands for
human-interface-device, also this is an
event,<br>
// see below for more info<br>
Hid hid;<br>
<br>
// This is a message, this will hold the
event's (keypress) information.<br>
HidMsg msg;<br>
<br>
// We should define a device number
since we would have multiple keyboards <br>
// attached to our computer, 0 would do
on most cases but you can try 1, or 2 <br>
// if that doesn't work.<br>
0 => int device_number;<br>
<br>
// We check if the device attach with
ChucK was successful, otherwise the
program <br>
// would end inmediately<br>
if(!hid.openKeyboard(device_number))
me.exit();<br>
<br>
<<<"Keyboard:", <a
moz-do-not-send="true"
href="http://hid.name" target="_blank">hid.name</a>(),
" ready!">>>;<br>
<br>
// We setup a simple sound chain for
demonstration pruposes only<br>
BeeThree organ => JCRev rev =>
dac;<br>
.05 => rev.mix;<br>
<br>
// And repeat forever, see how the
keyboard input is something that would
happen <br>
// *forever*, a keypress can occur
anytime so we need to stay alert until a
new <br>
// event comes in<br>
while(true) {<br>
// Events are things that happens
sometime, in ChucK this mains basically
<br>
// hold ourselves until the event
appears (thats why we wain for the event
<br>
// ChucKing it to now)<br>
hid => now;<br>
<br>
// When our wait finishes: check all
the messages that came from the keyboard<br>
// using the recv function, and
passing msg as the holder of the
information<br>
while(hid.recv(msg)) {<br>
<br>
// we check if the message is a
buttondown message, in that case:<br>
if(msg.isButtonDown()) {<br>
// We show the ascii value
of the key pressed<br>
<<< "Button down:",
msg.ascii >>>;<br>
<br>
// and make our generator
sound, see how we check if the<br>
// frequency too much high
we simply discard this message<br>
msg.ascii => Std.mtof
=> float freq;<br>
if(freq > 20000)
continue;<br>
<br>
freq => organ.freq;<br>
1 => organ.noteOn;<br>
<br>
// this will make sure the
sound will keep for a minimum amount of
<br>
// time, otherwise,
concurrent events may stop before even
commencing<br>
80::ms => now;<br>
} else {<br>
// If we're not in a
buttondown event, just assume it's a key
has been<br>
// left out and shut down
the sound.<br>
<<< "Button up:",
msg.ascii >>>;<br>
1 => organ.noteOff;<br>
}<br>
}<br>
<br>
}<br>
<br>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">2013/12/5
Manuel Bärenz <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:manuel@enigmage.de"
target="_blank">manuel@enigmage.de</a>></span><br>
<blockquote class="gmail_quote"
style="margin:0 0 0
.8ex;border-left:1px #ccc
solid;padding-left:1ex">
<div bgcolor="#FFFFFF"
text="#000000">
<div>Hi Julien,<br>
<br>
No, this is not the case. KBHits
are only key down events. I
tried to include several kb
=> now, but it didn't help.<br>
See also this example here:<br>
<a moz-do-not-send="true"
href="http://chuck.cs.princeton.edu/doc/examples/event/kb2.ck"
target="_blank">http://chuck.cs.princeton.edu/doc/examples/event/kb2.ck</a><br>
Apparently, the solution is
emptying the event queue by
calling kb.getchar() until
kb.more() returns false:
<div><br>
<br>
KBHit kb;<br>
<br>
me.sourceDir() + "/bum.wav"
=> string filename;<br>
<br>
adc => WvOut b =>
blackhole;<br>
filename => b.wavFilename;<br>
kb => now;<br>
</div>
while(kb.more()) kb.getchar();
<div><br>
b.closeFile();<br>
<br>
SndBuf buf => dac;<br>
filename => buf.read;<br>
kb => now;<br>
<br>
</div>
The important line is
"while(kb.more())
kb.getchar();", apparently. So I
guess kb => now; doesn't wait
at all if there are still
unprocessed keys in the queue.<br>
<br>
Best, Manuel<br>
<br>
Am 05/12/13 12:18, schrieb
Julien Saint-Martin:<br>
</div>
<div>
<div>
<blockquote type="cite">
<div dir="ltr">
<div>
<div>
<div>
<div>Hi Manuel,<br>
<br>
</div>
Maybe your problem
is as follow:<br>
For each key press
there is two kb
events: key down and
key up.<br>
<br>
</div>
A simple solution
maybe to write "kb
=> now;" twice.<br>
<br>
</div>
Cheers,<br>
</div>
Julien<br>
<div>
<div><br>
<br>
<div><br>
</div>
</div>
</div>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">2013/12/5
Manuel Bärenz <span
dir="ltr"><<a
moz-do-not-send="true"
href="mailto:manuel@enigmage.de" target="_blank">manuel@enigmage.de</a>></span><br>
<blockquote
class="gmail_quote"
style="margin:0 0 0
.8ex;border-left:1px
#ccc
solid;padding-left:1ex">Hello
again,<br>
<br>
I also wanted to
demonstrate a simple
sequencer prototype
that lets me<br>
record a file and then
plays it back to me.
I've come this far:<br>
<br>
KBHit kb;<br>
<br>
me.sourceDir() +
"/bum.wav" =>
string filename;<br>
<br>
adc => WvOut b
=> blackhole;<br>
filename =>
b.wavFilename;<br>
kb => now;<br>
b.closeFile();<br>
<br>
SndBuf buf => dac;<br>
filename =>
buf.read;<br>
kb => now;<br>
<br>
But strangely, the
program doesn't wait
for the second kb
event, but<br>
exits directly after
the first key that I
hit. Any ideas what
I'm doing<br>
wrong?<br>
<br>
Best, Manuel<br>
_______________________________________________<br>
chuck-users mailing
list<br>
<a
moz-do-not-send="true"
href="mailto:chuck-users@lists.cs.princeton.edu" target="_blank">chuck-users@lists.cs.princeton.edu</a><br>
<a
moz-do-not-send="true"
href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users"
target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
</blockquote>
</div>
<br>
</div>
<br>
<fieldset></fieldset>
<br>
<pre>_______________________________________________
chuck-users mailing list
<a moz-do-not-send="true" href="mailto:chuck-users@lists.cs.princeton.edu" target="_blank">chuck-users@lists.cs.princeton.edu</a>
<a moz-do-not-send="true" href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a>
</pre>
</blockquote>
</div>
</div>
</div>
<br>
_______________________________________________<br>
chuck-users mailing list<br>
<a moz-do-not-send="true"
href="mailto:chuck-users@lists.cs.princeton.edu"
target="_blank">chuck-users@lists.cs.princeton.edu</a><br>
<a moz-do-not-send="true"
href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users"
target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
<br>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
-Moisés </div>
<br>
<fieldset></fieldset>
<br>
<pre>_______________________________________________
chuck-users mailing list
<a moz-do-not-send="true" href="mailto:chuck-users@lists.cs.princeton.edu" target="_blank">chuck-users@lists.cs.princeton.edu</a>
<a moz-do-not-send="true" href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a>
</pre>
</blockquote>
</div>
</div>
</div>
<br>
_______________________________________________<br>
chuck-users mailing list<br>
<a moz-do-not-send="true"
href="mailto:chuck-users@lists.cs.princeton.edu"
target="_blank">chuck-users@lists.cs.princeton.edu</a><br>
<a moz-do-not-send="true"
href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users"
target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
<br>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
-Moisés
</div>
</div>
</div>
<br>
_______________________________________________<br>
chuck-users mailing list<br>
<a moz-do-not-send="true"
href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.princeton.edu</a><br>
<a moz-do-not-send="true"
href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users"
target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
<br>
</blockquote>
</div>
<br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
chuck-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.princeton.edu</a>
<a class="moz-txt-link-freetext" href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a>
</pre>
</blockquote>
</body>
</html>