Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/arch/m68k-amiga/hidd/keyboard/kbd.h b/arch/m68k-amiga/hidd/keyboard/kbd.h
- index 884cc6926e..352dec23d3 100644
- --- a/arch/m68k-amiga/hidd/keyboard/kbd.h
- +++ b/arch/m68k-amiga/hidd/keyboard/kbd.h
- @@ -2,7 +2,7 @@
- #define HIDD_KBD_H
- /*
- - Copyright © 1995-2018, The AROS Development Team. All rights reserved.
- + Copyright © 1995-2019, The AROS Development Team. All rights reserved.
- $Id$
- Desc: Include for the kbd HIDD.
- @@ -83,7 +83,7 @@ struct kbdbase
- struct kbd_data
- {
- - VOID (*kbd_callback)(APTR, UWORD);
- + VOID (*kbd_callback)(APTR, ULONG);
- APTR callbackdata;
- struct Library *TimerBase;
- UBYTE resetstate;
- diff --git a/arch/m68k-amiga/hidd/keyboard/kbdclass.c b/arch/m68k-amiga/hidd/keyboard/kbdclass.c
- index dfdfd7e149..62c60120ea 100644
- --- a/arch/m68k-amiga/hidd/keyboard/kbdclass.c
- +++ b/arch/m68k-amiga/hidd/keyboard/kbdclass.c
- @@ -63,17 +63,17 @@ static AROS_INTH1(keyboard_interrupt, struct kbd_data *, kbddata)
- if (keycode == 0x78) { // reset warning
- kbddata->resetstate++;
- if (kbddata->resetstate == 2) {
- - kbddata->kbd_callback(kbddata->callbackdata, keycode);
- + kbddata->kbd_callback(kbddata->callbackdata, (KBD_NOCAPSUP << 16) | keycode);
- // second reset warning, no handshake = starts 10s delay before forced reset
- return 0;
- }
- // first reset warning, handle it normally
- } else {
- - kbddata->kbd_callback(kbddata->callbackdata, keycode);
- + kbddata->kbd_callback(kbddata->callbackdata, (KBD_NOCAPSUP << 16) |keycode);
- }
- /* "release" UAE mouse wheel up/down key codes */
- if (keycode == 0x7a || keycode == 0x7b)
- - kbddata->kbd_callback(kbddata->callbackdata, 0x80 | keycode);
- + kbddata->kbd_callback(kbddata->callbackdata, (KBD_NOCAPSUP << 16) | 0x80 | keycode);
- // busy wait until handshake pulse has been long enough
- for (;;) {
- diff --git a/rom/devs/keyboard/keyboard.c b/rom/devs/keyboard/keyboard.c
- index 7fecfa86cb..bb0172b070 100644
- --- a/rom/devs/keyboard/keyboard.c
- +++ b/rom/devs/keyboard/keyboard.c
- @@ -1,5 +1,5 @@
- /*
- - Copyright © 1995-2014, The AROS Development Team. All rights reserved.
- + Copyright © 1995-2019, The AROS Development Team. All rights reserved.
- $Id$
- Desc: Keyboard device
- @@ -106,7 +106,7 @@ static const UWORD SupportedCommands[] =
- /****************************************************************************************/
- -VOID keyCallback(struct KeyboardBase *KBBase, UWORD keyCode);
- +VOID keyCallback(struct KeyboardBase *KBBase, ULONG keyData);
- AROS_INTP(kbdSendQueuedEvents);
- static BOOL writeEvents(struct IORequest *ioreq, struct KeyboardBase *KBBase);
- @@ -144,31 +144,34 @@ static int GM_UNIQUENAME(Open)
- return FALSE;
- }
- - if(KBBase->kb_keyBuffer == NULL)
- + if(KBBase->kb_keyEventBuffer == NULL)
- {
- - KBBase->kb_keyBuffer = AllocMem(sizeof(UWORD)*KB_BUFFERSIZE, MEMF_ANY);
- + KBBase->kb_keyEventBuffer = AllocMem(sizeof(KbdIrqData_t) * KB_BUFFERSIZE, MEMF_ANY);
- }
- /* No memory for key buffer? */
- - if(KBBase->kb_keyBuffer == NULL)
- + if(KBBase->kb_keyEventBuffer == NULL)
- {
- + D(bug("keyboard.device: failed to allocate keyboard event buffer storage\n"));
- ioreq->io_Error = IOERR_OPENFAIL;
- return FALSE;
- }
- if((ioreq->io_Unit = AllocMem(sizeof(KBUnit), MEMF_CLEAR)) == NULL)
- {
- + D(bug("keyboard.device: failed to allocate unit data\n"));
- ioreq->io_Error = IOERR_OPENFAIL;
- return FALSE;
- }
- -/* nlorentz: Some extra stuff that must be inited */
- +/* nlorentz: Some extra stuff that must be initialised */
- if (NULL == KBBase->kb_Matrix)
- {
- KBBase->kb_Matrix = AllocMem(KB_MATRIXSIZE, MEMF_ANY|MEMF_CLEAR);
- if (NULL == KBBase->kb_Matrix)
- {
- + D(bug("keyboard.device: failed to allocated keyboard matrix buffer\n"));
- ioreq->io_Error = IOERR_OPENFAIL;
- return FALSE;
- }
- @@ -180,7 +183,7 @@ static int GM_UNIQUENAME(Open)
- if (!HiddKbdAB)
- {
- ioreq->io_Error = IOERR_OPENFAIL;
- - D(bug("keyboard.device: Could not get attrbase\n"));
- + D(bug("keyboard.device: failed to obtain attrbase for '%s'\n", IID_Hidd_Kbd));
- return FALSE;
- }
- }
- @@ -394,10 +397,11 @@ AROS_LH1(void, beginio,
- static BOOL writeEvents(struct IORequest *ioreq, struct KeyboardBase *KBBase)
- {
- - int nEvents; /* Number of struct InputEvent:s that there is
- - room for in memory pointed to by io_Data */
- - UWORD code; /* Value of current keycode */
- - UWORD trueCode; /* Code without possible keypress addition */
- + int nEvents; /* # of InputEvent structures there is room
- + for in the memory pointed to by io_Data */
- + UWORD keFlags; /* flags set by the event source */
- + UWORD code; /* current keycode value of the event */
- + UWORD trueCode; /* keycode without possible keypress addition */
- int i; /* Loop variable */
- struct InputEvent *event; /* Temporary variable */
- BOOL moreevents = TRUE;
- @@ -426,12 +430,14 @@ static BOOL writeEvents(struct IORequest *ioreq, struct KeyboardBase *KBBase)
- for(i = 0; i < nEvents; i++)
- {
- - /* Update eventpointer -- this must be done here as I must set
- - ie_NextEvent to NULL if there are no more keys in the buffer. */
- + /* Update eventpointer -- this must be done here as ie_NextEvent
- + must be set to NULL if there are no more keys in the buffer. */
- if(i != 0)
- event = event->ie_NextEvent;
- - code = KBBase->kb_keyBuffer[kbUn->kbu_readPos++];
- + ULONG eventData = KBBase->kb_keyEventBuffer[kbUn->kbu_readPos++];
- + keFlags = (eventData >> 16) & 0xFFFF;
- + code = eventData & 0xFFFF;
- if(kbUn->kbu_readPos == KB_BUFFERSIZE)
- kbUn->kbu_readPos = 0;
- @@ -444,10 +450,7 @@ static BOOL writeEvents(struct IORequest *ioreq, struct KeyboardBase *KBBase)
- /* Key released ? ... */
- if(code & KEYUPMASK)
- {
- - #if 1
- - /* stegerg: on PC keyboards caps lock also generates up events */
- - if (trueCode != AKC_CAPS_LOCK)
- - #endif
- + if ((keFlags & KBD_NOCAPSUP) || (trueCode != AKC_CAPS_LOCK))
- kbUn->kbu_Qualifiers &= ~(1 << (trueCode - AKC_QUALIFIERS_FIRST));
- }
- else /* ... or pressed? */
- @@ -599,14 +602,16 @@ BOOL HIDDM_initKeyboard(struct KeyboardHIDD *kh)
- /****************************************************************************************/
- -VOID keyCallback(struct KeyboardBase *KBBase, UWORD keyCode)
- +VOID keyCallback(struct KeyboardBase *KBBase, ULONG keyData)
- {
- + UWORD keyCode = (keyData & 0xFFFF);
- +
- D(bug("keyCallBack(KBBase=%p, keyCode=%d)\n"
- , KBBase, keyCode));
- Disable();
- -
- - KBBase->kb_keyBuffer[(KBBase->kb_writePos)++] = keyCode;
- +
- + KBBase->kb_keyEventBuffer[(KBBase->kb_writePos)++] = keyData;
- D(bug("Wrote to buffer\n"));
- @@ -628,12 +633,7 @@ VOID keyCallback(struct KeyboardBase *KBBase, UWORD keyCode)
- if(!IsListEmpty(&KBBase->kb_PendingQueue))
- {
- -#if 0
- - D(bug("doing software irq\n"));
- - Cause(&KBBase->kb_Interrupt);
- -#else
- AROS_INTC1(kbdSendQueuedEvents, KBBase);
- -#endif
- }
- Enable();
- diff --git a/rom/devs/keyboard/keyboard_intern.h b/rom/devs/keyboard/keyboard_intern.h
- index d07aff0735..88abda1c82 100644
- --- a/rom/devs/keyboard/keyboard_intern.h
- +++ b/rom/devs/keyboard/keyboard_intern.h
- @@ -2,7 +2,7 @@
- #define KEYBOARD_INTERN_H
- /*
- - Copyright © 1995-2014, The AROS Development Team. All rights reserved.
- + Copyright © 1995-2019, The AROS Development Team. All rights reserved.
- $Id$
- Desc:
- @@ -35,7 +35,7 @@ struct KeyboardBase
- releases) and there are pending requests */
- UWORD kb_nHandlers; /* Number of reset handlers added */
- - UWORD *kb_keyBuffer;
- + ULONG *kb_keyEventBuffer; /* Should be KbdIrqData_t * */
- UWORD kb_writePos;
- BOOL kb_ResetPhase; /* True if reset has begun */
- UBYTE *kb_Matrix;
- diff --git a/rom/hidds/kbd/include/keyboard.h b/rom/hidds/kbd/include/keyboard.h
- index 2e99d9b97e..15863fa8b4 100644
- --- a/rom/hidds/kbd/include/keyboard.h
- +++ b/rom/hidds/kbd/include/keyboard.h
- @@ -23,6 +23,8 @@
- extern OOP_AttrBase HiddKbdAB;
- #endif
- +typedef ULONG KbdIrqData_t;
- +
- enum {
- aoHidd_Kbd_IrqHandler,
- aoHidd_Kbd_IrqHandlerData,
- @@ -35,6 +37,12 @@ enum {
- #define IS_HIDDKBD_ATTR(attr, idx) IS_IF_ATTR(attr, idx, HiddKbdAB, num_Hidd_Kbd_Attrs)
- +/*
- + * The following flags are OR'd by hardware drivers with the keycode to pass to the IrqHandler(s)
- + */
- +
- +#define KBD_NOCAPSUP (1 << 7)
- +
- /*
- * The following methods are legacy and deprecated. Do not use them.
- * Use HW_AddDriver() and HW_RemoveDriver() methods on CLID_HW_Kbd
- diff --git a/rom/hidds/kbd/kbd.h b/rom/hidds/kbd/kbd.h
- index d6dcbbaeba..f000478edd 100644
- --- a/rom/hidds/kbd/kbd.h
- +++ b/rom/hidds/kbd/kbd.h
- @@ -4,7 +4,7 @@
- struct kbd_data
- {
- struct MinNode node;
- - void (*callback)(APTR data, UWORD keyCode);
- + void (*callback)(APTR data, ULONG keyData);
- APTR callbackdata;
- };
- diff --git a/rom/hidds/kbd/kbdclass.c b/rom/hidds/kbd/kbdclass.c
- index 97b3526621..20b2eab198 100644
- --- a/rom/hidds/kbd/kbdclass.c
- +++ b/rom/hidds/kbd/kbdclass.c
- @@ -1,5 +1,5 @@
- /*
- - Copyright (C) 2004-2013, The AROS Development Team. All rights reserved.
- + Copyright (C) 2004-2019, The AROS Development Team. All rights reserved.
- $Id$
- */
- @@ -50,17 +50,22 @@
- CLID_Hidd_Kbd
- FUNCTION
- - Specifies a keyboard event handler. The handler will called be every time a
- - keyboard event happens. A "C" calling convention is used, declare the handler
- - functions as follows:
- + Specifies a keyboard event handler. The handler will be called every time a
- + keyboard event occurs. Handlers should be declared using 'C' calling conventions,
- + e.g.:
- - void KeyboardIRQ(APTR data, UWORD keyCode)
- + void KeyboardIRQ(APTR data, ULONG keyData)
- Handler parameters are:
- - data - Anything you specify using aoHidd_Kbd_IrqHandlerData
- - keyCode - A raw key code as specified in devices/rawkeycodes.h.
- - Key release event is indicated by ORing this value
- + data - The handler will be called with this set to the value
- + defined using the aoHidd_Kbd_IrqHandlerData attribute.
- + keyData - The keyData is an OR'd value of the input handlers flags
- + and the raw key code as specified in devices/rawkeycodes.h.
- + keyData = (flags << 16 ) | rawkeycode.
- + A key 'release' event is indicated by OR'ing this value
- with IECODE_UP_PREFIX (defined in devices/inputevent.h)
- + currently supported flags are -:
- + KBD_NOCAPSUP - The keyboard does not generate an UP event for Caps Lock.
- The handler is called inside interrupts, so usual restrictions apply to it.
Advertisement
Add Comment
Please, Sign In to add comment