-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Labels
Description
For luahid, as i mentioned in my design, I list the following APIs for my "class":
namefor driver's namematch_listfor matching the fixed device in bus(es). it is a table and must cantains thevendor_idandproduct_id.match: a function for dynamic matching devices, like
-- other codes
match = function(device)
return device.vendor == 0x0111
end- report_descriptor, a tables contains several byted number, like
report_descriptor = {
0x05, 0x01, 0x09, 0x01, 0xa1, 0x01,
0x05, 0x09, 0x19, 0x01, 0x29, 0x08,
-- ... etc
}` - init(device): a function to initialize the driver.
- on_event: a table to process diffierent types of event, like:
on_event = {
key = {
[hid.input.KEY.A] = function(value)
print("unsupported A, filtered", value)
return true
end,
[hid.input.KEY.B] = function(value)
print("Key B occured:", value)
return false
end,
default = function(key, value)
print("unknown key, filtered", key.name, value)
return true
end
},
-- there is no ABS.Z in the example,
-- so the default event handler of it will be used.
-- you can also redefine the default event handler.
abs = {
[hid.input.ABS.X] = function(value)
print("position X:", value)
return true
end,
[hid.input.ABS.Y] = function(value)
print("position Y:", value)
return true
end
},
raw = function(data)
if data[1] == 0x01 then
print("find a special data:", data[2])
return true
end
return false
end
}This is my inital design(given in examples) of on_event, but it is a little bit difficult to implement & process the hole on_event in C.
But names likeon_event_raw, on_event_key are lack of extensibility.
input_mapping: a function to process data "before" submit to Linux input subsys.input_mapped: a function to process data "after" submit to Linux input subsys.
the two above may use the submoduleluahid.input, but it is optional to use or not.
and the class is loaded by an API register in luahid and the other API funcs send_report is used to operate the device if you want.
feel free to discuss, thanks. =)