LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-23-2022, 08:20 AM   #1
coralfang
Member
 
Registered: Nov 2010
Location: Bristol, UK
Distribution: Slackware, FreeBSD
Posts: 836
Blog Entries: 3

Rep: Reputation: 297Reputation: 297Reputation: 297
C/C++ Libusb, detaching a kernel driver resets the keyboards X settings


Hi, working on a driver/library for a USB keyboard in C/C++
When i'm issuing this with libusb;

Code:
libusb_set_auto_detach_kernel_driver(device_handle, 1);
libusb_claim_interface(device_handle, 0);

...
...

libusb_release_interface(device_handle, 0);
libusb_close(device_handle);
libusb_exit(NULL);
As the kernel driver is reattached, all the xorg related settings for the keyboard are reset?
For example in my window manager startup commands i have these:
Code:
setxkbmap gb
xset r rate 400 25
But those settings are reset each time i'm running those function in a libusb program, and i end up on a US keyboard layout. Is there some way to stop this happening?

Possibly, i may need to include an xorg header to grab the current settings, and reapply them at the end of the program? But i'm not sure how to go about that if that is a potential solution...

Any help would be much appreciated, thanks.
 
Old 03-01-2022, 05:05 PM   #2
lucky_day
LQ Newbie
 
Registered: Feb 2022
Posts: 9

Rep: Reputation: 0
Quote:
Originally Posted by coralfang View Post
Hi, working on a driver/library for a USB keyboard in C/C++
When i'm issuing this with libusb;

Code:
libusb_set_auto_detach_kernel_driver(device_handle, 1);
libusb_claim_interface(device_handle, 0);

...
...

libusb_release_interface(device_handle, 0);
libusb_close(device_handle);
libusb_exit(NULL);
As the kernel driver is reattached, all the xorg related settings for the keyboard are reset?
For example in my window manager startup commands i have these:
Code:
setxkbmap gb
xset r rate 400 25
But those settings are reset each time i'm running those function in a libusb program, and i end up on a US keyboard layout. Is there some way to stop this happening?

Possibly, i may need to include an xorg header to grab the current settings, and reapply them at the end of the program? But i'm not sure how to go about that if that is a potential solution...

Any help would be much appreciated, thanks.
what you need is probably under <X11/XKBlib.h> I can't really tell which function you should use, https://www.x.org/releases/X11R7.6/d...KB/xkblib.html
 
  


Reply

Tags
c++, libusb, xorg



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
detaching a (graphical)process invoked without "&" from terminal deepclutch Programming 2 06-07-2010 09:20 AM
[SOLVED] ubuntu 9.10 - #include <libusb/libusb.h> stonehinge03 Linux - Newbie 5 04-20-2010 09:02 AM
"random" xorg resets ... quickly typing in the GUI a "2" resets X Tinkster Slackware 3 04-09-2010 04:25 AM
Detaching Amarok from bash script run from KMenu srunni Linux - Software 7 08-12-2008 02:09 AM
Detaching X-program from X-server matthewg42 Linux - General 2 06-18-2008 02:18 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration