- AVS
- AVS joystick control
Archive: AVS joystick control
Boktor
31st May 2005 12:14 UTC
AVS joystick control
A short while ago I came across winstick. A program to control your winamp with a joystick.
I saw it mimicks keyboard keys, which gave me the idea it could be used to control AVS.
I have worked out a little scheme, a list how to set it up and a test.avs. Klique here.
I hope at least some of you have a gamepad.
Well, check it out and tell me what you think.
jheriko
31st May 2005 23:29 UTC
with open source avs we might be able to add a good joystick/gamepad support which would eliminate the need to share the keyboard with winamp
Boktor
1st June 2005 10:59 UTC
I tend to believe that priority on open source AVS is and should not be joystick input. For real multi-tasking however it seem inevitable. One should be able to type and control AVS with a joystick at the same time
Until it happens the keyboard still has plenty of keys left. Maybe not enough to use whole a second controller, but one could give up some winamp hotkeys.
For now it works.
I wonder however if any AVS-user has either a logitech dual action or sidewinder.
jheriko
1st June 2005 11:50 UTC
I only recommended it because it has the look of a 10 minute job (not literally... read 'only needs small code changes') and would be very useful for making avs games. (the main thing always putting me off is the bad keyb support)
Boktor
1st June 2005 12:55 UTC
The highly responsive keyboard is annoying.
You made me think and here is an improvement.
q1=band(q2,(getkbmouse(79)));
q2=bnot(getkbmouse(79));
if(equal(q1, 1), assign(q3, q3+1), 0);
reg01=(q3|0)&1;
Now reg01 goes on and off by pressing o.
I've worked it out in the new example file, which can be found here.
Thanks for making me think.
Warrior of the Light
1st June 2005 19:00 UTC
my method:
frame
mc=getkbmouse(3); //mc=mouseclick
mcpulse=if(equal(mcold,mcnew),0,if(equal(mcold,0),1,0));
// enabled only 1 frame on mouseclick
mcold=var;
var=if(equal(mc,0),mcpulse,1); //var is only used as temp
mcnew=var;
mcswitch=if(mcpulse,bnot(mcswitch),mcswitch);
reg02=mcswitch;
I used this in Oil Grease Is Not Black in Preset Pack 2.
I wanted to attach it, but you can't attach presets in edit mode anymore. I hate doubleposting so I'll post a link to PP2 instead..
http://www.deviantart.com/download/12533150/
jheriko
1st June 2005 23:18 UTC
i normally stick with something simpler like this:
oldg=g;
g=getkbmouse(akeynum);
pressedonce=below(oldg,g);
pressedonce is 1 the frame that the user first pushes the key down and is otherwise 0.
also for doing time independant moves (i.e. a quake style camera walk) use:
dt=gettime(lasttime);
lasttime=gettime(0);
pos=pos+dt*(getkeybmouse(keyplus)-getkeybmouse(keyminus));
again, short and sweet :)
Warrior of the Light
2nd June 2005 08:12 UTC
Originally posted by jheriko
i normally stick with something simpler like this:
oldg=g;
g=getkbmouse(akeynum);
pressedonce=below(oldg,g);
why didn't I think of that!
^..^
2nd June 2005 11:31 UTC
wouldn't this even be a bit faster:
pressedonce=band(getkbmouse(3),stopit);
stopit=bnot(getkbmouse(3));
? 'pressedonce' is 1 during the frame you press the key, from the following frame on it's 0 again.
Well, atleast that's what i always use...
jheriko
2nd June 2005 12:32 UTC
Its debateable which would be faster (I'd guess at mine by a few clock cycles), but the difference would be slim anyway.
2 assignments + 2 getkbmouse + band + bnot
against
3 assignments + 1 getkbmouse + below
speed isnt that much of an issue... i just wanted to point out a tidier solution rather than a faster one. none of this code is particularly slow or time critical.
Boktor
2nd June 2005 12:35 UTC
counter
So a on/off switch could be this counter with an &1 added to it.
oldg=g;
g=getkbmouse(number);
counter=if(below(oldg,g), counter+1, counter);
reg03=counter&1;
or
counter=if(band(getkbmouse(number),g), counter+1, counter);
g=bnot(getkbmouse(number));
reg04=counter&1;
Nice. Or are there even better ways to do this?
jheriko
2nd June 2005 12:51 UTC
Avoid using those ifs when you dont need to.
counter = if(below(oldg,g),counter+1,counter);
could be
counter = counter + below(oldg,g);
which is better as it avoids the if which is slower than the + anyway, so dodging the + with if isnt a speed boost.
Whats the & 1 for? you want it to toggle from 0 to 1?
I'm not sure if its faster but I think it is tidier to use:
oldg=g;g=getkbmouse(number);
counter = (counter + below(oldg,g))%2;
I'm not sure but I think & and | are pretty slow 'cos of rounding to int, likewise %, floor etc. The %2 can be replaced by &1 if it is faster...
The other thing is that this can be expanded to 'toggle' between 0,1,2 or 0,1,2,3 and so on, by changing the final %2 for %3 or %4 etc... very useful for complicated menus.
The most comprehensive menu I have released on a preset is on this one:
http://www.deviantart.com/deviation/13908660/
Although its prolly full of bad coding practice, as all presets are, it shows some of this in use, like the color switchers and click buttons etc.
Boktor
2nd June 2005 13:16 UTC
Thanks for the +-instead-of-if tip. Never looked at it from this angle.
Whats the & 1 for? you want it to toggle from 0 to 1?
Yes, that was the idea.
I'm not sure either, but the difference between | & and % seems negliable (and the numbers used are integers already, I'd guess that it shouldn't take long to recognise). The extended 'toggle' is an advantage, though.
I was thinking about making something like a menu for the joystick control, so you'd see what you're doin, your example will be a great help. :)
Boktor
18th August 2005 17:02 UTC
A menu is rather irritating actually, so I dismissed it.
Made a little avi in which i use my gamepad.
Except for reencoding it to 3ivX, it's all AVS.
Reactions appreciated.
jheriko
14th September 2005 17:38 UTC
firstly. the video is huge.
secondly. why not post the avs preset and ape or whatever?
I'll give you another reply in 3 minutes when i have finished downloading your huge video.
--------
It uses Winstick? Thats so useful... a prerequisite for an avs preset that can be nicely wrapped into an installer .exe and requires no effort from the user. Joystick presets are the way to go!!! ¬
Seriously though, its pretty cool, but for reasons outlined above, not practical for an avs pack. I guess its awesome for VJ'ing though.
Boktor
14th September 2005 20:04 UTC
Thanks for your comment.
Originally posted by jheriko
firstly. the video is huge.
Depends on your definition of small/huge, for a video file it's not that big.
secondly. why not post the avs preset and ape or whatever?
It's an
AVS -file and it's already on my
site.
It uses Winstick? Thats so useful... a prerequisite for an avs preset that can be nicely wrapped into an installer .exe and requires no effort from the user. Joystick presets are the way to go!!! ¬
You should work on your irony skills.
But indeed an installer would be nice.
I don't think it's impossible.
Seriously though, its pretty cool, but for reasons outlined above, not practical for an avs pack.
I agree for now.
Though, the xbox360 will get a gamepad controlled
visualizer, called
lightsynth, which might change things.
I guess you don't want to download there
videos.
I guess its awesome for VJ'ing though.
It is. It's very pleasant.
jheriko
25th September 2005 03:03 UTC
yeah. glad you appreciated the humour and didnt take offense :)
any file > 500k is huge on dialup
i'm on 1meg and that took a long time to dl. and for that short a video... that is pretty huge, and not even at a justifyable quality.
i have videos of episodes of tv series that big or smaller :) and not just cartoons.
anyway, this does look cool. its just a shame there isnt inbuilt joystick control... if avs was really open we could add it :)
MaTTFURY
25th September 2005 07:26 UTC
another improvement for avs! mpeg's/other types of non-M$ video file formats!!! :D