fix syntax

This commit is contained in:
2026-02-17 09:15:15 -06:00
parent f310c18b84
commit 4e1b63fd0e
52 changed files with 2169 additions and 1754 deletions

View File

@@ -147,69 +147,73 @@ function create_user(index, config) {
// Pick user based on pairing policy
function pick_user(canon) {
var picked = null
var old_down = null
var i = 0
if (length(_users) == 0) return null
// For last_used: always user 0, just update active device
if (_config.pairing == 'last_used') {
var user = _users[0]
picked = _users[0]
// Only switch on button press, not axis/motion
if (canon.kind == 'button' && canon.pressed) {
if (user.active_device != canon.device_id) {
if (picked.active_device != canon.device_id) {
// Release all held actions when switching device
var old_down = user.router.down
old_down = picked.router.down
arrfor(array(old_down), action => {
if (old_down[action]) {
user.dispatch(action, { pressed: false, released: true, time: canon.time })
picked.dispatch(action, { pressed: false, released: true, time: canon.time })
}
})
user.active_device = canon.device_id
if (find(user.paired_devices, canon.device_id) == null) {
push(user.paired_devices, canon.device_id)
picked.active_device = canon.device_id
if (find(picked.paired_devices, canon.device_id) == null) {
push(picked.paired_devices, canon.device_id)
}
}
}
return user
return picked
}
// For explicit pairing: find user paired to this device
for (var i = 0; i < length(_users); i++) {
for (i = 0; i < length(_users); i++) {
if (find(_users[i].paired_devices, canon.device_id) != null) {
_users[i].active_device = canon.device_id
return _users[i]
}
}
// Unpaired device - could implement join logic here
return null
}
// Configure the input system
function configure(opts) {
opts = opts || {}
function configure(o) {
var opts = o || {}
var i = 0
_config.max_users = opts.max_users || 1
_config.pairing = opts.pairing || 'last_used'
_config.emacs = opts.emacs != false
_config.gestures = opts.gestures != false
if (opts.action_map) _config.action_map = opts.action_map
if (opts.display_names) _config.display_names = opts.display_names
if (opts.on_window) _window_callback = opts.on_window
// Copy gesture config
_config.swipe_min_dist = opts.swipe_min_dist
_config.swipe_max_time = opts.swipe_max_time
_config.pinch_threshold = opts.pinch_threshold
// Create users
_users = []
for (var i = 0; i < _config.max_users; i++) {
for (i = 0; i < _config.max_users; i++) {
push(_users, create_user(i, _config))
}
_initialized = true
}