Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - TheWhiteGuy

Pages: [1]
1
General / Re: One controller counted as two BUG
« on: July 08, 2020, 09:08:01 pm »
I've made an entirely new project that looks like this:

#include <iostream>
#include <SFML/Graphics.hpp>

using namespace sf;
using namespace std;

int main()
{
        sf::RenderWindow window(sf::VideoMode(800, 600), "window");

        sf::Event event;

        bool controller0;
        bool controller1;

        if (Joystick::isConnected(0))
        {
                controller0 = true;
        }
        if (Joystick::isConnected(1))
        {
                controller1 = true;
        }

        while (window.isOpen()) {

                while (window.pollEvent(event)) {

                        if (event.type == sf::Event::Closed) {

                                window.close();
                        }
                        if (event.type == Event::JoystickDisconnected)
                        {
                                if (event.joystickConnect.joystickId == 0)
                                {
                                        cout << "0 is disconnected" << endl;
                                        controller0 = false;
                                }
                                else if (event.joystickConnect.joystickId == 1)
                                {
                                        cout << "1 is disconnected" << endl;
                                        controller1 = false;
                                }
                                break;
                        }
                        if (event.type == Event::JoystickConnected)
                        {
                                if (event.joystickConnect.joystickId == 0)
                                {
                                        cout << "0 is connected" << endl;
                                        controller0 = true;
                                }
                                else if (event.joystickConnect.joystickId == 1)
                                {
                                        cout << "1 is connected" << endl;
                                        controller1 = true;
                                }
                                break;
                        }
                }
        }

        return 0;
}

Tested by:
1. Connecting c0
2. Connecting c1
3. Disconnecting c0

0 is connected
1 is connected
1 is disconnected
Failed to create DirectInput device: -2147467259
0 is disconnected
Failed to create DirectInput device: -2147467259
0 is connected

As you can see from console output, disconnecting c0 is recognized as disconnecting them both and reconnecting c0 after...

I've done some more tests and there is much more wrong going on including controller clonning as before :/

2
General / Re: One controller counted as two BUG
« on: July 08, 2020, 08:50:56 pm »
Ok, I've been struggling with CMake for quite a while, but eventually I've managed to make it work, but the problem persists. Nothing's changed :/

3
General / Re: One controller counted as two BUG
« on: July 07, 2020, 11:46:37 am »
I'm using Visual Studio and I went for configured version and not Cmake. Do I just get newer version of folders I downloaded before and replace them?

4
General / One controller counted as two BUG
« on: July 05, 2020, 12:47:58 pm »
Hi,
I'll start by saying, that I've already searched for the solution on the forum and google pretty thoroughly and no luck with finding it and I'm using SFML 2.5.1.

I'm making a game that uses two controllers and whenever I disconnect controller1 and reconnect it after everything works fine, but if I do the same with controller0 - controller1 quickly becomes controller1 and controller0 at the same time and reconnecting controller0 changes nothing and it's not even acknowledged anymore. I'm using JoystickDisconnected and JoystickConnected events in pollEvent loop

I've tried like everything:
- Joystick::update() in several places
- counting Joystick::getIdentification(i) where productId > 0
- additional bool variables
- additional loops
- Joystick::isConnected(i)
- additional pollEvent loop
- sleeping the thread for 100 and 1000 milliseconds
- all of above but in fuctions
and probably more, that I've already forgotten...

Atm my event handling looks like this:

                        if (event.type == Event::JoystickDisconnected)
                        {
                                if (event.joystickConnect.joystickId == 0)
                                {
                                        cout << "0 is disconnected" << endl;
                                        controller0 = false;
                                }
                                else if (event.joystickConnect.joystickId == 1)
                                {
                                        cout << "1 is disconnected" << endl;
                                        controller1 = false;
                                }
                                break;
                        }
                        if (event.type == Event::JoystickConnected)
                        {
                                if (event.joystickConnect.joystickId == 0)
                                {
                                        cout << "0 is connected" << endl;
                                        controller0 = true;
                                }
                                else if (event.joystickConnect.joystickId == 1)
                                {
                                        cout << "1 is connected" << endl;
                                        controller1 = true;
                                }
                                break;
                        }

                if (!controller0 || !controller1)
                {
                        this_thread::sleep_for(chrono::milliseconds(1000));

                        window.draw(rect, BlendNone);
                        window.draw(controllerDisconnectedSprite);
                        window.display();

                        continue;
                }

I can't really show you my previous attempts, but I can try to rewrite it if it's needed.

I've tried Windows settings too, but as expected it changes nothing. Controllers work fine outside of my game.

I'd really appreciate any help, cause I've been stuck with this for 3 days now.

Pages: [1]