[PLUGIN] Joystick / Game controller support! v1.2.0

Started by Wyz, Fri 20/08/2010 19:43:43

Previous topic - Next topic

Snarky


eri0o

Hey Wyz, found a repo in github that may contain interesting code github.com/ThemsAllTook/libstem_gamepad

my storage suggestion is Google Drive if you already have gmail.

Wyz

All of my Dropbox accounts are filled to past the brim unfortunately. Hmmm,... Google Drive might be an option; I can make a new gmail account for that I guess. I'll look into that! Thanks all for the suggestions. :)

edit:
All updated! I've counted: this is the fifth time I had to swap over files to another host; pretty please Google, don't fail me. I can't stand doing it once more. (roll)
Life is like an adventure without the pixel hunts.

eri0o

#103
Dear Wyz,

if you ever have time, please share the code for the joystick plugin . :] I really would like to take a stab at making a Linux .so version . (roll)

Edit: Recently I discovered that launching a game from steam (you can add non-steam games to steam) makes steam filter the joystick first, like, a PS4 joystick for instance, is converted in a joystick that feels like Xbox360 when looking from the Joystick plugin!

eri0o

I recently wanted to add joystick support in the Linux version of my game. I saw Until I Have You in my Steam library had it. Dualnames pointed me to qcaptain Nemo, and qcaptain Nemo was kind enough to provide me the source he wrote. He told me I could do what I want, and if I shared, I should stick a MIT license in it... So, here it is.

Github Repo | Release

When launching your game from command line, it will happily state Plugin 'agsjoy' loading succeeded, resolving imports... !

Just place the libagsjoy.so in your <Game Name>/Compiled/Linux/data/lib64 folder - I haven't yet built for 32-bits. :/

libagsjoy.so (64 bit)

Bear in mind this code uses SDL2, so your game will be dependant on SDL2 .

Crimson Wizard

#105
Finally, good to know someone did this, I was about to suggest you writing your own using SDL, but looks like this is no longer needed :).

BTW, is it really Linux-only code? If that's SDL it could work on Windows too... probably.

eri0o

#106
Hey! You were right CW.  Now I just need someone to help me figure out how to fuse both Windows and Linux version in the same code and which ifdef can save me.

agsjoy.dll (SDL2 edition) | SDL2.dll (you need to download this one too!)

libagsjoy.so

I created a folder called WindowsVersion in my repo. Source available on Github (requires VS 2017 )

