Adam's Lair Forum

game development and casual madness
It is currently 2017/08/17, 01:32

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 12 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: 2017/04/19, 13:43 
Junior Member
Junior Member

Joined: 2017/02/05, 13:06
Posts: 29
Role: Hobbyist
So I'm working on adding joystick support for my game. I wrote a loop to poll all of the joysticks so I could see what's being registered and what each axis's value is and which buttons are pressed.

The up/down axis seems to work fine and each button press works fine but when I press left or right no axis values change.

I tried two different gamepad controllers and calibrated them in windows' control panel and confirmed they are working correctly.

It looks like the axis which isn't changing is always "Axis0" so I'm wondering if there's an off-by-one bug somewhere. I see "Axis0" is my polling which currently has a value of -0.7143664 but that never changes.

Here's my joystick polling loop code:

Code:
        private void Poll(string poll)
        {
            if ("joysticks".Equals(poll, StringComparison.CurrentCultureIgnoreCase))
            {
                _output.Clear();

                DualityApp.Joysticks
                    .ForEach(j =>
                    {
                        foreach (JoystickAxis axis in Enum.GetValues(typeof(JoystickAxis)))
                        {
                            _output.Add($"{j.Description}, Axis: {axis}, Value: {j.AxisValue(axis)}, Speed: {j.AxisSpeed(axis)}");
                        }

                        foreach (JoystickButton btn in Enum.GetValues(typeof(JoystickButton)))
                        {
                            bool pressed = j.ButtonPressed(btn);
                            if (pressed)
                                _output.Add($"{j.Description}, Button: {btn}");
                        }
                    });
               
            }
        }


Top
 Profile  
 
PostPosted: 2017/04/19, 18:46 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 1993
Location: Germany
Role: Professional
Hey Divarin,

the code you posted looks fine at first glance.

  1. You checked buttons and axes - just to be extra sure that we're not missing something, can you also check hats?
  2. Can you reproduce this behavior in the Input Handling sample project and post a screenshot of the results so we can get a directly comparable idea of what we're dealing with?
  3. What Joystick / Gamepad do you use?
  4. If you switch to the SDL2 backend of OpenTk by putting the SDL2.dll into the executing directory of your game, does the behavior change?

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
PostPosted: 2017/04/19, 19:31 
Junior Member
Junior Member

Joined: 2017/02/05, 13:06
Posts: 29
Role: Hobbyist
I checked hats, seem to be working fine. The controllers I'm trying to get it to work with don't have hats but I have a lot of controllers and one of them does have a hat, I see that it's working fine. The left/right axis are not coming up as hat hits.

I was able to reproduce this behavior in the input handling sample project as well.

After adding SDL2.dll I get some different behavior. When running in the duality editor again, only the up/down axis is responding but when I run through VS (and not debugging because it started crashing while debugging after copying over SDL2.dll) then both axis' work but none of the buttons are responding.

I tried removing any controller other than whichever one I'm trying to work with but that didn't help.

The two controllers are:
A PS1 controller which is using a USB adapter
and this rather generic controller:

https://www.amazon.com/SteelSeries-PC-M ... series+1gc


Top
 Profile  
 
PostPosted: 2017/04/20, 11:42 
Junior Member
Junior Member

Joined: 2017/02/05, 13:06
Posts: 29
Role: Hobbyist
I recorded this screen cap of the input test project running with the windows game controller test screen active. As you can see the up/down is being picked up by duality but the left/right isn't.

https://youtu.be/2EJ1Syxt8tw


Top
 Profile  
 
PostPosted: 2017/04/20, 18:46 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 1993
Location: Germany
Role: Professional
Thanks! That helps a lot :)

Unfortunately I can't offer a solution right now, but it seems that this is a bug somewhere in joystick input handling. My first guess would have been a bug in the internal mapping from joystick input to gamepad layouts because that's somewhat flaky in OpenTK for the more obscure gamepads - however, you are experiencing the problem at the joystick input level directly, which rules out that problem cause.

