Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

PPJoy library


  • Please log in to reply
69 replies to this topic
victoras_h
  • Members
  • 6 posts
  • Last active: Jun 02 2010 07:16 AM
  • Joined: 28 May 2010
Ok, I did some more fiddling with this, tried to combine the codes from above, but I can't get any signal to the virtual joystick. I am doing something wrong

If I understood right, the first part of the code must remain the same, and at the end I can modify the mappings?

Also I tried with another version from the examples above, the one from DerRaphael, but that doesn't start, it gives some error at line 60 (the one with "static" near the end)

Can anyone help?

;PPJoy library
;by Ninja Bob
;January 2, 2010

hModule := 0

PPJ_Init()
{
	hModule := DllCall("LoadLibrary", "str", "PPJoy.dll")
	Result := DllCall("PPJoy\Initialize")
}

PPJ_Term()
{
	DllCall("PPJoy\Close")
	DllCall("FreeLibrary", "UInt", hModule)
}

PPJ_SetButton(button, state)
{
	DllCall("PPJoy\SetButton", "char", button - 1, "char", state)
	DllCall("PPJoy\Update")

}

PPJ_SetAxis(axis, value)
{
	DllCall("PPJoy\SetAxisPercent", "char", axis - 1, "char", value)
	DllCall("PPJoy\Update")
}

PPJ_GetButton(button)
{
	Return DllCall("PPJoy\GetButton", "char", button - 1)
}

PPJ_GetAxis(axis)
{
	Return DllCall("PPJoy\GetAxisPercent", "char", axis - 1)
}

PPJ_ResetButtons()
{
	DllCall("PPJoy\ResetButtons")
	DllCall("PPJoy\Update")
}

PPJ_ResetAxes()
{
	DllCall("PPJoy\ResetAxis")
	DllCall("PPJoy\Update")
}





OnExit, ExitHandler
CoordMode, Mouse, Screen

PPJ_Init()   ; Grab the Joystick

Loop {
   MouseGetPos, MouseX, MouseY
   
   ; Values must be within 0-100 range
      YVal := 100-Round(100*(A_ScreenHeight-MouseY)/A_ScreenHeight)
      XVal := 100-Round(100*(A_ScreenWidth-MouseX)/A_ScreenWidth)
   
   PPJ_SetAxis(2, Yval) ;Axis 2 is the Y axis
   PPJ_SetAxis(1, Xval) ;Axis 1 is the X axis
}

Return

a::
   PPJ_SetButton(1,1)   ; Set Button 1 True
   Keywait, a         ; Wait for button to be released
   PPJ_SetButton(1,0)   ; Set Button 1 False
Return

ExitHandler:
   PPJ_Term()   ; Release the Joystick
ExitApp


Seven
  • Members
  • 1 posts
  • Last active: Jun 01 2010 03:57 PM
  • Joined: 01 Jun 2010
Dear all,

this is me first post in this forum.

I followed the instruction from ninjabob7, but got stuck and have several questions:

Please can someone answer these simple questions ?
1.) ninjabob7 says:
[quote]You'll need to install PPJoy separately and set up a virtual joystick with the default settings.
Then just put PPJoy.dll with AutoHotkey.exe, and PPJ.ahk in the lib folder. [/quote][/quote]
Where is the "lib" folder ?
Nether "Program Files\AutoHotkey" has a "lib" folder" nor "Program Files\Paralle Port Joystick\" has a lib folder.
Where shall I create a "lib" folder and put these 3 files inside ?

2.) What shall I do with all the other files from ninjabos7 "PPJoy.zip" ?
There are more files inside: ( "PPJIoctl.h", "PPJoy.c" and "PPJoy.o")
Are they needed ? If not, why ninjabob7 puts them inside ?

3.) I installed PPJoy succesfully and created a Virtual Joystick.
But I dont know how to mapp the Joystick Buttons with AHK.
When I manually doubleclick the modified "PPJ.ahk" file from Mr Elmo it gives me an Error:
[quote] Error: Call to nonexistent function.
Specifically: PPJ_init()[/quote]
[/quote]

