PDA

View Full Version : Simulating key pressing, is that possible?



Filipe Xavier
08-03-2004, 11:10 AM
Hi people,

I have added an OpenGL interface to an old mathematical program that I had before. It has a loop system and in each iteration, part of the program calculates and the results are shown in the OpenGL visualization in realtime.

Due to an unknown reason, the next iteration of the loop only goes on if I hit a key or move the mouse around. I have no idea why it's happening and I was wondering, maybe I could trick the computer simulating that a key is pressed at each iteration, so it wouldn't be up to the user pressing a key to get the whole process working.

Any ideas, thoughts or suggestions?

Thanks

Obli
08-03-2004, 12:13 PM
This is probably not useful but I'll write it anyway.
Maybe you're waiting for an event using a blocking call (say XNextEvent or GetEvent in win32). Then, the result is here but it's not displayed until the blocking call returns.
As soon as you move the mouse, you get a <mouse move> message and the collateral result is that framebuffer goes updated.

What other informations are avaiable?

Filipe Xavier
08-03-2004, 12:33 PM
I had this thought too. Let me explain the situation:

I've coded everything in Fortran 90 using f90gl (http://math.nist.gov/f90gl/) to have the OpenGL, GLU and GLUT subroutines. I've had some problems with glutMainLoop. I've tried to use my older mathematical subroutines running in parallel and I've got many problems with that glut subroutine, once it never returns.

I made some modifications in GLUT source code based on the tips given by Steve Baker at http://sjbaker.org/steve/software/glut_hack.html. In my modifications, glutMainLoop returns making my program coding pretty easy but now I have this problem with event handling. Before modificating GLUT, key pressing was not needed.

Any else ideas? Maybe is the problem at GLUT code, something I didn't notice?

Thanks

Kilam Malik
08-05-2004, 02:32 AM
Hi,

can you call Windows SDK functions? Then you should call SendMessage. E.g.

SendMessage(hwnd, WM_KEYDOWN, VK_DELETE, 1L);

will simulate to press the DEL-key one time.

Kilam.

ZbuffeR
08-05-2004, 08:54 AM
Use the glutIdleFunc().
Source code :
http://raphaello.univ-fcomte.fr/IG/OpenGL/ExemplesGLUt/AnciensGLUt/GLUtIdle.htm

You can do other tricks with glutPostRedisplay() etc.