Jump to content



Photo
- - - - -

WIP - VP Mouse and Joystick Input Plugin


  • Please log in to reply
70 replies to this topic

#1 rascal

rascal

    two-faced as they come

  • VIP
  • 1,374 posts
  • Location:Indiana USA

  • Flag: United States of America

  • Favorite Pinball: Bally Eight Ball



Posted 29 December 2010 - 06:39 PM

I've been creating a COM plugin for VP that will allow Mouse and Joystick input. It's still under construction as I want to make a User Interface for assigning buttons to key presses. I think this is going to be a useful plugin for both desktop and cabinet users. I started posting about it in Rawd's Wiimote nudging thread. I realize now that I should have openned my own WIP thread for it. Here is a copy of the functions built into the plugin and what they do.

CODE
'MOUSE FUNCTIONS
'---------------
'startmouseinput - Initializes and starts the mouse input.
'mousex - Returns the mouse X axis location for the current screen resolution.
'mousey - Returns the mouse Y axis location for the current screen resolution.
'mbuttondown - Returns the mouse button being pressed. Constants = LeftMouseButton, RightMouseButton, MouseButton3, MouseButton4, and MouseButton5.
'mscrollwheel - Returns mouse scrollwheel clicks, starts at zero and can go both positive and negative.
'mresetscrollwheel - Reset the mouse scrollwheel to zero.
'mshowcursor - Shows the mouse cursor.
'mhidecursor - Hides the mouse cursor.
'
'JOYSTICK/CONTROLLER FUNCTIONS
'-----------------------------
'startjoystickinput - Initializes and starts the joystick input.
'jxaxispresent - Returns True or False, if the joystick has X axis capabilities.
'jyaxispresent - Returns True or False, if the joystick has Y axis capabilities.
'jzaxispresent - Returns True or False, if the joystick has Z axis capabilities.
'jxrotationpresent - Returns True or False, if the joystick has X rotation capabilities.
'jyrotationpresent - Returns True or False, if the joystick has Y rotation capabilities.
'jzrotationpresent - Returns True or False, if the joystick has Z rotation capabilities.
'jslider0present - Returns True or False, if the joystick has Slider 0 capabilities.
'jslider1present - Returns True or False, if the joystick has Slider 1 capabilities.
'jpov0present - Returns True or False, if the joystick has Point Of View 0 capabilities.
'jpov1present - Returns True or False, if the joystick has Point Of View 1 capabilities.
'jpov2present - Returns True or False, if the joystick has Point Of View 2 capabilities.
'jpov3present - Returns True or False, if the joystick has Point Of View 3 capabilities.
'jxaxis - Returns the joystick X axis value.
'jyaxis - Returns the joystick Y axis value.
'jzaxis - Returns the joystick Z axis value.
'jxrotation - Returns the joystick X rotation value.
'jyrotation - Returns the joystick Y rotation value.
'jzrotation - Returns the joystick Z rotation value.
'jslider0 - Returns the joystick slider 0 value.
'jslider1 - Returns the joystick slider 1 value.
'jpov0 - Returns the joystick Point Of View 0 value.
'jpov1 - Returns the joystick Point Of View 1 value.
'jpov2 - Returns the joystick Point Of View 2 value.
'jpov3 - Returns the joystick Point Of View 3 value.
'jbuttonpressed(24) - Is an array that represents 24 possible buttons on a joystick. Returns 0 or 1 for off and on.
'
'BOTH
'----
'endmousejoystickinput - Ends the input session.


If you want to give it a go, download this zip file. It contains the installer for the plugin, run Setup.exe. There is a demo table and a .vbs file, they need to be together in the same folder. You can always uninstall the plugin through Add/Remove programs in Control Panel (Windows Vista and Windows 7 users, you know how to remove programs I hope).

Right now the demo table uses the X and Y mouse for nudging, right and left buttons for flippers, and push the scrollwheel like a button for the plunger. It also has the joystick configured for a MS Sidewinder Freestyle Pro, the motion sensor nudges, the trigger buttons do the flippers, and the A button does the plunger. It will probably work with other joysticks, I just don't know the button layout and unless it has a motion sensor, the nudging will probably be linked to the gamepad or joystick control.

