Exemplo n.º 1
0
void interrupt_handler_keyboard(void){
	static int shift = 0;
	uint8_t scancode;
	uint8_t code;
	scancode = inb(0x60);
	switch(scancode)
	{
		case KBD_RIGHTSHIFT:
		case KBD_LEFTSHIFT :
			shift = 1;
			break;
		case KBD_RIGHTSHIFT_RELEASE:
		case KBD_LEFTSHIFT_RELEASE :
			shift = 0;
			break;
		default:
			break;
	}
	code=scancode_to_char(scancode,shift);
	if(code != 0)
	{
		printy("key pressed=%c     ",code);
		keycode=code;
		//attaching scanf
			if(start_buffer==1)
			{	
					
				if(clean_buffer==1)
				{	int i=0;
					count=0;
					for(i=0;i<512;i++)
					{
						buffer[i]='\0';
						return_buffer[i]='\0';
					}
					clean_buffer=0;
				}
				if(code!='\n')
				{
					return_buffer[count]=code;
					buffer[count++]=code;
					//countb=count;
					flag=1;
							
				}
				
				//printy("%c",code);	
				if(code=='\n')
				{
					buffer_complete=1;	
				}
				
			}

	}
	PIC_sendEOI(0x20);
}
Exemplo n.º 2
0
void keyboard_handler(uint32_t scancode){
	if(scancode != 250){
		if(sleep_time >= screensaver_time){
			restore_screen();
		}else{
			if(piano == 1){
				//print_number(scancode);
				uint32_t frec = getFrec(scancode);
				if(frec == 8){
					sys_write('\n',0xFF);
					piano = 0;
					}
				playPiano(frec);
			}
			else if(check_special_key(scancode)){
				if(keyboard_set_key(scancode_to_char(scancode)))
					sys_write(scancode_to_char(scancode),0xFF);
			}
		}
		sleep_time = 0;
	}
}
Exemplo n.º 3
0
int main(int argc, char **argv)
{
	int fd;
	struct input_event events[64];
	struct timeval last_read_at, now;
	if(argc < 2) {
		printf("usage: %s /dev/input/eventX \n", argv[0]);
		return 1;
	}
	fd = open(argv[1], O_RDONLY | O_NOCTTY | O_NDELAY);

	//printf("sizeof(events): %d\n", sizeof(events));
	while (1)
	{
		struct input_event *event;
		int i = 0;
		int readed = read(fd, &events, sizeof(events));
		int count = readed / (sizeof(struct input_event));
		debug("<DEBUG: readed: %d, count: %d>\n", readed, count);
		if ( readed > 0 ) {

			for (i = 0; i < count; i++) {
				event = &events[i];
				//debug("<DEBUG: type: %d, code: %d, value: %d>\n", event->type, event->code, event->value );
				if (event->type == EV_KEY && event->value == 0 && event->code <= KEY_COMMA) {
					char ch = scancode_to_char(event->code);
					if (ch) {
						putchar( ch );
					}
				}
			}
			gettimeofday (&last_read_at, NULL);
			fflush(stdout);
		} else if ( readed == -1 && errno == EAGAIN ) {
			debug("<DEBUG: timeout>\n");

			gettimeofday (&now, NULL);
			if (last_read_at.tv_sec && (now.tv_sec  - last_read_at.tv_sec) * 1000000 + now.tv_usec - last_read_at.tv_usec > LFTIMEOUT) {
				debug("<DEBUG: print LF>\n");
				last_read_at.tv_sec = 0;
				putchar('\n');
			}

			usleep(USLEEP);
		} else {
			perror("read");
			exit(1);
			//debug("<DEBUG: unknown readed: %d >\n", readed);
		}
	}
}