Csound Csound-dev Csound-tekno Search About

[Csnd-dev] can sensekey return something for arrow keys?

Date2019-01-28 21:14
Fromjoachim heintz
Subject[Csnd-dev] can sensekey return something for arrow keys?
currently the sensekey opcode does not return anything for the arrow 
keys (up, down, left, right).  i miss this a lot when i use the computer 
keyboard for live performances.

in PD these values are caught by the object "keyname".  i had a look in 
the pd sources; if i get it right, it is defined in line 342pp of 
https://github.com/pure-data/pure-data/blob/master/src/x_gui.c

can there be a similar way to implement it in csound?

thanks -

Date2019-01-29 16:03
Fromjohn
SubjectRe: [Csnd-dev] can sensekey return something for arrow keys?
Works for me on openSuSE.  What are you seeing?  How are you running 
csound?
  ==john

GFrom manual example

^[[D i1    27.00000
  i1    91.00000
  i1    68.00000
  i1    -1.00000
^[[C i1    27.00000
  i1    91.00000
  i1    67.00000
  i1    -1.00000
^[[A i1    27.00000
  i1    91.00000
  i1    65.00000
  i1    -1.00000
^[[6~ i1    27.00000
  i1    91.00000
  i1    54.00000
  i1   126.00000
  i1    -1.00000
^[[5~ i1    27.00000
  i1    91.00000
  i1    53.00000
  i1   126.00000
  i1    -1.00000
^[[B i1    27.00000
  i1    91.00000
  i1    66.00000
  i1    -1.00000
^[[C i1    27.00000
  i1    91.00000
  i1    67.00000
  i1    -1.00000


On Mon, 28 Jan 2019, joachim heintz wrote:

> currently the sensekey opcode does not return anything for the arrow keys 
> (up, down, left, right).  i miss this a lot when i use the computer keyboard 
> for live performances.
>
> in PD these values are caught by the object "keyname".  i had a look in the 
> pd sources; if i get it right, it is defined in line 342pp of 
> https://github.com/pure-data/pure-data/blob/master/src/x_gui.c
>
> can there be a similar way to implement it in csound?
>
> thanks -
> 	joachim

Date2019-01-29 17:41
Fromjoachim heintz
SubjectRe: [Csnd-dev] can sensekey return something for arrow keys?
ah you are right ... it works in the terminal.
so this is a csoundqt issue.
i didn't expect this to be the reason.  will move it to the csoundqt list.

	joachim



On 29/01/19 17:03, john wrote:
> Works for me on openSuSE.  What are you seeing?  How are you running
> csound?
>  ==john
>
> GFrom manual example
>
> ^[[D i1    27.00000
>  i1    91.00000
>  i1    68.00000
>  i1    -1.00000
> ^[[C i1    27.00000
>  i1    91.00000
>  i1    67.00000
>  i1    -1.00000
> ^[[A i1    27.00000
>  i1    91.00000
>  i1    65.00000
>  i1    -1.00000
> ^[[6~ i1    27.00000
>  i1    91.00000
>  i1    54.00000
>  i1   126.00000
>  i1    -1.00000
> ^[[5~ i1    27.00000
>  i1    91.00000
>  i1    53.00000
>  i1   126.00000
>  i1    -1.00000
> ^[[B i1    27.00000
>  i1    91.00000
>  i1    66.00000
>  i1    -1.00000
> ^[[C i1    27.00000
>  i1    91.00000
>  i1    67.00000
>  i1    -1.00000
>
>
> On Mon, 28 Jan 2019, joachim heintz wrote:
>
>> currently the sensekey opcode does not return anything for the arrow
>> keys (up, down, left, right).  i miss this a lot when i use the
>> computer keyboard for live performances.
>>
>> in PD these values are caught by the object "keyname".  i had a look
>> in the pd sources; if i get it right, it is defined in line 342pp of
>> https://github.com/pure-data/pure-data/blob/master/src/x_gui.c
>>
>> can there be a similar way to implement it in csound?
>>
>> thanks -
>>     joachim
>>

Date2019-01-29 21:49
FromTarmo Johannes
SubjectRe: [Csnd-dev] can sensekey return something for arrow keys?
Hi, John,

can you guess perhaps looking at this code (keyboardEventCallback in CsoundQt) 
-  why this kind of event like arrow keys are not caught (not my code and to 
be honest, I don't understand it completely):

---
int CsoundEngine::keyEventCallback(void *userData,
                                   void *p,
                                   unsigned int type)
{
    if (type != CSOUND_CALLBACK_KBD_EVENT && type != CSOUND_CALLBACK_KBD_TEXT) 
{
        return 1;
    }
    CsoundUserData *ud = (CsoundUserData *) userData;
    //  WidgetLayout *wl = (WidgetLayout *) ud->wl;
    int *value = (int *) p;
    int key = ud->csEngine->popKeyPressEvent();
    if (key >= 0) {
        *value = key;
	//	qDebug()  << "Pressed: " << key;
    }
    else if (type & CSOUND_CALLBACK_KBD_EVENT) {
        key = ud->csEngine->popKeyReleaseEvent();
        if (key >= 0) {
            *value = key | 0x10000;
	//		qDebug()  << "Released: " << key;
        }
    }
    return 0;
}

---
Thanks!
tarmo


On Tuesday, January 29, 2019 6:03:00 PM EET you wrote:
> Works for me on openSuSE.  What are you seeing?  How are you running
> csound?
>   ==john
> 
> GFrom manual example
> 
> ^[[D i1    27.00000
>   i1    91.00000
>   i1    68.00000
>   i1    -1.00000
> ^[[C i1    27.00000
>   i1    91.00000
>   i1    67.00000
>   i1    -1.00000
> ^[[A i1    27.00000
>   i1    91.00000
>   i1    65.00000
>   i1    -1.00000
> ^[[6~ i1    27.00000
>   i1    91.00000
>   i1    54.00000
>   i1   126.00000
>   i1    -1.00000
> ^[[5~ i1    27.00000
>   i1    91.00000
>   i1    53.00000
>   i1   126.00000
>   i1    -1.00000
> ^[[B i1    27.00000
>   i1    91.00000
>   i1    66.00000
>   i1    -1.00000
> ^[[C i1    27.00000
>   i1    91.00000
>   i1    67.00000
>   i1    -1.00000
> 
> On Mon, 28 Jan 2019, joachim heintz wrote:
> > currently the sensekey opcode does not return anything for the arrow keys
> > (up, down, left, right).  i miss this a lot when i use the computer
> > keyboard for live performances.
> > 
> > in PD these values are caught by the object "keyname".  i had a look in
> > the
> > pd sources; if i get it right, it is defined in line 342pp of
> > https://github.com/pure-data/pure-data/blob/master/src/x_gui.c
> > 
> > can there be a similar way to implement it in csound?
> > 
> > thanks -
> > 

Date2019-01-30 17:57
Fromjohn
SubjectRe: [Csnd-dev] can sensekey return something for arrow keys?
Hummm  Seems to be in C++, a languge in which I am not very familiar. 
First thought would be to uncomment the tracing statements to see what key 
is being seen.  Then I would need to know that the functions 
ud->csEngine->popKeyPressEvent() and ud->csEngine->popKeyReleaseEvent() 
were.


On Tue, 29 Jan 2019, Tarmo Johannes wrote:

> Hi, John,
>
> can you guess perhaps looking at this code (keyboardEventCallback in CsoundQt)
> -  why this kind of event like arrow keys are not caught (not my code and to
> be honest, I don't understand it completely):
>
> ---
> int CsoundEngine::keyEventCallback(void *userData,
>                                   void *p,
>                                   unsigned int type)
> {
>    if (type != CSOUND_CALLBACK_KBD_EVENT && type != CSOUND_CALLBACK_KBD_TEXT)
> {
>        return 1;
>    }
>    CsoundUserData *ud = (CsoundUserData *) userData;
>    //  WidgetLayout *wl = (WidgetLayout *) ud->wl;
>    int *value = (int *) p;
>    int key = ud->csEngine->popKeyPressEvent();
>    if (key >= 0) {
>        *value = key;
> 	//	qDebug()  << "Pressed: " << key;
>    }
>    else if (type & CSOUND_CALLBACK_KBD_EVENT) {
>        key = ud->csEngine->popKeyReleaseEvent();
>        if (key >= 0) {
>            *value = key | 0x10000;
> 	//		qDebug()  << "Released: " << key;
>        }
>    }
>    return 0;
> }
>
> ---
> Thanks!
> tarmo
>
>
> On Tuesday, January 29, 2019 6:03:00 PM EET you wrote:
>> Works for me on openSuSE.  What are you seeing?  How are you running
>> csound?
>>   ==john
>>
>> GFrom manual example
>>
>> ^[[D i1    27.00000
>>   i1    91.00000
>>   i1    68.00000
>>   i1    -1.00000
>> ^[[C i1    27.00000
>>   i1    91.00000
>>   i1    67.00000
>>   i1    -1.00000
>> ^[[A i1    27.00000
>>   i1    91.00000
>>   i1    65.00000
>>   i1    -1.00000
>> ^[[6~ i1    27.00000
>>   i1    91.00000
>>   i1    54.00000
>>   i1   126.00000
>>   i1    -1.00000
>> ^[[5~ i1    27.00000
>>   i1    91.00000
>>   i1    53.00000
>>   i1   126.00000
>>   i1    -1.00000
>> ^[[B i1    27.00000
>>   i1    91.00000
>>   i1    66.00000
>>   i1    -1.00000
>> ^[[C i1    27.00000
>>   i1    91.00000
>>   i1    67.00000
>>   i1    -1.00000
>>
>> On Mon, 28 Jan 2019, joachim heintz wrote:
>>> currently the sensekey opcode does not return anything for the arrow keys
>>> (up, down, left, right).  i miss this a lot when i use the computer
>>> keyboard for live performances.
>>>
>>> in PD these values are caught by the object "keyname".  i had a look in
>>> the
>>> pd sources; if i get it right, it is defined in line 342pp of
>>> https://github.com/pure-data/pure-data/blob/master/src/x_gui.c
>>>
>>> can there be a similar way to implement it in csound?
>>>
>>> thanks -
>>>
>>> 	joachim

Date2019-02-13 11:49
Fromjoachim heintz
SubjectRe: [Csnd-dev] can sensekey return something for arrow keys?
i am back with this, with two issues:

1. when i add the second output to sensekey, it does not any more return 
for the arrow keys the numbers 68, 67, etc, but only 27 followed by 91. 
can you try to change the example to
instr 1
   k1, k2 sensekey
   printk2 k1
endin

2. is there any way to return *one* number instead of a sequence? 
otherwise i cannot see how to use the key information in code like
  if kDown == 1 then
   if kKey == 32 then
     ...
   elseif kKey == 49 then
    ...
   endif
endif

thanks -
	joachim


On 29/01/19 17:03, john wrote:
> Works for me on openSuSE.  What are you seeing?  How are you running
> csound?
>  ==john
>
> GFrom manual example
>
> ^[[D i1    27.00000
>  i1    91.00000
>  i1    68.00000
>  i1    -1.00000
> ^[[C i1    27.00000
>  i1    91.00000
>  i1    67.00000
>  i1    -1.00000
> ^[[A i1    27.00000
>  i1    91.00000
>  i1    65.00000
>  i1    -1.00000
> ^[[6~ i1    27.00000
>  i1    91.00000
>  i1    54.00000
>  i1   126.00000
>  i1    -1.00000
> ^[[5~ i1    27.00000
>  i1    91.00000
>  i1    53.00000
>  i1   126.00000
>  i1    -1.00000
> ^[[B i1    27.00000
>  i1    91.00000
>  i1    66.00000
>  i1    -1.00000
> ^[[C i1    27.00000
>  i1    91.00000
>  i1    67.00000
>  i1    -1.00000
>
>
> On Mon, 28 Jan 2019, joachim heintz wrote:
>
>> currently the sensekey opcode does not return anything for the arrow
>> keys (up, down, left, right).  i miss this a lot when i use the
>> computer keyboard for live performances.
>>
>> in PD these values are caught by the object "keyname".  i had a look
>> in the pd sources; if i get it right, it is defined in line 342pp of
>> https://github.com/pure-data/pure-data/blob/master/src/x_gui.c
>>
>> can there be a similar way to implement it in csound?
>>
>> thanks -
>>     joachim
>>