test if ctrl or alt or shift is pressed

Under development: PCMCIA, wireless, etc.
Post Reply
Message
Author
GuestToo
Puppy Master
Posts: 4083
Joined: Wed 04 May 2005, 18:11

test if ctrl or alt or shift is pressed

#1 Post by GuestToo »

i wrote a C program that tests if the ctrl or alt or shift keys are pressed

i thought it might be useful when Puppy was booting ... for example, hold the ctrl key and it will not use a pup001 file ... something like that

it has to run with root priviledges for it to work properly

Useage:

port60
if [ $? -eq 29 ];then
# do something
fi

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

Brilliant

#2 Post by Lobster »

This should solve all the 'simple' versus 'boot up options'. With Puppy you can have your cake and all the trimmings.

Press Ctrl for extended boot options in small letters bottom right of the splash screen - see splash screens are useful.

Good job G2
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

GuestToo
Puppy Master
Posts: 4083
Joined: Wed 04 May 2005, 18:11

#3 Post by GuestToo »

i don't know how well it will work
it wouldn't allow you to pass boot options to the kernel, like noacpi
if it works well enough, it might be useful though

C doesn't seem to have a simple way to check if certain keys are pressed

i tried writing a few nasm programs ... the kernel doesn't let you access the ports directly ... maybe it would if you called ioperm, but if you do that, you might as well write the whole program in C

maybe there's an easier way, i am not a C expert

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#4 Post by BarryK »

GuestToo,
Thanks for that, I think it may have its uses...

for example, as we haven't solved the first-boot problem with multisession, holding down one of those keys could be the way to tell Puppy to bootup as multisession.

GuestToo
Puppy Master
Posts: 4083
Joined: Wed 04 May 2005, 18:11

#5 Post by GuestToo »

this is just the first thing i got to work

this program reads port 60 directly ... which is the ps2 port ... so this probably won't work for usb keyboards

i think a more straight-forward approach would be better ... C doesn't seem to have a simple way of checking keys ... there is getchar, but that stops and waits until you press a key and press enter

i tried a few things calling the kernel routines directly using nasm, but didn't get that working yet

there are ways to do this properly ...

Jesse
Posts: 466
Joined: Sun 08 May 2005, 16:07
Location: Auckland, NZ

fgetc

#6 Post by Jesse »

Yeah, I did wonder about how compatible a program would be with different keyboard interfaces,
though I did have a thought, instead of reading from hardware, would it be possible to just do a fgetc(stdin) ?
I don't know if this would work at boot time, but I think that the kernel has to detect and configure at least one keyboard plugged into system at some point., run your program after that point and use fgetc. Maybe this would work, maybe it wont, gotta try to see :-) I'm upto my eyeballs in cdrom ioctrls at the moment.

Jesse

Post Reply