u32 InputDevices::GetPadButtons(void)
{
    int i;
    static u32 prev_buttons = 0;
    static u64 repeat_time = 0;
    u32 buttons;

    buttons = m_wpad[0] | m_wpad[1];

    for( i = 0; keypad[i].code != 0; i++ ) {
        if( GetButtonStatus(keypad[i].key_a) ||
            GetButtonStatus(keypad[i].key_b) ) {
            buttons |= keypad[i].code;
        }
    }

    if( buttons != prev_buttons ) {
        prev_buttons = buttons;
            repeat_time = GetTickCount() + TIME_BEFORE_REPEATING;
            return buttons;
        }
        if( buttons != 0 && GetTickCount() > repeat_time ) {
            repeat_time = GetTickCount() + TIME_BETWEEN_REPEAT;
        return buttons;
    }
    return 0;
}
Exemple #2
0
// wait for a specific character 
void waituntil(int w,int h,int endchar) {
    int key;
int rawX, rawY, rawPressure,i;

	int Toggle=0;
    for (;;) {
	//Start(w,h);
	if (getTouchSample(&rawX, &rawY, &rawPressure)==0) continue;
	printf("x=%d y=%d\n",rawX,rawY);
	if(IsDisplayOn==0)
	{
				
				printf("Display ON\n");
				TransmitStop();
				ReceiveStop();
				init(&wscreen, &hscreen);
				Start(wscreen,hscreen);
				IsDisplayOn=1;			
				
				SelectPTT(15,0);
				SelectPTT(16,0);
				UpdateWindow();
				//usleep(500000);
				continue;
				
	}	
	for(i=0;i<IndexButtonInArray;i++)
	{
		if(IsButtonPushed(i,rawX,rawY)==1)
		{
			
			printf("Button Event %d\n",i);
			if((i>=0)&&(i<=4)) //SR			
			{
				SelectSR(i);
			}
			if((i>=5)&&(i<=9)) //FEC			
			{
				SelectFec(i);
			}
			if((i>=10)&&(i<=14)) //Source			
			{
				SelectSource(i,1);
			}
			if((i>=15)&&(i<=16)) //Source			
			{
				
				printf("Status %d\n",GetButtonStatus(i));
				if((i==15)&&(GetButtonStatus(i)==0))
				{
					
					
					
					usleep(500000);
					SelectPTT(i,1);
					UpdateWindow();
					TransmitStart();
					break;	
				}
				if((i==15)&&(GetButtonStatus(i)==1))
				{
					
						
					TransmitStop();
					usleep(500000);
					SelectPTT(i,0);
					UpdateWindow();	
					break;
				}
				if(i==16)
				{
					printf("DISPLAY OFF \n");
					finish();
					ReceiveStart();
					
					IsDisplayOn=0;
					usleep(500000);
				}

			}
			if(IsDisplayOn==1)
			{
				UpdateWindow();
	//			DrawButton(i);	

	//		End();
			}
			/*if((i==0)&&(GetButtonStatus(i)==0))
			{	
				printf("DISPLAY OFF \n");
				finish();
				IsDisplayOn=0;
			}
			if((i==0)&&(GetButtonStatus(i)==1))
			{	
				printf("DISPLAY ON  \n");
				init(&wscreen, &hscreen);
				Start(wscreen,hscreen);
				IsDisplayOn=1;	
				UpdateWindow();
			}*/
			//FixMe : Add a Antibounce
		}
	}
	//circleCursor(scaledX,h-scaledY);
	

//        key = getchar();
  //      if (key == endchar || key == '\n') {
    //        break;
     //   }
    }
}