Hardware:
- Logitech Extreme 3d Pro (
046d:c215 according to lsusb)
- unnamed "hama" brand USB keypad (
/dev/input/by-id/usb-05d5_KEYBOARD-event-kbd according to lsing that folder before and after plugging it in and looking what appeared)
Script:
devices = {
d0 = {
vendorid = 0x046d, -- Logitech
productid = 0xc215, -- Extreme 3D Pro
},
kbd0 = "/dev/input/by-id/usb-05d5_KEYBOARD-event-kbd", -- hama keypad
}
local d0buttons = { -- according to evtest
BTN_TRIGGER,
BTN_THUMB,
BTN_THUMB2,
BTN_TOP,
BTN_TOP2,
BTN_PINKIE,
BTN_BASE,
BTN_BASE2,
BTN_BASE3,
BTN_BASE4,
BTN_BASE5,
BTN_BASE6
}
local d0axes = { -- according to evtest
ABS_X, ABS_Y, ABS_RZ,
ABS_THROTTLE,
ABS_HAT0X, ABS_HAT0Y
}
local kpkeys = { -- according to looking at it
KEY_KPSLASH, KEY_KPASTERISK,
KEY_KP7, KEY_KP8, KEY_KP9, KEY_KPMINUS,
KEY_KP4, KEY_KP5, KEY_KP6, KEY_KPPLUS,
KEY_KP1, KEY_KP2, KEY_KP3, KEY_KPENTER,
KEY_KP0, KEY_KPDOT
}
-- making inverse lookup tables
local d0buttonsinv = {}
local d0axesinv = {}
local kpkeysinv = {}
for i=1,#d0buttons do
d0buttonsinv[d0buttons[i]] = i
end
for i=1,#d0axes do
d0axesinv[d0axes[i]] = i
end
for i=1,#kpkeys do
kpkeysinv[kpkeys[i]] = i
end
v_devices = {
v0 = {
buttons = #d0buttons + #kpkeys,
axes = #d0axes
}
}
-- make button events starting with TRIGGER_HAPPY1
function kbd0_pressed(value)
local i = kpkeysinv[value]
if i then
send_button_event(0,BTN_DEAD+i,1)
end
end
function kbd0_released(value)
local i = kpkeysinv[value]
if i then
send_button_event(0,BTN_DEAD+i,0)
end
end
-- forward buttons
for i=1,#d0buttons do
_ENV["d0_b"..d0buttons[i].."_event"] = function (value)
send_button_event(0,d0buttons[i],value)
end
end
-- forward axes
for i=1,#d0axes do
_ENV["d0_a"..d0axes[i].."_event"] = function (value)
send_axis_event(0,d0axes[i],value)
end
end
What I Expected:
A WeJoy Virtual Device 0 with combined buttons from joystick+keypad and the axes from the keypad (essentially extending the available joystick buttons using the keypad).
What I get instead:
wejoy:
$ sudo wejoy logitechPlusNumpad.lua
WeJoy v0.2 by Johannes Bergmark
Successfully created virtual device 0.
Successfully created virtual keyboard device.
Press 'q' and then 'ENTER' to quit!
[it does NOT react to `q\n`!]
evtest:
$ sudo evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
[...]
/dev/input/event29: WeJoy Virtual Device 0
/dev/input/event30: WeJoy Virtual Keyboard
Select the device event number [0-30]: 29
Input driver version is 1.0.1
Input device ID: bus 0x6 vendor 0x0 product 0x0 version 0x1
Input device name: "WeJoy Virtual Device 0"
Supported events:
Event type 0 (EV_SYN)
Properties:
Testing ... (interrupt to exit)
also pressing keys on the keypad still creates X11 keyboard input events (=typing numbers).
Hardware:
046d:c215according tolsusb)/dev/input/by-id/usb-05d5_KEYBOARD-event-kbdaccording tolsing that folder before and after plugging it in and looking what appeared)Script:
What I Expected:
A
WeJoy Virtual Device 0with combined buttons from joystick+keypad and the axes from the keypad (essentially extending the available joystick buttons using the keypad).What I get instead:
wejoy:
evtest:
also pressing keys on the keypad still creates X11 keyboard input events (=typing numbers).