It is currently Thu Aug 22, 2019 4:59 pm



Reply to topic  [ 12 posts ] 
 Assistance with script examples .... 
Author Message
One Eyed Hopeful

Joined: Wed Aug 07, 2013 12:09 am
Posts: 14
Reply with quote
Hello again,

I have been diligently looking for examples of FreePie scripts. I have searched the forums, the internet through google, webcrawler, bing and duckduckgo, for examples of scripts having to do with FP scripts and ppjoy or joystick .

The only real examples I have found, were the old syntax (lua ?) and will not work with python. I even looked for ways to access the joystick inputs directly with python and apparently, there is no way without using a pygame dev kit, or there was something called " gobject " but that was mainly for linux. Which is kind of funny, as I and my family have used linux for everything EXCEPT gaming, since 1995.

I have decided to post some snipets of my glovepie code ( :o not trying to start trouble ) in the hopes that someone with previous experience with GP, might assist me with the transition to FP. I will post snipets of my scripts, and if someone can translate the code to something that will work with FP, that would help kick-start my scripting with FreePie. Here goes:

I will leave my " //commments " in the scripts, so that you might understand what I am doing with GP.

/// These are all Global variables and settings.


//Axis (*note - I have 4 PPJoy Virtual sticks, so the first physical joystick is #5 )

PPJoy1.Analog0 = MapRange(Joystick6.x, -1,1, -1,1) //Ailerons
PPJoy1.Analog1 = MapRange(Joystick6.y, -1,1, -1,1) // Elevator
PPJoy1.Analog2 = MapRange(Joystick7.x, -1,1, -1,1) //Throtlle
PPJoy1.Analog3 = MapRange(Joystick8.pitch, -1,1, -1,1) //Rudder
PPJoy1.Analog4 = MapRange(Joystick7.y, -1,1, -1,1) //Radiator
PPJoy1.Analog5 = MapRange(Joystick7.z, -1,1, -1,1) //Mixture



//Modes (I actually run 12 modes, 6 regular and 6 shifted modes,
//but will only show snippets of the first 4 modes for brevity )

var.mode1 = HeldDown(Joystick8.Button1, 250 ms) and not Joystick6.Button4
var.mode1_sh = HeldDown(Joystick8.Button1, 250 ms) and Joystick6.Button4
var.mode2 = HeldDown(Joystick8.Button2, 250 ms) and not Joystick6.Button4
var.mode2_sh = HeldDown(Joystick8.Button2, 250 ms) and Joystick6.Button4


// Everything above are global variables. Below are mode specific conversions of joystick to virtual joystick commands.

//CH_CombatStick to PPJoy commands

if var.mode1
Key.F21 = Joystick6.Button9 //PTT TS3
PPJoy1.Digital0 = Joystick6.Button1 //Fire All Guns
PPJoy1.Digital5 = Joystick6.Button2 // Reload All Guns
Key.Numpad2 = Joystick6.Pov1Left //Tachometer
Key.Numpad1 = Joystick6.Pov1Right //Temperature
Key.Numpad6 = Joystick6.Pov1Down // Airspeed
Key.Numpad4 = Joystick6.Pov1Up //Altimetere
Key.NUMPAD0 = Joystick6.Button4 //Gunsight
Key.NumpadPlus = Joystick6.Button5 //Zoom-In
Key.Numpad5 = Joystick6.Button6 //View Re-Center
Key.NumpadMinus = Joystick6.Button7 //Zoom-Out
endif

if var.mode1_sh
Key.F24 = Released(Joystick6.Button9) and not Released(HeldDown(Joystick6.Button9, 300ms)) // TrackIR Recenter
Key.F23 = HeldDown(Joystick6.Button9, 300 ms) // TrackIR Pause
Key.F20 = Joystick6.Button5 //TS3 Volume Up
Key.F19 = Joystick6.Button7 // TS3 Volume Down
PPJoy1.Digital9 = Joystick6.Button1 // Drop Single Bomb
PPJoy1.Digital12 = Joystick6.Button10 // Toggle Bombbay Doors
endif


if var.mode2
Key.F21 = Joystick6.Button9 //PTT TS3
Key.Numpad2 = Joystick6.Pov1Left //Tachometer
Key.Numpad1 = Joystick6.Pov1Right //Temperature
Key.Numpad6 = Joystick6.Pov1Down // Airspeed
Key.Numpad4 = Joystick6.Pov1Up //Altimetere
Key.NUMPAD0 = Joystick6.Button4 //Gunsight
Key.NumpadPlus = Joystick6.Button5 //Zoom-In
Key.Numpad5 = Joystick6.Button6 //View Re-Center
Key.NumpadMinus = Joystick6.Button7 //Zoom-Out

