• Acolyte of the Butterfly
    Acolyte of the Butterfly
    Georg
    Posts: 106 from 2004/4/7
    Quote:

    cyfm wrote:

    I will just confirm that this ugly 68K SetFunction() patch won't work anyway



    Posting source with this gate/trap/whatever stuff (unless beautified by AROS macros)
    would have looked even worse ;-)

    So what about this, then (to have brightness, etc. with ALT + function keys):

    Code:

    #include <exec/interrupts.h>
    #include <devices/input.h>
    #include <devices/inputevent.h>
    #include <proto/exec.h>
    #include <proto/input.h>
    #include <clib/alib_protos.h>

    #define PRI1 121
    #define PRI2 119

    #define NAME1 "FKEYHACK1"
    #define NAME2 "FKEYHACK2"

    #define QUAL IEQUALIFIER_LALT

    #define SHIFTALTCTRL (IEQUALIFIER_LALT | IEQUALIFIER_RALT | IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT | IEQUALIFIER_CONTROL)
    #define IECLASS_HACK 0x7C

    struct MsgPort *mp;
    struct IOStdReq *io;
    struct Interrupt i1, i2;

    struct InputEvent *ihandler1(register struct InputEvent *ie asm("a0"))
    {
    struct InputEvent *e = ie;

    while(e)
    {
    if (e->ie_Class == IECLASS_RAWKEY)
    {
    int code = e->ie_Code &~ IECODE_UP_PREFIX;
    int quali = e->ie_Qualifier & SHIFTALTCTRL;

    if (code >= 0x50 && code <= 0x59) /* F1 .. F10 */
    {
    if (!quali)
    {
    e->ie_Class = IECLASS_HACK;
    }
    else if (quali == QUAL)
    {
    e->ie_Qualifier &= ~QUAL;
    }
    }

    }
    e = e->ie_NextEvent;
    }

    return ie;
    }

    struct InputEvent *ihandler2(register struct InputEvent *ie asm("a0"))
    {
    struct InputEvent *e = ie;

    while(e)
    {
    if (e->ie_Class == IECLASS_HACK)
    {
    e->ie_Class = IECLASS_RAWKEY;
    }
    e = e->ie_NextEvent;
    }

    return ie;
    }


    void dohandler(int cmd, struct Interrupt *i)
    {
    io->io_Command = cmd;
    io->io_Data = i;
    DoIO((struct IORequest *)io);
    }

    int main(void)
    {
    mp = CreateMsgPort();
    io = CreateIORequest(mp, sizeof(*io));

    i1.is_Code = (void *)ihandler1;
    i1.is_Node.ln_Pri = PRI1;
    i1.is_Node.ln_Name = NAME1;

    i2.is_Code = (void *)ihandler2;
    i2.is_Node.ln_Pri = PRI2;
    i2.is_Node.ln_Name = NAME2;

    if (!OpenDevice("input.device", 0, (struct IORequest *)io, 0))
    {
    struct InputEvent *ie;

    dohandler(IND_ADDHANDLER, &i1);
    dohandler(IND_ADDHANDLER, &i2);

    Wait(SIGBREAKF_CTRL_C);

    dohandler(IND_REMHANDLER, &i2);
    dohandler(IND_REMHANDLER, &i1);

    CloseDevice((struct IORequest *)io);
    }

    DeleteIORequest(io);
    DeleteMsgPort(mp);
    }
  • »22.05.23 - 17:29
    Profile