Пример #1
0
// ========================================================
int sys_conread (void) {
    return keyboard_poll ();
}
Пример #2
0
void pollKeyboard(void)
{
	KeyboardEvent e;
    
	// controller ranges:
	const int chan_begin= 0, chan_end= 7;
	const int chana_begin= 16, chana_end= 23;

	while(keyboard_poll(&e)) 
	{

		
		printf("%d %d %d\n", e.x, e.y, e.type);
//		fflush(stdout);
		
		if(e.type>>4 == 0x0b)	// control change
		{
			if( (e.x>=chan_begin) && (e.x<=chan_end) )
				chan[e.x-chan_begin]= e.y;
			else if( (e.x>=chana_begin) && (e.x<=chana_end) )
				chana[e.x-chana_begin]= e.y;
			else if((e.x >= 32)&&(e.x <= 39)&&(e.y == 127))
			{
		
				if(e.x < 32+animationcount)
				{
					for(uint8_t i = 32;i <= 39;i++)
					{
						keyboard_send(176,i,0);
					}
					for(uint8_t i = 48;i <= 55;i++)
					{
						keyboard_send(176,i,0);
					}
					for(uint8_t i = 64;i <= 71;i++)
					{
						keyboard_send(176,i,0);
					}
					keyboard_send(176,e.x,127);
				}
				
				
				button(e.x-32);
			}
			else if((e.x >= 48)&&(e.x <= 55)&&(e.y == 127))
			{
		
				if(e.x < 40+animationcount)
				{
					for(uint8_t i = 32;i <= 39;i++)
					{
						keyboard_send(176,i,0);
					}
					for(uint8_t i = 48;i <= 55;i++)
					{
						keyboard_send(176,i,0);
					}
					for(uint8_t i = 64;i <= 71;i++)
					{
						keyboard_send(176,i,0);
					}
					keyboard_send(176,e.x,127);
				}
				
				
				button(e.x-40);
			}
			else if((e.x >= 64)&&(e.x <= 71)&&(e.y == 127))
			{
		
				if(e.x < 48+animationcount)
				{
					for(uint8_t i = 32;i <= 39;i++)
					{
						keyboard_send(176,i,0);
					}
					for(uint8_t i = 48;i <= 55;i++)
					{
						keyboard_send(176,i,0);
					}
					for(uint8_t i = 64;i <= 71;i++)
					{
						keyboard_send(176,i,0);
					}
					keyboard_send(176,e.x,127);
				}
				
				
				button(e.x-48);
			}
		}
	}
}
Пример #3
0
void keyboard_wait(void) {
	while (!keyboard_ready()) {
		keyboard_poll();
		_delay_us(KEYBOARD_DEBOUNCE_WAIT_TIME);
	}
}