![]() |
|
keyboard translations && inversion of a value |
karistouf
Member #5,126
October 2004
![]() |
Hello!!! -first is there a function that can give me back when reading a key its programmation name ( KEY_COMMA , KEY_SEMICOLON2, ....) ? I will experience new beautifull keyboards like turkish and arabic and I would like two know wich code in full plain text the key get back. -second question BufferSaisie[prepman]=(int)(fValManuelAtBeg[prepman]+ (lRetFaderPreset * ((fValManuelAtEnd[prepman]-fValManuelAtBeg[prepman])/100)));
So in fact, my function there is working in only one way, from 100 to 0. It means to work I need to get back my faders up to do the next move. thanks for the answer! "step by step" |
CGamesPlay
Member #2,559
July 2002
![]() |
1. scancode_to_name -- Ryan Patterson - <http://cgamesplay.com/> |
karistouf
Member #5,126
October 2004
![]() |
Thanks first for your answer about scancode, I will use it !!!
if (keypressed()) { char const *keyname = scancode_to_name(scancode); textprintf_ex(buffer,font, 80, 230,makecol(100,0,255),-1,"You pressed the %s key.", keyname); } returns none as string... ok, I will try to be more explicit and clear ( wich is quite a thing ...) i have a real slider connected to my soft -100 I m searching how I can program, when my slider is down , an inversion of the values. To be more explicit, it affect the value of BufferSaisie[] thruth a crossfading of levels: from a Value at Begin TO the next value wich is at End. BufferSaisie[10]=30 at Begin I m using a physical hardware ( slider, fader, dont know the name) to do it you can see photo of it there:
"step by step" |
Elverion
Member #6,239
September 2005
![]() |
Why not just 100 - return value? If it were at 100 when you want 0, 100-100 = 0. If it were at 0 and you want 100, 100-0 = 100. I'm not sure exactly what you are after, but this is the closest thing I can make out to what you want. -- |
karistouf
Member #5,126
October 2004
![]() |
hum... because in fact I have TWO faders .... I wanted to make it more simpler in my explanation So I m using two fader, one that is manipulating the values at begin, the other the value at end. When BeginFader is at 0 and EndFader is at 100 my crossfade is done. Begin has a new value ( the before named End).... I have edited the post on the scan code... OK DEFINITEVELY SCANCODE RETURNS NONE.... must be a dummy thing....
"step by step" |
CGamesPlay
Member #2,559
July 2002
![]() |
Quote:
if (keypressed()) { char const *keyname = scancode_to_name(scancode); textprintf_ex(buffer,font, 80, 230,makecol(100,0,255),-1,"You pressed the %s key.", keyname); }
What is in the scancode value? -- Ryan Patterson - <http://cgamesplay.com/> |
karistouf
Member #5,126
October 2004
![]() |
keyname string is <none> scancode is O I made several try, thinking about a trouble with keypress or buffer satured because of the loop while....:'( "step by step" |
GullRaDriel
Member #3,861
September 2003
![]() |
Is keyboard installed ? And timer ? Show us your init routine. It should look like this: allegro_init(); install_timer(); install_keyboard(); install_mouse();
"Code is like shit - it only smells if it is not yours" |
karistouf
Member #5,126
October 2004
![]() |
yep...
"step by step" |
CGamesPlay
Member #2,559
July 2002
![]() |
Well of course it's none. 0 isn't a valid scancode! Try putting in an actual key value, like KEY_ENTER. -- Ryan Patterson - <http://cgamesplay.com/> |
karistouf
Member #5,126
October 2004
![]() |
wait wait wait.... if i well understand, scancode_funct is not a listening of keyboard but just a converting function ? "step by step" |
GullRaDriel
Member #3,861
September 2003
![]() |
Have you really look at exkeys ? If not you should. "Code is like shit - it only smells if it is not yours" |
karistouf
Member #5,126
October 2004
![]() |
no exkeys in dev pack... I will take a look. I was used to a version of allegro about 3 years ago. and characters are not at all my speciality... when using readkey function it crashes.... int ch; // I get out scancode int .... if(keypressed()) { ch=readkey();} char const *keyname = scancode_to_name(ch); textprintf_ex(buffer,font, 80, 230,makecol(100,0,255),-1,"You pressed the %s key. %d", keyname, ch); blit(buffer,screen,0,0,0,0,442,442);
"step by step" |
CGamesPlay
Member #2,559
July 2002
![]() |
Yeah, readkey returns a value and scancode combined. -- Ryan Patterson - <http://cgamesplay.com/> |
karistouf
Member #5,126
October 2004
![]() |
thanks a lot. Yes , I know, the following things must be ridiculous...;D All of that just to be helpfull to other keyboard and make adaptation quickly... waouaouwouaou...:-[ if(keypressed()) { ch=readkey(); //ch is an integer if (ch >> 8) //if ch is not a double key press { //asking to convert ch with scancode in the name of the key we put inside the string keyname char const *keyname = scancode_to_name(ch); textprintf_ex(buffer,font, 80, 230,makecol(100,0,255),-1,"You pressed the %s key. %d", keyname, ch); blit(buffer,screen,0,0,0,0,442,442); } }
"step by step" |
CGamesPlay
Member #2,559
July 2002
![]() |
No, it's not a double keypress. It gives you two types of information. One is the key value, stored in the first 8 bits of the returned value. The next is the scancode, suck as KEY_ENTER, etc. Both will always be in the value. Therefore, to get the scancode from the value, you take the value of readkey() and do the >> 8, then pass that shifted value to scancode_to_name. -- Ryan Patterson - <http://cgamesplay.com/> |
karistouf
Member #5,126
October 2004
![]() |
great, Ryan. This IS an answer. its very clear char const *key = scancode_to_name(ch>>8); works! thanks about your answer, because it is far more clear to know that readkey() returns 2 type of informations. merci "step by step" |
|