i'm sorry, but my english is terrible..
--
i want to several keys input on the same time keyboard based on "HIDKeys"
original keyPressed function is
scan PB 0~6 pin, PC 0~6 pin, PD 0~5 pin
when detect "1", stop the scan and return this key.
and no scan next keys..
so, i first tried keyPressed included Queue for remove repetition.
like this:
Code: Select all
static uchar keyPressed(void)
{
uchar i, mask, x;
uchar key=0;
x = PINB;
mask = 1;
for(i=0;i<6;i++){
if((x & mask) == 0) {
key = i+1;
if(!FzQ_inQue(key)) {
FzQ_Push(key);
return key;
}
}
mask <<= 1;
}
x = PINC;
mask = 1;
for(i=0;i<6;i++){
if((x & mask) == 0) {
key = i+7;
if(!FzQ_inQue(key)) {
FzQ_Push(key);
return key;
}
}
mask <<= 1;
}
x = PIND;
mask = 1 << 3;
for(i=0;i<5;i++){
if((x & mask) == 0) {
key = i+13;
if(!FzQ_inQue(key)) {
FzQ_Push(key);
return key;
}
}
mask <<= 1;
}
FzQ_Push(key);
return key;
}
but, was not solution.
maybe.. i pressed A and B
original was [A][A][A][A][A][A]....
this code is [A][B][A][B][A][B]...
but i want [A,B][A,B][A,B][A,B]...
so, i tried second way.
on main function, for usbSetInterrupt function
like this:
Code: Select all
static uchar reportBuffer2[4]; //global
// on main
buildReport(KEY_A);
reportBuffer2[0] = reportBuffer[0];
reportBuffer2[1] = reportBuffer[1];
buildReport(KEY_C);
reportBuffer2[2] = reportBuffer[0];
reportBuffer2[3] = reportBuffer[1];
usbSetInterrupt(reportBuffer2, sizeof(reportBuffer2));
but, second way was not the more.
second code was not input data.
guys, how can i ?[/code]