Jibble

Author Topic: [PLUGIN] AGS Controller Support (OPEN SOURCE) - v1.1  (Read 7449 times)

Olleh19

  • I'm an AGS n00b, please don't kill me
Re: [PLUGIN] AGS Controller Support (OPEN SOURCE) - v1.1
« Reply #20 on: 05 Nov 2020, 12:35 »
Hi!

I have been trying to use the Rumble feature, but i can't seem to change the values at all. Apart from raising the duration ???
Am i doing something wrong?
All i can change is the durations length but when i try to lower it. It rumbles 4ever instead. So i've deicided to use it as a neckmassage device when my neck hurts after drawing too much pixelart, kidding (laugh)
Is it a bug or am i not understanding the concept, i've tried lowering from 40 to 30 or 35 or such. Should i lower in specific values? If so please write some that you think might work.
I want "fast" short rumbles for an impact, not these 40 game loops rumbles!  (wrong)

Wished i knew what was wrong. This is the only code that works, if i change this a little either it rumbles forever. or if i raise the duration to 100 it will go for 100game loops, etc. But the other values, no

Edit: Should the gamespeed be set to 30 if i want 30 loops to work? :/ Don't want to do that, ofc.

Code: Adventure Game Studio
  1. if (!gamepad.IsButtonDownOnce(3))  
  2.  
  3. {
  4. gamepad.Rumble(65636,65535,40);
  5.  
  6. }
  7.  
« Last Edit: 05 Nov 2020, 12:47 by Olleh19 »

Re: [PLUGIN] AGS Controller Support (OPEN SOURCE) - v1.1
« Reply #21 on: 03 Dec 2021, 21:35 »
Hi. Plugin is not working with my Xbox One controller. Any suggestions?

Dualnames

  • Local Moderator
  • Rottwheelers
  • Pretty Badass
    • Dualnames worked on one or more games that won an AGS Award!
    •  
    • Dualnames worked on one or more games that was nominated for an AGS Award!
Re: [PLUGIN] AGS Controller Support (OPEN SOURCE) - v1.1
« Reply #22 on: 05 Dec 2021, 17:59 »
I have an xbox controller and it works fine on my end, can you paste your code here.
No more military army stuff. I'm alive and back.

deadsuperhero

  • Frustrated Game Developer
    • I can help with backgrounds
    • I can help with characters
    • I can help with making music
    • I can help with scripting
Re: [PLUGIN] AGS Controller Support (OPEN SOURCE) - v1.1
« Reply #23 on: 04 Jan 2022, 00:26 »
This is an amazing idea for a plugin! Quick question: is this plugin currently only available for Windows builds of AGS games, or will it also work with MacOS / Linux runtimes?

It's not the worst thing in the world if it's Windows-only at the moment, because Wine/Proton are pretty good for AGS games, but it'd be nice to support this kind of thing natively!
The fediverse needs great indie game developers! Find me there!

Dualnames

  • Local Moderator
  • Rottwheelers
  • Pretty Badass
    • Dualnames worked on one or more games that won an AGS Award!
    •  
    • Dualnames worked on one or more games that was nominated for an AGS Award!
No more military army stuff. I'm alive and back.

deadsuperhero

  • Frustrated Game Developer
    • I can help with backgrounds
    • I can help with characters
    • I can help with making music
    • I can help with scripting
Re: [PLUGIN] AGS Controller Support (OPEN SOURCE) - v1.1
« Reply #25 on: 05 Jan 2022, 00:54 »
Oops! Sorry I didn't catch that. I'll definitely check this out for some of my projects!
The fediverse needs great indie game developers! Find me there!

Volcan

  • I like making adventure games and flash movies
    • Volcan worked on one or more games that was nominated for an AGS Award!
Re: [PLUGIN] AGS Controller Support (OPEN SOURCE) - v1.1
« Reply #26 on: 16 Jan 2022, 19:31 »
I get this error:



I use AGS 3.5.1

I have AGSController.dll and SDL2.dll.
« Last Edit: 16 Jan 2022, 19:33 by Volcan »

eri0o

Re: [PLUGIN] AGS Controller Support (OPEN SOURCE) - v1.1
« Reply #27 on: 16 Jan 2022, 23:37 »
The SDL2.dll has to be 32 bits and placed in the same directory.