How does AHK know, that it shall work wit PPJoy ?
I guess that has something to do with the "Lib" Folder, where the 3 files have to be put inside...
I tried to create a "lib" folder in both directories "Program Files\AutoHotkey" and "Program Files\Paralle Port Joystick\"
and doubleclicked the "PPJ.ahk" from in there, but both give me the same error.
It looks like AHK cannot handle the function "PPJ_init()", cause it is not present.



Ninjabob7 or Mr Elmo,
can you please tell me, what the next steps are (after installing PPJoy and creating a standart virtual Joystick) ?
Where do I have to extract the zip files and which "PPJ.ahk" shall i Use (ninjabob´s or Mr Elmo´s; or both in different folders ?)
Till now I used Mr Elmos "PPJ.ahk" instead of ninjabob7´s from his ZIP File, because Mr Elmo says, that it works with his.
I understand, that ninjabob´s "PPJ.ahk" file from his ZIP is a sort of empty frame, which must be filled out (values, etc), so I use Mr Elmos:

[quote]OnExit, ExitHandler
CoordMode, Mouse, Screen

PPJ_Init() ; Grab the Joystick

Loop {
MouseGetPos, MouseX, MouseY

; Values must be within 0-100 range
YVal := 100-Round(100*(A_ScreenHeight-MouseY)/A_ScreenHeight)
XVal := 100-Round(100*(A_ScreenWidth-MouseX)/A_ScreenWidth)

PPJ_SetAxis(2, Yval) ;Axis 2 is the Y axis
PPJ_SetAxis(1, Xval) ;Axis 1 is the X axis
}

Return

a::
PPJ_SetButton(1,1) ; Set Button 1 True
Keywait, a ; Wait for button to be released
PPJ_SetButton(1,0) ; Set Button 1 False
Return

ExitHandler:
PPJ_Term() ; Release the Joystick
ExitApp
[/quote]


Thank you so much for your ansers.

Best regards,
Seven
[/quote]

Mr Elmo
  • Members
  • 18 posts
  • Last active: Jun 18 2010 05:46 PM
  • Joined: 25 Oct 2006
Ninjabob's .ZIP includes the source for his DLL. Unless you intend on modifying and re-compiling his code, this is of no importance to you, and you only need PPJ.ahk and PPJ.dll.

PPJ.ahk goes in your Autohotkey\Lib folder (You must create it if it does not exist. Look up Libraries of Functions in the AHK Help), and PPJ.dll should go alongside your Autohotkey.exe that is executing the script.

For compiled scripts, you still need the dll to be alongside your executable, which would be the compiled script.

That entire underlined sentence can be taken care of completely if only you include the following line at the beginning of your script: (it includes the dll in the compiled version, and extracts it at runtime.)

FileInstall, PPJoy.dll, PPJoy.dll

%MemorablePhrase%

doninss
  • Guests
  • Last active:
  • Joined: --
I can only get X and Y axes to work properly. The other six axes feed full on (100) for any value over 50 fed, and full off (0) for any value under 50.

jshafer817
  • Members
  • 17 posts
  • Last active: Aug 15 2015 03:23 AM
  • Joined: 10 Nov 2010
So can anyone figure out a way to Send to Button1 on a Virtual PPJoy Joystick?

I want to use it with a reg loop... If a registry key is present hold down this button.. If its not then let go. Worried about timings though.

Srele
  • Guests
  • Last active:
  • Joined: --
Hello.
I'm new here and my eng is not so good.
I Need help with this program (PPJoy), I installed it and it works perfect! My game recognize it and I can use it in game, but I have problem with mouse interfireing. For ex when I play game I can steare with mouse but i muve camera with mouse too.
Is there any way to disable mouse and just simulate Joystick (Stearing wheel)?

rumeal
  • Guests
  • Last active:
  • Joined: --
has anyone gotten this to work
can you post a simple ahk that just moves the Z axis

rumeal
  • Guests
  • Last active:
  • Joined: --
This code did absolutely nothing
the ahk was ran from the desktop
the dll is on the desktop
i used JoystickTest.ahk to monitor the joytstick

...

OnExit, ExitHandler
CoordMode, Mouse, Screen

PPJ_Init() ; Grab the Joystick