endif

if var.mode2_sh
Key.F24 = Released(Joystick6.Button9) and not Released(HeldDown(Joystick6.Button9, 300ms)) // TrackIR Recenter
Key.F23 = HeldDown(Joystick6.Button9, 300 ms) // TrackIR Pause
Key.F20 = Joystick6.Button5 //TS3 Volume Up
Key.F19 = Joystick6.Button7 // TS3 Volume Down
PPJoy1.Digital9 = Joystick6.Button1 // Drop Single Bomb
PPJoy1.Digital12 = Joystick6.Button10 // Toggle Bombbay Doors
endif
-------------------------------------------------------------------------------------

This is just part of the glovepie script that I use with Rise of Flight. The shortest of all of my scripts. I have only included the first 2 and shifted modes at that.

I already know that for now, FreePie does not do the F-16 through F-22 key codes. That is OK. I am just really needing to get a basic familiarity with the proper syntax to set global modes, and then call those modes to convert analog and digitial input from various joystiscks and gamepad, to the 4 ppjoy virtual sticks that I actually use to send data to games and gaming tools.

If you recognize any places in the above script where you can assist, I would appreciate it. I do not expect someone to completely convert my scripts, just give me an idea as to where to get started.

Especially in setting the global variables if it is even possible at all. I know python will accept " if - then ", and even " elif " statements, but have not found any reference to global settings. It may not even be possible.

Any assistance would be greatly appreciated,

EDIT: even if the assistance is just pointing me to documentation or websites that might have the info I am needing. I do not mind RTFM, if I can find the F*ck**g Manual. :lol:


Fri Aug 09, 2013 2:10 am
Profile
Petrif-Eyed

Joined: Mon Jun 22, 2009 8:36 am
Posts: 2160
Location: Stockholm, Sweden
Reply with quote
Theres one little demo script for ppJoy on the samples page

http://andersmalmgren.github.io/FreePIE/samples.html

Heres some answers to your questions.

Code:
if starting:   
    ppJoy[0].setRange(-1, 1)
    joystick[1].setRange)(-1, 1) #First stick is the ppJoy virtual stick
   
    #modes
    modeOne = False
    modeTwo = False
    #etc...
   
#Set x y axis on ppJoy stick   
ppJoy[0].setAxis(AxisTypes.X, joystick[1].x)
ppJoy[0].setAxis(AxisTypes.Y, joystick[1].y)


#toggle true/false when button 4 is pressed on real stick
if joystick[1].getPressed(4):
   modeOne = not modeOne
   
#Press button 4 once for this mode to fire, press again to make it stop
if modeOne:
   keyboard.setPressed(Key.F15) #setPressed will make F15 trigger once (its not hold down)
   
#diagnostics.watch is a good way to debug, remember it updates the GUI in real time so remove these when play games
#Because it will take some CPU/GPU resources
diagnostics.watch(modeOne)
   

   


F16 - F22 will be fixed, but it might take a while
Let me know if you have more questions

_________________
FreePIE
My blog


Fri Aug 09, 2013 2:32 am
Profile
One Eyed Hopeful

Joined: Wed Aug 07, 2013 12:09 am
Posts: 14
Reply with quote
Thanks CyberVillain,

Yeah, saw the example script at the FreePie website. Not much info there. :lol:

You provided enough info to get me started, especially defining modes.

Yeah, you already answered my (F)unction key question in the other thread, that is why I acknoweldged that and said it wasn't so important. Will be glad when it gets done, but no need to rush.

One more question, the first line ,

if starting:

is that needed in every script, at various places throughout the script, and is there a need for some sort of " stop ", kind of like a

if
endif

or is it just a one time in each script thing ?

BTW, once I get this script right, I will be providing it with notes on bugs I run into. Not neccesarily bugs in your program, but bugs in how badly I screw some things up as I work through it.

I may not be able to help so much with programming, but I am a scripting fool when it comes to makig use of alternate joystick software. ie.. I never did install the Saitek SST software for use wth the X45, I used the Dhauzimmer drivers and Hazzard scripts, and then switched to a scripting program called Biped. And was able to assist many people with those alternatives.

I promise, I will be able to contribute in helping others when it comes to putting FreePie to actual use. After all, what good is software, if no one can use it ? :o No insult intended.

