| Andres, Victor, Brian, Michael et al -
I have worked most of the way through the task of sending key-press events
in my OLPC Python script to a .csd.
Basically I'm working with the code below, which sends (for my versions 2
and 4) a keycode (keypress) through the "ascii2" or "ascii4" channels to
Csound. So far so good - even though these keycodes are completely different
set of numbers from ASCII codes.
My problem is this: the keycodes are the same for shifted and unshifted
keypresses. My question: Instead of event.hardware_keycode, is there a
property of event that can return the *ASCII character* - something like
"event.hardware_ASCII"?
In some places I need to identify shifted characters.
Otherwise I'm going to have to test keypresses *and keyreleases* for the
SHIFT key, and incorporate a keyrelease channel into my .csd code. I'd
rather not introduce this complication (or do the additional coding).
def onKeyPress(self, widget, event):
if self.w.ver == 2:
self.w.set_channel("ascii2", event.hardware_keycode)
elif self.w.ver == 4:
self.w.set_channel("ascii4", event.hardware_keycode)
def playcsd(self, widget):
if not self.w.on:
self.w.on = True
self.w.play()
self.but.set_label("STOP !")
if self.w.ver == 2 or self.w.ver == 4:
self.connect("key-press-event", self.onKeyPress)
Art Hunkins
|