Unterschiede zwischen den Revisionen 2 und 3
Revision 2 vom 2010-07-10 00:48:53
Größe: 6871
Autor: lars
Kommentar: Text is finished
Revision 3 vom 2010-07-10 00:53:07
Größe: 6899
Autor: lars
Kommentar: included picture
Gelöschter Text ist auf diese Art markiert. Hinzugefügter Text ist auf diese Art markiert.
Zeile 3: Zeile 3:
= What is it about = = Introduction =
Zeile 50: Zeile 50:
{{attachment:pad_numbers.png}}

InhaltTableOfContents

Introduction

This howto explains the configuration of a gamepad (joystick) for the Axis GUI of [http://linuxcnc.org EMC2]. It allows to control the basic operations of a 3-axes machine without a keyboard. The following approach is based on the joystick module of an [http://x.org xorg] server. Thus it is applicable for Linux or *BSD systems.

3-axes machine

usually a [http://en.wikipedia.org/wiki/Milling_machine milling machine]

EMC2

the most common [http://www.gnu.org/philosophy/free-sw.html free] machine controller software. It is used for turning toolpaths (GCode) into electric pulses for the drivers of the three axes.

Axis
one of the available graphical user interfaces of EMC2
gamepad
a small hand-held device with a few buttons and one or more joysticks. It is usually connected to a computer via USB, bluetooth or another serial connector.

Hardware

The following description is based on a gamepad labeled by Hama as Black Force. It is identified by lsusb with the following attributes:

 Bus 002 Device 009: ID 0079:0006 DragonRise Inc. Generic USB Joystick

Preparing the system

You need to install the joystick module for your xorg server.

Debian or Ubuntu users should run the following command as root:

apt-get install xserver-xorg-input-joystick

Keycodes for useful Axis commands

You can use xmodmap -pke for determining the keycodes of the Axis hotkeys that you want to emit via the gamepad. The following selection should be a good starting point. See [http://www.linuxcnc.org/docs/2.4/html/gui_axis.html#r1_4 hotkeys of Axis] for a list of important keys to be used within Axis.

Action

Key

Keycode

move X axis forward

right

102

move X axis backward

left

100

move Y axis forward

up

98

move Y axis backward

down

104

move Z axis up

page up

99

move Z axis down

page down

105

home all axes

home

97

pause program

p

33

resume program

s

39

decrease jogging speed

. (period)

59

increase jogging speed

, (comman)

60

increase jogging step size

I

50, 31

decrese jogging step size

i

31

continuous jogging mode

c

54

select axis X (e.g. for defining an offset)

x

53

select axis Y

y

29

select axis Z

z

52

zero the offset of the current axis

end

103

Gamepad buttons and axes

The Black Force gamepad has 12 buttons and 6 axes. Your X server reports 7 axes, but the first and the third one are basically the same.

The following picture illustrates the numbering scheme of the Black Force gamepad: pad_numbers.png

Mapping of buttons and axes

The following mapping of gamepad buttons and emitted keys can be used:

Axis / Button

Action

Axis1 (right)

move X axis forward

Axis1 (left)

move X axis backward

Axis2 (up)

move Y axis forward

Axis2 (down)

move Y axis backward

Button5

move Z axis up

Button7

move Z axis down

Button6

home all axes

Button9

pause program

Button10

resume program

Button8

decrease jogging speed

Button6

increase jogging speed

Axis7 (down)

decrese jogging step size

Axis7 (up)

increase jogging step size

Button10

continuous jogging mode

Button1

select axis X

Button2

select axis Y

Button3

select axis Z

Button4

zero the offset of the current axis

Additionally Axis4 and Axis5 are used as a mouse pointer replacement. Button11 and Button12 (triggered by pressing the two joysticks) can be used as mouse buttons.

Configure the X server

Add the following lines to your /etc/X11/xorg.conf. The ServerLayout and ServerFlags sections should be merged with existing sections in your config (if they exist).

Section "InputDevice"
        Identifier      "joystick"
        Driver          "joystick"
        # proper path to your joypad could be found by looking into '/dev/input/by-id' directory
        Option "Device"         "/dev/input/by-id/usb-DragonRise_Inc._Generic_USB_Joystick-joystick"
        # keyboard controls for Axis: http://www.linuxcnc.org/docs/2.4/html/gui_axis.html#r1_4
        # keycodes: "xmodmap -pke"
        # choose axis X (x)
        Option "MapButton1"     "key=53"
        # choose axis Y (y)
        Option "MapButton2"     "key=29"
        # choose axis Z (z)
        Option "MapButton3"     "key=52"
        # axis "zero G54 offset on selected axis" (END)
        Option "MapButton4"     "key=103"
        # axis +Z
        Option "MapButton5"     "key=99"
        # increase jogging speed (comma)
        Option "MapButton6"     "key=60"
        # axis -Z
        Option "MapButton7"     "key=105"
        # reduce jogging speed (period)
        Option "MapButton8"     "key=59"
        # axis "pause program" (p)
        Option "MapButton9"     "key=33"
        # axis "continus program" (s)
        Option "MapButton10"    "key=39"
        # mouse button: left
        Option "MapButton11"    "button=1"
        # mouse button: right
        Option "MapButton12"    "button=3"
        # axis X - Left /Right
        Option "MapAxis1"       "mode=relative deadzone=28000 keylow=100 keyhigh=102 axis=0.15key"
        # axis Y - Up / Down
        Option "MapAxis2"       "mode=relative deadzone=28000 keylow=98 keyhigh=104 axis=0.15key"
        # same as Axis1 - should be ignored
        Option "MapAxis3"       "mode=none"
        # Mouse (horizontal)
        Option "MapAxis4"       "mode=relative deadzone=2000 axis=+0.5x"
        # Mouse (vertical)
        Option "MapAxis5"       "mode=relative deadzone=2000 axis=+0.5y"
        # Homing (HOME) / jogging control continous mode (c)
        Option "MapAxis6"       "mode=accelerated deadzone=10000 keylow=97 keyhigh=54"
        # change jogging step (i / I)
        Option "MapAxis7"       "mode=accelerated deadzone=10000 keylow=31 keyhigh=50,31"
EndSection

Section "ServerLayout"
        Identifier      "DefaultServerLayout"
        InputDevice     "Joystick"      "SendCoreEvents"
EndSection

Section "ServerFlags"
        # This is an ugly way to disable the mouse pointer ability of the
        # gamepad. Otherwise the gamepad is interpreted as a mouse _and_
        # as a keyboard input (as defined above).
        Option "AutoAddDevices" "False"
EndSection

You need to restart the X server afterwards by pressing CTRL-ALT-Backspace.

Test

After restarting the X server with the new settings you should take a look at /var/log/Xorg.0.log and check for any errors (in case you changed the config above).

Now you can open a text editor (e.g. gedit) and check if all configured keys arrive at the editor window.

References


EMC2GamePad (zuletzt geändert am 2012-06-13 21:26:24 durch anonym)


Creative Commons Lizenzvertrag
This page is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.