Volcan

  • I like making adventure games and flash movies
    • Volcan worked on one or more games that was nominated for an AGS Award!
Re: [PLUGIN] AGS Controller Support (OPEN SOURCE) - v1.1
« Reply #28 on: 17 Jan 2022, 02:31 »
The SDL2.dll has to be 32 bits and placed in the same directory.

I don't get it since SDL2.dll is included with AGSController.dll.

Re: [PLUGIN] AGS Controller Support (OPEN SOURCE) - v1.1
« Reply #29 on: 17 Jan 2022, 02:49 »
I don't get it since SDL2.dll is included with AGSController.dll.

Have you copied SDL2.dll to where your game.exe is?

BTW, I could not see the picture that you posted until I copied the address into browser by hand, and answered to captcha.

deadsuperhero

  • Frustrated Game Developer
    • I can help with backgrounds
    • I can help with characters
    • I can help with making music
    • I can help with scripting
Re: [PLUGIN] AGS Controller Support (OPEN SOURCE) - v1.1
« Reply #30 on: 17 Jan 2022, 03:30 »
The SDL2.dll has to be 32 bits and placed in the same directory.

I don't get it since SDL2.dll is included with AGSController.dll.

Hey, I had the same problem earlier today. If you check earlier in the thread, it turns out you need to get the 32-bits version of the DLL from the LibSDL site: https://www.libsdl.org/download-2.0.php
The fediverse needs great indie game developers! Find me there!

Volcan

  • I like making adventure games and flash movies
    • Volcan worked on one or more games that was nominated for an AGS Award!
Re: [PLUGIN] AGS Controller Support (OPEN SOURCE) - v1.1
« Reply #31 on: 17 Jan 2022, 03:39 »
The SDL2.dll has to be 32 bits and placed in the same directory.

I don't get it since SDL2.dll is included with AGSController.dll.

Hey, I had the same problem earlier today. If you check earlier in the thread, it turns out you need to get the 32-bits version of the DLL from the LibSDL site: https://www.libsdl.org/download-2.0.php

Thanks

It works.

deadsuperhero

  • Frustrated Game Developer
    • I can help with backgrounds
    • I can help with characters
    • I can help with making music
    • I can help with scripting
Re: [PLUGIN] AGS Controller Support (OPEN SOURCE) - v1.1
« Reply #32 on: 19 Jan 2022, 09:35 »
Edit: Before reading any of this, note that I am using a Playstation 5 controller, which is less common on a PC (Linux) setup. It's entirely possible that different controllers read axis values differently.

Hey, so I'm currently working on adapting this to my game, but I have a couple of stumbling blocks to figure out:

So...the first one is getting the axis to work properly. In a nutshell, I'm trying to make one of my joysticks move the mouse cursor around. I have an extremely rough implementation right now:

Code: Adventure Game Studio
  1. if (gamepad.GetAxis(0) < -200 && !LEFT){ // LEFT STICK LEFT
  2.    Mouse.SetPosition(mouse.x - 1, mouse.y);
  3.    HitNoDirection();
  4.    LEFT=true;
  5.    }
  6.     else if (gamepad.GetAxis(0) > 200 && !RIGHT){ // LEFT STICK RIGHT
  7.       Mouse.SetPosition(mouse.x + 1, mouse.y);
  8.       HitNoDirection();
  9.       RIGHT=true;
  10.     }
  11.     else if (gamepad.GetAxis(1) < -200 && !UP){ // LEFT STICK UP
  12.       Mouse.SetPosition(mouse.x, mouse.y - 1);
  13.       HitNoDirection();
  14.       UP=true;
  15.     }
  16.     else if (gamepad.GetAxis(1) > 200 && !DOWN){ // LEFT STICK DOWN
  17.       Mouse.SetPosition(mouse.x, mouse.y + 1);
  18.       HitNoDirection();
  19.       DOWN=true;
  20.     }
  21.     else {
  22.       HitNoDirection();
  23. }
  24.  

Unfortunately, the cursor seems to get confused about where it's supposed to go on the screen. Up and left seem to work okay, but the game seems to get confused about down and right.


