*/ if (strncasecmp("RAW", iofs->io_Union.io_OpenDevice.io_DosName, 4)) iofs->IOFS.io_Unit = (struct Unit *)1; /* Set returncode */ iofs->IOFS.io_Error=0; /* Mark Message as recently used. */ iofs->IOFS.io_Message.mn_Node.ln_Type=NT_REPLYMSG; return TRUE; } /****************************************************************************************/ ADD2INITLIB(GM_UNIQUENAME(Init),0) ADD2OPENDEV(GM_UNIQUENAME(Open),0) /****************************************************************************************/ static LONG open_con(struct conbase *conbase, struct IOFileSys *iofs) { struct filehandle *fh = (struct filehandle *)iofs->IOFS.io_Unit; STRPTR filename = iofs->io_Union.io_OPEN.io_Filename; #if DEBUG ULONG mode = iofs->io_Union.io_OPEN.io_FileMode; #endif struct conTaskParams params; struct Task *contask; LONG err = 0;
/* /// "nHIDCtrlGUITask()" */ AROS_UFH0(void, GM_UNIQUENAME(nHIDCtrlGUITask)) { AROS_USERFUNC_INIT struct Task *thistask; struct NepHidBase *nh; struct NepClassHid *nch; thistask = FindTask(NULL); #undef ps #define ps nch->nch_HCPsdBase #undef IntuitionBase #define IntuitionBase nch->nch_HCIntBase #undef MUIMasterBase #define MUIMasterBase nch->nch_HCMUIBase nch = thistask->tc_UserData; nch->nch_HCGUITask = thistask; nh = nch->nch_ClsBase; ++nh->nh_Library.lib_OpenCnt; NewList(&nch->nch_HCGUIItems); if(!(MUIMasterBase = OpenLibrary(MUIMASTER_NAME, MUIMASTER_VMIN))) { KPRINTF(10, ("Couldn't open muimaster.library.\n")); GM_UNIQUENAME(nHIDCtrlGUITaskCleanup)(nch); return; } if(!(IntuitionBase = OpenLibrary("intuition.library", 39))) { KPRINTF(10, ("Couldn't open intuition.library.\n")); GM_UNIQUENAME(nHIDCtrlGUITaskCleanup)(nch); return; } if(!(ps = OpenLibrary("poseidon.library", 4))) { KPRINTF(10, ("Couldn't open poseidon.library.\n")); GM_UNIQUENAME(nHIDCtrlGUITaskCleanup)(nch); return; } nch->nch_HCActionClass = MUI_CreateCustomClass(NULL, MUIC_Area , NULL, sizeof(struct ActionData), GM_UNIQUENAME(HCActionDispatcher)); if(!nch->nch_HCActionClass) { KPRINTF(10, ("Couldn't create ActionClass.\n")); GM_UNIQUENAME(nHIDCtrlGUITaskCleanup)(nch); return; } nch->nch_HCApp = ApplicationObject, MUIA_Application_Title , (IPTR)nch->nch_CDC->cdc_HIDCtrlTitle, MUIA_Application_Version , (IPTR)VERSION_STRING, MUIA_Application_Copyright , (IPTR)"©2002-2009 Chris Hodges", MUIA_Application_Author , (IPTR)"Chris Hodges <*****@*****.**>", MUIA_Application_Description, (IPTR)"HID Device Output Control", MUIA_Application_Base , (IPTR)nch->nch_CDC->cdc_HIDCtrlRexx, MUIA_Application_HelpFile , (IPTR)"HELP:Poseidon.guide", MUIA_Application_Menustrip , (IPTR)MenustripObject, Child, (IPTR)MenuObjectT((IPTR)"Project"), Child, (IPTR)(nch->nch_HCAboutMI = MenuitemObject, MUIA_Menuitem_Title, (IPTR)"About...", MUIA_Menuitem_Shortcut, (IPTR)"?", End), Child, (IPTR)MenuitemObject, MUIA_Menuitem_Title, (IPTR)NM_BARLABEL, End, Child, (IPTR)(nch->nch_HCCloseMI = MenuitemObject, MUIA_Menuitem_Title, (IPTR)"Hide", MUIA_Menuitem_Shortcut, (IPTR)"H", End), End, Child, (IPTR)MenuObjectT((IPTR)"Settings"), Child, (IPTR)(nch->nch_HCMUIPrefsMI = MenuitemObject, MUIA_Menuitem_Title, (IPTR)"MUI Settings", MUIA_Menuitem_Shortcut, (IPTR)"M", End), End, End, SubWindow, (IPTR)(nch->nch_HCMainWindow = WindowObject, MUIA_Window_ID , MAKE_ID('H','C','T','L'), MUIA_Window_Title, (IPTR)nch->nch_CDC->cdc_HIDCtrlTitle, MUIA_HelpNode, (IPTR)GM_UNIQUENAME(libname), WindowContents, (IPTR)VGroup, Child, (IPTR)(nch->nch_HCActionObj = NewObject(nch->nch_HCActionClass->mcc_Class, 0, MUIA_ShowMe, FALSE, TAG_END)), Child, (IPTR)(nch->nch_HCGroupObj = ColGroup(4), End), Child, (IPTR)(nch->nch_HCCloseObj = TextObject, ButtonFrame, MUIA_Background, MUII_ButtonBack, MUIA_CycleChain, 1, MUIA_InputMode, MUIV_InputMode_RelVerify, MUIA_Text_Contents, (IPTR)"\33c Hide ", End), End, End), End; if(!nch->nch_HCApp) { KPRINTF(10, ("Couldn't create application\n")); GM_UNIQUENAME(nHIDCtrlGUITaskCleanup)(nch); return; } { struct ActionData *ad = INST_DATA(nch->nch_HCActionClass->mcc_Class, nch->nch_HCActionObj); ad->ad_NCH = nch; } /* add items */ { struct NepHidReport *nhr; struct NepHidItem **nhiptr; struct NepHidItem *nhi; struct NepHidGItem *nhgi; UWORD count; Object *obj; UWORD numobj = 0; nhr = (struct NepHidReport *) nch->nch_HidReports.lh_Head; while(nhr->nhr_Node.ln_Succ) { if((count = nhr->nhr_OutItemCount)) { nhiptr = nhr->nhr_OutItemMap; if(nhiptr) { do { nhi = *nhiptr++; obj = NULL; nhgi = NULL; if(nhi->nhi_Flags & RPF_MAIN_VARIABLE) { if(nhi->nhi_Flags & RPF_MAIN_RELATIVE) { if((nhi->nhi_LogicalMin == 0) && (nhi->nhi_LogicalMax == 1)) { if((nhgi = nAllocGHCItem(nch, nhi, NULL, nhi->nhi_Usage))) { /* one shot */ obj = VGroup, Child, (IPTR)VSpace(0), Child, (IPTR)(nhgi->nhgi_GUIObj = TextObject, ButtonFrame, MUIA_Background, MUII_ButtonBack, MUIA_CycleChain, 1, MUIA_InputMode, MUIV_InputMode_RelVerify, MUIA_Text_PreParse, (IPTR)"\33c", MUIA_Text_Contents, (IPTR)nhgi->nhgi_Name, End), Child, (IPTR)VSpace(0), End; nhgi->nhgi_ObjType = NHGIOT_SHOTBUTTON; } } else if(nhi->nhi_LogicalMin < 0) { if((nhgi = nAllocGHCItem(nch, nhi, NULL, nhi->nhi_Usage))) { /* Horizontal slider */ obj = VGroup, Child, (IPTR)VSpace(0), Child, (IPTR)HGroup, Child, (IPTR)Label((IPTR)nhgi->nhgi_Name), Child, (IPTR)(nhgi->nhgi_GUIObj = SliderObject, SliderFrame, MUIA_Slider_Horiz, TRUE, MUIA_CycleChain, 1, MUIA_InputMode, MUIV_InputMode_Immediate, MUIA_Numeric_Min, nhi->nhi_LogicalMin, MUIA_Numeric_Max, nhi->nhi_LogicalMax, MUIA_Numeric_Value, nhi->nhi_OldValue, End), End, Child, (IPTR)VSpace(0), End; nhgi->nhgi_ObjType = NHGIOT_SLIDERIMM; } } else { if((nhgi = nAllocGHCItem(nch, nhi, NULL, nhi->nhi_Usage))) { /* Vertical slider */ obj = HGroup, Child, (IPTR)HSpace(0), Child, (IPTR)VGroup, Child, (IPTR)(nhgi->nhgi_GUIObj = SliderObject, SliderFrame, MUIA_Slider_Horiz, FALSE, MUIA_CycleChain, 1, MUIA_InputMode, MUIV_InputMode_Immediate, MUIA_Numeric_Min, nhi->nhi_LogicalMin, MUIA_Numeric_Max, nhi->nhi_LogicalMax, MUIA_Numeric_Value, nhi->nhi_OldValue, End), Child, (IPTR)Label((IPTR)nhgi->nhgi_Name), End, Child, (IPTR)HSpace(0), End; nhgi->nhgi_ObjType = NHGIOT_SLIDERIMM; } } } else { if((nhi->nhi_LogicalMin == 0) && (nhi->nhi_LogicalMax == 1)) { if((nhgi = nAllocGHCItem(nch, nhi, NULL, nhi->nhi_Usage))) { /* toggle button */ obj = VGroup, Child, (IPTR)VSpace(0), Child, (IPTR)(nhgi->nhgi_GUIObj = TextObject, ButtonFrame, MUIA_Background, MUII_ButtonBack, MUIA_CycleChain, 1, MUIA_InputMode, MUIV_InputMode_Toggle, MUIA_Text_PreParse, (IPTR)"\33c", MUIA_Text_Contents, (IPTR)nhgi->nhgi_Name, End), Child, (IPTR)VSpace(0), End; nhgi->nhgi_ObjType = NHGIOT_TOGGLEBUTTON; } } else if(nhi->nhi_LogicalMin < 0) { if((nhgi = nAllocGHCItem(nch, nhi, NULL, nhi->nhi_Usage))) { /* Horizontal slider */ obj = VGroup, Child, (IPTR)VSpace(0), Child, (IPTR)HGroup, Child, (IPTR)Label((IPTR)nhgi->nhgi_Name), Child, (IPTR)(nhgi->nhgi_GUIObj = SliderObject, SliderFrame, MUIA_Slider_Horiz, TRUE, MUIA_CycleChain, 1, MUIA_Numeric_Min, nhi->nhi_LogicalMin, MUIA_Numeric_Max, nhi->nhi_LogicalMax, MUIA_Numeric_Value, nhi->nhi_OldValue, End), End, Child, (IPTR)VSpace(0), End; nhgi->nhgi_ObjType = NHGIOT_SLIDER; } } else { if((nhgi = nAllocGHCItem(nch, nhi, NULL, nhi->nhi_Usage))) { /* Vertical slider */ obj = HGroup, Child, (IPTR)HSpace(0), Child, (IPTR)VGroup, Child, (IPTR)(nhgi->nhgi_GUIObj = SliderObject, SliderFrame, MUIA_Slider_Horiz, FALSE, MUIA_CycleChain, 1, MUIA_Numeric_Min, nhi->nhi_LogicalMin, MUIA_Numeric_Max, nhi->nhi_LogicalMax, MUIA_Numeric_Value, nhi->nhi_OldValue, End), Child, (IPTR)Label(nhgi->nhgi_Name), End, Child, (IPTR)HSpace(0), End; nhgi->nhgi_ObjType = NHGIOT_SLIDER; } } } } if(obj) { DoMethod(nch->nch_HCGroupObj, OM_ADDMEMBER, obj); switch(nhgi->nhgi_ObjType) { case NHGIOT_SHOTBUTTON: DoMethod(nhgi->nhgi_GUIObj, MUIM_Notify, MUIA_Pressed, FALSE, nch->nch_HCActionObj, 2, MUIM_Action_UpdateHIDCtrl, nhgi); break; case NHGIOT_TOGGLEBUTTON: DoMethod(nhgi->nhgi_GUIObj, MUIM_Notify, MUIA_Selected, MUIV_EveryTime, nch->nch_HCActionObj, 2, MUIM_Action_UpdateHIDCtrl, nhgi); break; case NHGIOT_SLIDERIMM: DoMethod(nhgi->nhgi_GUIObj, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, nch->nch_HCActionObj, 2, MUIM_Action_UpdateHIDCtrl, nhgi); break; case NHGIOT_SLIDER: DoMethod(nhgi->nhgi_GUIObj, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime, nch->nch_HCActionObj, 2, MUIM_Action_UpdateHIDCtrl, nhgi); break; } numobj++; } } while(--count); } } nhr = (struct NepHidReport *) nhr->nhr_Node.ln_Succ; } if(!numobj) { DoMethod(nch->nch_HCGroupObj, OM_ADDMEMBER, Label("No output items in this interface!")); } } DoMethod(nch->nch_HCMainWindow, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, nch->nch_HCActionObj, 1, MUIM_Action_HideHIDControl); DoMethod(nch->nch_HCCloseObj, MUIM_Notify, MUIA_Pressed, FALSE, nch->nch_HCActionObj, 1, MUIM_Action_HideHIDControl); DoMethod(nch->nch_HCAboutMI, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, nch->nch_HCActionObj, 1, MUIM_Action_About); DoMethod(nch->nch_HCCloseMI, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, nch->nch_HCActionObj, 1, MUIM_Action_HideHIDControl); DoMethod(nch->nch_HCMUIPrefsMI, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, nch->nch_HCApp, 2, MUIM_Application_OpenConfigWindow, 0); { IPTR isopen = 0; IPTR iconify = 0; ULONG sigs; ULONG sigmask; LONG retid; if(nch->nch_CDC->cdc_HIDCtrlOpen) { get(nch->nch_HCApp, MUIA_Application_Iconified, &iconify); set(nch->nch_HCMainWindow, MUIA_Window_Open, TRUE); get(nch->nch_HCMainWindow, MUIA_Window_Open, &isopen); if(!(isopen || iconify)) { GM_UNIQUENAME(nHIDCtrlGUITaskCleanup)(nch); return; } } sigmask = 0; do { retid = DoMethod(nch->nch_HCApp, MUIM_Application_NewInput, &sigs); if(sigs) { sigs = Wait(sigs | sigmask | SIGBREAKF_CTRL_C); if(sigs & SIGBREAKF_CTRL_C) { break; } } } while(retid != MUIV_Application_ReturnID_Quit); set(nch->nch_HCMainWindow, MUIA_Window_Open, FALSE); } GM_UNIQUENAME(nHIDCtrlGUITaskCleanup)(nch); AROS_USERFUNC_EXIT }
if (!--unit->usecount) { Remove(&unit->n); /* The task will free its unit structure itself */ Signal(unit->port->mp_SigTask, SIGBREAKF_CTRL_C); } ReleaseSemaphore(&hdskBase->sigsem); return TRUE; } /****************************************************************************************/ ADD2INITLIB(GM_UNIQUENAME(Init), -5) ADD2EXPUNGELIB(HostDisk_Cleanup, -5); ADD2OPENDEV(GM_UNIQUENAME(Open), 0) ADD2CLOSEDEV(GM_UNIQUENAME(Close), 0) /****************************************************************************************/ static const UWORD NSDSupported[] = { // CMD_RESET, CMD_READ, CMD_WRITE, CMD_UPDATE, CMD_CLEAR, // CMD_STOP, // CMD_START, CMD_FLUSH,
static int GM_UNIQUENAME(Open)(LIBBASETYPEPTR hdskBase, struct IOExtTD *iotd, IPTR unitnum, ULONG flags) { STRPTR unitname; struct unit *unit; UBYTE unitflags = 0; if (unitnum < 1024) { ULONG len = strlen(hdskBase->DiskDevice) + 5; unitname = AllocVec(len, MEMF_ANY); if (!unitname) return FALSE; unitflags = UNIT_FREENAME; NewRawDoFmt(hdskBase->DiskDevice, (VOID_FUNC)RAWFMTFUNC_STRING, unitname, unitnum + hdskBase->unitBase); } else unitname = (STRPTR)unitnum; D(bug("hostdisk: open unit %s\n", unitname)); ObtainSemaphore(&hdskBase->sigsem); unit = (struct unit *)FindName(&hdskBase->units, unitname); if (unit) { unit->usecount++; ReleaseSemaphore(&hdskBase->sigsem); iotd->iotd_Req.io_Unit = (struct Unit *)unit; iotd->iotd_Req.io_Error = 0; iotd->iotd_Req.io_Message.mn_Node.ln_Type = NT_REPLYMSG; DOPEN(bug("hostdisk: in libopen func. Yep. Unit is already open\n")); return TRUE; } DOPEN(bug("hostdisk: in libopen func. No, it is not. So creating new unit ...\n")); unit = (struct unit *)AllocMem(sizeof(struct unit), MEMF_PUBLIC | MEMF_CLEAR); if (unit != NULL) { ULONG p = strlen(GM_UNIQUENAME(LibName)); char taskName[p + strlen(unitname) + 2]; struct Task *unitTask; DOPEN(bug("hostdisk: in libopen func. Allocation of unit memory okay. Setting up unit and calling CreateNewProc ...\n")); CopyMem(GM_UNIQUENAME(LibName), taskName, p); taskName[p] = ' '; strcpy(&taskName[p + 1], unitname); unit->n.ln_Name = unitname; unit->usecount = 1; unit->hdskBase = hdskBase; unit->flags = unitflags; NEWLIST((struct List *)&unit->changeints); iotd->iotd_Req.io_Unit = (struct Unit *)unit; SetSignal(0, SIGF_SINGLE); unitTask = NewCreateTask(TASKTAG_PC , unitentry, TASKTAG_NAME, taskName, TASKTAG_ARG1, iotd, TAG_DONE); DOPEN(bug("hostdisk: in libopen func. NewCreateTask() called. Task = 0x%p\n", unitTask)); if (unitTask) { DOPEN(bug("hostdisk: in libopen func. Waiting for signal from unit task...\n")); Wait(SIGF_SINGLE); DOPEN(bug("hostdisk: in libopen func. Unit error %u, flags 0x%02X\n", iotd->iotd_Req.io_Error, unit->flags)); if (!iotd->iotd_Req.io_Error) { AddTail((struct List *)&hdskBase->units, &unit->n); ReleaseSemaphore(&hdskBase->sigsem); return TRUE; } } else iotd->iotd_Req.io_Error = TDERR_NoMem; freeUnit(unit); } else iotd->iotd_Req.io_Error = TDERR_NoMem; ReleaseSemaphore(&hdskBase->sigsem); return FALSE; }
case UNIT_WAITUNTIL: case UNIT_MICROHZ: case UNIT_ECLOCK: case UNIT_WAITECLOCK: tr->tr_node.io_Error = 0; tr->tr_node.io_Unit = (struct Unit *)unitNum; tr->tr_node.io_Device = (struct Device *)LIBBASE; break; default: tr->tr_node.io_Error = IOERR_OPENFAIL; } return TRUE; } /****************************************************************************************/ static int GM_UNIQUENAME(Expunge)(LIBBASETYPEPTR LIBBASE) { outb((inb(0x61) & 0xfd) | 1, 0x61); /* Enable the timer (set GATE on) */ RemIntServer(INTB_VERTB, &LIBBASE->tb_VBlankInt); return TRUE; } /****************************************************************************************/ ADD2INITLIB(GM_UNIQUENAME(Init), 0) ADD2OPENDEV(GM_UNIQUENAME(Open), 0) ADD2EXPUNGELIB(GM_UNIQUENAME(Expunge), 0)