nanogui: Problem with event capture -- code added


Previous by date: 27 Sep 2005 06:30:36 +0100 flnx-cross compile problem, murali krishna
Next by date: 27 Sep 2005 06:30:36 +0100 flnx callback functions, Marcel Karras
Previous in thread:
Next in thread: 27 Sep 2005 06:30:36 +0100 Re: Problem with event capture -- code added, David Cullen

Subject: Problem with event capture -- code added
From: amareesh ####@####.####
Date: 27 Sep 2005 06:30:36 +0100
Message-Id: <1127799169.30421.35.camel@Amareesh>

Hi,

I have a multithreaded application where Ive put the code for waiting
for keys (using GrGetNextEvent()) in while loop in main().

But problem is that it is not accepting key-events once the code/thread
for making the screen finishes its task and context switches to main().

However, any key pressed during the execution of the 'Drawing thread'
can be captured successfully.

Please tell me if im going wrong anywhere.

Code snippet for main thread is added along with this mail.


/********************************************************/

Following is the part of the code

/**********************************************************/


if (GrOpen() >= 0)
		{
      gc	  	=	GrNewGC();  
			/*Parent window -- all subsequent windows are its childeren */
			g_WindowParent= GrNewWindow(GR_ROOT_WINDOW_ID,

					K_IPSTB_PARENTX,
					K_IPSTB_PARENTY,
					K_IPSTB_PARENTLEN,
					K_IPSTB_PARENTWD,
					K_IPSTB_PARENTBORDERTHICKNESS,
					MWRGB(0,91,160),
			    WHITE);


			/*associating events to the Parent window*/  
			GrSelectEvents(g_WindowParent,
			                 GR_EVENT_MASK_EXPOSURE |
					/*GR_EVENT_TYPE_MOUSE_ENTER*/GR_EVENT_MASK_KEY_DOWN |
					 GR_EVENT_MASK_CLOSE_REQ);

			/*Making visible the Parent window*/
			GrMapWindow(g_WindowParent);
			
			/*setting focus on the parent window */
			GrSetFocus(g_WindowParent);


      /* DUmmy message to inititate the 1st screen */
      msgsnd(g_Resource.m_HapNanoMsgQ_Id,
	 						    (void *) &sendMsg,
							    NANO_MSG_SIZE,
							    IPC_NOWAIT);
      fprintf(stderr,"Key Pressed from OSD is %d",sendMsg.ausMessage[0]);
                                  
			while(1)      /*  while 1 loop to receive the keys */
			{
        printf("I am in Main ");   // check 
				

		/*pending for events */
		GrGetNextEvent(&event);        

       
  			/*passing ascii value of key pressed to chKeypressed*/
				sendMsg.ausMessage[0] =	usRemoteKey;      
        event.type =   GR_EVENT_TYPE_KEY_DOWN;
        
				/*what type of event received , take action accordingly*/
				switch(event.type)	
				{
					case GR_EVENT_TYPE_NONE :
					/* do nothing here  */
			      break;
			
					/*Key is pressed*/
					case GR_EVENT_TYPE_KEY_DOWN :
			                {   
					/*passing ascii value of key pressed to chKeypressed*/
					sendMsg.ausMessage[0] =	(event.keystroke.scancode);   /* (keypoint->ch);   */

										
					/* sending message to the HAP */
					if((msgsnd(g_Resource.m_HapNanoMsgQ_Id,
	 						(HAP_MSG_STRUCT *) &sendMsg,
							NANO_MSG_SIZE,
							IPC_NOWAIT))== -1)


					{
						HlmWriteLog("Message Not sent");
                                        }
       	                                else
					{
             fprintf(stderr,"Key Pressed from OSD is %d",sendMsg.ausMessage[0]);
                                          HlmWriteLog("OSD : Message sent to HAP");
					}
					}
					break;	
					

					
				//	default :
					/* Do Nothing here  */
					//break;
                                 
				}/*switch*/
		
		          } /*	while 1 loop	*/
		 
		}
		else
		{ 
			HlmWriteLog(" Graphics Engine not intitialised  ");
		}


/****************************/

Code snippet ends here..

/*******************************/



THe dummy key is accepted above and corresponding action is taken in the thread to which it is sent.

On completion of the 'Drawing thread ', when control returns; it is NOT receiving any keys from the console.

Please help me on this with suggestions.


------------------------------
Thank You.

Regards,

Amareesh

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s)and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender or ####@####.####

Previous by date: 27 Sep 2005 06:30:36 +0100 flnx-cross compile problem, murali krishna
Next by date: 27 Sep 2005 06:30:36 +0100 flnx callback functions, Marcel Karras
Previous in thread:
Next in thread: 27 Sep 2005 06:30:36 +0100 Re: Problem with event capture -- code added, David Cullen


Powered by ezmlm-browse 0.20.