If you check this out, please give me some feedback.

Attached Files


Posted Image


#2 Rawd

Rawd

    Pinball Wizard

  • VIP
  • 4,313 posts
  • Location:Edmonton, Canada

  • Flag: Canada

  • Favorite Pinball: Triple Strike



Posted 29 December 2010 - 07:12 PM

This is a really big deal. Thanks a lot for your work on this Rascal.



 


#3 pinball buzz

pinball buzz

    Pinball Fan

  • VIP
  • 823 posts
  • Location:United Kingdom

  • Flag: United Kingdom

  • Favorite Pinball: TOM



Posted 29 December 2010 - 07:35 PM

Nice work Rascal biggrin.gif

Cheers Buzz
Pinball Buzz - Builder of pinball cabs since May 2008.

See my cab pictures here

http://www.flickr.co...s/94649948@N00/
[/size][/size]

#4 gStAv

gStAv

    Pinball Lover

  • Members
  • PipPipPipPip
  • 1,331 posts

  • Flag: Sweden

  • Favorite Pinball: TOM, IJ, AFM, WC94

Posted 29 December 2010 - 08:45 PM

QUOTE (rascal @ Dec 29 2010, 03:22 PM) <{POST_SNAPBACK}>
@ gStAv - Right now, it's all script functions, and not integrated into VP9 at all. So any Dead Zoning would have to be worked out through script. I don't know about you, but the added support for this joystick that was added to VP 9.09, actually messed up me using the joystick with it. The ball does some really wacky stuff in VP 9.09 and is unusable. Thanks for adding the support Destruk, but I don't think it works right. I've been using VP 9.08 to test this plugin. If you make a textbox on the table now (say TextBox1) and in the timer that is controlling the demo now, you put TextBox1.Text = jslider0 you will see the values of the scrollwheel on the Sidewinder. That value can now be used to animate the plunger.


Same for me Rascal!

9.09 dosen´t work at all. Running 9.08 here for now as I understand the deadzone wasn´t working, resulting in the table tilt like crazy.
Hope that this will work in the next realase, or at least the option to turn off the gamepad support so you can use the new version with the MS pad with external support like XPadder, or yours! whistle.gif

3rs054-6.png


#5 Rawd

Rawd

    Pinball Wizard

  • VIP
  • 4,313 posts
  • Location:Edmonton, Canada

  • Flag: Canada

  • Favorite Pinball: Triple Strike



Posted 03 January 2011 - 11:41 PM

Good things are happening! smile.gif



 


#6 FDSystems

FDSystems

    Eclectic end-user

  • Charter Member
  • 2,477 posts
  • Location:Bahia

  • Flag: Brazil

  • Favorite Pinball: I will have to find out again.............

Posted 04 January 2011 - 01:46 AM

QUOTE (rascal @ Dec 29 2010, 03:39 PM) <{POST_SNAPBACK}>
I've been creating a COM plugin for VP that will allow Mouse and Joystick input. It's still under construction as I want to make a User Interface for assigning buttons to key presses. I think this is going to be a useful plugin for both desktop and cabinet users. I started posting about it in Rawd's Wiimote nudging thread. I realize now that I should have openned my own WIP thread for it. Here is a copy of the functions built into the plugin and what they do.


With this plugin I will be able to play VP on my laptop just using a mouse, without slowly destroying my right & left shift or using an extra, strong & cheap keyboard.
Do I understand right?

From Brasil. Updated version of 1234fd



#7 unclewilly

unclewilly

    sofa king.....

  • VIP
  • 5,174 posts
  • Location:Baltimore, Maryland

  • Flag: United States of America

  • Favorite Pinball: tz, tom, big hurt, who dunnit



Posted 04 January 2011 - 02:18 AM

QUOTE (1234fd @ Jan 4 2011, 02:46 AM) <{POST_SNAPBACK}>
QUOTE (rascal @ Dec 29 2010, 03:39 PM) <{POST_SNAPBACK}>
I've been creating a COM plugin for VP that will allow Mouse and Joystick input. It's still under construction as I want to make a User Interface for assigning buttons to key presses. I think this is going to be a useful plugin for both desktop and cabinet users. I started posting about it in Rawd's Wiimote nudging thread. I realize now that I should have openned my own WIP thread for it. Here is a copy of the functions built into the plugin and what they do.


