void * CaptureUserInput(void * arg) {
	int i;
	
	GetMyDeviceType();
	ReadDeviceKeyDB();
	
	printf("sizeof(struct input_event) = %d\n", sizeof(struct input_event));
	maxEventPlusOne = -1;
			
	for (i=0; i<=MAX_INPUT_FILE_ID; i++) {		
		if (nKeyEntries[i] == 0) {
			inputEvents[i] = -1;
		} else {
			inputEvents[i] = OpenInputDevice(i);
			if (inputEvents[i] > maxEventPlusOne) maxEventPlusOne = inputEvents[i];
		}
	}
	maxEventPlusOne++;	
	
	while (1) {
		if (!HandleEvents()) break;
	}

	printf("Thread CaptureUserInput() exit.\n");

	for (i=0; i<=MAX_INPUT_FILE_ID; i++) {
		CloseInputDevice(i);
	}
	
	return 0;
}
예제 #2
0
int
ProcXCloseDevice(register ClientPtr client)
{
    int i;
    WindowPtr pWin, p1;
    DeviceIntPtr d;

    REQUEST(xCloseDeviceReq);
    REQUEST_SIZE_MATCH(xCloseDeviceReq);

    d = LookupDeviceIntRec(stuff->deviceid);
    if (d == NULL) {
	SendErrorToClient(client, IReqCode, X_CloseDevice, 0, BadDevice);
	return Success;
    }

    if (d->grab && SameClient(d->grab, client))
	(*d->DeactivateGrab) (d);	/* release active grab */

    /* Remove event selections from all windows for events from this device 
     * and selected by this client.
     * Delete passive grabs from all windows for this device.      */

    for (i = 0; i < screenInfo.numScreens; i++) {
	pWin = WindowTable[i];
	DeleteDeviceEvents(d, pWin, client);
	p1 = pWin->firstChild;
	DeleteEventsFromChildren(d, p1, client);
    }

    CloseInputDevice(d, client);
    return Success;
}
int
ProcXCloseDevice(ClientPtr client)
{
    int rc, i;
    WindowPtr pWin, p1;
    DeviceIntPtr d;

    REQUEST(xCloseDeviceReq);
    REQUEST_SIZE_MATCH(xCloseDeviceReq);

    rc = dixLookupDevice(&d, stuff->deviceid, client, DixUseAccess);
    if (rc != Success)
	return rc;

    if (d->deviceGrab.grab && SameClient(d->deviceGrab.grab, client))
	(*d->deviceGrab.DeactivateGrab) (d);	/* release active grab */

    /* Remove event selections from all windows for events from this device
     * and selected by this client.
     * Delete passive grabs from all windows for this device.      */

    for (i = 0; i < screenInfo.numScreens; i++) {
	pWin = WindowTable[i];
	DeleteDeviceEvents(d, pWin, client);
	p1 = pWin->firstChild;
	DeleteEventsFromChildren(d, p1, client);
    }

    CloseInputDevice(d, client);
    return Success;
}
예제 #4
0
파일: user_input.c 프로젝트: 904498910/ARO
void * CaptureUserInput(void * arg) { 
	int i;
	
	__android_log_print(ANDROID_LOG_DEBUG, "Thread CaptureUserInput() ", "pre_getMyDeviceType");
	GetMyDeviceType();
	__android_log_print(ANDROID_LOG_DEBUG, "Thread CaptureUserInput() ", "pre_ReadDeviceKeyDB");
	ReadDeviceKeyDB();
	
	__android_log_print(ANDROID_LOG_DEBUG, "Thread CaptureUserInput() ", "post_ReadDeviceKeyDB");
	printf("sizeof(struct input_event) = %d\n", sizeof(struct input_event));
	maxEventPlusOne = -1;
			
	char aLine[256];
	for (i=0; i<=MAX_INPUT_FILE_ID; i++) {		
		sprintf(aLine, "i = %d", i);
		if (nKeyEntries[i] == 0) {
			inputEvents[i] = -1;
		} else {
			inputEvents[i] = OpenInputDevice(i);
			if (inputEvents[i] > maxEventPlusOne) {
				maxEventPlusOne = inputEvents[i];
				sprintf(aLine, "NOT_EXPECTED: i = %d, inputEvents[i] (%d) > maxEventPlusOne = %d", 
					i, inputEvents[i], maxEventPlusOne);
				#ifdef TEST_INPUT
				WriteUserInputLog("libpcap: b CaptureUserInput() nKeyEntries[i] != 0 ", aLine);
				#endif
			} 
		}
	}
	maxEventPlusOne++;	
	
	while (1) {
		if  (!HandleEvents()) { 
		    #ifdef TEST_INPUT
		    WriteUserInputLog("libpcap: After HandleEvents returns 0 in CaptureUserInput() ", 
					"setting exitFlag = 3 and breaking from loop");
		    #endif
		    exitFlag = 3; 
		    break; 
		}
		if (exitFlag == 4) { 
		    #ifdef TEST_INPUT
		    WriteUserInputLog("libpcap: After HandleEvents exitFlag is 4 ", 
					"setting exitFlag = 3 and breaking from loop");
		    #endif
		    exitFlag = 3; 
		    break; 
		}
	}
	printf("Thread CaptureUserInput() exit.\n");
	__android_log_print(ANDROID_LOG_DEBUG, "Thread CaptureUserInput() exit", "EXIT");
	printf("sizeof(struct input_event) = %d\n", sizeof(struct input_event));
	
	for (i=0; i<=MAX_INPUT_FILE_ID; i++) {
		CloseInputDevice(i);
	}
	CloseUserInputLog();
	return 0;
}