Main > Linux
Attempting to hack and document GunCon2 for Linux, FreeBSD, and MacOS X.
Numbski:
I have a question for you edumacated programmers out there.
My script above has a couple of obvious flaws that I can point out:
1. Button states do not persist from one loop to the next - ie, if you keep the trigger pulled, it's like a turbo button effect. I need to track the state of the button from on instance to the next.
2. Should I really just be reading every 6 bytes like that as fast as the processor can possibly do it, or is there a more efficient way to go about this? Perhaps some sort of buffering effect? Somewhere in the back of my brain it's screaming that I should be using a "while" loop there rather than for each...
Other than that, I now understand that the repetition on the X-axis is the definition of the rolling X problem. It only exists on the first-party guncon 2's. If I can more efficiently read input and track button states from update to update, this script will actually be usable to provide a rudimentary mouse driver under X11. I can then add support for Win32::GuiTest, so that the Gun can be used as a mouse under windows. :) The catch of course is getting a character device.
Man I wish I could code even a little bit of c or c++ driver code. :(
Silver:
Can't really help with the programming in perl, but:
1) Persistent states. You would need to store the state of each button in a variable/array, and then compare states on your next "loop" to read values from the gun.
2)Effeciency. I'm sure there is a whole world of good device driver coding practices out there, but at the very least you need to instruct your program to "Do System Events" or whatever on a repeating basis within your loop. VB6 and .NET allow you to use DoEvents() IIRC but this is basic and designed more for programs rather than always running device drivers.
You may find there is a simple perl command to wait/pass priority over to the system which will gain you the lower overhead you need.
notaburger:
i've only done a little bit of programming (none in perl) but i always did what silver did for storing key strokes
in this case i would have an array storing all of my previous keystrokes
keep up the good work, this is starting to look very promising
Numbski:
Looks like I could use this for event handling:
http://search.cpan.org/~vparseval/Event-Lib-1.01/lib/Event/Lib.pm
Navigation
[0] Message Index
[*] Previous page
Go to full version