With this plugin I will be able to play VP on my laptop just using a mouse, without slowly destroying my right & left shift or using an extra, strong & cheap keyboard.
Do I understand right?


The problem with mouse input is that, it will only read one keypress at a time, so you could only use one flipper at a time, no simultaneous flipper presses

"it will all be ok in the end, if it's not ok, it's not the end"
 
Monster Bash VP10 WIP https://dl.dropboxus... (vpx)WIP15.vpx

uw2.gif


#8 rascal

rascal

    two-faced as they come

  • VIP
  • 1,374 posts
  • Location:Indiana USA

  • Flag: United States of America

  • Favorite Pinball: Bally Eight Ball



Posted 04 January 2011 - 11:14 AM

I've changed directions here a bit guys. I've been experimenting with VP source code directly with joystick/controller code. This way I can control the default plunger just like a Pinball Wizard controller (internal code). Making a lot of progress with this. Once I work out the joystick/controller methods, I'll look into adding mouse features right into VP. I'll have to submit my work to the VP dev team to have it compiled in official releases. I'm being very careful as to not creating new bugs in the existing code. However, the existing controller input code could be optimized quite a bit, I may work on that too. There is a lot of repetitious code going on there and unnecessary bulk.

On the bright side, this will be part of VP and run faster and more stable, along with complete integration with the program itself. Downside is, each joystick/controller would have to be added individually with a hard coded configuration (what buttons are assigned to what, and what x,y, and z axis and rotation, and point of view hats control which part of VP). Right now I'm working with Rawd and his Logitech Gamepad F310 and my MS Sidewinder Freestyle Pro. Once I figure out the ins and outs of the VP code for controller input, I can start adding more controllers. I'll be starting a new thread here soon asking people which joystick/controller they have and directing them on how to submit the information I would need to add their device to the source.

@1234fd - Yeah the mouse buttons are not designed for multiple button presses (mouse button data is sequential). I do have it now where you can hold two flippers up at the same time, but both are released together (one gets released, they both get released). This doesn't seem to effect game play unless you are in a multiball situation and trying to hold a ball while shooting another. However, you could get a cheap or not so cheap USB joystick, and I can code that into VP for you.

Start digging out your joystick guys! dblthumb.gif

Posted Image


#9 FDSystems

FDSystems

    Eclectic end-user

  • Charter Member
  • 2,477 posts
  • Location:Bahia

  • Flag: Brazil

  • Favorite Pinball: I will have to find out again.............

Posted 04 January 2011 - 11:28 AM

QUOTE (rascal @ Jan 4 2011, 08:14 AM) <{POST_SNAPBACK}>
I've changed directions here a bit guys. I've been experimenting with VP source code directly with joystick/controller code. This way I can control the default plunger just like a Pinball Wizard controller (internal code). Making a lot of progress with this. Once I work out the joystick/controller methods, I'll look into adding mouse features right into VP. I'll have to submit my work to the VP dev team to have it compiled in official releases. I'm being very careful as to not creating new bugs in the existing code. However, the existing controller input code could be optimized quite a bit, I may work on that too. There is a lot of repetitious code going on there and unnecessary bulk.

On the bright side, this will be part of VP and run faster and more stable, along with complete integration with the program itself. Downside is, each joystick/controller would have to be added individually with a hard coded configuration (what buttons are assigned to what, and what x,y, and z axis and rotation, and point of view hats control which part of VP). Right now I'm working with Rawd and his Logitech Gamepad F310 and my MS Sidewinder Freestyle Pro. Once I figure out the ins and outs of the VP code for controller input, I can start adding more controllers. I'll be starting a new thread here soon asking people which joystick/controller they have and directing them on how to submit the information I would need to add their device to the source.

@1234fd - Yeah the mouse buttons are not designed for multiple button presses (mouse button data is sequential). I do have it now where you can hold two flippers up at the same time, but both are released together (one gets released, they both get released). This doesn't seem to effect game play unless you are in a multiball situation and trying to hold a ball while shooting another. However, you could get a cheap or not so cheap USB joystick, and I can code that into VP for you.

