rama wrote:
Hi all,
I'm using the joystick interface to control an wxPy app,
and I'm going crazy about an eternal problem I can't solution to since
long.Each time I switch to a different kernel, the codes for each button
pressed on the joystick change to different values.I'm using always the same joystick which is Logitech WingMan Rumblepad.
I've started using wx.Joystick one year ago with the help of Robin,
and by that time, ie, button A from my joystick (a gamepad actually) was
producing a value of 1 when pressed... B was producing 2, C was
producing 4......now A produces 795649, now B = 795650, C = 795652....
it wouldn't be very serious problem if it just changed between different
kernel versions, but I've found and proved that "sometimes" for unkown
reasons to me, it changes *also* within the same kernel version (at
least after reboots, and not always).sounds strange, no? how could I debug this? I can't figure out.
This value is a bitmask, is it not? You can have multiple buttons pressed at once? That means you should not be saying:
if button == 1:
# A button pressed
elif button == 2:
# B button pressed
elif button == 4:
# C button pressed
Instead, you should be saying:
if button & 1:
# A button pressed
if button & 2:
# B button pressed
if button & 4:
# C button pressed
If you had written it that way to begin with, you never even would have noticed this change. The new values are the same as the old ones in the lower 8 bits.
···
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.