summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPliable Pixels <pliablepixels@gmail.com>2018-07-24 16:03:10 -0400
committerPliable Pixels <pliablepixels@gmail.com>2018-07-24 16:03:10 -0400
commit72a5fba411dece864109e3a4dc13ea55810abeaa (patch)
treea606e3a3ced07a680bea7142b8403c538928cfb3
parent206d3f7dcefd486d1927251a3c062d6b0e198e2e (diff)
#675 keyboard bindings - initial
-rw-r--r--www/js/MonitorModalCtrl.js99
1 files changed, 99 insertions, 0 deletions
diff --git a/www/js/MonitorModalCtrl.js b/www/js/MonitorModalCtrl.js
index 0875b25a..f956a6a3 100644
--- a/www/js/MonitorModalCtrl.js
+++ b/www/js/MonitorModalCtrl.js
@@ -76,6 +76,100 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$
}.bind(this), zm.alarmStatusTime);
+
+
+ if ($rootScope.platformOS == 'desktop') {
+ window.addEventListener('keydown', keyboardHandler, true);
+
+ }
+
+ // Keyboard handler for desktop versions
+ function keyboardHandler(evt) {
+
+ var handled = false;
+ var keyCodes = {
+
+ //monitors
+ LEFT: 37,
+ RIGHT: 39,
+
+ // ptz
+
+ TOGGLEPTZ_P: 80,
+
+ UPLEFT_Q: 81,
+ UP_W:87,
+ UPRIGHT_E:69,
+
+ LEFT_A:65,
+ CENTER_S: 83,
+ RIGHT_D:68,
+
+ DOWNLEFT_Z:90,
+ DOWN_X:88,
+ DOWNRIGHT_C:67,
+
+ ESC: 27
+
+ };
+
+ $timeout (function () {
+ var keyCode = evt.keyCode;
+
+ console.log (keyCode + " PRESSED");
+
+ if (keyCode == keyCodes.ESC) {
+
+ $scope.closeModal();
+
+ }
+ else if (keyCode == keyCodes.LEFT) {
+ $scope.monStatus = "";
+ moveToMonitor($scope.monitorId, -1);
+ }
+ else if (keyCode == keyCodes.RIGHT) {
+ $scope.monStatus = "";
+ moveToMonitor($scope.monitorId, 1);
+ }
+
+ else if (keyCode == keyCodes.TOGGLEPTZ_P) {
+ $scope.togglePTZ();
+ }
+ else { // rest of the functions are PTZ
+ if (!$scope.showPTZ) {
+ NVRDataModel.debug ("PTZ is not on, or disabled");
+ return;
+ }
+ // coming here means PTZ is on
+ var cmd = "";
+ switch (keyCode) {
+ case keyCodes.UPLEFT_Q: cmd = 'UpLeft'; break;
+ case keyCodes.UP_W:cmd = 'Up'; break;
+ case keyCodes.UPRIGHT_E:cmd = 'UpRight'; break;
+ case keyCodes.LEFT_A:cmd = 'Left'; break;
+ case keyCodes.CENTER_S: cmd = ''; break;
+ case keyCodes.RIGHT_D: cmd = 'Right'; break;
+ case keyCodes.DOWNLEFT_Z: cmd = 'UpLeft'; break;
+ case keyCodes.DOWN_X: cmd = 'Down'; break;
+ case keyCodes.DOWNRIGHT_C: cmd = 'DownRight'; break;
+ }
+ if (cmd) {
+ NVRDataModel.debug ("Invoking controlPTZ with "+cmd);
+ }
+ else {
+ NVRDataModel.debug ("ignoring invalid PTZ command");
+ }
+
+ }
+
+ handled = true;
+ return handled;
+
+ })
+ }
+
+
+
// This is the PTZ menu
@@ -1220,6 +1314,11 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$
$scope.$on('modal.removed', function () {
+ if ($rootScope.platformOS == 'desktop') {
+ NVRDataModel.debug ("Removing keyboard handler");
+ window.removeEventListener('keydown', keyboardHandler, true);
+
+ }
as(); // dregister auth success
$scope.isModalActive = false;