Keybord drivers

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
thoover
Posts: 14
Joined: Thu Nov 24, 2005 12:00 am
Location: A HOT PLACE CALLED HELL!!!
Contact:

Keybord drivers

Post by thoover »

i went up to page 40 and couldnt find any keybord support that works, i am on my 3rd hour of programming and i need help to find keypress support, i am using djgpp and i need input suport for my doslike , thus far, os. links or codes are appreciated thks in advance.
i will be back soon it is time to take a break.

THOOVER
Mikae
Member
Member
Posts: 94
Joined: Sun Jul 30, 2006 1:08 pm

Post by Mikae »

I think, this link may help you.
thoover
Posts: 14
Joined: Thu Nov 24, 2005 12:00 am
Location: A HOT PLACE CALLED HELL!!!
Contact:

Post by thoover »

I think, this link may help you.
The link gave me some of the info i need, but i cant find out how to put it into my kernel, any help? :cry:
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

Maybe try different search queries on google...
http://www.osdev.org/osfaq2/index.php/G ... rd%20Input

Sample KB module from my os:
http://dimensionalrift.homelinux.net/co ... dumper.bas
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

thoover
Posts: 14
Joined: Thu Nov 24, 2005 12:00 am
Location: A HOT PLACE CALLED HELL!!!
Contact:

Post by thoover »

I made this code,

Code: Select all

 unsigned char getch()
{
	char in;
	char oin;
	outportb(0x60,0xf4);
	outportb(0x64,0x60);
	outportb(0x64,0x20);
	outportb(0x60,0xff);
	oin=inportb(0x60);
	do {
		in=inportb(0x60);
	}  while(in == oin);
}
 
i need help with it it dosnt work at all what did i do wrong.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

What those writes to port 60h and 64h are doing, i have no clue. No code i've seen used that, so why would you?

As for the second part, you are reading a keypress, then you are waiting for a different scancode (the release, another keypress, or the remaining scancode). This would only give you each other scancode, possibly making you lose half the information you wanted.

Also, no return value?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
thoover
Posts: 14
Joined: Thu Nov 24, 2005 12:00 am
Location: A HOT PLACE CALLED HELL!!!
Contact:

Post by thoover »

i got it off of a another forum here: http://www.osdev.org/phpBB2/viewtopic.php?t=306 the last reply it worked once for me but it wont work again. which i believe is odd.
thoover
Posts: 14
Joined: Thu Nov 24, 2005 12:00 am
Location: A HOT PLACE CALLED HELL!!!
Contact:

Post by thoover »

nvm i fixed it now it is:

Code: Select all

 unsigned char getch()
{
   char in;
   char oin;
   outportb(0x60,0xf4);
   outportb(0x64,0x60);
   outportb(0x64,0x20);
   oin=inportb(0x60);
   do {
      in=inportb(0x60);
   }  while(in == oin);
}  
works perfectly now
all i have to do is set up which key is which bye
thoover
Posts: 14
Joined: Thu Nov 24, 2005 12:00 am
Location: A HOT PLACE CALLED HELL!!!
Contact:

Post by thoover »

the code above works for PS/2 only, how can i get one that works on AT style? any suggestions??
Mikae
Member
Member
Posts: 94
Joined: Sun Jul 30, 2006 1:08 pm

Post by Mikae »

You have to use ports 0x60 (commands) and 0x61 (data), instead of port 0x64 for both.
Post Reply