Start digging out your joystick guys! dblthumb.gif


I have NO experience at all with joystick.
Could you tell what are the pros & cons of using it instead of a keyboard to play VP ?
From Brasil. Updated version of 1234fd



#10 kruge99

kruge99

    Pinball Wizard

  • VPF Staff
  • 3,901 posts
  • Location:Markham, Ont.

  • Flag: Canada

  • Favorite Pinball: Black Knight, High Speed and Pin*Bot



Posted 04 January 2011 - 11:58 AM

Hey rascal, why not have some hard coded controllers and the end user can have access to a generic XML file with which to customize different controllers? Kind of the way Hyperpin organizes it's tables databases? Or put all the controllers into an XML database, would that be possible.


Best Regards,
Todd.

[proud owner of a Williams Solar Fire]

- It's called "The American Dream" because you have to be asleep to believe it.
George Carlin
- Truly great madness cannot be achieved without significant intelligence.
Henrik Tikkanen
- "Reality check, Michelle, Talk about composure, Total lack of. He's a man-- About-- 12 Feet Tall--"
Carrie Kelly
Posted Image

#11 rascal

rascal

    two-faced as they come

  • VIP
  • 1,374 posts
  • Location:Indiana USA

  • Flag: United States of America

  • Favorite Pinball: Bally Eight Ball



Posted 04 January 2011 - 12:15 PM

QUOTE (1234fd @ Jan 4 2011, 05:28 AM) <{POST_SNAPBACK}>
I have NO experience at all with joystick.
Could you tell what are the pros & cons of using it instead of a keyboard to play VP ?

Well the pros would be, possibly better control over the plunger, sitting back in your chair with a controller in hand, less wear and tear on your keyboard, and for cab builders, alternative options for cheap and creative control over the cabs. Not being locked into using the PBW controller. Freedom to use the controller of your choice! cool.gif

Cons: You may get gamer's thumb syndrome (similar to texting thumb syndrome, no cure, and you will never be able to give people the thumbs up sign as your thumbs will be curled permanently), unless the controller has an ample amount of buttons, you may still have to rely on some keyboard for certain features. Your eyes may go bad sitting to far away from your monitor. You may loose grip on the joystick in the middle of a game. Your elbows may bump together on occasion during multiball. You may yank the USB cord out of your PC or the batteries may go dead in your wireless controller. Some pinball fanatics may complain that to play pinball, it is wrong and not natural to have your hands so close together and like anti-fur people they may throw paint on you. Sorry, I had to make up a few cons, because there aren't any really. tapping.gif

Edited by rascal, 04 January 2011 - 12:28 PM.

Posted Image


#12 FDSystems

FDSystems

    Eclectic end-user

  • Charter Member
  • 2,477 posts
  • Location:Bahia

  • Flag: Brazil

  • Favorite Pinball: I will have to find out again.............

Posted 04 January 2011 - 02:48 PM

QUOTE (rascal @ Jan 4 2011, 09:15 AM) <{POST_SNAPBACK}>
QUOTE (1234fd @ Jan 4 2011, 05:28 AM) <{POST_SNAPBACK}>
I have NO experience at all with joystick.
Could you tell what are the pros & cons of using it instead of a keyboard to play VP ?

Well the pros would be, possibly better control over the plunger, sitting back in your chair with a controller in hand, less wear and tear on your keyboard, and for cab builders, alternative options for cheap and creative control over the cabs. Not being locked into using the PBW controller. Freedom to use the controller of your choice! cool.gif

Cons: You may get gamer's thumb syndrome (similar to texting thumb syndrome, no cure, and you will never be able to give people the thumbs up sign as your thumbs will be curled permanently), unless the controller has an ample amount of buttons, you may still have to rely on some keyboard for certain features. Your eyes may go bad sitting to far away from your monitor. You may loose grip on the joystick in the middle of a game. Your elbows may bump together on occasion during multiball. You may yank the USB cord out of your PC or the batteries may go dead in your wireless controller. Some pinball fanatics may complain that to play pinball, it is wrong and not natural to have your hands so close together and like anti-fur people they may throw paint on you. Sorry, I had to make up a few cons, because there aren't any really. tapping.gif