Loop, 100
{

; Values must be within 0-100 range

PPJ_SetAxis(3, 25) ;3 is Z axis
sleep 100

}

Return

ExitHandler:
PPJ_Term() ; Release the Joystick
ExitApp

le-mec
  • Members
  • 51 posts
  • Last active: Dec 15 2011 02:30 AM
  • Joined: 24 Dec 2006
Please note that this library *might* not work with AHK_L or Autohotkey 64-bit versions!!!!!

le-mec
  • Members
  • 51 posts
  • Last active: Dec 15 2011 02:30 AM
  • Joined: 24 Dec 2006
I spent a little time in MSVC and recompiled ninjabob's source code because I needed more than 16 buttons.

Maybe the code wasn't optimized, but as a result of my meddling, the DLL shrank to a measly 7k! I had to export the DLL's functions since they weren't exported in ninjabob's code (maybe he used a DEF file).

32 button/16 axes support

le-mec
  • Members
  • 51 posts
  • Last active: Dec 15 2011 02:30 AM
  • Joined: 24 Dec 2006

This code did absolutely nothing
the ahk was ran from the desktop
the dll is on the desktop


(-_-')

Put the DLL into your autohotkey folder. You know, the one that contains "autohotkey.exe"

le-mec
  • Members
  • 51 posts
  • Last active: Dec 15 2011 02:30 AM
  • Joined: 24 Dec 2006

Since you figure out how to make pp_joy work, can you send me a simple code just to press the button 1 of the joystick? I tried without success:


#include Lib\PPJ.ahk
OnExit, ExitHandler

PPJ_Init() ; Grab the Joystick

F4::
DllCall("PPJoy\SetButton", "char", 1, "char", 100)
DllCall("PPJoy\Update")
Keywait, F4 ; Wait for button to be released
DllCall("PPJoy\SetButton", "char", 1, "char", 1)
DllCall("PPJoy\Update")
Return

ExitHandler:
PPJ_Term() ; Release the Joystick
ExitApp


Next time don't ask via PMs because others cannot benefit from replies.

#Persistent
#SingleInstance force

PPJ_Init()
SetTimer, ButtonMash, 300

TrayTip, PPJ ButtonMash Example, hit ESCAPE To Exit
return

ButtonMash:
	mashOn := mashOn ? False : True
	if (mashOn)
	{
		PPJ_SetButton(1, 1)
		PPJ_SetAxis(1, 100)
	}
	else
	{
		PPJ_SetButton(1, 0)
		PPJ_SetAxis(1, 0)
	}
return

Escape::
AppQuit:
	PPJ_SetButton(1, 0)
	PPJ_SetAxis(1, 50)
	PPJ_Term()
ExitApp


le-mec
  • Members
  • 51 posts
  • Last active: Dec 15 2011 02:30 AM
  • Joined: 24 Dec 2006

Hello.
I'm new here and my eng is not so good.
I Need help with this program (PPJoy), I installed it and it works perfect! My game recognize it and I can use it in game, but I have problem with mouse interfireing. For ex when I play game I can steare with mouse but i muve camera with mouse too.
Is there any way to disable mouse and just simulate Joystick (Stearing wheel)?


try

BlockInput, MouseMove


  • Guests
  • Last active:
  • Joined: --
It seems that noone including me understands how this works.
no examples work either.
cant this be better documented?

le-mec
  • Members
  • 51 posts
  • Last active: Dec 15 2011 02:30 AM
  • Joined: 24 Dec 2006
If you donate your eyeballs to science I would be happy to help. The preferred packaging method is in hermetically-sealed containers filled with formaldehyde. Please try to keep the optic nerves intact, and don't forget to clearly label each jar with "L" and "R".

L is for the left eyeball, and R is for the right eyeball.

If you are unwilling to donate your eyeballs, or are already without your eyeballs due to unfortunate circumstances such as work-related accidents involving ice picks or due to birth defects, then photographic proof of your condition will be acceptable.

If, however, you are still unable to accept these conditions, please provide a more accurate description of your troubles and attempts than "it doesn't work please help give me something for nothing" and I may try to see what I can do.

Unless you were born in Papua New Guinea.