View Single Post
Old 04 May 2021, 01:37   #26
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,479
Quote:
Originally Posted by alpine9000 View Post
As well as registering an input handler to null out any input events, you would also probably want to set the pr_WindowPtr of the current Process/Task to -1 to stop any requesters silently waiting behind the screen. Don't forget to restore the pr_WindowPtr pointer as well when you're done (if it's not already -1).
Yep, this is in my trap events handler and contain pr_WindowPtr=-1 setup:
Code:
	include LVOs.i
	include exec/execbase.i
	include	exec/tasks.i
	include dos/dosextens.i
	include	devices/input.i
	include	devices/inputevent.i


trap_events

	movea.l	$4.w,a6
	lea	ioreq(pc),a4
	movea.l	ThisTask(a6),a5

	; hide possible requesters since user has no way to
	; see or close them.
	moveq	#-1,d0
	movea.l	pr_WindowPtr(a5),a3	; oldwinptr
	move.l	d0,pr_WindowPtr(a5)

allocSignal
;	moveq	#-1,d0
	jsr	_LVOAllocSignal(a6)
	move.b	d0,sigbit-ioreq(a4)
	bmi.b	nosig
	move.l	d0,d7

gotsignal
	move.l	a5,sigtask-ioreq(a4)

	; open input.device
	lea	inputname-ioreq(a4),a0
	moveq	#0,d0
	moveq	#0,d1
	lea	(a4),a1					; ioreq
	jsr	_LVOOpenDevice(a6)
	tst.l	d0
	bne.b	nodev


	; install inputhandler
install
	lea	(a4),a1					; ioreq
	jsr	_LVODoIO(a6)

;**************************
.ll	move.w	$dff006,$dff180
	btst	#6,$bfe001
	bne.b	.ll
;**************************
	
	; remove inputhandler
	lea	(a4),a1					; ioreq
	move.w	#IND_REMHANDLER,IO_COMMAND(a1)
	jsr	_LVODoIO(a6)

	lea	(a4),a1					; ioreq
	jsr	_LVOCloseDevice(a6)

nodev
	move.l	d7,d0				; sigbit
	jsr	_LVOFreeSignal(a6)

nosig
	move.l	a3,pr_WindowPtr(a5)	; oldwinptr
	moveq	#0,d0
	rts


ih_code
	move.l	a0,d0
.loop
	cmpi.b	#IECLASS_TIMER,ie_Class(a0)
	beq.b	.skip				; keep only TIMER events
	clr.b	ie_Class(a0)		; #IECLASS_NULL
.skip:
	move.l	(a0),a0
	move.l	a0,d1
	bne.b	.loop
	rts							; d0 is the original a0


ioreq
	dc.l	0,0				; LN_SUCC, LN_PRED
	dc.b	NT_REPLYMSG,0	; LN_TYPE, LN_PRI
	dc.l	0				; LN_NAME
	dc.l	msgport			; MN_REPLYPORT
	dc.w	IOSTD_SIZE		; MN_LENGTH
	dc.l	0				; IO_DEVICE
	dc.l	0				; IO_UNIT
	dc.w	IND_ADDHANDLER	; IO_COMMAND
	dc.b	0,0				; IO_FLAGS, IO_ERROR
	dc.l	0				; IO_ACTUAL
	dc.l	0				; IO_LENGTH
	dc.l	ih_is			; IO_DATA
	dc.l	0				; IO_OFFSET

ih_is
	dc.l	0,0				; LN_SUCC, LN_PRED
	dc.b	NT_INTERRUPT,127; LN_TYPE, LN_PRI ** highest priority ** 
	dc.l	0				; LN_NAME	;ihname
	dc.l	0				; IS_DATA
	dc.l	ih_code			; IS_CODE
	
msgport
	dc.l	0,0				; LN_SUCC, LN_PRED
	dc.b	NT_MSGPORT,0	; LN_TYPE, LN_PRI
	dc.l	0				; LN_NAME
	dc.b	PA_SIGNAL		; MP_FLAGS
sigbit
	dc.b	-1				; MP_SIGBIT
sigtask
	dc.l	0				; MP_SIGTASK
.head
	dc.l	.tail			; MLH_HEAD
.tail
	dc.l	0				; MLH_TAIL
	dc.l	.head			; MLH_TAILPRED
	dc.b	NT_MSGPORT,0	; MLH_TYPE, MLH_pad

;ih_name
;	dc.b	'trap-events',0
inputname
	dc.b	'input.device',0

	even
I keep the TIMER events, I remember having problems otherwise.

ross is offline  
 
Page generated in 0.04321 seconds with 11 queries