Note: It appears that the newest version of OpenTK has a more extensive mapping than the Duality fork of it has - might consider updating that at some point, but that wouldn't help here.

Back to the problem: I'd have to look into this on the OpenTK backend level, reproduce this behavior and find out what's wrong. Without the specific hardware that you're using that is a bit of a problem. For now, you could try a workaround using re-mapping / device emulation software, but of course that'd only help for your dev machine.

The other option would be to compile the OpenTK fork of Duality yourself, run their input handling sample (it's "GameWindow States" - my guess would be that it also reproduces the issue) and then step through some code to find out where this is coming from.

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
PostPosted: 2017/04/20, 20:08 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 1993
Location: Germany
Role: Professional
I've investigated the state of the current OpenTK fork of Duality and found that there were a few pending updates related to Joystick and Gamepad input. Merged them and published a new release of the OpenTK backend packages - not sure if that will help, but probably won't hurt to try, and that update was due at some point anyway.

Check the Package Manager dialog for updates (wait at least 15 min from now so NuGet can get its indexing done) and let me know if that helps with your issue - and also if behavior changes from one wrong into another :)

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
PostPosted: 2017/04/21, 11:42 
Junior Member
Junior Member

Joined: 2017/02/05, 13:06
Posts: 29
Role: Hobbyist
Adam wrote:
I've investigated the state of the current OpenTK fork of Duality and found that there were a few pending updates related to Joystick and Gamepad input. Merged them and published a new release of the OpenTK backend packages - not sure if that will help, but probably won't hurt to try, and that update was due at some point anyway.

Check the Package Manager dialog for updates (wait at least 15 min from now so NuGet can get its indexing done) and let me know if that helps with your issue - and also if behavior changes from one wrong into another :)


Okay that's promising. I assumed what you wanted me to do was either:
Code:
Update-Package Duality

or
Code:
Update-Package OpenTK

but what I got was:
Code:
Update-Package : 'Duality' was not installed in any project. Update failed.

and
Code:
Update-Package : 'OpenTK' was not installed in any project. Update failed.


I also tried the NuGet GUI by right-clicking on References and clicking "Manage NuGet Packages. Nothing is showing up under Installed or Updates. Which is strange because I see the references to Dualtiy and DualityPrimitives in References.


Top
 Profile  
 
PostPosted: 2017/04/21, 12:04 
Junior Member
Junior Member

Joined: 2017/02/05, 13:06
Posts: 29
Role: Hobbyist
I did, however, see AdamsLair.OpenTK and AdamsLair.OpenTK.GLControl under available packages, updated yesterday, so I went ahead and installed them into my CorePlugin project (not sure if that is going to make the Duality reference use these or the versions it was packed with), my joystick issue is unchanged though :(

You know I wouldn't mind shipping you one of these: https://www.amazon.com/SteelSeries-PC-M ... series+1gc
they're cheap and it's one of the two controllers I'm working with which has this issue, maybe it'd help you on your end to reproduce the issue.

I'd like to test more gamepads myself but these are the only two I have. With the PS1 controller I noticed that if I switch it to analog then the right thumb (whatever that thing is called) responds to both axis' whereas the left only up/down.

I have a bunch of flight simulator controls hooked up as well so I tested them. The yoke both axis' work as well as various throttle potentiometers (which are also analog)

So it seems like it mostly works with analog controls with the exception of the left-thumb on the PS1 controller.


Top
 Profile  
 
PostPosted: 2017/04/21, 18:09 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 1993
Location: Germany
Role: Professional
Divarin wrote:
You know I wouldn't mind shipping you one of these: https://www.amazon.com/SteelSeries-PC-M ... series+1gc
they're cheap and it's one of the two controllers I'm working with which has this issue, maybe it'd help you on your end to reproduce the issue.

I would have to decline for now, but I appreciate that :1+:

Divarin wrote:
I also tried the NuGet GUI by right-clicking on References and clicking "Manage NuGet Packages. Nothing is showing up under Installed or Updates. Which is strange because I see the references to Dualtiy and DualityPrimitives in References.


No no, I was assuming that you were using the binary release of Duality and thus talking about the package manager dialog within the Duality editor. If you're building from source, you shouldn't manually update any referenced packages. :)