Maybe a thread or sets of threads just for scripts. I am also eyeballing those TrackIR/ FreeTrack stuff as well for intergration in my gaming experience. To be perfectly honest, I do not like having to run NaturalPoint software, I can not stand the company, so if I can use the HW I bought, without having to run the NP software at all, I will.

I currently have GP scripts that are in excess of 1200 lines of code, that work perfectly. controlling game commands, and 4 or 5 utilities/ tools all at the same time so that I never have to reach for a keyboard, my own little "virtual reality" you might say. Everything right there on the HOTAS and panel systems.

Once again, Thanks for all that you do.

EDIT: BTW, I do not know just how much of this code is exclusive of actual Python code (syntax) but I found an excellent page for people that do not know python or programming at all, here is a link.

http://wiki.python.org/moin/BeginnersGuide

Just a thought, but maybe a thread on the forums with helpful links to information for newbies like me would be appropriate. :)


Fri Aug 09, 2013 3:35 am
Profile
Petrif-Eyed

Joined: Mon Jun 22, 2009 8:36 am
Posts: 2160
Location: Stockholm, Sweden
Reply with quote
Code:
if starting:
   x = 0

Will create a x variable the first time, if you skipped the "if starting" line it would set x to zero all the time which would overwrite values from hardware

There is also a if stopping: variable, but its usually not needed


Good to have a hard core user on board, you are bound to find hard to find bugs, which is welcomed.

I think there is a thread about scripting, not very active though (And some of the scripts are Lua)
viewtopic.php?f=139&t=15052

I appricate that you spread word about FreePIE in the flight sim community, thanks a million. Let me know if I can assist you further.

I'm having a dialog with the creator of vJoy (The open source version) so we will probably see support for it very soon (So that you can skip ppJoy and all the troubles of unsigned drivers and w7)

_________________
FreePIE
My blog


Fri Aug 09, 2013 5:05 am
Profile
One Eyed Hopeful

Joined: Wed Aug 07, 2013 12:09 am
Posts: 14
Reply with quote
CyberVillain wrote:
I'm having a dialog with the creator of vJoy (The open source version) so we will probably see support for it very soon (So that you can skip ppJoy and all the troubles of unsigned drivers and w7)



Just to be clear, it will not skip the unsigned drivers issue. The Headsoft driver is signed, the opensource vJoy driver is not.

see here

http://vjoystick.sourceforge.net/site/index.php/download-a-install/80-install-x86x64

but the same reason that I am starting with FreePie, is the same reason for looking at vJoy as a possible replacement for PPJoy. And there is only one reason for that, PPJoy is no longer being developed, vJoy is, and with vJoy, you can create up to 16 virtual joysticks. I do not really need that many :lol: right now anyway.

Seriously, I have been using PPjoy since my Win 95 days. many many years ago. and have never found a need to even consider switching, until now.

but vJoy is still being developed. So I am taking a serious look.

BTW, saw your post over at vJoy forum.

Sick minds think alike. :lol:

yeah, I am certifiable too .......


Fri Aug 09, 2013 6:23 am
Profile
Petrif-Eyed

Joined: Mon Jun 22, 2009 8:36 am
Posts: 2160
Location: Stockholm, Sweden
Reply with quote
I thought it was signed, missed that :/
If two sticks is enough you can use Headsoft VJoy (Once the 5 minute limit is fixed)

_________________
FreePIE
My blog


Fri Aug 09, 2013 7:13 am
Profile
One Eyed Hopeful

Joined: Wed Aug 07, 2013 12:09 am
Posts: 14
Reply with quote
Quote:
I thought it was signed, missed that :/
If two sticks is enough you can use Headsoft VJoy (Once the 5 minute limit is fixed)


No needy, I do not mind the "TEST Mode" at all. I keep an eye on my OS like a hawk, so not worried about that. And, the undocumented time limit crap is just that "crap". I much prefer to stay away from SW that does such things.

But I am also really impressed with FreePie and with vJoy, ie .. it is first time in a very long time, that I post a comment on a forum, addressing 3 people: all developers of SW, and get a RE: from all 3 with in mere hours, that is both helpful and quick. Did I say I am REALLY IMPRESSED. Not shouting just excited to be working with/ associated with a great bunch of guys.

Have you even heard back from the headsoft people to your inquiry ? So, you see what I mean ?

Last thing, someone asked at the other forum, got me to wondering, does FreePie swallow commands ? Not really necessary, but a nice feature, maybe for the future.


Fri Aug 09, 2013 12:09 pm
Profile
Petrif-Eyed

