Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Control Key Combo w/ & w/o Other Keys

Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
10-18-2009 08:40
heyas;

http://lslwiki.net/lslwiki/wakka.php?wakka=control


okay, i'm trying to hold down the forward key and tap the left and right key semi-simultaneously to do a combo. which... i can do, but... i want to see if the l/r key is pressed whether or not any other key is also pressed. and i'm only coming up with either ONLY the l&r keys are pressed, or, either the left and/or the right key is pressed.


in other words...

i want a press of left or right, and a held of left AND right, but not care if other keys are pressed at this time or not.


integer secret_style = CONTROL_ROT_LEFT | CONTROL_ROT_RIGHT;

if ((held & change & secret_style) == secret_style)

for example, this ONLY works if you tap both keys at the same time, and no other keys are held. (contrary to what the wiki seems to say....)

if ((held & change) == secret_style)

this seems to be working the same way as the above.


if ((held & change) && (held == secret_style))

annnnnd this is... doing the same thing. i hold one other key, and it doesn't trigger. the only thing that is changing is whether i need both keys pressed or just one, and how 'together' i have to press them.



so i want um...

press & rot left OR press & rot right
and held rot left & rot right
and don't care about any other key

let me try writing that out.

no, that gives me a trigger at pressing either left OR right.




AAAAAAAAAAAAAAAAAAAAAAAAAUGH!!!!!!!
_____________________
Why Johnny Can't Rotate:
http://forums.secondlife.com/showthread.php?t=94705
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
10-19-2009 00:05
hmmm...

if (change & secret_style)
{
if ((held & secret_style) == secret_style)
{
//Activated
}
else
{
//Deactivated
}
}

No? Yes?
Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
11-06-2009 07:02
heyas;

sorry, kalura... i wander away from projects for a while.

but YES, it is WORKING!!


and i totally don't understand why.

my first mistake, i think, is i put that secret_style = control rot rt & ctrl rot left. instead of |
duh.


but i'm reading your code like this (probably wrong)

if there's any key change that intersects the secret style...
...and then if the intersection of held and secret style is exactly ONLY secret style
--it activates.

which says to me that if i'm pressing another key ALSO, it shouldnt trigger. but, it does. so, i'm confused. happy that it is working, but confused. if you wander by again, can you straighten me out? thanks :)

or anybody? i'm bad enough at reading regular if statements, let alone bitwise whatsitses.
_____________________
Why Johnny Can't Rotate:
http://forums.secondlife.com/showthread.php?t=94705
Riisu Boa
Polygon Project
Join date: 2 Aug 2008
Posts: 1
11-06-2009 13:13
Let try to explain binary logics...

Let's say that the "1" in binary are pipes, the "0" are plugs and there's some mysterious light coming from the core of your CPU.

When you do value1 & value2, the light that goes through 'value1' must also go through pipes in 'value2' or it won't be visible. So...

if (change & secret_style)

...or its longer form...

if (change & secret_style) != 0)

...means if there is some light that goes through 'change' and is visible also through 'secret_style' --> Next line. In plain English, if some change occured in the keys described by the value 'secret_style', go on to next line.

if ((held & secret_style) == secret_style)

If the light that goes through 'held' and then through 'secret_style' shows the word 'secret_style' --> Activate! In English: Whatever the pressed keys, if at least the keys contained in 'secret_style' are pressed/held, do you your thing...

plug & plug == plug
plug & pipe == plug (No light can go through)
pipe & plug == plug (The same)
pipe & pipe == pipe (I see the light!)

And I hope you'll see the light too because I've no idea how to explain in a simple way the relation in between binary and decimal numbers... ;)