The second stumbling block is that I'm trying to treat the X button as a Left Click, and the Square button as a Right Click:

Code: Adventure Game Studio
  1.     if (gamepad.IsButtonDownOnce(0)) // X Button
  2.       {
  3.         if (gWheel.Visible == true) {
  4.           Wait(1); // Have to have this, otherwise the first lines of dialogue get skipped?
  5.           Mouse.Click(eMouseLeft); // Clicking on buttons
  6.         }
  7.         else if (gInventory.Visible == true) {
  8.           Mouse.Click(eMouseLeftInv); // Interact with Inventory Items
  9.         }
  10.         else {
  11.           Mouse.Click(eMouseLeft); // Normal default Left Click, which is normally just walking to a specific point.
  12.         }
  13.       }
  14.  

So...the Wheel menu buttons work fine when left clicking...but! When a message comes up on the screen, this simulated left click is incapable of dismissing them. It also can't seem to skip speech.

« Last Edit: 19 Jan 2022, 10:13 by deadsuperhero »
The fediverse needs great indie game developers! Find me there!

eri0o

Re: [PLUGIN] AGS Controller Support (OPEN SOURCE) - v1.1
« Reply #33 on: 19 Jan 2022, 20:43 »
If you need to click, use this plugin function ClickMouse instead. Mouse.Click goes through a different click pipeline through the engine.

Re: [PLUGIN] AGS Controller Support (OPEN SOURCE) - v1.1
« Reply #34 on: 19 Jan 2022, 20:59 »
So...the Wheel menu buttons work fine when left clicking...but! When a message comes up on the screen, this simulated left click is incapable of dismissing them. It also can't seem to skip speech.

Can you clarify, where exactly do you call that code from? What do you refer to as a "message", is this a message from Display() function?

If you need to click, use this plugin function ClickMouse instead. Mouse.Click goes through a different click pipeline through the engine.

I checked what the plugin does, and it calls engine->SimulateMouseClick(), which in turn calls PluginSimulateMouseClick:
https://github.com/adventuregamestudio/ags/blob/master/Engine/plugin/agsplugin.cpp#L779
The script's Mouse.Click also calls PluginSimulateMouseClick:
https://github.com/adventuregamestudio/ags/blob/master/Engine/ac/mouse.cpp#L573

These should be identical in result. What matters is what circumstances you are calling them (e.g. on which event or callback).
« Last Edit: 19 Jan 2022, 21:17 by Crimson Wizard »

deadsuperhero

  • Frustrated Game Developer
    • I can help with backgrounds
    • I can help with characters
    • I can help with making music
    • I can help with scripting
Re: [PLUGIN] AGS Controller Support (OPEN SOURCE) - v1.1
« Reply #35 on: 20 Jan 2022, 09:20 »
So...the Wheel menu buttons work fine when left clicking...but! When a message comes up on the screen, this simulated left click is incapable of dismissing them. It also can't seem to skip speech.

Can you clarify, where exactly do you call that code from? What do you refer to as a "message", is this a message from Display() function?

These should be identical in result. What matters is what circumstances you are calling them (e.g. on which event or callback).

Hey, no problem! This is what I'm currently doing for handling clicks normally:

Code: Adventure Game Studio
  1.  
  2.   if (button == eMouseLeft) {
  3.    if (gWheel.Visible == false) {
  4.      Room.ProcessClick(mouse.x, mouse.y, mouse.Mode);
  5.    }
  6.    else {
  7.      gWheel.Visible = false;
  8.      gContext.Visible = false;
  9.    }
  10.   }
  11.  
  12.  


