I want something like this in a program running on linux:
where <code> is a function to automatically press the key "C" in the keyboard, and the program "think" its me pressing the key.Code:if ( ok() ) { <code> }
I want something like this in a program running on linux:
where <code> is a function to automatically press the key "C" in the keyboard, and the program "think" its me pressing the key.Code:if ( ok() ) { <code> }
You mean so the key goes down like a ghost was there?
What you are asking for could mean different things depending on the context. What/where/why do you want this?
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
You'd need to use a Linux API call similar to the SendInput() function on Windows. I'm not a Linux expert, so I'd have to search for it just like you.
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010
well, im trying to edit the source code of an emulator, to accept a key only if ok() allow, but the emulator accept the keys and buttons everywhere, so dont matter the content of ok(), if i press the "c" key (or the button 7 in joystick for example) the emulator accept the button every time, so i was thinking the only way is the own program press the key when the ok() function tells toYou mean so the key goes down like a ghost was there?
What you are asking for could mean different things depending on the context. What/where/why do you want this?
i found this page:You'd need to use a Linux API call similar to the SendInput() function on Windows. I'm not a Linux expert, so I'd have to search for it just like you.
http://linux.die.net/man/
but every section have A LOT of commands...
edit:
i think i found something:
http://help.lockergnome.com/linux/si...ict487117.html
Last edited by fbs777; 03-23-2009 at 11:04 AM.
well, using the comand on terminal:
xvkbd -text c
he returns the letter "c" on terminal, but if i try this:
when i press the button 7 the results of system() (the 'C" keypressed) go to terminal, not the program itself...Code:if ( ok() ) { if ( event.jbutton.button == 7 ) { system("xvkbd -text c"); } }
I hate to deal a crushing blow, but it sounds kind of like you are in over your head; if you are trying to alter some source, I really doubt this is the appropriate method to accomplish your ends (but I haven't seen that source either). This is a bit of a guess(es): is this an SDL program (I thought I saw that in an earlier post but you have edited it out) -- I've never used SDL but I would assume you are trying to short circuit (ie, trip) some kind of signal handler function, because SDL must use them.
If you don't know what I mean by signal handler function, you simply do not have enough C prowess to satisfy your programming desires today, but you might get there by the end of the week.
If you do know what I mean and think I'm an upstart fool, ignore this post
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
sorry, on the last edit to include the links i forgot to put all again... yes, is the sdlmame and use sdl.
i will see the source code of the xvkbd to see how he send the signal, and try to put in the emulator the same code instead using the system()
Again, I am sure you are going the wrong way! How familiar are you with the SDL API (I am guessing not very)? "how he sent the signal" vis, system calls or whatever is going to be by intention OPAQUE; the point of the API is to give you functions for this, and I would bet money that is how the code you are looking at works. Otherwise you might as well write your own SDL from scratch (that is the way you will be going by resorting to the xvkdb source) which will make modifying some piece of code WRITTEN FOR USE WITH SDL irrelevent.
It will be IMPOSSIBLE to modify if you do not have enough experience with SDL (as I said, I do not, but I at least understand this much about how it must operate).
You do not need to look at or understand xvkbd.
You do not need to simulate a keyboard event at all.
You DO need to understand C and SDL.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge