Sony Dualshock 2 (Playstation 2) joystick support?

Topics regarding Scripting with Reality Factory
Post Reply
User avatar
Nighthawk_0973
Posts: 234
Joined: Tue Apr 19, 2011 2:08 am
Location: In front of my computer.

Sony Dualshock 2 (Playstation 2) joystick support?

Post by Nighthawk_0973 » Tue May 03, 2011 4:06 am

I have a sony ps2 controller and it works with other games on my computer so I was wondering if it would work with RF. The buttons it has, that work (all work) are:
X button
O button
Square Button
Triangle Button
R1 button
R2 button
L1 button
L2 button
Left Analog Stick
Right Analog Stick
Left Analog Stick Click (L3)
Right Analog Stick Click (R3)
Directional Pad (up, down, left right)
Start button
Select Button
Analog toggle button

They all work great. Also is there a way to configure them? I wan't it so that the controls are:

Left Stick - Moves around
Right Stick - Looks around
START Button - acts as the esc key
X button - Jump
R1 - Shoot
L2 - Sprint
L1 - Crouch
Square - Inventory (if in game)
D-pad - Naviagate through menus (don't care if not)
Triangle - Toggle Weapons

Can you guys help me out in this aspect of RF? Really don't know. Will keep messing with stuff for now though! :D
https://sites.google.com/site/theneverendinguniverse/ <-- Infinite Universe Website. It's a 2D MMORPG I'm releasing into beta near the late summer (I hope :D) note: RF isn't an MMO maker. Not yet anyways.

Allanon
Posts: 493
Joined: Mon Aug 29, 2005 8:23 am

Re: Sony Dualshock 2 (Playstation 2) joystick support?

Post by Allanon » Tue May 03, 2011 7:21 am

If the joystick is DirectInput compatible then you can use it with RF. You will need to make sure UseDirectInput is set to true in the realityfactory.ini file. And then use the joystick scripting commands to write a script to move the camera and/or player. The joystick commands are documented in the manual that comes with RF.

User avatar
Nighthawk_0973
Posts: 234
Joined: Tue Apr 19, 2011 2:08 am
Location: In front of my computer.

Re: Sony Dualshock 2 (Playstation 2) joystick support?

Post by Nighthawk_0973 » Tue May 03, 2011 4:31 pm

ok thanx :)

But about the controllers scripting, where would I put the script?
https://sites.google.com/site/theneverendinguniverse/ <-- Infinite Universe Website. It's a 2D MMORPG I'm releasing into beta near the late summer (I hope :D) note: RF isn't an MMO maker. Not yet anyways.

Allanon
Posts: 493
Joined: Mon Aug 29, 2005 8:23 am

Re: Sony Dualshock 2 (Playstation 2) joystick support?

Post by Allanon » Tue May 03, 2011 7:26 pm

You can see examples of scripts that control the player's movement by looking at the genericplayer.s file in RF's /scripts/sample folder or the player.s file located in the /scripts/player folder of the Nirhis Train game. The examples don't include joystick control but you can see how the isKeyDown() function is used and use the joystick functions in a similar way. Use the manual that comes with RF if you need to figure out what a script function does, all the RF script functions are in the manual.

Also, when you add a pawn entity in the level editor there is a ScriptName property where you place the filename of the script that controls that pawn. And the SpawnOrder property that allows you to specify the script order to run when the pawn is spawned. For example you would put something like script/sample/genericplayer.s as the ScriptName and Spawn as the SpawnOrder.

User avatar
Nighthawk_0973
Posts: 234
Joined: Tue Apr 19, 2011 2:08 am
Location: In front of my computer.

Re: Sony Dualshock 2 (Playstation 2) joystick support?

Post by Nighthawk_0973 » Wed May 04, 2011 9:51 pm

ok well, would it work if I used the script below by replacing the

Code: Select all

IsKeyDown(KeyNum)
code with the

Code: Select all

IsButtonDown(int 1, int 1)
for each input I wanted to use. Where would I save this script and how would I get it to work? also, how do I know what buttons are what scancode etc.
https://sites.google.com/site/theneverendinguniverse/ <-- Infinite Universe Website. It's a 2D MMORPG I'm releasing into beta near the late summer (I hope :D) note: RF isn't an MMO maker. Not yet anyways.

Allanon
Posts: 493
Joined: Mon Aug 29, 2005 8:23 am

Re: Sony Dualshock 2 (Playstation 2) joystick support?

Post by Allanon » Thu May 05, 2011 1:44 am

That is the right idea but the script might need some modifying to move the pawn the way you would like. The IsButtonDown(value1, value2) function will return true if the specified joystick button is being pressed and false if it is not. The first value in the function is the joystick number which will probably be 0 for the first connected joystick and 1 for the next and so on. The second value will be the button number which starts at 0, you will need to experiment to figure out the number of each button. Also for the directional pad and analog sticks you will need to use the GetJoyAxis functions, some of the pads and/or sticks might not be able to be polled or they might show up as different joystick numbers, again you will need to experiment.

Also the second paragraph of my last post states how to add the script to a pawn. The script can be in any folder since you are specifying the script's path in the pawn's ScriptName property.

Post Reply