CETECIran / jkeys

exported from code.google.com/p/jkeys
0 stars 0 forks source link

Axis motion events as digital button presses #11

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Many thanks to KillerKiwi for developing this neat software. jkeys helped me to 
solve many problems, which had in the past forced me to shelve my gamepad in 
favor of the keyboard.

This is a suggestion and not really a defect, but I'm not sure how to post it.

For some odd cases it would be nice to include a feature to emulate digital 
button presses for axis motion events. For example in case of gamepads that 
have analog shoulder buttons (akin to the L2/R2 triggers on DualShock 3 or 4), 
the user may want to configure them as digital button presses.

I encountered a case where I needed such a feature and tried the following 
methods (contents of .joy configuration file are shown):

1.  <axis number="5" low="Scroll_Lock" high="Page_Up" />
        - The key code for "low" axis event is valid, but not used in the target application.
        - This works, but it is quite difficult to move the axis to the position where key events will be triggered.

2.  <axis number="5" digital="True" high="Page_Up" />
        - "low" axis event is not considered in this case, hence no key code is assigned.
        - "high axis event is considered as digital button press.
        - This works better, but requires small changes to be made in joystick.py.
        - I think a similar approach may be used to solve issue #5.

I have attached a patch for the second method (applicable to SVN r7 of 
joystick.py). It also includes the changes from Charles hat.patch, but does not 
include commenting out of the "x.SendKeyRelease( key )" line for mouse events. 
jkeys would not work for me without applying hat.patch and would always end up 
with "NameError: global name 'gethatcode' is not defined" (already reported in 
issues #3 and #10).

Another suggestion is to document the source for key names provided in the 
quoted strings in .joy configuration files. Some users may not be aware and go 
through a bit of struggle to find them (happened to me).

List of key codes can be found inside X11/keysymdef.h. The "XK_" prefix must be 
removed when providing quoted key name strings in the .joy configuration files.

Original issue reported on code.google.com by ninja.sp...@gmail.com on 10 Jun 2015 at 5:41

Attachments: