stuck writing keyboard driver

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.
User avatar
AndrewAPrice
Member
Member
Posts: 2311
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post by AndrewAPrice »

Brendan wrote:Now, see if you can answer these questions:
Okay
Brendan wrote: - what happened on the 9th of November in 2001 (9/11/2001)?
a) Planes flew into the twin towers in New York.
b) The morning I work up to watch my cartoons (I was 12 at the time) to find out all the channels had been overrun by some live broadcast from the President.
Brendan wrote: - how is "colour" spelt?
Just as you spelt it, of course!
Brendan wrote: - is 1.501 slightly more than one and a half, or slightly more than fifteen hundred?
Slightly more than one and a half
Brendan wrote: - did Microsoft release DOS about 20 years before the year 2000, a few thousand years after the year 2000, or several hundred years before the year 2000?
about 20 years before the year 2000 (assuming by 'year 2000' you mean 7 years before the current year)
Brendan wrote:- is 14:00 before or after midday?
2 hours after mid day
Brendan wrote:- when does daylight savings start?
The state I'm living in doesn't follow daylight savings.
Brendan wrote:- if both of our computers send a fax to the same fax machine in Italy, would both computers dial the same phone number?
It'd depend on your telephone network's prefix to activate international dialing.
Brendan wrote:- if you lend me $1000 and I repay a quarter each week for 5 weeks, would you make a profit or a loss?
I'd have a profit of $250. Would you like to borrow $1000? :D
My OS is Perception.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

MessiahAndrw wrote:
Brendan wrote:Now, see if you can answer these questions:
Okay
Brendan wrote: - what happened on the 9th of November in 2001 (9/11/2001)?
a) Planes flew into the twin towers in New York.
b) The morning I work up to watch my cartoons (I was 12 at the time) to find out all the channels had been overrun by some live broadcast from the President.
Did they? On the 9th of November, 2001? or perhaps was it the 11th of September?

Incidentally as a sidenote, would it be the 9th November or the 9th of November?
Brendan wrote: - how is "colour" spelt?
Just as you spelt it, of course!
I'm confused! You capitalised the word 'President' above, which makes me assume you meant the US president, but you spell 'colour' in the British fashion...?
Brendan wrote: - is 1.501 slightly more than one and a half, or slightly more than fifteen hundred?
Slightly more than one and a half
I hope you know that in Europe they use '.' for ',' and ',' for '.' when representing large decimal numbers.
Brendan wrote: - did Microsoft release DOS about 20 years before the year 2000, a few thousand years after the year 2000, or several hundred years before the year 2000?
about 20 years before the year 2000 (assuming by 'year 2000' you mean 7 years before the current year)
Brendan wrote:- is 14:00 before or after midday?
2 hours after mid day
Brendan wrote:- when does daylight savings start?
The state I'm living in doesn't follow daylight savings.
Brendan wrote:- if both of our computers send a fax to the same fax machine in Italy, would both computers dial the same phone number?
It'd depend on your telephone network's prefix to activate international dialing.
Brendan wrote:- if you lend me $1000 and I repay a quarter each week for 5 weeks, would you make a profit or a loss?
I'd have a profit of $250. Would you like to borrow $1000? :D
I can't work out whether you saw the point in Brendan's questions...?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

Good way though to get this back to the fun side and driving home the lesson at the same time.
Brendan wrote:- what happened on the 9th of November in 2001 (9/11/2001)?
Some people did date their letters 9/11/2001, some 11/9/2001, some 11.9.2001, and a few even ISO style, 2001-09-11.

