What does your OS look like? (Screen Shots..)
Posted: Tue Apr 24, 2012 6:24 pm
Piranha, how did you get arrow keys working ? Did you port libreadline ?
The Place to Start for Operating System Developers
http://f.osdev.org/
Scancodes for Arrow Keys:gerryg400 wrote:Piranha, how did you get arrow keys working ? Did you port libreadline ?
Thanks, but I was wondering how the keys get to the application. I compiled Dash on my OS and when I ran it the arrow key didn't work. Dash configure didn't detect libreadline (I didn't port it) and apparently disabled arrow key handling. Because Piranha has ported Bash (I think) I though he might know the easy way to get it going.Nessphoro wrote:Scancodes for Arrow Keys:gerryg400 wrote:Piranha, how did you get arrow keys working ? Did you port libreadline ?
0x48 : Up
0x50 : Down
0x4D : Right
0x4B : Left
My keyboard handler detects if it's an arrow key, using appropriate scan codes. My tty read function returns the appropriate escape sequence: "\E[A" is the code for the up arrow. Took quite a while to actually get it to work, but tty_read returns that sequence in the buffer (ncurses requests 1 key at a time, so it returns 1 element of the sequence per call to ncurses since the count argument is 1).gerryg400 wrote:Piranha, how did you get arrow keys working ? Did you port libreadline ?
It's quite depressing just how convoluted some of this sh*t is. It's no great surprise then that it didn't 'just work' for me.piranha wrote:My keyboard handler detects if it's an arrow key, using appropriate scan codes. My tty read function returns the appropriate escape sequence: "\E[A" is the code for the up arrow. Took quite a while to actually get it to work, but tty_read returns that sequence in the buffer (ncurses requests 1 key at a time, so it returns 1 element of the sequence per call to ncurses since the count argument is 1).gerryg400 wrote:Piranha, how did you get arrow keys working ? Did you port libreadline ?
The annoying part is that the way ncurses decides if you've pressed the escape key or if you're giving it an escape sequence is by calling select() to figure out if theres data to read still (I've stubbed this, it always says theres more data). select() has to deal with timeouts (and it wasn't until I properly implemented the timeout code that the arrow keys started to work).
Basically, a lot of trial and error, looking through the ncurses library code and researching select() and termios. I didn't port libreadline, but I did port termcap.
I don't actually have bash detecting the arrow keys, but I ported bash before I implemented all the termios and select() stuff. At some point in the near future, I'll report bash and see if it detects arrow keys.
-JL
It's not too bad. There are just a lot of details that you need to work out...gerryg400 wrote:It's quite depressing just how convoluted some of this sh*t is. It's no great surprise then that it didn't 'just work' for me.
AHAHAHA. debugging?gerryg400 wrote:What level of debugging support do you have on your OS ?
Dat old school zenpiranha wrote:AHAHAHA. debugging?gerryg400 wrote:What level of debugging support do you have on your OS ?
Haha, uh, what do you mean? As in, can I debug applications? Like with gdb? Or in kernel? I don't currently have a kernel debugger, I mostly just do a lot of printks if I need to get information. Why do you ask?
-JL