Exemple #1
0
    NOTES

    EXAMPLE

    BUGS

    SEE ALSO
	RemTask()

    INTERNALS

******************************************************************************/
{
    AROS_LIBFUNC_INIT

    struct Task *t;
    
    D(bug("Call AddTask (%08lx (\"%s\"), %08lx, %08lx)\n"
	, task
	, task->tc_Node.ln_Name
	, initialPC
	, finalPC
    ));

    t = NewAddTask(task, initialPC, finalPC, NULL);
    
    ReturnPtr ("AddTask", struct Task *, t);
    
    AROS_LIBFUNC_EXIT
} /* AddTask */
Exemple #2
0
static int GM_UNIQUENAME(Init)(LIBBASETYPEPTR InputDevice)
{
    NEWLIST( &(InputDevice->HandlerList) );

    /*
	These defaults are in terms of 50 Hz ticks. The real VBlank frequency
	does not effect them.
    */
    InputDevice->KeyRepeatThreshold.tv_secs = DEFAULT_KEY_REPEAT_THRESHOLD / 50;
    InputDevice->KeyRepeatThreshold.tv_micro
	= (DEFAULT_KEY_REPEAT_THRESHOLD % 50) * 1000000 / 50;

    InputDevice->KeyRepeatInterval.tv_secs  = DEFAULT_KEY_REPEAT_INTERVAL / 50;
    InputDevice->KeyRepeatInterval.tv_micro
	= (DEFAULT_KEY_REPEAT_INTERVAL % 50) * 1000000 / 50;

    /* Initialise the input.device task. */
    InputDevice->InputTask = AllocMem(sizeof(struct Task), MEMF_PUBLIC | MEMF_CLEAR);
    if(InputDevice->InputTask)
    {
	struct Task *task = InputDevice->InputTask;
	APTR stack;

	NEWLIST(&task->tc_MemEntry);
	task->tc_Node.ln_Type = NT_TASK;
	task->tc_Node.ln_Name = "input.device";
	task->tc_Node.ln_Pri = IDTASK_PRIORITY;

	/* Initialise CommandPort now we have the task */
	InputDevice->CommandPort.mp_SigTask = task;
	InputDevice->CommandPort.mp_Flags = PA_SIGNAL;
	NEWLIST(&InputDevice->CommandPort.mp_MsgList);
	
	/*
	 *  This is always safe, nobody else knows about our task yet.
	 *  Both the AROS and AmigaOS AddTask() initialise zeroed fields,
	 *  otherwise we have to do it ourselves.
	 */
	InputDevice->CommandPort.mp_SigBit = 16;
	task->tc_SigAlloc = 1L<<16 | SysBase->TaskSigAlloc;

	stack = AllocMem(IDTASK_STACKSIZE, MEMF_CLEAR|MEMF_PUBLIC);
	if(stack != NULL)
	{
#if 1
    	    struct TagItem tags[] =
	    {
	    	{TASKTAG_ARG1, (IPTR)InputDevice},
		{TAG_DONE   	    	    	}
	    };
	    
	    task->tc_SPLower = stack;
	    task->tc_SPUpper = (UBYTE *)stack + IDTASK_STACKSIZE;

    	#if AROS_STACK_GROWS_DOWNWARDS
	    task->tc_SPReg = (UBYTE *)task->tc_SPUpper - SP_OFFSET;
    	#else
	    task->tc_SPReg = (UBYTE *)task->tc_SPLower + SP_OFFSET;
    	#endif

	    if(NewAddTask(task, ProcessEvents, NULL, tags) != NULL)
	    {
		return TRUE;
	    }
#else
	    task->tc_SPLower = stack;
	    task->tc_SPUpper = (UBYTE *)stack + IDTASK_STACKSIZE;

    	#if AROS_STACK_GROWS_DOWNWARDS
	    task->tc_SPReg = (UBYTE *)task->tc_SPUpper - SP_OFFSET - sizeof(APTR);
	    ((APTR *)task->tc_SPUpper)[-1] = InputDevice;
    	#else
	    task->tc_SPReg = (UBYTE *)task->tc_SPLower + SP_OFFSET + sizeof(APTR);
	    ((APTR *)task->tc_SPLower)[0] = InputDevice;
    	#endif

	    if(AddTask(task, ProcessEvents, NULL) != NULL)
	    {
		return TRUE;
	    }
#endif
	}
    }

    Alert(AT_DeadEnd | AG_NoMemory | AO_Unknown | AN_Unknown);
    
    return FALSE;
}