For deeper context, here's my click handler in entirety:
Code: Adventure Game Studio
  1. function on_mouse_click(MouseButton button)
  2. {
  3.   // called when a mouse button is clicked. button is either LEFT or RIGHT
  4.   if (IsGamePaused())
  5.   {
  6.     // game is paused, so do nothing (i.e. don't process mouse clicks)
  7.     if (gInventory.Visible == true) {
  8.        if (button == eMouseLeftInv) {
  9.               if (mouse.Mode == eModeLookat) {
  10.                 examineItem(inventory[game.inv_activated]);
  11.                }
  12.                else if (mouse.Mode == eModeInteract) {
  13.                  inventory[game.inv_activated].RunInteraction(eModeInteract);
  14.                }
  15.                else if (mouse.Mode == eModeUseinv) {
  16.                  inventory[game.inv_activated].RunInteraction(eModeUseinv);
  17.                }              
  18.                else if (mouse.Mode == eModePointer) {
  19.                  player.ActiveInventory = inventory[game.inv_activated];
  20.                  mouse.Mode = eModeUseinv;
  21.                  mouse.ChangeModeHotspot(eModeUseinv, 0, 0);
  22.                }              
  23.       }
  24.     }
  25.      else if (gMemories.Visible == true) {
  26.        if (button == eMouseLeftInv) {
  27.          openJournal(inventory[game.inv_activated]);
  28.        }
  29.      }
  30.    
  31.   }
  32.   else if (button == eMouseLeft)
  33.   {
  34.    if (gWheel.Visible == false) {
  35.      Room.ProcessClick(mouse.x, mouse.y, mouse.Mode);
  36.    }
  37.    else {
  38.      gWheel.Visible = false;
  39.      gContext.Visible = false;
  40.    }
  41.   }
  42.   else if (button == eMouseRight){
  43.     // right-click or mouse wheel down will cycle the mouse cursor mode forwards
  44.     setContext();
  45.     setPointer();
  46.  //   gWheel.SetPosition(mouse.x, mouse.y);
  47.     gWheel.Visible = true;
  48.   }
  49.   else if (button == eMouseMiddle)
  50.   {
  51.     // middle-click makes the character walk to clicked area, regardless of cursor mode
  52.     Room.ProcessClick(mouse.x, mouse.y, eModeWalkto);
  53.   }
  54. }
  55.  

To clarify - skipping speech, cutscenes, and Display() messages works just fine with both the mouse and the keyboard. But, the gamepad input just seems to ignore it.
« Last Edit: 20 Jan 2022, 09:22 by deadsuperhero »
The fediverse needs great indie game developers! Find me there!

Re: [PLUGIN] AGS Controller Support (OPEN SOURCE) - v1.1
« Reply #36 on: 20 Jan 2022, 09:26 »
Can you clarify, where exactly do you call that code from?

Hey, no problem! This is what I'm currently doing for handling clicks normally:

I meant, could you tell where do you call the code that you posted above, the one with Mouse.Click?

For example, are you calling it from repeatedly_execute, or repeatedly_execute_always, or other place?
« Last Edit: 20 Jan 2022, 13:58 by Crimson Wizard »

Re: [PLUGIN] AGS Controller Support (OPEN SOURCE) - v1.1
« Reply #37 on: 21 Jan 2022, 14:40 »
Ah! :facepalm: I just realized that forgot to explain. The reason i ask is that:

1. The speech is a blocking action; repeatedly_execute does not run during blocking actions. repeatedly_execute_always does. So that matters.

2. Display() command is special in AGS, it's "super-blocking", because even repeatedly_execute_always does not run during it. That's of course a design oversight, but I think it was made so because engine uses Display() for special messages too that are supposed to completely freeze the game. Because of that, you won't be able to call Mouse.Click in script while Display is on screen.
The only solution to this I am aware of is to not use Display, but instead make your custom overlay or GUI for such messages.
What remains of course are these special messages that I mentioned. The only fix for them would be when the engine itself would handle gamepad.

OR, if plugin would also handle these events and called "SimulateClick" automatically, not forcing you to do that in script.
« Last Edit: 21 Jan 2022, 14:43 by Crimson Wizard »

deadsuperhero

  • Frustrated Game Developer
    • I can help with backgrounds
    • I can help with characters
    • I can help with making music
    • I can help with scripting
Re: [PLUGIN] AGS Controller Support (OPEN SOURCE) - v1.1
« Reply #38 on: 24 Jan 2022, 11:25 »
Hey, sorry for the delay - it turns out that I was calling it from repeatedly_execute! That one was 100% my bad, moving over to repeatedly_execute_always totally fixed it.

Looks like I'll have to come up with something clever for working around the Display() issue.
« Last Edit: 24 Jan 2022, 11:36 by deadsuperhero »
The fediverse needs great indie game developers! Find me there!