|
|
@ -15,8 +15,8 @@ TRANSPARENT_PEN = to_pen{tile=0, ch=0}
|
|
|
|
KEEP_LOWER_PEN = to_pen{ch=32, fg=0, bg=0, keep_lower=true}
|
|
|
|
KEEP_LOWER_PEN = to_pen{ch=32, fg=0, bg=0, keep_lower=true}
|
|
|
|
|
|
|
|
|
|
|
|
local MOUSE_KEYS = {
|
|
|
|
local MOUSE_KEYS = {
|
|
|
|
_MOUSE_L = true,
|
|
|
|
_MOUSE_L = function(is_set) df.global.enabler.mouse_lbut = is_set and 1 or 0 end,
|
|
|
|
_MOUSE_R = true,
|
|
|
|
_MOUSE_R = function(is_set) df.global.enabler.mouse_rbut = is_set and 1 or 0 end,
|
|
|
|
_MOUSE_M = true,
|
|
|
|
_MOUSE_M = true,
|
|
|
|
_MOUSE_L_DOWN = true,
|
|
|
|
_MOUSE_L_DOWN = true,
|
|
|
|
_MOUSE_R_DOWN = true,
|
|
|
|
_MOUSE_R_DOWN = true,
|
|
|
@ -27,7 +27,7 @@ local FAKE_INPUT_KEYS = copyall(MOUSE_KEYS)
|
|
|
|
FAKE_INPUT_KEYS._STRING = true
|
|
|
|
FAKE_INPUT_KEYS._STRING = true
|
|
|
|
|
|
|
|
|
|
|
|
function simulateInput(screen,...)
|
|
|
|
function simulateInput(screen,...)
|
|
|
|
local keys = {}
|
|
|
|
local keys, enabled_mouse_keys = {}, {}
|
|
|
|
local function push_key(arg)
|
|
|
|
local function push_key(arg)
|
|
|
|
local kv = arg
|
|
|
|
local kv = arg
|
|
|
|
if type(arg) == 'string' then
|
|
|
|
if type(arg) == 'string' then
|
|
|
@ -35,6 +35,10 @@ function simulateInput(screen,...)
|
|
|
|
if kv == nil and not FAKE_INPUT_KEYS[arg] then
|
|
|
|
if kv == nil and not FAKE_INPUT_KEYS[arg] then
|
|
|
|
error('Invalid keycode: '..arg)
|
|
|
|
error('Invalid keycode: '..arg)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if MOUSE_KEYS[arg] then
|
|
|
|
|
|
|
|
df.global.enabler.tracking_on = 1
|
|
|
|
|
|
|
|
enabled_mouse_keys[arg] = true
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if type(kv) == 'number' then
|
|
|
|
if type(kv) == 'number' then
|
|
|
|
keys[#keys+1] = kv
|
|
|
|
keys[#keys+1] = kv
|
|
|
@ -57,6 +61,11 @@ function simulateInput(screen,...)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
for mk, fn in pairs(MOUSE_KEYS) do
|
|
|
|
|
|
|
|
if type(fn) == 'function' then
|
|
|
|
|
|
|
|
fn(enabled_mouse_keys[mk])
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
dscreen._doSimulateInput(screen, keys)
|
|
|
|
dscreen._doSimulateInput(screen, keys)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -696,17 +705,6 @@ end
|
|
|
|
|
|
|
|
|
|
|
|
DEFAULT_INITIAL_PAUSE = true
|
|
|
|
DEFAULT_INITIAL_PAUSE = true
|
|
|
|
|
|
|
|
|
|
|
|
-- ensure underlying DF screens don't also react to handled clicks
|
|
|
|
|
|
|
|
function markMouseClicksHandled(keys)
|
|
|
|
|
|
|
|
if keys._MOUSE_L then
|
|
|
|
|
|
|
|
df.global.enabler.mouse_lbut = 0
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
if keys._MOUSE_R then
|
|
|
|
|
|
|
|
df.global.enabler.mouse_rbut_down = 0
|
|
|
|
|
|
|
|
df.global.enabler.mouse_rbut = 0
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ZScreen = defclass(ZScreen, Screen)
|
|
|
|
ZScreen = defclass(ZScreen, Screen)
|
|
|
|
ZScreen.ATTRS{
|
|
|
|
ZScreen.ATTRS{
|
|
|
|
defocusable=true,
|
|
|
|
defocusable=true,
|
|
|
@ -791,23 +789,17 @@ function ZScreen:onInput(keys)
|
|
|
|
self:raise()
|
|
|
|
self:raise()
|
|
|
|
else
|
|
|
|
else
|
|
|
|
self:sendInputToParent(keys)
|
|
|
|
self:sendInputToParent(keys)
|
|
|
|
return
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if ZScreen.super.onInput(self, keys) then
|
|
|
|
if ZScreen.super.onInput(self, keys) then
|
|
|
|
markMouseClicksHandled(keys)
|
|
|
|
-- noop
|
|
|
|
return
|
|
|
|
elseif self.pass_mouse_clicks and keys._MOUSE_L and not has_mouse then
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.pass_mouse_clicks and keys._MOUSE_L and not has_mouse then
|
|
|
|
|
|
|
|
self.defocused = self.defocusable
|
|
|
|
self.defocused = self.defocusable
|
|
|
|
self:sendInputToParent(keys)
|
|
|
|
self:sendInputToParent(keys)
|
|
|
|
return
|
|
|
|
|
|
|
|
elseif keys.LEAVESCREEN or keys._MOUSE_R then
|
|
|
|
elseif keys.LEAVESCREEN or keys._MOUSE_R then
|
|
|
|
self:dismiss()
|
|
|
|
self:dismiss()
|
|
|
|
markMouseClicksHandled(keys)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
local passit = self.pass_pause and keys.D_PAUSE
|
|
|
|
local passit = self.pass_pause and keys.D_PAUSE
|
|
|
|
if not passit and self.pass_mouse_clicks then
|
|
|
|
if not passit and self.pass_mouse_clicks then
|
|
|
@ -829,8 +821,8 @@ function ZScreen:onInput(keys)
|
|
|
|
if passit then
|
|
|
|
if passit then
|
|
|
|
self:sendInputToParent(keys)
|
|
|
|
self:sendInputToParent(keys)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function ZScreen:raise()
|
|
|
|
function ZScreen:raise()
|
|
|
|