ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi,
I'm working on a Java software for using the microscope QX3 in the primary school and I need a way to figure out when the user press the button on the microscope. I can't get this from V4L2 library, so reading the CPiA(1) - gspca driver[1] I found the var button on the struct qx3:
Code:
struct {
/* Intel QX3 specific data */
u8 qx3_detected; /* a QX3 is present */
u8 toplight; /* top light lit , R/W */
u8 bottomlight; /* bottom light lit, R/W */
u8 button; /* snapshot button pressed (R/O) */
u8 cradled; /* microscope is in cradle (R/O) */
} qx3;
Could someone kindly tell me if there is a way to read this value?
Hi.
At a glance to the cpia1.c, the button pressing event is processed here:
Code:
1758 #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
1759 /* If the last button state is pressed, release it now! */
1760 if (sd->params.qx3.button) {
1761 /* The camera latch will hold the pressed state until we reset
1762 the latch, so we do not reset sd->params.qx3.button now, to
1763 avoid a false keypress being reported the next sd_start */
1764 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
1765 input_sync(gspca_dev->input_dev);
1766 }
1767 #endif
You can try to catch KEY_CAMERA input event using the evtest utility as described here. Also look at this link, esp. section 5.
Sorry but I don't understand which /dev/input/eventX I have to use with evtest.
I don't know which one to choose either. Try them all or figure out correct one using following command
Code:
$ cat /sys/class/input/event*/device/name | nl -v0
0 Lid Switch
1 Sleep Button
2 Power Button
3 AT Translated Set 2 keyboard
4 Logitech USB Laser Mouse
5 WebCam
6 Video Bus
7 HDA Intel Mic
8 HDA Intel Headphone
9 SynPS/2 Synaptics TouchPad
Does (un-)plugging your device changes this list?
If nothing helps, try to compile kernel module yourself and insert printk("<1>..."); where appropriate to see what's happening (messages go to system log).
I tried to (un)plug but the list doesn't change, I also tried all the /dev/input/eventX but no one is the microscope.
In the meantime I write a mail to the driver's writers and one of theme reply me this:
Quote:
Button events get reported as regular linux input events, so if you've a recent distro where
X automatically detects and configures new input devices (try for example Fedora 15), then the button
should report X keypress events. Unfortunately the button needs to be polled, and currently that is
only done when the camera is streaming. So if I start a stream from the camera, and then run xev
(a small utility which reports X events) and then press the button I get:
Code:
KeyPress event, serial 33, synthetic NO, window 0x2c00001,
root 0xc4, subw 0x0, time 20841206, (1631,-58), root:(1632,439),
state 0x0, keycode 220 (keysym 0x1008ff8f, XF86WebCam), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 33, synthetic NO, window 0x2c00001,
root 0xc4, subw 0x0, time 20841494, (1631,-58), root:(1632,439),
state 0x0, keycode 220 (keysym 0x1008ff8f, XF86WebCam), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
But on my Ubuntu 11.04 (with 2.6.38-11-generic-pae kernel) the event doesn't detected from the xev program.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.