Ejemplo n.º 1
0
int main(int argc, char **argv){
	struct sockaddr_rc loc_addr = { 0 }, rem_addr = { 0 };
	char buf[1] = { 0 };
	int s, client, bytes_read;
	socklen_t opt = sizeof(rem_addr);
	sdp_session_t *sdp_session;

	//register the service an acquire the session
	sdp_session = register_service();
	
	for(;;){
		// allocate socket
		s = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);

		// bind socket to port 1 of the first available 
		// local bluetooth adapter
		loc_addr.rc_family = AF_BLUETOOTH;
		loc_addr.rc_bdaddr = *BDADDR_ANY;
		loc_addr.rc_channel = (uint8_t) SVC_CHANNEL;
	

		bind(s, (struct sockaddr *)&loc_addr, sizeof(loc_addr));

		// put socket into listening mode
		fprintf(stderr, "listening\n");
		listen(s, 1);

		// accept one connection
		fprintf(stderr, "accepting\n");
		client = accept(s, (struct sockaddr *)&rem_addr, &opt);

		ba2str( &rem_addr.rc_bdaddr, buf );
		fprintf(stderr, "accepted connection from %s\n", buf);
		memset(buf, 0, sizeof(buf));

		// read data from the client
	
		initInput();
		bytes_read = 1;
		while(bytes_read > 0){
			bytes_read = read(client, buf, sizeof(buf));
			scroll(buf[0]);
			printf("received %d\n", buf[0]);
		}	
		deinitInput();

		// close connection
		close(client);
		close(s);		
	}
	
	//close sdp session	
	sdp_close(sdp_session);
	return 0;
}
Ejemplo n.º 2
0
	void OISSubsystem::toggleMouseGrab()
	{
		mGrabbedMouse = !mGrabbedMouse;
		deinitInput();
		initInput(mHandle,mGrabbedMouse);
	}