home *** CD-ROM | disk | FTP | other *** search
- /*
- ** MMBShift.c Version 37.1 (16. Januar 1994)
- **
- ** Ein Commodity-Programm um die mittlere Maustaste mit "Shift"
- ** zu belegen. Benötigt Amiga-OS 2.04 (37.175) oder höher.
- **
- ** (c) Copyright 1994 Ralf Seyfarth
- ** Alle Rechte vorbehalten
- **
- ** Dieses Programm ist FREEWARE, es darf frei weitergegeben werden,
- ** solange alle Dateien im original Zustand enthalten sind.
- **
- ** Aufruf für DICE (2.07.56R) :
- **
- ** DCC MMBShift.c -o MMBShift -3.0 -mi
- */
-
-
- #include <clib/alib_protos.h>
- #include <dos/dos.h>
- #include <intuition/intuitionbase.h>
- #include <libraries/commodities.h>
- #include <workbench/startup.h>
- #include <workbench/workbench.h>
-
- #define CxBase_DECLARED
- #define IntuitionBase_DECLARED
-
- #include <proto/commodities.h>
- #include <proto/dos.h>
- #include <proto/exec.h>
- #include <proto/icon.h>
- #include <proto/intuition.h>
- #include <proto/utility.h>
-
- #include <stdlib.h>
-
- VOID _main(VOID);
- VOID _waitwbmsg(VOID);
- VOID HandleEvent(VOID);
- VOID MainLoop(VOID);
-
- __geta4 VOID CxHandler(CxMsg *);
-
- IMPORT struct IntuitionBase *IntuitionBase;
- IMPORT struct WBStartup *_WBMsg;
-
- #define LEFTSHIFT 0x60
-
- struct Library *CxBase;
- struct MsgPort *BrokerMP;
-
- struct NewBroker NewBroker =
- {
- NB_VERSION,
- "MMBShift",
- "MMBShift 37.1 (16.1.94)",
- "Copyright © 1994 Ralf Seyfarth",
- NBU_NOTIFY | NBU_UNIQUE,
- 0,
- 0,
- NULL,
- 0
- };
-
- STATIC const UBYTE VersionsTag[] = "\0$VER: MMBShift 37.1 (16.1.94)";
-
- CxObj *Broker;
- LONG *ArgA[1];
- Priority;
- UBYTE *PriStr;
- ULONG CxSigFlag;
-
-
- VOID
- _main(VOID)
- {
- if (IntuitionBase->LibNode.lib_Version < 37)
- _exit(RETURN_FAIL);
-
- if (_WBMsg)
- {
- struct DiskObject *DObj;
-
- CurrentDir(_WBMsg->sm_ArgList[0].wa_Lock);
-
- if (DObj = GetDiskObject(_WBMsg->sm_ArgList[0].wa_Name))
- {
- if (PriStr = FindToolType(DObj->do_ToolTypes, "CX_PRIORITY"))
- StrToLong(PriStr, &Priority);
-
- FreeDiskObject(DObj);
- }
- }
- else
- {
- struct RDArgs *RDArgs;
-
- if (!(RDArgs = ReadArgs("CX_PRIORITY/N/K", ArgA, NULL)))
- {
- PrintFault(IoErr(), NULL);
- _exit(RETURN_FAIL);
- }
-
- if (ArgA[0])
- Priority = *ArgA[0];
-
- FreeArgs(RDArgs);
- }
-
- MainLoop();
- }
-
-
- VOID
- HandleEvent(VOID)
- {
- FOREVER
- {
- ULONG SigRec = Wait(SIGBREAKF_CTRL_C | CxSigFlag);
-
- if (SigRec & SIGBREAKF_CTRL_C)
- return;
-
- if (SigRec & CxSigFlag)
- {
- CxMsg *CxMsg;
-
- while (CxMsg = GetMsg(BrokerMP))
- {
- ULONG MsgID,
- MsgType;
-
- MsgID = CxMsgID(CxMsg);
- MsgType = CxMsgType(CxMsg);
-
- ReplyMsg((struct Message *) CxMsg);
-
- if (MsgType == CXM_COMMAND)
- {
- switch (MsgID)
- {
- case CXCMD_KILL :
- case CXCMD_UNIQUE : return;
-
- case CXCMD_ENABLE : ActivateCxObj(Broker, TRUE);
- break;
-
- case CXCMD_DISABLE : ActivateCxObj(Broker, FALSE);
- }
- }
- }
- }
- }
- }
-
-
- VOID
- MainLoop(VOID)
- {
- CxObj *CxObj;
- CxMsg *CxMsg;
- ULONG ECode = RETURN_FAIL;
-
- if (CxBase = OpenLibrary("commodities.library", 37L))
- {
- if (BrokerMP = CreateMsgPort())
- {
- NewBroker.nb_Pri = (BYTE) Priority;
- NewBroker.nb_Port = BrokerMP;
-
- if (Broker = CxBroker(&NewBroker, NULL))
- {
- if (CxObj = CxCustom(CxHandler, NULL))
- {
- AttachCxObj(Broker, CxObj);
- CxSigFlag = 1L << BrokerMP->mp_SigBit;
-
- if (!CxObjError(Broker))
- {
- ActivateCxObj(Broker, TRUE);
- HandleEvent();
-
- ECode = RETURN_OK;
- }
- }
-
- DeleteCxObjAll(Broker);
- }
- else
- ECode = RETURN_OK;
-
- while (CxMsg = GetMsg(BrokerMP))
- ReplyMsg((struct Message *) CxMsg);
-
- DeleteMsgPort(BrokerMP);
- }
-
- CloseLibrary(CxBase);
- }
-
- _exit(ECode);
- _waitwbmsg();
- }
-
-
- __geta4 VOID
- CxHandler(CxMsg *CxMsg)
- {
- struct InputEvent *IEvent;
-
- if (IEvent = (struct InputEvent *) CxMsgData(CxMsg))
- {
- if (IEvent->ie_Qualifier & IEQUALIFIER_MIDBUTTON)
- IEvent->ie_Qualifier -= IEQUALIFIER_MIDBUTTON - IEQUALIFIER_LSHIFT;
-
- if (IEvent->ie_Class == IECLASS_RAWMOUSE)
-
- if ((IEvent->ie_Code & ~IECODE_UP_PREFIX) == IECODE_MBUTTON)
- {
- IEvent->ie_Code -= IECODE_MBUTTON - LEFTSHIFT;
- IEvent->ie_Class = IECLASS_RAWKEY;
- }
- }
- }
-