Re: [Eric-develop] We can read scan codes in Win32 :/
Status: Pre-Alpha
Brought to you by:
andrew_turner
|
From: Gavin R. B. <ga...@ga...> - 2001-09-01 02:07:40
|
> Ismail PAZARBASI wrote: > > Guys, > > I wrote a code in Win32 platform, that can read from keyboard > microcontroller' s port 0x60 (96), and can write there too. However, > actually, I did not try to write anything to keyboard... > > The thing that it makes now is simple. There is a function in a C > code, that is reading from 0x60, this is the last pressed key's scan > code. then there is another function to match the scan codes to ascii > codes is called... We can read scan code, convert it into ascii... > > What I want to do exactly? > > I want to first, check if keyboard is present. Then, check if keyboard > buffer is full. If it is, what is it? Did kernel processed it? If no, > it is not full (=empty), keep tracking it. When user presses a key, > keyboard writes some code (I dont remember it, it is in my > bookmarks.), and we invoke kernel' s keyread function (I examined test > directory in CVSROOT, and I realized that io.cpp!! Dammit guys, I have > been searching for such thing for days, and it was on there, under my > hands for 3 weeks :p :) Kernel then starts to check when key will be > released, and is there another key being pressed. Meanwhile, kernel' s > keyboard driver's asciimatch function matches scancode to ascii > character, and checks for kernel' s command list for any special > meaning of the key (e.g. alt+function keys in FreeBSD console changes > ttys). There is also one more point here: is key pressed alone? or > pressed with modifier keys (alt, altgr, ctrl, shift)... Keyboard then > stops reading, when user releases key kernel stops. Good approach. Could you research 'defensive programming'? I believe it is mentioned in 'Software Engineering', by Ian Sommerville. We need all the defenses we can get when doing assembler. (It's just too dangerous to do otherwise..) > The Mach Thing: > > I tried but failed to download MachOS. I don' t know why, I could not > do it. I could not find server (I have found address from yahoo! and > cmu.edu). I want to have it. You guys have any URLs? Is there keyboard > stuff inside Mach kernel currently? (PS: I need source, there are > hundereds of sites offering *free* suggestions, knowledge, 2 lines of > examples...) Guys, visit this site: ftp://ftp.gnu.org/pub/gnu/gnumach/gnumach-1.2.tar.gz > After this point, I mean reading from keyboard, we can simply try to > code in Eric environment. I believe we can use something at least we > can write our names to screen with keyboard :p Anyway, seriously, we > need a loader, I think it will be ELF, is this right? If it is so, we > can use lots of compatible binaries. Use the FreeBSD loader. > Finally, guys, I want to be enlightened about kernel' s current > status, and utility (i.e. can we use it for a few stupid commands?). I > am so excited right now, and I realized I really wrote this mail very > untidy.... > Summary: We have a Win32 source/binary to read from keyboard, the > scancode, and convert it into ASCII.. Win32 codes are available in C > and Assembler (MASM) formats. Note that assembler source can only read > codes and saves them into stack. We don' t have ANSI C/C++, AT&T > assembler codes right now. Use intel2gas. d;-) > I hope we will :/ Because it did not work > in my FreeBSD box, and a Red Hat Linux box in my school. It failed > with "Bus error", at the line where we try to read from 0x60. Kernels > might be restricting us to read, or my code is wrong. Code is at > below, take a look. Ouch. There is a timing chain problem here. > short port = 0x69; > unsigned char nKeyScanCode=0; > > // Initialization is cool agreed d:-D > __asm__ __volatile__("inb %%dx,%%al;outb %%al,$0x80":"=a" > (nKeyScanCode):"d" (port)); Ahh, no offence, but methinks you have activated the interrupt and been calling from the keyboard buffer without any form of buffer protection. It might be a good idea to scrap the entire inline assembly thing, and just put all the nasty assembler definitions into .S file. This saves on all the *ugly* inline code...(Pls. dont take this personal, it's just a feature of AT&T...) > there is another code, i grabbed from somewhere else (I dunno where it > was, but from a Linux source site) Grab all the code you can d;-) There is simply no point in 'reinventing the wheel'. We have no time for that. > __asm__ __volatile__("in%B0 (%1)": "=a" (nKeyScanCode) : "d" > (port)); Even more primal, dude. *grin*. I still think you guys need to use: 1) External function defs in .S file (Fully annotated) 2) Buffer protection built in, (perhaps at the C++ level?) All the best, Gavin. |