|
|
|
@ -770,6 +770,14 @@ |
|
|
|
|
for(k in _mods) _mods[k] = event[modifierMap[k]]; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
function isModifierPressed(mod) { |
|
|
|
|
if (mod=='control'||mod=='ctrl') return _mods[17]; |
|
|
|
|
if (mod=='shift') return _mods[16]; |
|
|
|
|
if (mod=='meta') return _mods[91]; |
|
|
|
|
if (mod=='alt') return _mods[18]; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// handle keydown event
|
|
|
|
|
function dispatch(event) { |
|
|
|
|
var key, handler, k, i, modifiersMatch, scope; |
|
|
|
@ -995,6 +1003,7 @@ |
|
|
|
|
global.key.deleteScope = deleteScope; |
|
|
|
|
global.key.filter = filter; |
|
|
|
|
global.key.isPressed = isPressed; |
|
|
|
|
global.key.isModifier = isModifierPressed; |
|
|
|
|
global.key.getPressedKeyCodes = getPressedKeyCodes; |
|
|
|
|
global.key.noConflict = noConflict; |
|
|
|
|
global.key.unbind = unbindKey; |
|
|
|
@ -1681,8 +1690,21 @@ var Screen = (function () { |
|
|
|
|
(function() { |
|
|
|
|
var x = i % W; |
|
|
|
|
var y = Math.floor(i / W); |
|
|
|
|
e.addEventListener('click', function () { |
|
|
|
|
Input.onTap(y, x); |
|
|
|
|
e.addEventListener('mouseenter', function (evt) { |
|
|
|
|
Input.onMouseMove(x, y); |
|
|
|
|
}); |
|
|
|
|
e.addEventListener('mousedown', function (evt) { |
|
|
|
|
Input.onMouseDown(x, y, evt.button+1); |
|
|
|
|
}); |
|
|
|
|
e.addEventListener('mouseup', function (evt) { |
|
|
|
|
Input.onMouseUp(x, y, evt.button+1); |
|
|
|
|
}); |
|
|
|
|
e.addEventListener('contextmenu', function (evt) { |
|
|
|
|
evt.preventDefault(); |
|
|
|
|
}); |
|
|
|
|
e.addEventListener('mousewheel', function (evt) { |
|
|
|
|
Input.onMouseWheel(x, y, evt.deltaY>0?1:-1); |
|
|
|
|
return false; |
|
|
|
|
}); |
|
|
|
|
})(); |
|
|
|
|
|
|
|
|
@ -2003,10 +2025,6 @@ var Input = (function() { |
|
|
|
|
Conn.send("STR:"+str); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function sendPosMsg(y, x) { |
|
|
|
|
Conn.send("TAP:"+y+','+x); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function sendBtnMsg(n) { |
|
|
|
|
Conn.send("BTN:"+n); |
|
|
|
|
} |
|
|
|
@ -2129,6 +2147,10 @@ var Input = (function() { |
|
|
|
|
_bindFnKeys(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var mb1 = 0; |
|
|
|
|
var mb2 = 0; |
|
|
|
|
var mb3 = 0; |
|
|
|
|
|
|
|
|
|
function init() { |
|
|
|
|
_initKeys(); |
|
|
|
|
|
|
|
|
@ -2138,11 +2160,30 @@ var Input = (function() { |
|
|
|
|
sendBtnMsg(+this.dataset['n']); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
window.addEventListener('mousedown', function(evt) { |
|
|
|
|
if (evt.button == 0) mb1 = 1; |
|
|
|
|
if (evt.button == 1) mb2 = 1; |
|
|
|
|
if (evt.button == 2) mb3 = 1; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
window.addEventListener('mouseup', function(evt) { |
|
|
|
|
if (evt.button == 0) mb1 = 0; |
|
|
|
|
if (evt.button == 1) mb2 = 0; |
|
|
|
|
if (evt.button == 2) mb3 = 0; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function packModifiersForMouse() { |
|
|
|
|
return (key.isModifier('ctrl')?1:0) | |
|
|
|
|
(key.isModifier('shift')?2:0) | |
|
|
|
|
(key.isModifier('alt')?4:0) | |
|
|
|
|
(key.isModifier('meta')?8:0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
init: init, |
|
|
|
|
onTap: sendPosMsg, |
|
|
|
|
// onTap: sendPosMsg,
|
|
|
|
|
sendString: sendStrMsg, |
|
|
|
|
setAlts: function(cu, np, fn) { |
|
|
|
|
if (opts.cu_alt != cu || opts.np_alt != np || opts.fn_alt != fn) { |
|
|
|
@ -2154,6 +2195,28 @@ var Input = (function() { |
|
|
|
|
_bindFnKeys(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
onMouseMove: function(x, y) { |
|
|
|
|
// TODO gather held buttons & key modifiers
|
|
|
|
|
var b = (mb1?1:0) | (mb2?2:0) | (mb3?4:0); |
|
|
|
|
var m = packModifiersForMouse(); |
|
|
|
|
Conn.send("MM:"+y+','+x+','+b+','+m); |
|
|
|
|
}, |
|
|
|
|
onMouseDown: function(x, y, which) { |
|
|
|
|
if(which>3) return; |
|
|
|
|
var m = packModifiersForMouse(); |
|
|
|
|
Conn.send("MP:"+y+','+x+','+which+','+m); |
|
|
|
|
}, |
|
|
|
|
onMouseUp: function(x, y, which) { |
|
|
|
|
if(which>3) return; |
|
|
|
|
var m = packModifiersForMouse(); |
|
|
|
|
Conn.send("MR:"+y+','+x+','+which+','+m); |
|
|
|
|
}, |
|
|
|
|
onMouseWheel: function(x, y, dir) { |
|
|
|
|
// -1 ... btn 4 (away from user)
|
|
|
|
|
// +1 ... btn 5 (towards user)
|
|
|
|
|
var m = packModifiersForMouse(); |
|
|
|
|
Conn.send("MP:"+y+','+x+','+(dir<0?4:5)+','+m); |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
})(); |
|
|
|
|
|
|
|
|
|