Guest User

Untitled

a guest
Nov 5th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 11.21 KB | None | 0 0
  1. diff --git a/arch/m68k-amiga/hidd/keyboard/kbd.h b/arch/m68k-amiga/hidd/keyboard/kbd.h
  2. index 884cc6926e..352dec23d3 100644
  3. --- a/arch/m68k-amiga/hidd/keyboard/kbd.h
  4. +++ b/arch/m68k-amiga/hidd/keyboard/kbd.h
  5. @@ -2,7 +2,7 @@
  6.  #define HIDD_KBD_H
  7.  
  8.  /*
  9. -    Copyright © 1995-2018, The AROS Development Team. All rights reserved.
  10. +    Copyright © 1995-2019, The AROS Development Team. All rights reserved.
  11.      $Id$
  12.  
  13.      Desc: Include for the kbd HIDD.
  14. @@ -83,7 +83,7 @@ struct kbdbase
  15.  
  16.  struct kbd_data
  17.  {
  18. -    VOID    (*kbd_callback)(APTR, UWORD);
  19. +    VOID    (*kbd_callback)(APTR, ULONG);
  20.      APTR    callbackdata;
  21.      struct Library *TimerBase;
  22.      UBYTE resetstate;
  23. diff --git a/arch/m68k-amiga/hidd/keyboard/kbdclass.c b/arch/m68k-amiga/hidd/keyboard/kbdclass.c
  24. index dfdfd7e149..62c60120ea 100644
  25. --- a/arch/m68k-amiga/hidd/keyboard/kbdclass.c
  26. +++ b/arch/m68k-amiga/hidd/keyboard/kbdclass.c
  27. @@ -63,17 +63,17 @@ static AROS_INTH1(keyboard_interrupt, struct kbd_data *, kbddata)
  28.      if (keycode == 0x78) { // reset warning
  29.          kbddata->resetstate++;
  30.          if (kbddata->resetstate == 2) {
  31. -            kbddata->kbd_callback(kbddata->callbackdata, keycode);
  32. +            kbddata->kbd_callback(kbddata->callbackdata, (KBD_NOCAPSUP << 16) | keycode);
  33.              // second reset warning, no handshake = starts 10s delay before forced reset
  34.              return 0;
  35.          }
  36.          // first reset warning, handle it normally
  37.      } else {
  38. -        kbddata->kbd_callback(kbddata->callbackdata, keycode);
  39. +        kbddata->kbd_callback(kbddata->callbackdata, (KBD_NOCAPSUP << 16) |keycode);
  40.      }
  41.      /* "release" UAE mouse wheel up/down key codes */
  42.      if (keycode == 0x7a || keycode == 0x7b)
  43. -   kbddata->kbd_callback(kbddata->callbackdata, 0x80 | keycode);
  44. +   kbddata->kbd_callback(kbddata->callbackdata, (KBD_NOCAPSUP << 16) | 0x80 | keycode);
  45.  
  46.      // busy wait until handshake pulse has been long enough
  47.      for (;;) {
  48. diff --git a/rom/devs/keyboard/keyboard.c b/rom/devs/keyboard/keyboard.c
  49. index 7fecfa86cb..bb0172b070 100644
  50. --- a/rom/devs/keyboard/keyboard.c
  51. +++ b/rom/devs/keyboard/keyboard.c
  52. @@ -1,5 +1,5 @@
  53.  /*
  54. -    Copyright © 1995-2014, The AROS Development Team. All rights reserved.
  55. +    Copyright © 1995-2019, The AROS Development Team. All rights reserved.
  56.      $Id$
  57.  
  58.      Desc: Keyboard device
  59. @@ -106,7 +106,7 @@ static const UWORD SupportedCommands[] =
  60.  
  61.  /****************************************************************************************/
  62.  
  63. -VOID keyCallback(struct KeyboardBase *KBBase, UWORD keyCode);
  64. +VOID keyCallback(struct KeyboardBase *KBBase, ULONG keyData);
  65.  AROS_INTP(kbdSendQueuedEvents);
  66.  static BOOL writeEvents(struct IORequest *ioreq, struct KeyboardBase *KBBase);
  67.      
  68. @@ -144,31 +144,34 @@ static int GM_UNIQUENAME(Open)
  69.     return FALSE;
  70.      }
  71.      
  72. -    if(KBBase->kb_keyBuffer == NULL)
  73. +    if(KBBase->kb_keyEventBuffer == NULL)
  74.      {
  75. -   KBBase->kb_keyBuffer = AllocMem(sizeof(UWORD)*KB_BUFFERSIZE, MEMF_ANY);
  76. +   KBBase->kb_keyEventBuffer = AllocMem(sizeof(KbdIrqData_t) * KB_BUFFERSIZE, MEMF_ANY);
  77.      }
  78.  
  79.      /* No memory for key buffer? */
  80. -    if(KBBase->kb_keyBuffer == NULL)
  81. +    if(KBBase->kb_keyEventBuffer == NULL)
  82.      {
  83. +        D(bug("keyboard.device: failed to allocate keyboard event buffer storage\n"));
  84.     ioreq->io_Error = IOERR_OPENFAIL;
  85.     return FALSE;
  86.      }
  87.  
  88.      if((ioreq->io_Unit = AllocMem(sizeof(KBUnit), MEMF_CLEAR)) == NULL)
  89.      {
  90. +        D(bug("keyboard.device: failed to allocate unit data\n"));
  91.     ioreq->io_Error = IOERR_OPENFAIL;
  92.     return FALSE;
  93.      }
  94.  
  95. -/* nlorentz: Some extra stuff that must be inited */
  96. +/* nlorentz: Some extra stuff that must be initialised */
  97.      if (NULL == KBBase->kb_Matrix)
  98.      {
  99.          KBBase->kb_Matrix = AllocMem(KB_MATRIXSIZE, MEMF_ANY|MEMF_CLEAR);
  100.  
  101.     if (NULL == KBBase->kb_Matrix)
  102.     {
  103. +       D(bug("keyboard.device: failed to allocated keyboard matrix buffer\n"));
  104.         ioreq->io_Error = IOERR_OPENFAIL;
  105.         return FALSE;
  106.     }
  107. @@ -180,7 +183,7 @@ static int GM_UNIQUENAME(Open)
  108.     if (!HiddKbdAB)
  109.     {
  110.         ioreq->io_Error = IOERR_OPENFAIL;
  111. -       D(bug("keyboard.device: Could not get attrbase\n"));
  112. +       D(bug("keyboard.device: failed to obtain attrbase for '%s'\n", IID_Hidd_Kbd));
  113.         return FALSE;
  114.     }
  115.      }
  116. @@ -394,10 +397,11 @@ AROS_LH1(void, beginio,
  117.  
  118.  static BOOL writeEvents(struct IORequest *ioreq, struct KeyboardBase *KBBase)
  119.  {
  120. -    int    nEvents;             /* Number of struct InputEvent:s that there is
  121. -                  room for in memory pointed to by io_Data */
  122. -    UWORD  code;                /* Value of current keycode */
  123. -    UWORD  trueCode;            /* Code without possible keypress addition */
  124. +    int    nEvents;             /* # of InputEvent structures there is room
  125. +                  for in the memory pointed to by io_Data */
  126. +    UWORD  keFlags;             /* flags set by the event source */
  127. +    UWORD  code;                /* current keycode value of the event */
  128. +    UWORD  trueCode;            /* keycode without possible keypress addition */
  129.      int    i;          /* Loop variable */
  130.      struct InputEvent *event;   /* Temporary variable */
  131.      BOOL   moreevents = TRUE;
  132. @@ -426,12 +430,14 @@ static BOOL writeEvents(struct IORequest *ioreq, struct KeyboardBase *KBBase)
  133.      
  134.      for(i = 0; i < nEvents; i++)
  135.      {
  136. -   /* Update eventpointer -- this must be done here as I must set
  137. -      ie_NextEvent to NULL if there are no more keys in the buffer. */
  138. +   /* Update eventpointer -- this must be done here as ie_NextEvent
  139. +            must be set to NULL if there are no more keys in the buffer. */
  140.     if(i != 0)
  141.         event = event->ie_NextEvent;
  142.  
  143. -   code = KBBase->kb_keyBuffer[kbUn->kbu_readPos++];
  144. +        ULONG eventData = KBBase->kb_keyEventBuffer[kbUn->kbu_readPos++];
  145. +        keFlags = (eventData >> 16) & 0xFFFF;
  146. +        code = eventData & 0xFFFF;
  147.    
  148.     if(kbUn->kbu_readPos == KB_BUFFERSIZE)
  149.         kbUn->kbu_readPos = 0;
  150. @@ -444,10 +450,7 @@ static BOOL writeEvents(struct IORequest *ioreq, struct KeyboardBase *KBBase)
  151.         /* Key released ? ... */
  152.         if(code & KEYUPMASK)
  153.         {
  154. -           #if 1
  155. -               /* stegerg: on PC keyboards caps lock also generates up events */
  156. -               if (trueCode != AKC_CAPS_LOCK)
  157. -           #endif
  158. +               if ((keFlags & KBD_NOCAPSUP) || (trueCode != AKC_CAPS_LOCK))
  159.         kbUn->kbu_Qualifiers &= ~(1 << (trueCode - AKC_QUALIFIERS_FIRST));
  160.         }
  161.         else  /* ... or pressed? */
  162. @@ -599,14 +602,16 @@ BOOL HIDDM_initKeyboard(struct KeyboardHIDD *kh)
  163.  
  164.  /****************************************************************************************/
  165.  
  166. -VOID keyCallback(struct KeyboardBase *KBBase, UWORD keyCode)
  167. +VOID keyCallback(struct KeyboardBase *KBBase, ULONG keyData)
  168.  {
  169. +    UWORD keyCode = (keyData & 0xFFFF);
  170. +
  171.      D(bug("keyCallBack(KBBase=%p, keyCode=%d)\n"
  172.             , KBBase, keyCode));
  173.        
  174.      Disable();
  175. -    
  176. -    KBBase->kb_keyBuffer[(KBBase->kb_writePos)++] = keyCode;
  177. +
  178. +    KBBase->kb_keyEventBuffer[(KBBase->kb_writePos)++] = keyData;
  179.  
  180.      D(bug("Wrote to buffer\n"));
  181.      
  182. @@ -628,12 +633,7 @@ VOID keyCallback(struct KeyboardBase *KBBase, UWORD keyCode)
  183.      
  184.      if(!IsListEmpty(&KBBase->kb_PendingQueue))
  185.      {    
  186. -#if 0
  187. -   D(bug("doing software irq\n"));
  188. -   Cause(&KBBase->kb_Interrupt);
  189. -#else
  190.      AROS_INTC1(kbdSendQueuedEvents, KBBase);
  191. -#endif
  192.      }
  193.      
  194.      Enable();
  195. diff --git a/rom/devs/keyboard/keyboard_intern.h b/rom/devs/keyboard/keyboard_intern.h
  196. index d07aff0735..88abda1c82 100644
  197. --- a/rom/devs/keyboard/keyboard_intern.h
  198. +++ b/rom/devs/keyboard/keyboard_intern.h
  199. @@ -2,7 +2,7 @@
  200.  #define  KEYBOARD_INTERN_H
  201.  
  202.  /*
  203. -    Copyright © 1995-2014, The AROS Development Team. All rights reserved.
  204. +    Copyright © 1995-2019, The AROS Development Team. All rights reserved.
  205.      $Id$
  206.  
  207.      Desc:
  208. @@ -35,7 +35,7 @@ struct KeyboardBase
  209.                        releases) and there are pending requests */
  210.  
  211.      UWORD   kb_nHandlers;              /* Number of reset handlers added */
  212. -    UWORD  *kb_keyBuffer;
  213. +    ULONG  *kb_keyEventBuffer;  /* Should be KbdIrqData_t * */
  214.      UWORD   kb_writePos;
  215.      BOOL    kb_ResetPhase;         /* True if reset has begun */
  216.      UBYTE  *kb_Matrix;
  217. diff --git a/rom/hidds/kbd/include/keyboard.h b/rom/hidds/kbd/include/keyboard.h
  218. index 2e99d9b97e..15863fa8b4 100644
  219. --- a/rom/hidds/kbd/include/keyboard.h
  220. +++ b/rom/hidds/kbd/include/keyboard.h
  221. @@ -23,6 +23,8 @@
  222.  extern OOP_AttrBase HiddKbdAB;
  223.  #endif
  224.  
  225. +typedef ULONG KbdIrqData_t;
  226. +
  227.  enum {
  228.     aoHidd_Kbd_IrqHandler,
  229.     aoHidd_Kbd_IrqHandlerData,
  230. @@ -35,6 +37,12 @@ enum {
  231.  
  232.  #define IS_HIDDKBD_ATTR(attr, idx) IS_IF_ATTR(attr, idx, HiddKbdAB, num_Hidd_Kbd_Attrs)
  233.  
  234. +/*
  235. + * The following flags are OR'd by hardware drivers with the keycode to pass to the IrqHandler(s)
  236. + */
  237. +
  238. +#define KBD_NOCAPSUP (1 << 7)
  239. +
  240.  /*
  241.   * The following methods are legacy and deprecated. Do not use them.
  242.   * Use HW_AddDriver() and HW_RemoveDriver() methods on CLID_HW_Kbd
  243. diff --git a/rom/hidds/kbd/kbd.h b/rom/hidds/kbd/kbd.h
  244. index d6dcbbaeba..f000478edd 100644
  245. --- a/rom/hidds/kbd/kbd.h
  246. +++ b/rom/hidds/kbd/kbd.h
  247. @@ -4,7 +4,7 @@
  248.  struct kbd_data
  249.  {
  250.      struct MinNode node;
  251. -    void (*callback)(APTR data, UWORD keyCode);
  252. +    void (*callback)(APTR data, ULONG keyData);
  253.      APTR callbackdata;
  254.  };
  255.  
  256. diff --git a/rom/hidds/kbd/kbdclass.c b/rom/hidds/kbd/kbdclass.c
  257. index 97b3526621..20b2eab198 100644
  258. --- a/rom/hidds/kbd/kbdclass.c
  259. +++ b/rom/hidds/kbd/kbdclass.c
  260. @@ -1,5 +1,5 @@
  261.  /*
  262. -    Copyright (C) 2004-2013, The AROS Development Team. All rights reserved.
  263. +    Copyright (C) 2004-2019, The AROS Development Team. All rights reserved.
  264.      $Id$
  265.  */
  266.  
  267. @@ -50,17 +50,22 @@
  268.          CLID_Hidd_Kbd
  269.  
  270.      FUNCTION
  271. -        Specifies a keyboard event handler. The handler will called be every time a
  272. -        keyboard event happens. A "C" calling convention is used, declare the handler
  273. -        functions as follows:
  274. +        Specifies a keyboard event handler. The handler will be called every time a
  275. +        keyboard event occurs.  Handlers should be declared using 'C' calling conventions,
  276. +        e.g.:
  277.  
  278. -        void KeyboardIRQ(APTR data, UWORD keyCode)
  279. +        void KeyboardIRQ(APTR data, ULONG keyData)
  280.  
  281.          Handler parameters are:
  282. -            data    - Anything you specify using aoHidd_Kbd_IrqHandlerData
  283. -            keyCode - A raw key code as specified in devices/rawkeycodes.h.
  284. -                      Key release event is indicated by ORing this value
  285. +            data    - The handler will be called with this set to the value
  286. +                      defined using the aoHidd_Kbd_IrqHandlerData attribute.
  287. +            keyData - The keyData is an OR'd value of the input handlers flags
  288. +                      and the raw key code as specified in devices/rawkeycodes.h.
  289. +                      keyData = (flags << 16 ) | rawkeycode.
  290. +                      A key 'release' event is indicated by OR'ing this value
  291.                        with IECODE_UP_PREFIX (defined in devices/inputevent.h)
  292. +                      currently supported flags are -:
  293. +                      KBD_NOCAPSUP - The keyboard does not generate an UP event for Caps Lock.
  294.  
  295.          The handler is called inside interrupts, so usual restrictions apply to it.
Advertisement
Add Comment
Please, Sign In to add comment