No significant change of the number of deaths worldwide was recorded that day.
- how is "colour" spelt?
Depends on locale (BE "colour" vs. AE "color").
- is 1.501 slightly more than one and a half, or slightly more than fifteen hundred?
Depends on locale (24 countries use decimal point, 60 countries use decimal comma, Luxembourg uses both, Canada uses point in the English-speaking parts and comma in the French-speaking parts, South Africa uses comma officially but point is widespread in business, and on the rest Wikipedia has no info).
- did Microsoft release DOS about 20 years before the year 2000, a few thousand years after the year 2000, or several hundred years before the year 2000?
Depends on locale. The Islamic calendar is currently reconning the year as 1428 (I think), with a year having less than 365 days. The Hebrew calendar recons the year as 5768, also derivating from the Gregorian calendar. Those are the two most known derivations from the Gregorian, but neither the only nor the strangest.
- is 14:00 before or after midday?
The question is rather, is 2:00 a complete time (indicating two hours after midnight), or does it lack AM / PM qualifiers? The answer, of course, is depending on locale. (I don't think 14:00 is ambiguous, as it indicates a 24-hour clock - or am I mistaken?)

And while we're at it, is this GMT, UTC, UT, TAI, or local time? And do you know the difference between each of them? Did your time checking code allow for a minute to have anywhere from 59 to 61 seconds?
- when does daylight savings start?
Depending on locale and year (because these rules keep changing).
- if both of our computers send a fax to the same fax machine in Italy, would both computers dial the same phone number?
Depending on locale, with or without international exit code, which might differ by locale too...
- if you lend me $1000 and I repay a quarter each week for 5 weeks, would you make a profit or a loss?
Depending on locale, "a quarter" might mean 25% of a total or a coin worth USD 0.25.

You see, as long as you refuse both to ever move outside your county and ever to have anything to do with someone from the outside, locales are a reality. Virtually everywhere outside Kentucky people are too aware of this fact to ignore it, even if it means going to some lengths before getting back to the hacking fun. ;)
Every good solution is obvious once you've found it.
exkor
Member
Member
Posts: 111
Joined: Wed May 23, 2007 9:38 pm

Post by exkor »

Offtopic going on.
Lets continue: if somebody wants to create OS in cooperation with others then the only way they can do it is to hire and pay money because two people will always face disagreement at some point. I keep my ideas with me and hell with those who think differently.
instead of arguing if some feature should exist in OS tell how to implement it and the 'stuck writing keyboard driver' guy will decide himself if he needs it at his current development stage.
LOLs
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Post by Candy »

Solar wrote:
- when does daylight savings start?
Depending on locale and year (because these rules keep changing).
And if your locale happens to be Iran, it also depends on some people who you cannot control and whom are inpredictable.
User avatar
lollynoob
Member
Member
Posts: 150
Joined: Sun Oct 14, 2007 11:49 am

What an odd first post for me.

Post by lollynoob »

Haha oh wow, I've never though that I'd see OS developers, of all people, hop onto the prejudice bandwagon. Perhaps someone just wants to write an ASCII-only kernel; why should we bother him? It worked for DOS. It doesn't matter whether you're writing it for the "average dumb white male", or the exceptionally intelligent black female we all seem to be here (judging by the heat you gave him for not mentioning you); it's just a hobby kernel.

Seriously, calm down; there are enough people going ape about $prejudice everywhere, no need to add to the idiocy.

Edit: Oh no, I said "black." I feel like a horrible person now.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

I am usually not giving much on post count as being a meaningful measure, but the pattern is too obvious. Someone asks about keyboard driver techniques.

In the neutral corner, AJ, frank, exkor, mystran and XCHG (average post count 389.4) giving advice on the technicalities. bewing actually provides code, but I don't count him in here for obvious reasons.

In the blue corner, bewing and LordMage (average post count 57.5) claiming that you don't need to bother with i18n if you are lucky enough to be a dumb white American male (attention, irony), and that only people from the EU and those loving their kernel slow and bloated do more than basic ASCII 7 support.

In the red corner and XCHG, Brendan, myself, Albion, JamesM, and MessiahAndrew (average post count 1340.3) taking offense by this.

And as referee, exkor (57 posts) and a "lollynoob" who only just registered and uses his first post to tell us to "calm down".

What does all this mean?

I don't know. I go to bed now.
Every good solution is obvious once you've found it.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

I'm a dumb white(ish..) Canadian male, but can trace my lineage back to Ireland and Germany.

I consider myself human(ish..), and as such.. would obviously try supporting languages used by other cultures.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
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 »

Solar wrote:What does all this mean?
Someone turned this thread into a fist fight, and since the admins are all in the same corner nobody bothered to break up the parties and shut down the arena.

And to up the average post count for referees, I do think "Tolerance" is the key word. If somebody can not be bothered to do something then we should just let him, not start a holy war on requiring unicode support.

I do agree that at least taking different locales into consideration is a Good Thing.
"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
AndrewAPrice
Member
Member
Posts: 2311
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post by AndrewAPrice »

JamesM wrote:I can't work out whether you saw the point in Brendan's questions...?
Of course I did, He wanted to point out that the questions would be answered differently depending on where the answerer (for lack of a better word) has come from.
My OS is Perception.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

Combuster wrote:If somebody can not be bothered to do something then we should just let him, not start a holy war on requiring unicode support.
Apparently I didn't make it clear enough that I couldn't care less what somebody does or does not in his OS. I just had a problem with the notion that locale support is "the first step towards a bloated, slow kernel" and "nonsense unless your primary target is the EU".