Note that feature parity with Wyz plugin hasn`t been reached yet.

Note: Build your game using Wyz's .dll and then switch in the game folder for this fall and SDL2.dll if you want to test it.

Edit:
I think to add each ePOV enumerator to the editor, to be compatible with Wyz's agsjoy, I would need to use something like editor->RegisterScriptHeader . The values I got from experiementing, but I don't know if I should get them from somewhere...

Edit2: has someone ever written a plugin for OSX? How does one build for it?

eri0o

New 0.2.1 release | github repository

Windows build: agsjoy.dll (SDL2 edition) | SDL2.dll (you need to download this one too!)

Linux build: libagsjoy.so

MAC OSX build: libagsjoy.dylib

feature parity with Wyz plugin hasn't been reached yet.

Note:

  • For Windows Build your game using Wyz's .dll and then switch in the compiled game folder for this agsjoy.dll and SDL2.dll if you want to test it.
  • For Linux, just place libagsjoy.so in the same folder as the binary ags (if you are building the Engine yourself) or in Compiled/Linux/data/lib64 if you are using prebuilt Linux right from the Editor. SDL2 must either be installed through your package manager or the game should be loaded through Steam.
  • For MAC OSX I don't know yet, but it should be working. Requires SDL2 too.

Wyz

Ok, I've just read the developments here. I have been disconnected from the world for a while, my apologies. I saw your PM earlier eri0o; I have responded to it.
Let me state a couple of things I wrote him.

I have just released my incomplete refactor of the Joystick plugin what was going to be version 1.3.0. As the name suggests it is in an unfinished state; life happened unexpectedly, and I had to stop working on it.
This version has a nice build system and supports building multi-platform. That also allows adding SDL as a platform bypassing any unfinished code. So I've prepped for this and put it up on GitHub.

However, this version does not help reverse engineering the plugin I guess; so if you want sources for 1.2.x, please PM me. I don't want to release them though.

I do want to finish it in the future, but it seems unfair to let you all wait. I hope this helps at least.

And the repo: https://github.com/FTPlus/agsjoy
Life is like an adventure without the pixel hunts.

Vincent

Hello guys and Wyz, I think I have find an issue which I don't know how to fix at the moment. One of my friend which I am working with has sent me a saved game data of our game for testing purpose. Now whenever I try to load the saved game data I get these message from Ags (3.2.1).

If I try to load the game when the editor is opened:




If I try to load the game from the .exe file:


Wyz

Hmm which version of the plug-in are you using? Do you perhaps know if the game was using more than one Joystick at the time the savegame was made?
I can see how the second error might occur, but the first one is a bit puzzling. :-\
Life is like an adventure without the pixel hunts.

Crimson Wizard

Idk what kind of game setup you have there, but the first error may also mean that the save was done running a game with different exe name, and it tries to find and run that game data.

Vincent

@Wyz: I am using the version 1.2.1.0 it is dated 01/09/2017. I remember you have done a fixed version for me two years ago or something and it is what I am using right now. When the game was saved from my friend no joystick were plugged in. If I try to load the game with a joystick plugged in then I got a different message from Ags (if you would like I can provide this error message too). The first problem is a bit puzzling for me too since in my game I am not calling any "RunAgsGame" function so I am just wondered why this is happening!?

@Crimson Wizard: What you mean by what kind of game setup I have? Me and my friend are using the same version (Ags 3.2.1) same name of the game and same scripts. I'm really surprised that this isn't working. This must have something to do with the plugin problem, maybe if we can cure it then the game can loaded correctly.

Wyz

Hmm I see. Yes that error message would probably help a lot, thanks! :)
Well, save games are a delicate thing, and moving them between machines could unearth all sorts of subtle and hard to reproduce errors. ;)
Life is like an adventure without the pixel hunts.

Vincent

Yes I can understand what you mean. If somehow it cannot be solved then is just okay. If I try to load the game with a joystick plugged in while the editor is opened I still get the same message regarding "RunAgsGame". But if I try to load the game with a joystick plugged in from the .exe file then I get this error message:


Crimson Wizard

#115
Quote from: Vincent on Mon 08/04/2019 09:12:36The first problem is a bit puzzling for me too since in my game I am not calling any "RunAgsGame" function so I am just wondered why this is happening!?

RunAGSGame is also called automatically under following condition: if the save was made when main game file (for example - exe) had one name, but you are loading it with another. It's some old logic that had its reasons.

It may be easier to find out what's going on if you open your savegame in a hex editor, or even simple text editor, and search for anything that looks like a filename, it should be somewhere at the beginning of the file.

Vincent

Quote from: Crimson Wizard on Mon 08/04/2019 11:18:31
RunAGSGame is also called automatically under following condition: if the save was made when main game file (for example - exe) had one name, but you are loading it with another. It's some old logic that had its reasons.

I don't know if all of this has something to do with the joystick plugin but the exe file it is called in the same way.

Quote from: Crimson Wizard on Mon 08/04/2019 11:18:31
It may be easier to find out what's going on if you open your savegame in a hex editor, or even simple text editor, and search for anything that looks like a filename, it should be somewhere at the beginning of the file.

I have opened the savegame with a text editor and this is what I have:







I can see the name of the game and the description we used into the saved game file but I can't see anything which is wrong with them.

Crimson Wizard

#117
I don't think this particular error (with RunAGSGame) is related to plugin, but I may be wrong.

Regarding save contents: try to search for ".exe" or ".ags" or "*.dat". There should also be engine's version nearby, something like 3.21.1111 or with slightly different numbers).

Vincent

I was just able to find a line from the search ".exe" but nothing regarding the other two.


Crimson Wizard

Ok, so "Tales of Jayvin.exe" is your real current exe name?

Dumb question, do you have any extra files in Compiled folder, _Debug folder or project root, that may be left from other games or other version of this game?

SMF spam blocked by CleanTalk