QueryKeys keys issues

This forum is for general developer support questions.
Post Reply
kas1e
Beta Tester
Beta Tester
Posts: 542
Joined: Sat Jun 18, 2011 7:56 am
Contact:

QueryKeys keys issues

Post by kas1e »

User "rjd324" for some reason can't post on the forum (he have zero permissions, while logged in), so I just forward his findings he wants to write there.

He think that he found 2 bugs. There is an example:

Code: Select all

/* GetKey:    gcc -D__USE_INLINE__ -DGK -o main main.c -lauto
   QueryKeys: gcc -D__USE_INLINE__ -DQK -o main main.c -lauto */

#if defined __amigaos4__
#define INTUITION_PRE_V36_NAMES
#include <intuition/iobsolete.h>
#endif

#include <proto/graphics.h>
#include <proto/lowlevel.h>
#include <proto/intuition.h>
#include <proto/exec.h>

struct NewWindow nw={
  100,100,200,100,NULL,NULL,
  CLOSEWINDOW,
  ACTIVATE|WINDOWCLOSE|SIMPLE_REFRESH,
  NULL, NULL,
  "rjd324_W_A_S_D", 
  NULL, NULL, 0, 0, 0, 0, WBENCHSCREEN
};
struct Window *window;

UBYTE W[2]={ 'W', 0 };
UBYTE A[2]={ 'A', 0 };
UBYTE S[2]={ 'S', 0 };
UBYTE D[2]={ 'D', 0 };

struct IntuiText w={1, NULL, JAM1, 0, 0, NULL, W, NULL};
struct IntuiText a={1, NULL, JAM1, 0, 0, NULL, A, NULL};
struct IntuiText s={1, NULL, JAM1, 0, 0, NULL, S, NULL};
struct IntuiText d={1, NULL, JAM1, 0, 0, NULL, D, NULL};

struct KeyQuery q[4] = { { 0x0011, 0 }, { 0x0020, 0 }, { 0x0021, 0 }, { 0x0022, 0 } };

int main(void) {
  window=(struct Window*)OpenWindow(&nw);
  if(!window)
    {
      goto ENDER;
    }

  {
    SetAPen(window->RPort,0);
    while(1) {
#if defined (QK)
      QueryKeys(q, 4u);
      if(q[0].kq_Pressed){
        PrintIText(window->RPort,&w,100,40);
      } else {
        RectFill(window->RPort,95,35,115,55);
      }
      if(q[1].kq_Pressed){
        PrintIText(window->RPort,&a,25,80);
      } else {
        RectFill(window->RPort,20,75,40,95);
      }
      if(q[2].kq_Pressed){
        PrintIText(window->RPort,&s,100,80);
      } else {
        RectFill(window->RPort,95,75,115,95);
      }
      if(q[3].kq_Pressed){
        PrintIText(window->RPort,&d,175,80);
      } else {
        RectFill(window->RPort,170,75,190,95);
      }
#elif defined (GK)
          ULONG k = GetKey();
      if(k==0x0011){
        PrintIText(window->RPort,&w,100,40);
      } else {
        RectFill(window->RPort,95,35,115,55);
      }
      if(k==0x0020){
        PrintIText(window->RPort,&a,25,80);
      } else {
        RectFill(window->RPort,20,75,40,95);
      }
      if(k==0x0021){
        PrintIText(window->RPort,&s,100,80);
      } else {
        RectFill(window->RPort,95,75,115,95);
      }
      if(k==0x0022){
        PrintIText(window->RPort,&d,175,80);
      } else {
        RectFill(window->RPort,170,75,190,95);
      }

#else
#error "Please define QK or GW"
#endif
      struct IntuiMessage *msg= GetMsg(window->UserPort);
      if(msg) {
            if( msg->Class==CLOSEWINDOW){ ReplyMsg(msg);
                break;
              }
        ReplyMsg(msg);
      }
        }
 ENDER:
  if(window) CloseWindow(window);
  return 0;
  }
}
Here is a quick hacked-as-hell program where Querykeys works on the classic machine, but nothing on my X1000. In all cases, GetKey works.

It probably shows 2 bugs:

Shows two bugs.

1 - As the SDK says, the interrupt routine is not being called when reading the SDK information it should do.
2 - QueryKeys does not seem to work, yet it does on version 3.

Can anyone comment/confirm so we can make a BZs if it is reasons for?

Thanks!
Post Reply