But you are right, this was too long and too intense. I apologize.
Every good solution is obvious once you've found it.
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Re: stuck writing keyboard driver

Post by frank »

sancho1980 wrote:hi

i'm still trying to write a meaningful keyboard driver, but im really stuck, cuz i dont see the system behind the scancodes
most keyboard events emit only one scancode, and then some have 2 and 2 keys produce even 4 scancodes
would someone please sketch a meaningful algorithm of what i have to check first in the keyboard isr and how to elegantly map keyboard events to ascii characters or special events?

thanks

martin
I use a state machine in my keyboard handler. I just keep a flag set that remembers if the last keycode indicates that this one should be treated differently. I haven't worked out what to do for some of the keys that send like four keycodes yet.

I guess I should say that I don't have support for Unicode in my OS yet. I do plan on adding it one day. I just don't have the time right now.

I do however believe that all new OSs should be made future proof. What if the internet itself where to suddenly go to Unicode (not likely but you have to think about stuff like this) would your OS be able to handle it?
User avatar
mystran
Member
Member
Posts: 670
Joined: Thu Mar 08, 2007 11:08 am

Re: stuck writing keyboard driver

Post by mystran »

frank wrote: I do however believe that all new OSs should be made future proof. What if the internet itself where to suddenly go to Unicode (not likely but you have to think about stuff like this) would your OS be able to handle it?
No, not suddenly. Yet slowly, but surely, the internet is going towards Unicode.
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Re: stuck writing keyboard driver

Post by frank »

mystran wrote:
frank wrote: I do however believe that all new OSs should be made future proof. What if the internet itself where to suddenly go to Unicode (not likely but you have to think about stuff like this) would your OS be able to handle it?
No, not suddenly. Yet slowly, but surely, the internet is going towards Unicode.
I know that. I was trying to prove a point. :)
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Post by bewing »

*sigh* Quite an aside there, based on a misinterpretation of what I said.
There are many philosophies you can use when building something for the first time. Building something so that it beautifully suits how *you* want to use it, is one of the best methods known for inventing new and wonderful things. The number of you that reject that pragmatic concept astonishes me. Trying to create a contraption that does everything for everyone is one of the *worst* ways known to make a good product. Perhaps you whippersnappers should contemplate that.
I'll assume that means white American males who happen to use English, don't travel to different time zones and are willing to change their computers clocks for daylight savings, don't have a multimedia keyboard with unusual keys (or a dvorak keyboard), aren't involved with a business that imports or exports, use words like "resume" when applying for jobs and "cafe lata" when asking for coffee, don't do any mathmatics or physics, and don't want to use speech recognition or handwriting recognition instead of (or in addition to) their keyboard.
My degrees are in math and physics. I'm a published mathematician, and I occasionally get credits in topology, because I wrote the program that almost all knot theorists have used for the last 20 years to calculate knot polynomials -- because my specialty is writing extremely high efficiency code; and knot polynomial calculations are Np(hard). I am writing my OS for people who use their machines the way I do, because I understand how such a thing *should* work. If any of you think you truly understand how a Mandarin is going to be using their machine, you are deluding yourselves.
Brendan wrote: There may be a fundamental flaw in the way you approach OS design, and it's a flaw that (IMHO) other OS developers might share.

When designing an OS, you should/must try to take into account *everything*.
Right back atcha -- do you honestly not realize that it would take an infinite amount of code to take into account *everything*?
If you don't you'll either end up with "hack on a hack on a hack" or "rewrite after rewrite after rewrite" as you try to add things you didn't originally consider.
I disagree. I will simply end up with two mutually incompatible versions of the OS. A US version, and an international version. The US version will be tiny and ultra-efficient, and the other will support everything for everyone and be fat and slow.

Most of the above examples of internationalization dealt with formats and daemon processes. These are all userapp level considerations. Almost none of them should be (or need to be) hardcoded into the kernel or OS or API. They are irrelevant to OS design.

Unicode/UTF is one exception -- since it directly impacts the concept of "string termination". However, I consider the current impementation vastly unweildy, and I think it will certainly be completely superceded at some point by something better. Implementing and supporting a botched standard is not a guaranteed way to gain acceptance for your OS.

And I didn't mean to imply I was going to use ASCII-7. Of course I will be implementing extended ANSI Latin1. I have 8 bits, and my target is efficiency, remember. I want the US version of the OS to boot to a full GUI shell in under 1 second, and I'm well under that target, currently.
Post Reply