Class: UinputTouchpad
- Inherits:
-
Ruinput::UinputDevice
- Object
- Ruinput::UinputDevice
- UinputTouchpad
- Includes:
- Ruinput
- Defined in:
- lib/fusuma/plugin/remap/uinput_touchpad.rb
Instance Method Summary collapse
-
#create_from_device(name:, device:) ⇒ Object
create from original event device copy absinfo using eviocgabs.
- #set_all_events ⇒ Object
Instance Method Details
#create_from_device(name:, device:) ⇒ Object
create from original event device copy absinfo using eviocgabs
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fusuma/plugin/remap/uinput_touchpad.rb', line 8 def create_from_device(name:, device:) id = Revdev::InputId.new( { bustype: Revdev::BUS_I8042, vendor: device.device_id.vendor, product: device.device_id.product, version: device.device_id.version } ) absinfo = { Revdev::ABS_X => device.absinfo_for_axis(Revdev::ABS_X), Revdev::ABS_Y => device.absinfo_for_axis(Revdev::ABS_Y), Revdev::ABS_MT_POSITION_X => device.absinfo_for_axis(Revdev::ABS_MT_POSITION_X), Revdev::ABS_MT_POSITION_Y => device.absinfo_for_axis(Revdev::ABS_MT_POSITION_Y), Revdev::ABS_MT_SLOT => device.absinfo_for_axis(Revdev::ABS_MT_SLOT), Revdev::ABS_MT_TOOL_TYPE => device.absinfo_for_axis(Revdev::ABS_MT_TOOL_TYPE), Revdev::ABS_MT_TRACKING_ID => device.absinfo_for_axis(Revdev::ABS_MT_TRACKING_ID) } uud = Ruinput::UinputUserDev.new({ name: name, id: id, ff_effects_max: 0, absmax: Array.new(Revdev::ABS_CNT, 0).tap { |a| absinfo.each { |k, v| a[k] = v[:absmax] } }, absmin: Array.new(Revdev::ABS_CNT, 0).tap { |a| absinfo.each { |k, v| a[k] = v[:absmin] } }, absfuzz: Array.new(Revdev::ABS_CNT, 0).tap { |a| absinfo.each { |k, v| a[k] = v[:absfuzz] } }, absflat: Array.new(Revdev::ABS_CNT, 0).tap { |a| absinfo.each { |k, v| a[k] = v[:absflat] } }, resolution: Array.new(Revdev::ABS_CNT, 0).tap { |a| absinfo.each { |k, v| a[k] = v[:resolution] } } }) @file.syswrite uud.to_byte_string set_all_events @file.ioctl UI_DEV_CREATE, nil @is_created = true end |
#set_all_events ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/fusuma/plugin/remap/uinput_touchpad.rb', line 47 def set_all_events raise "invalid method call: this uinput is already created" if @is_created mouse_btns = [ Revdev::BTN_0, Revdev::BTN_MISC, Revdev::BTN_1, Revdev::BTN_2, Revdev::BTN_3, Revdev::BTN_4, Revdev::BTN_5, Revdev::BTN_6, Revdev::BTN_7, Revdev::BTN_8, Revdev::BTN_9, Revdev::BTN_LEFT, Revdev::BTN_MOUSE, Revdev::BTN_MIDDLE, Revdev::BTN_RIGHT, Revdev::BTN_SIDE, Revdev::BTN_EXTRA, Revdev::BTN_FORWARD, Revdev::BTN_BACK, Revdev::BTN_TASK # Revdev::BTN_TRIGGER, # disable because libinput recognize this device as a joystick ].freeze touchpad_btns = [ Revdev::BTN_TOUCH, Revdev::BTN_TOOL_FINGER, Revdev::BTN_TOOL_DOUBLETAP, Revdev::BTN_TOOL_TRIPLETAP, Revdev::BTN_TOOL_QUADTAP, 0x148 # define BTN_TOOL_QUINTTAP 0x148 /* Five fingers on trackpad */ ].freeze @file.ioctl UI_SET_EVBIT, Revdev::EV_KEY @counter = 0 Revdev::KEY_CNT.times do |i| # https://github.com/mooz/xkeysnail/pull/101/files if mouse_btns.include?(i) || touchpad_btns.include?(i) # puts "setting #{i} (#{Revdev::REVERSE_MAPS[:KEY][i]})" @file.ioctl UI_SET_KEYBIT, i else # puts "skipping #{i} (#{Revdev::REVERSE_MAPS[:KEY][i]})" end end touchpad_abs = [ Revdev::ABS_X, Revdev::ABS_Y, # Revdev::ABS_PRESSURE, Revdev::ABS_MT_SLOT, # Revdev::ABS_MT_TOUCH_MAJOR, # Revdev::ABS_MT_TOUCH_MINOR, Revdev::ABS_MT_POSITION_X, Revdev::ABS_MT_POSITION_Y, Revdev::ABS_MT_TRACKING_ID, Revdev::ABS_MT_TOOL_TYPE ].freeze # kernel bug: device has min == max on ABS_Y @file.ioctl UI_SET_EVBIT, Revdev::EV_ABS Revdev::ABS_CNT.times do |i| if touchpad_abs.include?(i) # puts "setting #{i} (#{Revdev::REVERSE_MAPS[:ABS][i]})" @file.ioctl UI_SET_ABSBIT, i else # puts "skipping #{i} (#{Revdev::REVERSE_MAPS[:ABS][i]})" end end touchpad_rels = [ Revdev::REL_X, Revdev::REL_Y, Revdev::REL_WHEEL, Revdev::REL_HWHEEL ].freeze @file.ioctl UI_SET_EVBIT, Revdev::EV_REL Revdev::REL_CNT.times do |i| if touchpad_rels.include?(i) # puts "setting #{i} (#{Revdev::REVERSE_MAPS[:REL][i]})" @file.ioctl UI_SET_RELBIT, i else # puts "skipping #{i} (#{Revdev::REVERSE_MAPS[:REL][i]})" end end @file.ioctl UI_SET_EVBIT, Revdev::EV_REP touchpad_mscs = [ 0x05 # define MSC_TIMESTAMP 0x05 ] @file.ioctl UI_SET_EVBIT, Revdev::EV_MSC Revdev::MSC_CNT.times do |i| if touchpad_mscs.include?(i) # puts "setting #{i} (#{Revdev::REVERSE_MAPS[:MSC][i]})" @file.ioctl UI_SET_MSCBIT, i else # puts "skipping #{i} (#{Revdev::REVERSE_MAPS[:MSC][i]})" end end end |