Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ioctl input/output error whenever I attempt to load a config from the system tray menu in linux #127

Open
linusrg1 opened this issue Sep 24, 2024 · 4 comments

Comments

@linusrg1
Copy link

This also happens when attempting to use ctrl + c to stop joyshock mapper as well. Running joyshockmapper as root I am able to overcome this issue, but while running as root I don't think that my inputs that are going through joyshockmapper have the ability to interact with my game running as my user.

I am running Arch with kernel 6.10. I just built joyshockmapper from here last night, so I am sure it is up to date.

@linusrg1
Copy link
Author

I have attempted to add all the suggested udev rules to my system too, no dice.

I should also mention that I am currently using Joyshockmapper under wayland.

@Jazztache
Copy link

I am having the exact same issue, I was just about to report the following:

"
Hello!

I am getting an error whilst using split Joy-Cons on JoyShockMapper on Arch Linux. I have complied the progream from source on the main branch.
When trying to close JoyShockMapper using Ctrl + C from the command line, occasionally, I get the following error:
ioctl: Innapropruate ioctl for this device

I suspect this happens when a controller disconnects, and JSM can no longer find that controller.

When this occurs, the process becomes unkillable, even with something like killall joyshockmapper in console.
I am not sure if JSM is checking if the controller is disconnected or not when trying to quit.

I am using joycond and the kernel-inbuilt hid-nintendo drivers.
"

I am also running the latest Arch kernel.

@Jazztache
Copy link

I found out where this breaks:

JoyShockMapper/src/linux/InputHelpers.cpp at line 569:
if (::ioctl(STDIN_FD, TIOCSTI, &c) < 0)

I cloned the build somewhere else and isolated what error code I got from the ::ioctl call. It always comes up with -1 if you're not the root user, and 0 for the root user.

The problem function is on line 563 of the same file above. I replaced it with this code for debugging purposes.

bool WriteToConsole(in_string command)
{
	constexpr auto STDIN_FD{ 0 };
	for (auto c : command)
	{
    // https://www.geeksforgeeks.org/how-to-find-the-type-of-an-object-in-cpp/
    string commandType = typeid(c).name();
    string whichCommand = "[JAZZ] Attempting to process command that has object type of" + commandType + "\n";
    std::fprintf(stdout,whichCommand.c_str());
    int ioctlResult = ::ioctl(STDIN_FD, TIOCSTI, &c); //I think it breaks here.
    // BUG FOUND: ::ioctl call is not working, so I have to fix that.
    string report = "[JAZZ] Result of variable ioctlResult is " + to_string(ioctlResult) + "\n";
    // https://stackoverflow.com/questions/14784367/cs-printf-and-fprintfstdout-are-not-printing
    // https://cplusplus.com/forum/beginner/26196/
    std::fprintf(stdout, report.c_str());
		if (ioctlResult < 0)
		{
			perror("ioctl");
			return false;
		}
	}

	char NEW_LINE = '\n';
	::ioctl(STDIN_FD, TIOCSTI, &NEW_LINE);

	return true;
}

Not sure what TIOCSTI does. I'm going to read up on the ::ioctl function and come back to this.

@Jazztache
Copy link

Jazztache commented Nov 27, 2024

...So, TIOCSTI is being used to manually type the letter Q,U,I,T into the terminal. It does this for both Ctrl+C and the status icon.
I can tell because when I run with sudo permissions, I see every letter get output between my debugging statements. When I run without, I get this:

Screenshot_20241127_210723

This means that in the Linux version of JoyShockMapper, inputting characters on the user's behalf is broken. This is why both the Q,U,I,T and the .,/,A,u,t,o,L,o,a,d,/,w,h,a,t,e,v,e,r,.,t,x,t are broken.

I think that the systray should call the internal C++ functions directly? That would completely sidestep the entire issue. Same with Ctrl + C just leading directly to the quit function. I hate to be critical, but the current method of using text macros seems like a really hacky workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants