2 *----------------------------------------------------------------------------
3 * bootmouse class for poseidon
4 *----------------------------------------------------------------------------
5 * By Chris Hodges <chrisly@platon42.de>
10 #include "bootmouse.class.h"
13 static const STRPTR libname
= MOD_NAME_STRING
;
15 static int libInit(LIBBASETYPEPTR nh
)
17 KPRINTF(10, ("libInit nh: 0x%08lx SysBase: 0x%08lx\n", nh
, SysBase
));
19 nh
->nh_UtilityBase
= OpenLibrary("utility.library", 39);
21 #define UtilityBase nh->nh_UtilityBase
25 struct NepClassHid
*nch
;
26 NewList(&nh
->nh_Bindings
);
27 nch
= &nh
->nh_DummyNCH
;
28 nch
->nch_ClsBase
= nh
;
29 nch
->nch_Interface
= NULL
;
30 nch
->nch_CDC
= AllocVec(sizeof(struct ClsDevCfg
), MEMF_PUBLIC
|MEMF_CLEAR
);
36 KPRINTF(20, ("libInit: OpenLibrary(\"utility.library\", 39) failed!\n"));
40 KPRINTF(10, ("libInit: Ok\n"));
44 static int libOpen(LIBBASETYPEPTR nh
)
46 KPRINTF(10, ("libOpen nh: 0x%08lx\n", nh
));
51 static int libExpunge(LIBBASETYPEPTR nh
)
53 KPRINTF(10, ("libExpunge nh: 0x%08lx SysBase: 0x%08lx\n", nh
, SysBase
));
54 CloseLibrary(UtilityBase
);
55 FreeVec(nh
->nh_DummyNCH
.nch_CDC
);
59 ADD2INITLIB(libInit
, 0)
60 ADD2OPENLIB(libOpen
, 0)
61 ADD2EXPUNGELIB(libExpunge
, 0)
65 * ***********************************************************************
66 * * Library functions *
67 * ***********************************************************************
70 /* /// "usbAttemptInterfaceBinding()" */
71 struct NepClassHid
* usbAttemptInterfaceBinding(struct NepHidBase
*nh
, struct PsdInterface
*pif
)
78 KPRINTF(1, ("nepHidAttemptInterfaceBinding(%08lx)\n", pif
));
79 if((ps
= OpenLibrary("poseidon.library", 4)))
81 psdGetAttrs(PGA_INTERFACE
, pif
,
83 IFA_SubClass
, &subclass
,
88 if((ifclass
== HID_CLASSCODE
) && (subclass
== HID_BOOT_SUBCLASS
) && (proto
== HID_PROTO_MOUSE
))
90 return(usbForceInterfaceBinding(nh
, pif
));
97 /* /// "usbForceInterfaceBinding()" */
98 struct NepClassHid
* usbForceInterfaceBinding(struct NepHidBase
*nh
, struct PsdInterface
*pif
)
101 struct NepClassHid
*nch
;
102 struct PsdConfig
*pc
;
103 struct PsdDevice
*pd
;
108 struct Task
*tmptask
;
110 KPRINTF(1, ("nepHidForceInterfaceBinding(%08lx)\n", pif
));
111 if((ps
= OpenLibrary("poseidon.library", 4)))
113 psdGetAttrs(PGA_INTERFACE
, pif
,
115 IFA_IDString
, &ifidstr
,
117 psdGetAttrs(PGA_CONFIG
, pc
,
120 psdGetAttrs(PGA_DEVICE
, pd
,
121 DA_ProductName
, &devname
,
122 DA_IDString
, &devidstr
,
124 if((nch
= psdAllocVec(sizeof(struct NepClassHid
))))
126 nch
->nch_ClsBase
= nh
;
127 nch
->nch_CDC
= psdAllocVec(sizeof(struct ClsDevCfg
));
135 nch
->nch_Device
= pd
;
136 nch
->nch_Interface
= pif
;
137 nch
->nch_DevIDString
= devidstr
;
138 nch
->nch_IfIDString
= ifidstr
;
140 nLoadBindingConfig(nch
);
142 psdSafeRawDoFmt(buf
, 64, "bootmouse.class<%08lx>", nch
);
143 nch
->nch_ReadySignal
= SIGB_SINGLE
;
144 nch
->nch_ReadySigTask
= FindTask(NULL
);
145 SetSignal(0, SIGF_SINGLE
);
146 if((tmptask
= psdSpawnSubTask(buf
, nHidTask
, nch
)))
148 psdBorrowLocksWait(tmptask
, 1UL<<nch
->nch_ReadySignal
);
151 nch
->nch_ReadySigTask
= NULL
;
152 //FreeSignal(nch->nch_ReadySignal);
153 psdAddErrorMsg(RETURN_OK
, (STRPTR
) libname
,
154 "I'm pleased to introduce a mouse alliance to '%s'!",
158 AddTail(&nh
->nh_Bindings
, &nch
->nch_Node
);
164 nch
->nch_ReadySigTask
= NULL
;
165 //FreeSignal(nch->nch_ReadySignal);
166 psdFreeVec(nch
->nch_CDC
);
176 /* /// "usbReleaseInterfaceBinding()" */
177 void usbReleaseInterfaceBinding(struct NepHidBase
*nh
, struct NepClassHid
*nch
)
180 struct PsdConfig
*pc
;
181 struct PsdDevice
*pd
;
184 KPRINTF(1, ("nepHidReleaseInterfaceBinding(%08lx)\n", nch
));
185 if((ps
= OpenLibrary("poseidon.library", 4)))
188 nch
->nch_ReadySignal
= SIGB_SINGLE
;
189 nch
->nch_ReadySigTask
= FindTask(NULL
);
192 Signal(nch
->nch_GUITask
, SIGBREAKF_CTRL_C
);
195 while(nch
->nch_GUITask
)
197 Wait(1L<<nch
->nch_ReadySignal
);
203 Signal(nch
->nch_Task
, SIGBREAKF_CTRL_C
);
208 Wait(1L<<nch
->nch_ReadySignal
);
210 //FreeSignal(nch->nch_ReadySignal);
211 psdGetAttrs(PGA_INTERFACE
, nch
->nch_Interface
, IFA_Config
, &pc
, TAG_END
);
212 psdGetAttrs(PGA_CONFIG
, pc
, CA_Device
, &pd
, TAG_END
);
213 psdGetAttrs(PGA_DEVICE
, pd
, DA_ProductName
, &devname
, TAG_END
);
214 psdAddErrorMsg(RETURN_OK
, (STRPTR
) libname
,
215 "A cat ate my mouse '%s'!",
218 Remove(&nch
->nch_Node
);
220 psdFreeVec(nch
->nch_CDC
);
227 /* /// "usbGetAttrsA()" */
228 AROS_LH3(LONG
, usbGetAttrsA
,
229 AROS_LHA(ULONG
, type
, D0
),
230 AROS_LHA(APTR
, usbstruct
, A0
),
231 AROS_LHA(struct TagItem
*, tags
, A1
),
232 LIBBASETYPEPTR
, nh
, 5, nep
)
239 KPRINTF(1, ("nepHidGetAttrsA(%ld, %08lx, %08lx)\n", type
, usbstruct
, tags
));
243 if((ti
= FindTagItem(UCCA_Priority
, tags
)))
245 *((SIPTR
*) ti
->ti_Data
) = -100;
248 if((ti
= FindTagItem(UCCA_Description
, tags
)))
250 *((STRPTR
*) ti
->ti_Data
) = "Support for mice/tablets in boot protocol mode";
253 if((ti
= FindTagItem(UCCA_HasClassCfgGUI
, tags
)))
255 *((IPTR
*) ti
->ti_Data
) = TRUE
;
258 if((ti
= FindTagItem(UCCA_HasBindingCfgGUI
, tags
)))
260 *((IPTR
*) ti
->ti_Data
) = TRUE
;
263 if((ti
= FindTagItem(UCCA_AfterDOSRestart
, tags
)))
265 *((IPTR
*) ti
->ti_Data
) = TRUE
;
268 if((ti
= FindTagItem(UCCA_UsingDefaultCfg
, tags
)))
270 *((IPTR
*) ti
->ti_Data
) = nh
->nh_DummyNCH
.nch_UsingDefaultCfg
;
276 if((ti
= FindTagItem(UCBA_UsingDefaultCfg
, tags
)))
278 *((IPTR
*) ti
->ti_Data
) = ((struct NepClassHid
*) usbstruct
)->nch_UsingDefaultCfg
;
288 /* /// "usbSetAttrsA()" */
289 AROS_LH3(LONG
, usbSetAttrsA
,
290 AROS_LHA(ULONG
, type
, D0
),
291 AROS_LHA(APTR
, usbstruct
, A0
),
292 AROS_LHA(struct TagItem
*, tags
, A1
),
293 LIBBASETYPEPTR
, nh
, 6, nep
)
301 /* /// "usbDoMethodA()" */
302 AROS_LH2(IPTR
, usbDoMethodA
,
303 AROS_LHA(ULONG
, methodid
, D0
),
304 AROS_LHA(IPTR
*, methoddata
, A1
),
305 LIBBASETYPEPTR
, nh
, 7, nep
)
309 struct NepClassHid
*nch
;
311 KPRINTF(10, ("Do Method %ld\n", methodid
));
314 case UCM_AttemptInterfaceBinding
:
315 return((IPTR
) usbAttemptInterfaceBinding(nh
, (struct PsdInterface
*) methoddata
[0]));
317 case UCM_ForceInterfaceBinding
:
318 return((IPTR
) usbForceInterfaceBinding(nh
, (struct PsdInterface
*) methoddata
[0]));
320 case UCM_ReleaseInterfaceBinding
:
321 usbReleaseInterfaceBinding(nh
, (struct NepClassHid
*) methoddata
[0]);
324 case UCM_OpenCfgWindow
:
325 return(nOpenBindingCfgWindow(nh
, &nh
->nh_DummyNCH
));
327 case UCM_OpenBindingCfgWindow
:
328 return(nOpenBindingCfgWindow(nh
, (struct NepClassHid
*) methoddata
[0]));
330 case UCM_ConfigChangedEvent
:
331 nLoadClassConfig(nh
);
333 nch
= (struct NepClassHid
*) nh
->nh_Bindings
.lh_Head
;
334 while(nch
->nch_Node
.ln_Succ
)
336 nLoadBindingConfig(nch
);
337 nch
= (struct NepClassHid
*) nch
->nch_Node
.ln_Succ
;
350 /* /// "nLoadClassConfig()" */
351 BOOL
nLoadClassConfig(struct NepHidBase
*nh
)
353 struct NepClassHid
*nch
= &nh
->nh_DummyNCH
;
355 struct ClsDevCfg
*cdc
;
356 struct PsdIFFContext
*pic
;
358 KPRINTF(10, ("Loading Class Config...\n"));
363 if(!(ps
= OpenLibrary("poseidon.library", 4)))
369 /* Create default config */
370 nch
->nch_CDC
->cdc_ChunkID
= AROS_LONG2BE(MAKE_ID('B','M','S','E'));
371 nch
->nch_CDC
->cdc_Length
= AROS_LONG2BE(sizeof(struct ClsDevCfg
)-8);
372 nch
->nch_CDC
->cdc_Wheelmouse
= FALSE
;
373 nch
->nch_UsingDefaultCfg
= TRUE
;
374 /* try to load default config */
375 pic
= psdGetClsCfg(libname
);
378 cdc
= psdGetCfgChunk(pic
, AROS_LONG2BE(nch
->nch_CDC
->cdc_ChunkID
));
381 CopyMem(((UBYTE
*) cdc
) + 8, ((UBYTE
*) nch
->nch_CDC
) + 8, min(AROS_LONG2BE(cdc
->cdc_Length
), AROS_LONG2BE(nch
->nch_CDC
->cdc_Length
)));
383 nch
->nch_UsingDefaultCfg
= FALSE
;
392 /* /// "nLoadBindingConfig()" */
393 BOOL
nLoadBindingConfig(struct NepClassHid
*nch
)
395 struct NepHidBase
*nh
= nch
->nch_ClsBase
;
397 struct ClsDevCfg
*cdc
;
398 struct PsdIFFContext
*pic
;
400 KPRINTF(10, ("Loading Binding Config...\n"));
405 //nLoadClassConfig(nh);
406 *nch
->nch_CDC
= *nh
->nh_DummyNCH
.nch_CDC
;
407 nch
->nch_UsingDefaultCfg
= TRUE
;
409 if(!(ps
= OpenLibrary("poseidon.library", 4)))
416 pic
= psdGetUsbDevCfg(libname
, nch
->nch_DevIDString
, nch
->nch_IfIDString
);
419 cdc
= psdGetCfgChunk(pic
, AROS_LONG2BE(nch
->nch_CDC
->cdc_ChunkID
));
422 CopyMem(((UBYTE
*) cdc
) + 8, ((UBYTE
*) nch
->nch_CDC
) + 8, min(AROS_LONG2BE(cdc
->cdc_Length
), AROS_LONG2BE(nch
->nch_CDC
->cdc_Length
)));
424 nch
->nch_UsingDefaultCfg
= FALSE
;
433 /* /// "nOpenBindingCfgWindow()" */
434 LONG
nOpenBindingCfgWindow(struct NepHidBase
*nh
, struct NepClassHid
*nch
)
437 KPRINTF(10, ("Opening GUI...\n"));
438 if(!(ps
= OpenLibrary("poseidon.library", 4)))
443 if(!nch
->nch_GUITask
)
445 if((nch
->nch_GUITask
= psdSpawnSubTask(MOD_NAME_STRING
" GUI", nGUITask
, nch
)))
458 /**************************************************************************/
461 #define ps nch->nch_Base
463 /* /// "nHidTask()" */
464 AROS_UFH0(void, nHidTask
)
468 struct NepClassHid
*nch
;
484 BOOL firstpkt
= TRUE
;
486 if((nch
= nAllocHid()))
489 if(nch
->nch_ReadySigTask
)
491 Signal(nch
->nch_ReadySigTask
, 1L<<nch
->nch_ReadySignal
);
494 sigmask
= (1L<<nch
->nch_TaskMsgPort
->mp_SigBit
)|SIGBREAKF_CTRL_C
;
495 bufreal
= buf
= nch
->nch_EP1Buf
;
496 psdSendPipe(nch
->nch_EP1Pipe
, buf
, nch
->nch_EP1PktSize
);
499 sigs
= Wait(sigmask
);
500 while((pp
= (struct PsdPipe
*) GetMsg(nch
->nch_TaskMsgPort
)))
502 if(pp
== nch
->nch_EP1Pipe
)
504 if(!(ioerr
= psdGetPipeError(pp
)))
514 KPRINTF(1, ("Data: %08lx %08lx\n", (*(ULONG
*) bufreal
), ((ULONG
*) bufreal
)[1]));
516 qualifier
= IEQUALIFIER_RELATIVEMOUSE
;
518 iecode
= wheeliecode
= IECODE_NOBUTTON
;
522 qualifier
|= IEQUALIFIER_LEFTBUTTON
;
526 qualifier
|= IEQUALIFIER_RBUTTON
;
530 qualifier
|= IEQUALIFIER_MIDBUTTON
;
532 if(nch
->nch_CDC
->cdc_Wheelmouse
)
534 wheel
= ((BYTE
*) bufreal
)[3];
535 if(wheel
!= oldwheel
)
539 wheeliecode
= RAWKEY_NM_WHEEL_UP
|IECODE_UP_PREFIX
;
542 else if(oldwheel
< 0)
544 wheeliecode
= RAWKEY_NM_WHEEL_DOWN
|IECODE_UP_PREFIX
;
551 wheeliecode
= RAWKEY_NM_WHEEL_UP
;
557 wheeliecode
= RAWKEY_NM_WHEEL_DOWN
;
563 if((buts
^oldbuts
) & 1)
565 iecode
= (buts
& 1) ? IECODE_LBUTTON
: IECODE_LBUTTON
|IECODE_UP_PREFIX
;
568 else if((buts
^oldbuts
) & 2)
570 iecode
= (buts
& 2) ? IECODE_RBUTTON
: IECODE_RBUTTON
|IECODE_UP_PREFIX
;
573 else if((buts
^oldbuts
) & 4)
575 iecode
= (buts
& 4) ? IECODE_MBUTTON
: IECODE_MBUTTON
|IECODE_UP_PREFIX
;
578 nch
->nch_FakeEvent
.ie_X
= ((BYTE
*) bufreal
)[1];
579 nch
->nch_FakeEvent
.ie_Y
= ((BYTE
*) bufreal
)[2];
580 nch
->nch_FakeEvent
.ie_Class
= IECLASS_RAWMOUSE
;
581 nch
->nch_FakeEvent
.ie_SubClass
= 0;
582 nch
->nch_FakeEvent
.ie_Code
= iecode
;
583 nch
->nch_FakeEvent
.ie_NextEvent
= NULL
;
584 nch
->nch_FakeEvent
.ie_Qualifier
= qualifier
;
585 nch
->nch_InpIOReq
->io_Data
= &nch
->nch_FakeEvent
;
586 nch
->nch_InpIOReq
->io_Length
= sizeof(struct InputEvent
);
587 nch
->nch_InpIOReq
->io_Command
= IND_WRITEEVENT
;
588 DoIO((struct IORequest
*) nch
->nch_InpIOReq
);
593 KPRINTF(1, ("Doing wheel %ld\n", wheel
));
594 nch
->nch_FakeEvent
.ie_Class
= IECLASS_RAWKEY
;
595 nch
->nch_FakeEvent
.ie_SubClass
= 0;
596 nch
->nch_FakeEvent
.ie_Code
= wheeliecode
;
597 nch
->nch_FakeEvent
.ie_NextEvent
= NULL
;
598 nch
->nch_FakeEvent
.ie_Qualifier
= qualifier
;
599 nch
->nch_InpIOReq
->io_Data
= &nch
->nch_FakeEvent
;
600 nch
->nch_InpIOReq
->io_Length
= sizeof(struct InputEvent
);
601 nch
->nch_InpIOReq
->io_Command
= IND_WRITEEVENT
;
602 DoIO((struct IORequest
*) nch
->nch_InpIOReq
);
604 nch
->nch_FakeEvent
.ie_Class
= IECLASS_NEWMOUSE
;
605 nch
->nch_FakeEvent
.ie_SubClass
= 0;
606 nch
->nch_FakeEvent
.ie_Code
= wheeliecode
;
607 nch
->nch_FakeEvent
.ie_NextEvent
= NULL
;
608 nch
->nch_FakeEvent
.ie_Qualifier
= qualifier
;
609 nch
->nch_InpIOReq
->io_Data
= &nch
->nch_FakeEvent
;
610 nch
->nch_InpIOReq
->io_Length
= sizeof(struct InputEvent
);
611 nch
->nch_InpIOReq
->io_Command
= IND_WRITEEVENT
;
612 DoIO((struct IORequest
*) nch
->nch_InpIOReq
);
616 KPRINTF(1, ("Int Pipe failed %ld\n", ioerr
));
619 psdSendPipe(nch
->nch_EP1Pipe
, buf
, nch
->nch_EP1PktSize
);
623 } while(!(sigs
& SIGBREAKF_CTRL_C
));
624 KPRINTF(20, ("Going down the river!\n"));
625 psdAbortPipe(nch
->nch_EP1Pipe
);
626 psdWaitPipe(nch
->nch_EP1Pipe
);
633 /* /// "nAllocHid()" */
634 struct NepClassHid
* nAllocHid(void)
636 struct Task
*thistask
;
637 struct NepClassHid
*nch
;
640 thistask
= FindTask(NULL
);
641 nch
= thistask
->tc_UserData
;
644 if(!(nch
->nch_Base
= OpenLibrary("poseidon.library", 4)))
649 psdGetAttrs(PGA_INTERFACE
, nch
->nch_Interface
,
650 IFA_Config
, &nch
->nch_Config
,
651 IFA_InterfaceNum
, &nch
->nch_IfNum
,
653 psdGetAttrs(PGA_CONFIG
, nch
->nch_Config
,
654 CA_Device
, &nch
->nch_Device
,
657 nch
->nch_EP1
= psdFindEndpoint(nch
->nch_Interface
, NULL
,
659 EA_TransferType
, USEAF_INTERRUPT
,
663 KPRINTF(1, ("Ooops!?! No Endpoints defined?\n"));
666 psdGetAttrs(PGA_ENDPOINT
, nch
->nch_EP1
,
667 EA_MaxPktSize
, &nch
->nch_EP1PktSize
,
669 if((nch
->nch_InpMsgPort
= CreateMsgPort()))
671 if((nch
->nch_InpIOReq
= (struct IOStdReq
*) CreateIORequest(nch
->nch_InpMsgPort
, sizeof(struct IOStdReq
))))
673 if(!OpenDevice("input.device", 0, (struct IORequest
*) nch
->nch_InpIOReq
, 0))
675 if((nch
->nch_TaskMsgPort
= CreateMsgPort()))
677 if((nch
->nch_EP0Pipe
= psdAllocPipe(nch
->nch_Device
, nch
->nch_TaskMsgPort
, NULL
)))
679 if((nch
->nch_EP1Pipe
= psdAllocPipe(nch
->nch_Device
, nch
->nch_TaskMsgPort
, nch
->nch_EP1
)))
681 psdPipeSetup(nch
->nch_EP0Pipe
, URTF_CLASS
|URTF_INTERFACE
,
682 UHR_SET_PROTOCOL
, HID_PROTO_BOOT
, nch
->nch_IfNum
);
683 ioerr
= psdDoPipe(nch
->nch_EP0Pipe
, NULL
, 0);
686 psdPipeSetup(nch
->nch_EP0Pipe
, URTF_CLASS
|URTF_INTERFACE
,
687 UHR_SET_IDLE
, 0, nch
->nch_IfNum
);
688 ioerr
= psdDoPipe(nch
->nch_EP0Pipe
, NULL
, 0);
691 psdAddErrorMsg(RETURN_WARN
, (STRPTR
) libname
,
692 "SET_IDLE=0 failed: %s (%ld)!",
693 psdNumToStr(NTS_IOERR
, ioerr
, "unknown"), ioerr
);
695 if((nch
->nch_EP1Buf
= psdAllocVec(nch
->nch_EP1PktSize
)))
697 psdSetAttrs(PGA_PIPE
, nch
->nch_EP1Pipe
,
698 PPA_AllowRuntPackets
, TRUE
,
700 nch
->nch_Task
= thistask
;
704 psdAddErrorMsg(RETURN_FAIL
, (STRPTR
) libname
,
705 "SET_PROTOCOL=BOOT failed: %s (%ld)!",
706 psdNumToStr(NTS_IOERR
, ioerr
, "unknown"), ioerr
);
708 psdFreePipe(nch
->nch_EP1Pipe
);
710 psdFreePipe(nch
->nch_EP0Pipe
);
712 DeleteMsgPort(nch
->nch_TaskMsgPort
);
714 CloseDevice((struct IORequest
*) nch
->nch_InpIOReq
);
716 DeleteIORequest((struct IORequest
*) nch
->nch_InpIOReq
);
718 DeleteMsgPort(nch
->nch_InpMsgPort
);
721 CloseLibrary(nch
->nch_Base
);
723 nch
->nch_Task
= NULL
;
724 if(nch
->nch_ReadySigTask
)
726 Signal(nch
->nch_ReadySigTask
, 1L<<nch
->nch_ReadySignal
);
732 /* /// "nFreeHid()" */
733 void nFreeHid(struct NepClassHid
*nch
)
735 psdFreeVec(nch
->nch_EP1Buf
);
736 psdFreePipe(nch
->nch_EP1Pipe
);
737 psdFreePipe(nch
->nch_EP0Pipe
);
738 DeleteMsgPort(nch
->nch_TaskMsgPort
);
739 CloseDevice((struct IORequest
*) nch
->nch_InpIOReq
);
740 DeleteIORequest((struct IORequest
*) nch
->nch_InpIOReq
);
741 DeleteMsgPort(nch
->nch_InpMsgPort
);
742 CloseLibrary(nch
->nch_Base
);
744 nch
->nch_Task
= NULL
;
745 if(nch
->nch_ReadySigTask
)
747 Signal(nch
->nch_ReadySigTask
, 1L<<nch
->nch_ReadySignal
);
752 /**************************************************************************/
755 #define ps nch->nch_PsdBase
757 #define IntuitionBase nch->nch_IntBase
759 #define MUIMasterBase nch->nch_MUIBase
761 /* /// "nGUITask()" */
762 AROS_UFH0(void, nGUITask
)
766 struct Task
*thistask
;
767 struct NepHidBase
*nh
;
768 struct NepClassHid
*nch
;
771 thistask
= FindTask(NULL
);
772 nch
= thistask
->tc_UserData
;
773 nh
= nch
->nch_ClsBase
;
775 ++nh
->nh_Library
.lib_OpenCnt
;
776 if(!(MUIMasterBase
= OpenLibrary(MUIMASTER_NAME
, MUIMASTER_VMIN
)))
778 KPRINTF(10, ("Couldn't open muimaster.library.\n"));
779 nGUITaskCleanup(nch
);
783 if(!(IntuitionBase
= OpenLibrary("intuition.library", 39)))
785 KPRINTF(10, ("Couldn't open intuition.library.\n"));
786 nGUITaskCleanup(nch
);
789 if(!(ps
= OpenLibrary("poseidon.library", 4)))
791 KPRINTF(10, ("Couldn't open poseidon.library.\n"));
792 nGUITaskCleanup(nch
);
796 nch
->nch_App
= ApplicationObject
,
797 MUIA_Application_Title
, (IPTR
)libname
,
798 MUIA_Application_Version
, (IPTR
)VERSION_STRING
,
799 MUIA_Application_Copyright
, (IPTR
)"©2002-2009 Chris Hodges",
800 MUIA_Application_Author
, (IPTR
)"Chris Hodges <chrisly@platon42.de>",
801 MUIA_Application_Description
, (IPTR
)"Settings for the bootmouse.class",
802 MUIA_Application_Base
, (IPTR
)"BOOTMOUSE",
803 MUIA_Application_HelpFile
, (IPTR
)"HELP:Poseidon.guide",
804 MUIA_Application_Menustrip
, (IPTR
)MenustripObject
,
805 Child
, (IPTR
)MenuObjectT((IPTR
)"Project"),
806 Child
, (IPTR
)(nch
->nch_AboutMI
= MenuitemObject
,
807 MUIA_Menuitem_Title
, (IPTR
)"About...",
808 MUIA_Menuitem_Shortcut
, (IPTR
)"?",
811 Child
, (IPTR
)MenuObjectT((IPTR
)"Settings"),
812 Child
, (IPTR
)(nch
->nch_UseMI
= MenuitemObject
,
813 MUIA_Menuitem_Title
, (IPTR
)"Save",
814 MUIA_Menuitem_Shortcut
, (IPTR
)"S",
816 Child
, (IPTR
)(nch
->nch_SetDefaultMI
= MenuitemObject
,
817 MUIA_Menuitem_Title
, (IPTR
)"Save as Default",
818 MUIA_Menuitem_Shortcut
, (IPTR
)"D",
820 Child
, (IPTR
)MenuitemObject
,
821 MUIA_Menuitem_Title
, (IPTR
)NM_BARLABEL
,
823 Child
, (IPTR
)(nch
->nch_MUIPrefsMI
= MenuitemObject
,
824 MUIA_Menuitem_Title
, (IPTR
)"MUI Settings",
825 MUIA_Menuitem_Shortcut
, (IPTR
)"M",
830 SubWindow
, (IPTR
)(nch
->nch_MainWindow
= WindowObject
,
831 MUIA_Window_ID
, MAKE_ID('M','A','I','N'),
832 MUIA_Window_Title
, (IPTR
)libname
,
833 MUIA_HelpNode
, (IPTR
)libname
,
835 WindowContents
, (IPTR
)VGroup
,
836 Child
, (IPTR
)HGroup
, GroupFrameT((IPTR
)(nch
->nch_Interface
? "Device Settings" : "Default Device Settings")),
837 Child
, (IPTR
)HSpace(0),
838 Child
, (IPTR
)ColGroup(2),
839 Child
, (IPTR
)Label((IPTR
) "Experimental Wheelmouse support:"),
841 Child
, (IPTR
)(nch
->nch_WheelmouseObj
= ImageObject
, ImageButtonFrame
,
842 MUIA_Background
, MUII_ButtonBack
,
844 MUIA_InputMode
, MUIV_InputMode_Toggle
,
845 MUIA_Image_Spec
, MUII_CheckMark
,
846 MUIA_Image_FreeVert
, TRUE
,
847 MUIA_Selected
, nch
->nch_CDC
->cdc_Wheelmouse
,
848 MUIA_ShowSelState
, FALSE
,
850 Child
, (IPTR
)HSpace(0),
853 Child
, (IPTR
)HSpace(0),
855 Child
, (IPTR
)VSpace(0),
857 MUIA_Group_SameWidth
, TRUE
,
858 Child
, (IPTR
)(nch
->nch_UseObj
= TextObject
, ButtonFrame
,
859 MUIA_ShowMe
, (IPTR
)nch
->nch_Interface
,
860 MUIA_Background
, MUII_ButtonBack
,
862 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
863 MUIA_Text_Contents
, (IPTR
)"\33c Save ",
865 Child
, (IPTR
)(nch
->nch_SetDefaultObj
= TextObject
, ButtonFrame
,
866 MUIA_Background
, MUII_ButtonBack
,
868 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
869 MUIA_Text_Contents
, (IPTR
)(nch
->nch_Interface
? "\33c Save as Default " : "\33c Save Defaults "),
871 Child
, (IPTR
)(nch
->nch_CloseObj
= TextObject
, ButtonFrame
,
872 MUIA_Background
, MUII_ButtonBack
,
874 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
875 MUIA_Text_Contents
, (IPTR
)"\33c Use ",
884 KPRINTF(10, ("Couldn't create application\n"));
885 nGUITaskCleanup(nch
);
889 DoMethod(nch
->nch_MainWindow
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
890 nch
->nch_App
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
891 DoMethod(nch
->nch_UseObj
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
892 nch
->nch_App
, 2, MUIM_Application_ReturnID
, ID_STORE_CONFIG
);
893 DoMethod(nch
->nch_SetDefaultObj
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
894 nch
->nch_App
, 2, MUIM_Application_ReturnID
, ID_DEF_CONFIG
);
895 DoMethod(nch
->nch_CloseObj
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
896 nch
->nch_App
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
898 DoMethod(nch
->nch_AboutMI
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
899 nch
->nch_App
, 2, MUIM_Application_ReturnID
, ID_ABOUT
);
900 DoMethod(nch
->nch_UseMI
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
901 nch
->nch_App
, 2, MUIM_Application_ReturnID
, ID_STORE_CONFIG
);
902 DoMethod(nch
->nch_SetDefaultMI
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
903 nch
->nch_App
, 2, MUIM_Application_ReturnID
, ID_DEF_CONFIG
);
904 DoMethod(nch
->nch_MUIPrefsMI
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
905 nch
->nch_App
, 2, MUIM_Application_OpenConfigWindow
, 0);
913 get(nch
->nch_App
, MUIA_Application_Iconified
, &iconify
);
914 set(nch
->nch_MainWindow
, MUIA_Window_Open
, TRUE
);
915 get(nch
->nch_MainWindow
, MUIA_Window_Open
, &isopen
);
916 if(!(isopen
|| iconify
))
918 nGUITaskCleanup(nch
);
924 retid
= DoMethod(nch
->nch_App
, MUIM_Application_NewInput
, &sigs
);
928 case ID_STORE_CONFIG
:
929 case MUIV_Application_ReturnID_Quit
:
930 get(nch
->nch_WheelmouseObj
, MUIA_Selected
, &nch
->nch_CDC
->cdc_Wheelmouse
);
932 if(retid
== ID_DEF_CONFIG
)
934 pic
= psdGetClsCfg(libname
);
937 psdSetClsCfg(libname
, NULL
);
938 pic
= psdGetClsCfg(libname
);
942 if(psdAddCfgEntry(pic
, nch
->nch_CDC
))
944 psdSaveCfgToDisk(NULL
, FALSE
);
948 if(nch
->nch_Interface
)
950 pic
= psdGetUsbDevCfg(libname
, nch
->nch_DevIDString
, nch
->nch_IfIDString
);
953 psdSetUsbDevCfg(libname
, nch
->nch_DevIDString
, nch
->nch_IfIDString
, NULL
);
954 pic
= psdGetUsbDevCfg(libname
, nch
->nch_DevIDString
, nch
->nch_IfIDString
);
958 if(psdAddCfgEntry(pic
, nch
->nch_CDC
))
960 if(retid
!= MUIV_Application_ReturnID_Quit
)
962 psdSaveCfgToDisk(NULL
, FALSE
);
964 retid
= MUIV_Application_ReturnID_Quit
;
968 retid
= MUIV_Application_ReturnID_Quit
;
973 MUI_RequestA(nch
->nch_App
, nch
->nch_MainWindow
, 0, NULL
, "Blimey!", VERSION_STRING
, NULL
);
976 if(retid
== MUIV_Application_ReturnID_Quit
)
982 sigs
= Wait(sigs
| sigmask
| SIGBREAKF_CTRL_C
);
983 if(sigs
& SIGBREAKF_CTRL_C
)
989 set(nch
->nch_MainWindow
, MUIA_Window_Open
, FALSE
);
991 nGUITaskCleanup(nch
);
997 /* /// "nGUITaskCleanup()" */
998 void nGUITaskCleanup(struct NepClassHid
*nch
)
1002 MUI_DisposeObject(nch
->nch_App
);
1003 nch
->nch_App
= NULL
;
1007 CloseLibrary(MUIMasterBase
);
1008 MUIMasterBase
= NULL
;
1012 CloseLibrary(IntuitionBase
);
1013 IntuitionBase
= NULL
;
1021 nch
->nch_GUIBinding
= NULL
;
1022 nch
->nch_GUITask
= NULL
;
1023 if(nch
->nch_ReadySigTask
)
1025 Signal(nch
->nch_ReadySigTask
, 1L<<nch
->nch_ReadySignal
);
1027 --nch
->nch_ClsBase
->nh_Library
.lib_OpenCnt
;