Advertisement

vgakeyboard

Started by October 28, 2000 06:56 AM
7 comments, last by 3d Wolf 23 years, 11 months ago
I have problems with the vgakeyboard.I''m trying to make this program : #include #include #include int main() { vga_init(); keyboard_init(); while(!keyboard_keypressed(ESCAPE)) { keyboard_update(); if(keyboard_keypressed(LEFTCONTROL)) printf("LEFTCONTROL "); if(keyboard_keypressed(LEFTCONTROL))printf("RIGHCONTROL "); printf("\n"); } keyboard_close(); return(0); } This is my compile line : gcc vgakeytest.c -o vgakeytest -lvgagl -lvga This are the error''s : bash-2.03#gcc vgakeytest.c -o vgakeytest -lvgagl -lvga vgakeytest.c:In function `main'': vgakeytest.c:7: `ESCAPE'' undeclared (first use in this function) vgakeytest.c:7: (Each undeclared identifier is reported only once vgakeytest.c:7:for each function it appears in.) vgakeytest.c:11: `LEFTCONTROL'' undeclared (first use in this function) this is from a tutorial sow I don''t know what is wrong....
Any reply ? What is wrong ??????????
Advertisement
First of all, you should really be a little nicer, okay? It's not like you're paying us to answer your questions We're all volounteers here... You should also be a little more patient, just because someone hasn't replied to your thread in one hour doesn't mean we're ignoring you.

Have you included all of the required header files? It would also help if you told us _what_ tutorial you got that code from.

Edited by - Muzzafarath on October 28, 2000 10:48:29 AM
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
Ok , the tuturial I have is from
http://sunsite.dk/lgdc/articles.php3?mode=body&articleid=14
If you didn't notice, you lost your headers when you posted. You can use &lt; for <.

#include <iostream>

The compiler is telling you that it can't find ESCAPE or LEFTCONTROL. You have to make sure you have the libraries that define them!

Make sure you've included <vgakeyboard.h>


"Whoever performs only his duty is not doing his duty." --Bahya ibn Pakuda

Edited by - CobraA1 on October 28, 2000 1:54:05 PM
"If a man does not keep pace with his companions, perhaps it is because he hears a different drummer. Let him step to the music he hears, however measured or far away"--Henry David Thoreau
I have the files vgakeyboard.h vga.h and vgagl.h in my program.
Do I need other header files ?
Advertisement
I have tested a demo called vgakeytest.That works , so I don''t think I''m missing files.I think something is wrong with the source code.I have these header files in my code :

vgakeyboard.h
vga.h
vgagl.h

But I don''t know where ESCAPE and LEFTCONTROL are in.
I can''t find out what is wrong.Are there other tutorials for the vgakeyboard ?
Here is a working script



#include
#include
#include

int main()
{
int x;
char *keymap;

keymap = (char *) malloc( sizeof (char) * 256 );

keyboard_init(); /* this puts us in raw mode */

while( 1 ) /* an infinite loop */
{
keyboard_update(); /* get the keyboard state */

/* this way is slower than the keymap way */
if( keyboard_keypressed( SCANCODE_ESCAPE ) )
break;

if( keyboard_keypressed( SCANCODE_CURSORBLOCKUP ))
printf( "\n''UP'' was pressed\n" );

/* this loads the state into keymap */
keymap = keyboard_getstate();

/* and print out the keymap in an understandable form */
printf("These keys are pressed: ");
for (x=0 ; x<255 ; ++x )
if( keymap[ x ] == KEY_PRESSED )
printf( "%d ", x );
printf( " \r" );
}

keyboard_close(); /* this is critical! puts us back in ascii mode */
return 0;
}

This topic is closed to new replies.

Advertisement