Divarin wrote:
I did, however, see AdamsLair.OpenTK and AdamsLair.OpenTK.GLControl under available packages, updated yesterday, so I went ahead and installed them into my CorePlugin project (not sure if that is going to make the Duality reference use these or the versions it was packed with), my joystick issue is unchanged though :(


Referencing backend plugins in your core plugin doesn't change which one is used when running the application! Can you try again by updating the Duality backend plugins in the package manager dialog of the editor in the project folder you're working in?

(Just to be extra sure that we're on the same page, can you share the PackageConfig.xml after you've done that and restarted the editor?)

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
PostPosted: 2017/04/22, 11:33 
Junior Member
Junior Member

Joined: 2017/02/05, 13:06
Posts: 29
Role: Hobbyist
Oh I see, yeah I'm using the binary release of Duality but I guess when you said "package manager" my brain immediately went to the NuGet Package Manager in VS.
I updated the OpenTK Backend (through the package manager in the duality editor).

After doing that I started getting null reference exceptions in Duality.Editor.Plugins.CamView.CamView.graphicsControl_MouseMove(Object sender, MouseEventArgs e)
but then I did an "Update All" and that fixed that.

The joystick behavior now though is not improved. The cheaper controller still only responds to up/down but the PS1 controller doesn't respond to any axis (however all buttons still work)

Here is my PackageConfig.xml:

Code:
<?xml version="1.0" encoding="utf-8"?>
<PackageConfig>
  <RepositoryUrl>https://packages.nuget.org/api/v2</RepositoryUrl>
  <Packages>
    <Package id="AdamsLair.Duality.Launcher" version="2.3.2.0" />
    <Package id="AdamsLair.Duality.Backend.DotNetFramework" version="2.1.1.0" />
    <Package id="AdamsLair.Duality.Plugins.Compatibility" version="2.0.2.0" />
    <Package id="AdamsLair.Duality.Docs" version="2.0.1.0" />
    <Package id="AdamsLair.Duality.Editor.Plugins.Base" version="2.2.7.0" />
    <Package id="AdamsLair.Duality.Editor.Plugins.HelpAdvisor" version="2.0.4.0" />
    <Package id="AdamsLair.Duality.Editor.Plugins.ObjectInspector" version="2.0.5.0" />
    <Package id="AdamsLair.Duality.Editor.Plugins.PackageManagerFrontend" version="2.0.6.0" />
    <Package id="importjingles.Duality.Editor.Plugins.DualityExtendedAudioImporter" version="1.0.2.0" />
    <Package id="AdamsLair.Duality.Samples.ParticleSystem" version="2.0.2.0" />
    <Package id="AdamsLair.Duality.Samples.InputHandling" version="2.0.3.0" />
    <Package id="AdamsLair.Duality" version="2.11.2.0" />
    <Package id="AdamsLair.Duality.Backend.DefaultOpenTK" version="2.0.19.0" />
    <Package id="AdamsLair.Duality.Editor" version="2.7.24.0" />
    <Package id="AdamsLair.Duality.Editor.Plugins.CamView" version="2.4.1.0" />
    <Package id="AdamsLair.Duality.Editor.Plugins.LogView" version="2.1.8.0" />
    <Package id="AdamsLair.Duality.Editor.Plugins.ProjectView" version="2.0.11.0" />
    <Package id="AdamsLair.Duality.Editor.Plugins.SceneView" version="2.0.12.0" />
    <Package id="AdamsLair.Duality.Editor.Backend.DefaultOpenTK" version="2.0.5.0" />
  </Packages>
</PackageConfig>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 2 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

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group