think.gif I hadn´t realized that my hobby was in fact such a risky & dangerous sport! rofl.gif

From Brasil. Updated version of 1234fd



#13 Sabbat

Sabbat

    The Pinball Monk

  • VIP
  • 4,510 posts
  • Location:Aberdeen, WA

  • Flag: United States of America

  • Favorite Pinball: Solar Ride, Centaur, Gorgar, Cyclopes, Fathom, Frontier, ElviraATPM, Atlantis, Hang Glider, Mystic, Old Chicago, Ed/Gordon Gottliebs

  • PS3 Gamer Tag: SabbatM
  • 360 Gamer Tag: Mions Hill


Posted 04 January 2011 - 03:53 PM

lol
If you have a widescreen 16:9 monitor and want to play your VP9 desktop tables without them being stretched, check out This Link

#14 blur

blur

    Pinball Fan

  • VIP
  • 1,500 posts

  • Flag: Croatia

  • Favorite Pinball: Amazing Spiderman, Black Hole, Totem



Posted 04 January 2011 - 08:15 PM

Great job rascal - i was hoping that it could be added to vp directly.

Why do you have to add each and every gamepad and joystick? Can you use direct input or some other way to make sure all joystick look the same to you and you interface only generic windows driver?

After all, all you have to see is buttons1 to n and some analog axis - x, y, z, z2 and so on.

1234fd real advantage of gamepad and mouse is analog control - button is button - you can connect it to keyboard ipac or some gamepad board (which you will be able to map directly without xpadder now) - still it is button

analog control is what gives you new features - for example standard ps2 joystick gives you 2 joysticks with 4 axis,

so you can use two axis for nudging and one axis or mouse for plunger.

it is already implemented in future pinball so you can take a look how it would look like.

actually for non-cab user keyboard is much better, only advantage of gamepad is you can use joystick as a plunger. use of gamepad for nudging for non cab user is not so good idea. Why?

Because gamepad nudge is done in a way that you expect to have some physical ball on your joystick so when you nudge pinball the ball moves joystick along x and y axis. This movement is then translated to the ball. So you have real life reactions of the ball in your cab, you can nudge a little or little more or very hard and everything will be transferred. With more options comes more responsibilities cause with button nudge you have to just press the key, vp or fp would do everything else real nice - for every press you would get perfect nudge.

