Gamepad & Keyboard: Mapping & Simulation Notes

flerchjj
  11 years ago
  4

These are just some random notes for myself while configuring gamepads to hook into keyboard controls (for games or programs that do not support gamepads), to make hotkeys consistent between different environments (for example make apple+c and control+c hotkeys do the same thing - since my fingers get confused switching between OSX, MS Windows, and Mint).

 

AGAIN THESE ARE NOTES TO HELP ORGANIZE CONFIGURATION STEPS AND SOLUTIONS TO COMMON PROBLEMS

THEY'RE NOT A FULL COHESIVE TUTORIALS YET, BUT HAVE SOME MINI GEMS THAT CAN BE INCORPORATED INTO THEM LATER

 

**************************************************

QJoypad - remap a joystick to act like a mouse or keyboard keys

qjoypad is a great tool for mapping a gamepad, joypad, or joystck to keyboard events. This has let me use a gamepad with games intended for use with a keyboard - to include controlling DVDs in mythtv with a joystick and acting like a mouse so I could use a browser from across the room.

It has a very nice gui to configure graphically.

****************************************************************

xdotool - simulate keyboard keys, simulate mouse actions, and control windows

Similar to QJoypad in that it simulates input device actions. Of course this program lets you script these events from the shell. By inserting these commands as keyboard shortcuts

  1. Install xdotool (brilliant piece of software by the way)
  2. go to Control Center→ Keyboard Shortcuts
  3. Add a new shortcut
    • give a name to describe the action you want to perform
    • enter a shell command to execute with the desired hotkey
      • xdotool key Delete
  4. click on the row for the entry in the table and press the key combination you want to assign that hotkey

In this will send the keyboard commands every time you hit the keyboard shortcut (albeit a bit slowly, about 150ms).

To add any other character, go to the gnome character map and search for it; In the status bar you should see the hexadecimal index of the glyph - i.e. "U+203d".

For some reason to get a Delete to properly send from xdotool I had to set a delay and send another key first

xdotool key -delay 1000 Shift Delete

I mapped this to command+backspace on a macbook so I could delete files by hitting command+backspace just like in OS X. This is because Macs do not have delete keys - they have backspace keys in the exact same position as the delete key with "delete" written on them.

Ubuntu xdotool Manpage

****************************************************************

XBindKeys

XBindKeys provides a daemon that runs and continually maps key presses to other key presses or mouse actions. Think of a qjoypad where the input is the keyboard instead of a gamepad and there is no gui based configuration.

****************************************************************

Interesting note: xdotool and QJoypad both make use of XTest to simulate keyboard and mouse actions

****************************************************************

AutoHotKey For Linux

I'm using AutoHotKey to script hotkeys and message boxes in a virtual box installation of Windows XP. It let me make key combinations in XP more uniform with the host OS and simplify start-up and shutdown of the XP virtual machine.

A prog called IronAHK  uses the same syntax and runs the same scripts but is Linux compatable, provided you install Mono to run .NET applications.

****************************************************************

ControllerMate

This is an OS X product, but in my opinion is the king of input/output mapping. Scripts are programmed using a gui flow chart method. There all kinds of input options for keyboards, mice, and midi devices that can be routed to virtual keyboard, mouse, and midi outputs. Timers and various logic elements can be inserted to control how these devices act. Think of Scratch Programming focused on computer i/o. Possibly too complicated for most, but can simplify complicated setups. Consider an Idea to bundle some of this functionality for Linux.