111
Mach4 General Discussion / v2336 Keyboard Simulator plugin
« on: June 05, 2015, 01:17:25 PM »
...the working one
Attached is the keyboard simulator plugin from m4 ver. 2336.
Just delete the keyboard sim from your plugin folder and paste this one in. It works like a charm. I have 30 inputs mapped to functions.
Below is some sample code to put into your signal table/library in the screen load up script. You can map keys straight from m4 input tabs under configuration for jogging. You can really do a lot with it.
I would recommend when you map a key to have the Caps Lock on. This way when you type the keyboard sim doesn't interfere.
I can manipulate mach4 using the keyboard simulator with my Bluetooth keyboard away from the computer. It is also good to simulate probe inputs to test code with using the Mach4 Simulator plugin (as a motion controller sim).
--josh
Attached is the keyboard simulator plugin from m4 ver. 2336.
Just delete the keyboard sim from your plugin folder and paste this one in. It works like a charm. I have 30 inputs mapped to functions.
Below is some sample code to put into your signal table/library in the screen load up script. You can map keys straight from m4 input tabs under configuration for jogging. You can really do a lot with it.
I would recommend when you map a key to have the Caps Lock on. This way when you type the keyboard sim doesn't interfere.
I can manipulate mach4 using the keyboard simulator with my Bluetooth keyboard away from the computer. It is also good to simulate probe inputs to test code with using the Mach4 Simulator plugin (as a motion controller sim).
--josh
Code: [Select]
--Keyboard Sim 'Return' w/Caps Lock on to enable Mach 4.
sigLib[mc.ISIG_INPUT60] = function (state)
local inst = mc.mcGetInstance ()
local hSig = mc.mcSignalGetHandle (inst, mc.OSIG_MACHINE_ENABLED)
local sigState = mc.mcSignalGetState (hSig)
if state == 1 then
if sigState == 0 then
mc.mcSignalSetState (hSig, 1)
elseif sigState == 1 then
mc.mcSignalSetState (hSig, 0)
end
end
end
--Keyboard Sim 'C' w/Caps Lock on to center table.
sigLib[mc.ISIG_INPUT61] = function (state)
local inst = mc.mcGetInstance ()
local gCode = ""
if state == 1 then
gCode = "G00 G90 X9.0 Y2.0 Z0.0 \n"
mc.mcCntlMdiExecute (inst, gCode)
end
end
--Keyboard Sim 'Esc' for Estop.
sigLib[mc.ISIG_INPUT62] = function (state)
local inst = mc.mcGetInstance ()
local rc = 0
mc.mcCntlEStop (inst, 1)
end
--Keyboard Sim 'H' w/Caps Lock on to home all axes.
sigLib[mc.ISIG_INPUT63] = function (state)
local inst = mc.mcGetInstance ()
if state == 1 then
mc.mcAxisHomeAll (inst)
end