With analog nudging device you will have to learn how to make perfect nudge just like in real pinball - no more easy nudging. But when you learn it you can nudge in a thousand different ways (if you don't break your cab)

Ok, but why is that bad for desktop user - because while cab user has to turn his head around to make that ball inside the cab move, desktop user can just pull stick from one end to the other and get the ball where ever he wants - for example this is possible in FP right now - i can make a ball go to the top and keep it there for ever. But this is more like me cheating then wrong driver - driver is great but it is invented for cabs.

As for plunger - if you have support for analog devices it is really easy to implement it in cabs, you can use gamepad axis or mouse axis - whatever - and it gives you perfect support for ALL tables out of the box - without need for messing with each table script.



#15 Rawd

Rawd

    Pinball Wizard

  • VIP
  • 4,313 posts
  • Location:Edmonton, Canada

  • Flag: Canada

  • Favorite Pinball: Triple Strike



Posted 04 January 2011 - 08:44 PM

Been doing some testing, and I think with proper tweaking, anyone will be able to build an analog plunger for their cabinets using one of the analog axis of a gamepad. I am thinking of using the other two axis, either for a lockdown bar nudge device, or some other type of nudge device.

For desktop users, the analog plunger on a gamepad for hitting those skill shots is a plus. smile.gif I am finding it very comfortable to play 4:3 tables on my desktop with the gamepad.

Desktop players will be able to build their own "Pinball Wizard" type controllers, with full analog support if they want.

Edited by Rawd, 04 January 2011 - 08:49 PM.


 


#16 rascal

rascal

    two-faced as they come

  • VIP
  • 1,374 posts
  • Location:Indiana USA

  • Flag: United States of America

  • Favorite Pinball: Bally Eight Ball



Posted 04 January 2011 - 09:34 PM

QUOTE (blur @ Jan 4 2011, 02:15 PM) <{POST_SNAPBACK}>
Why do you have to add each and every gamepad and joystick? Can you use direct input or some other way to make sure all joystick look the same to you and you interface only generic windows driver?

After all, all you have to see is buttons1 to n and some analog axis - x, y, z, z2 and so on.

The program is using directinput to read in the controller. It can already read in any joystick/controller. It was coded to filter out other controllers, and only use the PBW and the Ushock controllers. So rather then recoding the whole thing over, I am just adding additional allowed controllers. The other reason is that not all controllers are created equal. Sure Buttons go from 1 to n, but some joysticks don't have X, Y, and Z axis and rotation. Some have Sliders (scrollwheels), and some have Point of View (POV). For example, the PBW uses Z axis for it's plunger, my MS Sidewinder Freestyle only has X and Y axis, but it has a Slider0. So instead of using Z axis for the plunger, I am trying to use the Slider0. My MSSFP also has a motion sensor built in that uses X and Y axis, so I want to code that for the nudge. I also want to use my POV0 hat as 4 or 8 extra buttons. Rawd wants to use Y rotation for his plunger, because his Z axis is used for two analog buttons on his Logitech Gamepad F310 (not conducive for a plunger). These are things that you would not be able to do easily through a "pick a button set to keyboard interface". But more then anything, there is no interface right now to select your configuration and no way to save or read in your configuration (make profile for your controller). So right now, I'm just happy to add and hard code configure additional controller. Maybe some day this will be revamped with an interface and a external method to save, but for now this is the method I am going to use.

Feel free to look at pininput.cpp if you think you can add all that stuff I'll cheer ya on. wink.gif

Posted Image


#17 lettuce

lettuce

    Pinball Fan

  • Silver Supporter
  • 929 posts

  • Flag: England

  • Favorite Pinball: Monster Bash

Posted 04 January 2011 - 09:39 PM

Would this mean we would finally have analog control of the plunger, say for instance if you were using a analog stick on a 360 pad??

#18 Rawd

Rawd

    Pinball Wizard

  • VIP
  • 4,313 posts
  • Location:Edmonton, Canada

  • Flag: Canada

  • Favorite Pinball: Triple Strike



Posted 04 January 2011 - 09:42 PM

QUOTE (lettuce @ Jan 4 2011, 02:39 PM) <{POST_SNAPBACK}>
Would this mean we would finally have analog control of the plunger, say for instance if you were using a analog stick on a 360 pad??


That is what it means. smile.gif



 


#19 lettuce

lettuce

    Pinball Fan

  • Silver Supporter
  • 929 posts

  • Flag: England

  • Favorite Pinball: Monster Bash

Posted 04 January 2011 - 09:56 PM

QUOTE (Rawd @ Jan 4 2011, 09:42 PM) <{POST_SNAPBACK}>
QUOTE (lettuce @ Jan 4 2011, 02:39 PM) <{POST_SNAPBACK}>
Would this mean we would finally have analog control of the plunger, say for instance if you were using a analog stick on a 360 pad??


That is what it means. smile.gif



Cool, so will we be able to hook something up for our cabs, without forking out for that mot-ion digital plunger?

#20 Rawd

Rawd

    Pinball Wizard

  • VIP
  • 4,313 posts
  • Location:Edmonton, Canada

  • Flag: Canada

  • Favorite Pinball: Triple Strike



Posted 04 January 2011 - 09:57 PM

QUOTE (lettuce @ Jan 4 2011, 02:56 PM) <{POST_SNAPBACK}>
QUOTE (Rawd @ Jan 4 2011, 09:42 PM) <{POST_SNAPBACK}>
QUOTE (lettuce @ Jan 4 2011, 02:39 PM) <{POST_SNAPBACK}>
Would this mean we would finally have analog control of the plunger, say for instance if you were using a analog stick on a 360 pad??


That is what it means. smile.gif



Cool, so will we be able to hook something up for our cabs, without forking out for that mot-ion digital plunger?


Yes! smile.gif