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

Question: How to detect DriverCodeIDs for a specific model #19

Open
jonathannerat opened this issue Feb 16, 2024 · 4 comments
Open

Question: How to detect DriverCodeIDs for a specific model #19

jonathannerat opened this issue Feb 16, 2024 · 4 comments

Comments

@jonathannerat
Copy link

I'm trying to add support for the XP-Pen G640S since I saw the controller for the G640 in the code and figured it should be almost the same.

My model has a Stylus with 2 buttons as well as 6 buttons in the tablet. I have managed to get the mappings for the tablet buttons working, but for some reason the mappings for the Stylus don't seem to work. Every time I change the mappings, I save the config, but when I open the settings again, the mappings are gone for the stylus.

I think the problem could be:

  1. The driver codes for those buttons is incorrect (hence my initial question)
  2. I'm trying to map those to middle and right click, I'm not really sure if it should support that kind of mapping since my tablet buttons are mapped to keyboard shortcuts and work fine. Maybe that's why it doesn't work

Thanks for this software btw. I recently installed the official xp-pen driver and it constantly crashes, and this has been working perfectly besides this problem.

@kurikaesu
Copy link
Owner

Thanks for reaching out. Do you see your device as selection choice when running the GUI? If so it probably means the config is being saved in a weird state or under the wrong ID.

The actual saving of the configuration is handled by both this GUI and the daemon code.

Daemon Code:

For completeness sake, the daemon code that handles saving config changes is here: https://github.com/kurikaesu/userspace-tablet-driver-daemon/blob/main/src/event_handler.cpp#L135-L150

It obtains the configuration to save from the individual device handlers themselves. For the G640, it would be here: https://github.com/kurikaesu/userspace-tablet-driver-daemon/blob/main/src/star_g640.cpp#L39-L54

Specifically line 53 is what sets the configuration by calling this function: https://github.com/kurikaesu/userspace-tablet-driver-daemon/blob/main/src/transfer_handler.cpp#L420

Gui Code:

For the GUI side of things, it works by loading in the existing configuration and then overwriting a device's specific configuration then saving it. This can be seen here on the Artist 16 pro controller for example: https://github.com/kurikaesu/userspace-tablet-driver-gui/blob/main/src/main/kotlin/dev/villanueva/userland_utility/products/xppen/artist_pro_16/ArtistPro16Controller.kt#L26-L29

This is actually used here by the commitChanges code:

open fun commitChanges(deviceConfiguration: DeviceConfiguration?) {
println("Committing changes")
if (deviceConfiguration != null) {
deviceConfiguration.mapping.stylusButtons = this.stylusButtonMappings
deviceConfiguration.mapping.buttons = this.buttonBindings
deviceConfiguration.mapping.dials = this.dialBindings
deviceConfiguration.disabled.stylusButtons = this.stylusButtonDisabled
deviceConfiguration.disabled.buttons = this.buttonDisabled
deviceConfiguration.disabled.dials = this.dialDisabled
val existingConfig = updateExistingDeviceConfig(deviceConfiguration)
existingConfig.writeConfig()
if (DriverSocket.connected) {
DriverPackets.reloadConfiguration().writeToOutputStream(DriverSocket.getOutputStream()!!)
}
}
}

Line 114 will send a message packet to the driver daemon telling it to reload the configuration which is how the config is updated in semi-real-time.

@kurikaesu
Copy link
Owner

Now that the details of the implementation are shown above, the next steps is to get you to provide a set of pull requests with the changes you have made. I'll be able to inspect what is going on in your code and hopefully either point out what needs to be updated to get it to work or we will find some weird bug/implementation difference that your specific tablet has that needs to be researched and then accounted for.

Reference your pull requests (for the daemon as well if you have code changes there) in this thread once you are done.

@jonathannerat
Copy link
Author

Okay, I got into the daemon to try and arrange a new driver for g640s, and got the buttons working (basically by copying from generic_xp_pen_device), but still can't get it to work.

Still, I think the problem is within the UI. I saved my changes in the daemon to another branch, switched to main, and with the my modified version of the gui I get this:

  • If I launch the gui, select the device, set ONLY stylus button 1 (for example, to right click), and save, the mapping works.
  • Same as above, but set ONLY stylus button 2 (for example, to middle click), and save, the mapping works.
  • Same, but if I try to do both at the same time, it doesn't work. It's like they cancel each other out.

I'll make a PR with the changes so you can try it, would love some input on this.

@kurikaesu
Copy link
Owner

Thanks. I could be remembering incorrectly since it has been a while but the generic driver doesn't really have proper mappings at it doesn't properly save anything. Not sure if that is what you are trying to do here but if you are then the first step is to make sure to create a daemon implementation for your specific device first so that it has a proper device ID to map the configurations to.

Let's get the daemon changes done first so that we can make sure that all of the stylus buttons are actually assignable in the daemon itself. Once you have that PR ready please send it through and I'll have a look over it.

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