Joined: Mon Jun 22, 2009 8:36 am
Posts: 2160
Location: Stockholm, Sweden
Reply with quote
It does not swallow keyboard nor joystick.
We use SlimDX to to get the keys pressed. I think we would need to rewrite it to use win32 hooks instead if we want to be able to swallow key strokes, i can look into it.


If there is a key that the game input settings does not trigger on you can use that key, each time you press it a new virtual joystyick command is sent. like

Code:
from System import Int16

if starting:
   sequence = 0

def resetAxis():
   vJoy[0].x = 0

if keyboard.getPressed(Key.Pause):
   resetAxis()
   if sequence == 0:
      vJoy[0].setPressed(0)
   elif sequence == 1:
      vJoy[0].setPressed(1)
   elif sequence == 2:
      vJoy[0].x = Int16.MaxValue #Max axis      
   elif sequence == 3:
      vJoy[0].x = -Int16.MaxValue #Max axis

   sequence = sequence + 1
   if sequence > 3:
      sequence = 0


Each time you press Pause a new sequence will be played

_________________
FreePIE
My blog


Sat Aug 10, 2013 4:51 am
Profile
One Eyed Hopeful

Joined: Wed Aug 07, 2013 12:09 am
Posts: 14
Reply with quote
I am leaving the post, but want to say that it is again, the time limit, or pay crap. That little tid bit was not disclosed by the facetracknoir guys, until after I had installed and then I found this ...

http://sourceforge.net/p/facetracknoir/discussion/1150909/thread/4bfabf98

I am about to register there, and let them know what I think about their non-disclosure of the time limited driver crap.
-------------------------------------

Updated info about a signed Vjoy driver.

Over here ...

http://facetracknoir.sourceforge.net/home/default.htm

More specifically this page

http://facetracknoir.sourceforge.net/news/news.htm

Notice that in the 1.7 release info, they have an updated ( ? ) working signed Vjoy driver included in their install package. The problem is, that I have searched but been unable to ascertain, which VJoy is being provided. Headsoft or OpenSource ? No matter which though, if it is a signed driver (signed by who ? ) , working without a time disable function, it could be a solution to our issues here. Maybe ?

I have downloaded, and am about to install. Actually I am backing up my registry and the files as are, and then will un-install PPJoy as there is apparently an occasional bug/ conflict between PPJoy and VJoy installs.

I hate the idea of messing up my PPJoy configuration, but am going to risk it.

I will install, test, and report back later. Hopefully without any major issues.

EDIT: they already include support for glovepie at that project, maybe a contact from a developer of this project might be useful in getting them to include support for FreePie. Being included with a project such as facetracknoir is bound to draw some attention to this project. Just a thought ;)


Fri Aug 16, 2013 10:39 pm
Profile
Petrif-Eyed

Joined: Mon Jun 22, 2009 8:36 am
Posts: 2160
Location: Stockholm, Sweden
Reply with quote
Here is a little hack that removes the limit

https://github.com/AndersMalmgren/FreeP ... y/VJoy.dll

Replace that dll with the one in FreePIE

_________________
FreePIE
My blog


Sat Aug 17, 2013 2:41 am
Profile
One Eyed Hopeful

Joined: Wed Aug 07, 2013 12:09 am
Posts: 14
Reply with quote
CyberVillain wrote:
Here is a little hack that removes the limit

https://github.com/AndersMalmgren/FreeP ... y/VJoy.dll

Replace that dll with the one in FreePIE



Thanks for that but .....

It did not take me but about 1 minute to make up my mind, and a half hour of uninstall, reboot, uninstall, reboot, re-install the software I had removed earlier (PPJoy) etc ...

Until I had my system back to where I wanted it. I just chalk it up to a learning exerience. Some software developers, think that it is OK to have you install what is basically Shareware in the guise of opensource or free SW, so that maybe you will pay for the right to use it. And that is OK, as long as they tell you about it before hand.

But thank you for providing the dll for those that may get caught in the "I already installed it, and do not want to have to uninstall it " situation. I would rather format my Windows partition and do a complete reinstall rather than let that software stay on my computer, but that is just me .... Lucky for me I have figured out how to avoid the install, and tear that crap out by the roots.


Sat Aug 17, 2013 4:03 am
Profile
Petrif-Eyed

Joined: Mon Jun 22, 2009 8:36 am
Posts: 2160
Location: Stockholm, Sweden
Reply with quote
Yes, its really shitty of them not to inform about that limit. But since its the only signed driver currenly available its not much choice if you don't want to run in test mode. The dll with removed timelimit will be included in next release of FreePIE

_________________
FreePIE
My blog


Sat Aug 17, 2013 4:10 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 12 posts ] 

Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by STSoftware.