*dies*
Thanks for your replies, everyone, but I am soo outta my depth here.
Combuster wrote:hook yourself onto the keyboard IRQ so that you can keep a list of current key statuses.
*blinks*
ru2aqare wrote:If your code runs in real mode, and the BIOS handles the keyboard IRQ, there is a status byte in the BDA you can use to figure out the state of the modifier keys (Ctrl, Alt, Shift).
I see. This is something I can run with, and I've tried to, but not gotten very far (probably because of the next bit of info):
Walling wrote:I think most of the code in GRUB is made to run in protected mode (with interrupts disabled), but it actually runs in real mode most of the time (waiting for a key press using BIOS). They made a system to call real mode code: it switches to real mode, invokes the real mode code and when it returns it switches to protected mode and returns. Key handling is implemented by using the BIOS int 0x16. I just peeked in the code. You can see the key handling in stage2/asm.S at line 1991 and 2025. Maybe you can hack that code to return a special value, when the shift key status is changed.
Oooh.
Walling wrote:There are no tutorials telling you how to do a special job like this... go learn some assembly and low-level C. RBIL is a must-have reference.
mathematician wrote:mov ax, 40h
mov es,ax
test byte ptr es:[17h], 3
jnz shift_key_down
*
Reaches for the Intel-to-AT&T syntax translator*
bewing wrote:Address 0x417 in the BDA (as said above) should give you the current instantaneous value of the Left and Right shift state (bits 0 and 1). If you can't poll this address, however, then you are limited to guessing whether the bits have remained unchanged the entire time between the moments that you check them.
Oh ok.
bewing wrote:There are some ways to avoid guessing, but they are much harder.
One half of me is asking "what are they" while the other is RUNNING in the other direction and shouting over my shoulder "and these methods are EASY?"
bewing wrote:The C parts of GRUB are compiled by GCC, which produces pmode code only, as said above.
bewing wrote:I really do think that just checking address 0x417 every time through your ASM loop will be the simplest way to handle your issue.
*
hears "your" and "asm" in the same sentence and spontaneously combusts*
*
hears "simplest" in the same context and sends a nuclear-sized shock wave in all directions*
bewing wrote:BTW: I'm glad to hear that someone wants to adopt/improve the GRUB legacy code.

Well, I would
like to.
There was a time when I didn't understand C. Tutorials would make no sense to me, I couldn't understand pointers, and I wrote
extremely long monologues on forums about my problems. While a little unusual, it took me 3 or 4 sessions of pushing myself beyond my own abilities of comprehension - to the point of crying, actually - before something sparked and I went "ooooh". (Except I'm still going "oooh", approx 3 or so months after the fact).
I can write simple programs in C, such as a bandwidth checker for my ISP (bigpond) because libraries like cURL exist - just basic string processing, really - and I've also written a (really) basic X task list program (like a panel, except it's vertical, doesn't double-buffer, doesn't use a toolkit (homespun button code FTW), and is extremely hacky in that it asks the X server for the whole window list whenever a window is created or killed), but beyond that I'm kinda... yeah. I'd probably have to push myself to the point of tears again to understand low-level C/asm/etc, heh. Although I'd probably be better for it...
</quandry>
-dav7