This is what I did to add my joypad with ANALOGUE control from the sticks!! I used rejoystick to map the buttons initially.
Presuming your machine is called "my-mill"
I identified the USB joypad by typing in a terminal window
lsusb
My joypad is named "DragonRise Inc. Generic USB Joystick ".
cnc-mill@cnc-mill:~$ lsusb
Bus 004 Device 003: ID 0e8f:0021 GreenAsia Inc.
Bus 004 Device 002: ID 0079:0006 DragonRise Inc. Generic USB Joystick
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 002: ID 046d:c001 Logitech, Inc. N48/M-BB48 [FirstMouse Plus]
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
cnc-mill@cnc-mill:~$
So in your machine's my-mill.hal file add the following lines
# joypad
loadusr -W hal_input -KRAL DragonRise
In your machines my-mill.ini file, under the [HAL] section add the following if it is not already there
HALUI = halui
Add the following line to your custom_postgui.hal file The number is in mm per minute for my machine.
setp halui.jog-speed 900
Add the following to your custom_postgui.hal file
net joy-x-jog halui.jog.0.analog <= input.0.abs-x-position
net joy-y-jog halui.jog.1.analog <= input.0.abs-y-position
net joy-z-jog halui.jog.2.analog <= input.0.abs-rz-position
I needed to reverse the direction of Y and Z axes.
setp input.0.abs-y-scale -127.5
setp input.0.abs-rz-scale -127.5
I found the left hand buttons can work under HAL too if you use input.0.btn.hat0x-is-neg, hat0x-is-pos, hat0y-is-neg and hat0y-is-pos.
I use the right SICK x-movement (input.0.abs-rx-is-pos and input.0.abs-rx-is-neg) to increment & decrement the jog-step,
and the right BUTTONS x-movement (input.0.btn.top and input.0.btn.thumb) to select continuous/incremental mode
Other button mapping I found useful
Key |
Function |
hal.btn |
pad-button |
F1 |
E-Stop |
input.0.btn-base |
6 - Top Left lower |
F2 |
Power |
input.0.btn-top2 |
4 - Top Left upper |
Shf |
Shift-key |
input.0.btn-base2 |
7 - Top Right lower |
Ent |
Enter |
input.0.btn-pinkie |
5 - Top Right upper |
F7 |
SpindleOn |
input.0.btn-base3 |
8 - select |
F8 |
Dust Extract |
input.0.btn-base4 |
9 - start |
R |
Run |
input.0.btn-base5 |
10 - press left stick |
End |
Touch-Off |
input.0.btn-base6 |
11 - press right stick |
I use the left buttons for XY incremental jog, and the right up/down for Z incremental jog.
All in all a busy little joypad!!
Hope this is helpful to you.
Noel.