rickf@pnet02.cts.com (Rick Flower) (03/28/89)
I'm attempting to open the console port on a standard window using a regular CUSTOMSCREEN type window.. Anyway, I would like to receive input from the window using the console device, and not the RAWKEY function of Intuition. So, I've been able to open the console for writing to my window, that works without any problems.. Except, now that I'm trying to open the console for reading from the keyboard via my window, as soon as I generate a mask for it from the signal bit it is using, it NEVER returns saying that a key was pressed at all! I've been putzing around with my code for the last week and haven't found ANYTHING that will make it work ok.. So, I've included some of my initialization code and whatnot to take a look at.. Perhaps some of you Asm68k guru's out there could tell me if anything looks wrong [ probably does! (:->) ], or perhaps give me a direction to head myself..? The routines that I've included below are : OpenRdConsole : Opens the read console, ONLY after opening the write console first (it does the OpenDevice call). StartConsoleIO: This starts the console looking for characters (maybe?) WaitForIDCMP : This will supposedly "wait" until a key is pressed.. If you have any suggestions, PLEEZE let me know via either e-mail or here in the form of another message... Thanks MUCHO in advance.. ============================================================================= CODE SNIPPET BELOW ============================================================================= ;---------------------------------------------------------------------------- ;- Open a Console Port for Reading from the Main Window's Keyboard ;---------------------------------------------------------------------------- OpenRdConsole: move.l _SysBase,a6 ; Get the base address of Exec.. move.l #-1,d0 jsr Exec_AllocSignal(a6) ; Attempt to allocate a signal! cmp.l #-1,d0 ; Did it fail?? bne ORC_0 ; If not, continue.. ;----------------------------------------------------------------- ;- If it couldn't get a signal, return with pointer to msg in D0 ;----------------------------------------------------------------- move.l #ConsFail2Msg,d2 ; Get the Fail Msg addr move.l #ConsFail2MsgE,d3 rts ;----------------------------------------------- ;- Create a Message Port for the Console Device ;----------------------------------------------- ORC_0: move.b d0,ConRdSignal ; Save the Signal # lea ConReadPort,a1 ; Load addr of MsgPort structure move.l #ConReadName,LN_NAME(a1) move.b #NT_MESSAGE,LN_TYPE(a1) ; Make it a Message Port move.b #0,LN_PRI(a1) ; Make it a Medium Priority move.l OurTask,MP_SIGTASK(a1) ; Get our task pointer move.b #PA_SIGNAL,MP_FLAGS(a1) ; Setup the Signal Pointer info move.b ConRdSignal,MP_SIGBIT(a1) jsr Exec_AddPort(a6) ; Add the Port! ;---------------------------------------------------------- ;- Initialize the Console Read Data Structure (IOStdReq) ;---------------------------------------------------------- lea ConsoleName,a0 ; Load the addr of Console Name lea ConsoleReadReq,a1 ; Load StdIOReq structure addr move.l #ConReadPort,MN_REPLYPORT(a1) move.l MainWindow,IO_DATA(a1) lea ConsoleWriteReq,a2 ; Load StdIOReq structure Write addr move.l IO_DEVICE(a2),IO_DEVICE(a1) move.l IO_UNIT(a2),IO_UNIT(a1) move.l #0,d2 ; set to OK status.. rts ;------------------------------------------------------------------------ ;- Start the Console Device Looking for Characters from the Keyboard.. ;------------------------------------------------------------------------ StartConsoleIO: movem.l a0-a7/d0-d7,-(sp) lea ConsoleReadReq,a1 move.l #ConReadBuff,IO_DATA(a1) move.l #1,IO_LENGTH(a1) move.w #CMD_READ,IO_COMMAND(a1) move.l _SysBase,a6 jsr Exec_SendIO(a6) movem.l (sp)+,a0-a7/d0-d7 rts ;---------------------------------------------------------------------------- ;- This Routine Will Generate a Correct IDCMP "Wait" Mask and Wait Until ;- Exec Say's that there is an Event to Process! At that Point, it will ;- Return to the Caller for Processing which event happened (in Reg. D0!) ;---------------------------------------------------------------------------- WaitForIDCMP: movem.l d1-d7/a0-a6,-(sp) ; Save ALL Registers! clr.l d0 ; Clear out for shifting.. move.l ConReadPort,a0 ; Get the Console Read Port.. move.b MP_SIGBIT(a0),d0 ; Get the Signal Bit for this Port! moveq.l #1,d1 ; Set a "1" in first bit position lsl.l d0,d1 ; Shift it left "MP_SIGBIT" times.. move.l d1,SigBit_Console ; Save the Signal Bit Indicator ;-------------------------------------------------------------------------- move.l SigBit_Console,d0 ; Get the Console Signal Bit Pos. move.l _SysBase,a6 ; Get the base address of Exec.. jsr Exec_Wait(a6) ; Wait for a Signal from the either! movem.l (sp)+,d1-d7/a0-a6 ; Restore ALL Registers! rts ;--------------------------------------------------------------------------- ;- Global Data Area ;--------------------------------------------------------------------------- SECTION regdata,DATA ConReadName dc.b 'Term87 - Con:R',0 SECTION bssdata,BSS SigBit_Console ds.l $1 ; Signal Bit Position for Console Read Port ConReadPort ds.b $22 ; Bytes for Console Read Port ConsoleReadReq ds.b $30 ; Bytes for Console Read Struct (IOStdReq) ConRdSignal ds.b $1 ; Signal Number for Console Read Port cnop 0,2 ConReadBuff ds.w $1 ; Console Read Channel Key Buffer end =============================================================================== I Thought So... UUCP: {ames!elroy, <backbone>}!gryphon!pnet02!rickf INET: rickf@pnet02.cts.com ===============================================================================