Page 1 of 1

HIDKeys.. several keys input on the same time

Posted: Wed Sep 05, 2007 7:18 pm
by freezn
hello.
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. :evil:


guys, how can i ?[/code]

Posted: Sat Sep 08, 2007 8:41 pm
by christian
For real keyboard features (such as multiple keys pressed), please look at the C64 keyboard in the projects section. The code published there is capable to do that (among other things).