bool_t _gmouseInitDriver(GDriver *g, void *display, unsigned driverinstance, unsigned systeminstance) {
    #define m   ((GMouse *)g)
    (void) systeminstance;

	// The initial display is passed in the parameter for mice
	m->display = display;

	#if !GINPUT_TOUCH_NOTOUCH
		// Should this mouse start in finger mode? (according to the VMT)
		if ((gmvmt(m)->d.flags & GMOUSE_VFLG_DEFAULTFINGER))
			m->flags |= GMOUSE_FLG_FINGERMODE;
	#endif

	// Init the mouse
    if (!gmvmt(m)->init((GMouse *)g, driverinstance))
        return FALSE;

	// Ensure the Poll timer is started
	if (!gtimerIsActive(&MouseTimer))
		gtimerStart(&MouseTimer, MousePoll, 0, TRUE, GINPUT_MOUSE_POLL_PERIOD);

    return TRUE;

    #undef m
}
Beispiel #2
0
bool_t gadcLowSpeedStart(uint32_t physdev, adcsample_t *buffer, GADCCallbackFunction fn, void *param) {
	struct lsdev *p;

	DoInit();

	/* Start the Low Speed Timer */
	chMtxLock(&gadcmutex);
	if (!gtimerIsActive(&LowSpeedGTimer))
		gtimerStart(&LowSpeedGTimer, LowSpeedGTimerCallback, NULL, TRUE, TIME_INFINITE);

	/* Find a slot */
	for(p = ls; p < &ls[GADC_MAX_LOWSPEED_DEVICES]; p++) {
		if (!(p->flags & GADC_FLG_ISACTIVE)) {
			/* We know we have a slot - this should never wait anyway */
			chSemWaitTimeout(&gadcsem, TIME_IMMEDIATE);
			p->lld.physdev = physdev;
			p->lld.buffer = buffer;
			p->fn = fn;
			p->param = param;
			p->flags = GADC_FLG_ISACTIVE;
			chMtxUnlock();
			StartADC(FALSE);
			return TRUE;
		}
	}
	chMtxUnlock();
	return FALSE;
}
Beispiel #3
0
	GSourceHandle gadcHighSpeedGetSource(void) {
		DoInit();
		if (!gtimerIsActive(&HighSpeedGTimer))
			gtimerStart(&HighSpeedGTimer, HighSpeedGTimerCallback, NULL, TRUE, TIME_INFINITE);
		hs.flags |= GADC_FLG_GTIMER;
		return (GSourceHandle)&HighSpeedGTimer;
	}
Beispiel #4
0
bool_t _gkeyboardInitDriver(GDriver *g, void *param, unsigned driverinstance, unsigned systeminstance) {
#define k   ((GKeyboard *)g)
    (void) param;
    (void) systeminstance;

    // The initial keyboard layout comes from the VMT
    k->pLayout = gkvmt(k)->defLayout;

    // Init the mouse
    if (!gkvmt(k)->init((GKeyboard *)g, driverinstance))
        return FALSE;

    // Ensure the Poll timer is started
    if (!gtimerIsActive(&KeyboardTimer))
        gtimerStart(&KeyboardTimer, KeyboardPoll, 0, TRUE, GINPUT_KEYBOARD_POLL_PERIOD);

    return TRUE;

#undef k
}
Beispiel #5
0
void gadcLowSpeedGet(uint32_t physdev, adcsample_t *buffer) {
	struct lsdev *p;
	BSEMAPHORE_DECL(mysem, TRUE);

	/* Start the Low Speed Timer */
	chMtxLock(&gadcmutex);
	if (!gtimerIsActive(&LowSpeedGTimer))
		gtimerStart(&LowSpeedGTimer, LowSpeedGTimerCallback, NULL, TRUE, TIME_INFINITE);
	chMtxUnlock();

	while(1) {
		/* Wait for an available slot */
		chSemWait(&gadcsem);

		/* Find a slot */
		chMtxLock(&gadcmutex);
		for(p = ls; p < &ls[GADC_MAX_LOWSPEED_DEVICES]; p++) {
			if (!(p->flags & GADC_FLG_ISACTIVE)) {
				p->lld.physdev = physdev;
				p->lld.buffer = buffer;
				p->fn = BSemSignalCallback;
				p->param = &mysem;
				p->flags = GADC_FLG_ISACTIVE;
				chMtxUnlock();
				StartADC(FALSE);
				chBSemWait(&mysem);
				return;
			}
		}
		chMtxUnlock();

		/**
		 *  We should never get here - the count semaphore must be wrong.
		 *  Decrement it and try again.
		 */
	}
}
Beispiel #6
0
GSourceHandle ginputGetDial(uint16_t instance) {
	struct DialStatus_t *pds;

	if (instance >= GINPUT_DIAL_NUM_PORTS)
		return 0;

	// Do we need to initialise the dial subsystem?
	if (!gtimerIsActive(&DialTimer)) {
		for(pds = DialStatus; pds < DialStatus+GINPUT_DIAL_NUM_PORTS; pds++) {
			pds->max = GINPUT_DIAL_MAX_VALUE;
#if GINPUT_DIAL_MAX_VALUE < 100
			pds->sensitivity = 1;
#else
			pds->sensitivity = GINPUT_DIAL_MAX_VALUE/100;
#endif
			pds->lastvalue = 0;
		}
		ginput_lld_dial_init();
		gtimerStart(&DialTimer, (GTimerFunction)ginput_lld_dial_poll, DialCallback, TRUE, GINPUT_DIAL_POLL_PERIOD);
	}

	// OK - return this input
	return (GSourceHandle)(DialStatus+instance);
}
Beispiel #7
0
	GSourceHandle gaudinGetSource(void) {
		if (!gtimerIsActive(&AudGTimer))
			gtimerStart(&AudGTimer, AudGTimerCallback, NULL, TRUE, TIME_INFINITE);
		audFlags |= AUDFLG_USE_EVENTS;
		return (GSourceHandle)&aud;
	}