Community

SCI Programming => Mega Tokyo SCI Archive => Topic started by: Chris Cromer on April 07, 2002, 06:36:45 AM

Title: Checking for keys pressed
Post by: Chris Cromer on April 07, 2002, 06:36:45 AM
For some reason I can't seem to get it to detect whether or not certain keys are pressed.

I used this:

Code: [Select]
           (case evkeyboard
                (if (== message key_t or == message (| key_t $20))
                    (= game_running false)
                )
            )
and when I pressed t it would make the game stop running but when I use key_up and any other keys of that nature it would not work. I am trying to get the ego to move using this method but can't seem to get it to work.
Title: Re:Checking for keys pressed
Post by: Chris Cromer on April 08, 2002, 05:50:01 PM
*bump* I really need to figure this out.

I have been able to get the ego to be controlled by the mouse but can't seem to set it up to check for these keys. Please help!!!
Title: Re:Checking for keys pressed
Post by: Brian Provinciano on April 08, 2002, 06:52:04 PM
I must have some of the key codes incorrect. I believe I just took the PC ones and imported them into SCI Studio. SCI must use different keycodes then.

Write a routine to print the character pressed on the screen in hex (%x) and you'll have a keycode.
Title: Re:Checking for keys pressed
Post by: Chris Cromer on April 08, 2002, 07:01:35 PM
Alright I will try that.
Title: Re:Checking for keys pressed
Post by: Chris Cromer on April 08, 2002, 07:46:28 PM
Yeah some of your key codes are incorrect. The up key is supposed to be $4800 and the keys.sch sets it to $26 and the key_(numbers) and the key_numpad(numbers) are backwards and need to be switched. I will go through all the keys myself and make sure they are correct then put out a correct version of keys.sch for use in SCI games.
Title: Re:Checking for keys pressed
Post by: Chris Cromer on April 08, 2002, 09:53:10 PM
Well I have posted the corrections in this board. I guess this is just one more step before I can get my template game done. I will release an updated keys.sch and scc.sch when I release the template game. I guess it's time to get to work on making the ego controllable by the keyboard. Then I need to get a good default ego character...

I also have a question about the mouse, am I able to get the game to tell the difference between a left click and a right click? I tried using the hex thing to find out but it kept printing out $0 or a NULL. I know that Quest for Glory 1 original used the right mouse button for descriptions on the screen. But what is the hex code for it?
Title: Re:Checking for keys pressed
Post by: lskovlun on May 29, 2002, 10:35:27 AM
Strictly speaking, you shouldn't be using the key codes
for the cursor keys explicitly. Instead you should use the
kernel function MapKeyToDir. This gets you two advantages:

1. No assumptions about the used keyboard driver
(Sierra SCI had keyboard drivers for Tandy keyboards as
well as the usual ones, which probably mapped these keys
differently. FreeSCI always returns the usual mappings.)
2. Instant support for joysticks.

Nowadays, (2) is the most important point, of course.