查看: 8806|回复: 15

[有事请教] mv有全键盘的插件吗

[复制链接]
梦石
0
星屑
141
在线时间
20 小时
注册时间
2015-5-5
回帖
1
发表于 2019-2-26 14:34:36 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
rt 有大佬提供一个么 找了好久都没有找到
梦石
0
星屑
39336
在线时间
11161 小时
注册时间
2009-3-15
回帖
4768
发表于 2019-2-26 15:08:25 | 显示全部楼层
  1. //=============================================================================
  2. // MV全按鍵  版本2
  3. // 最終更新:2016/4/15
  4. //=============================================================================
  5. /*:
  6. * @plugindesc 全按鍵,解決您按鍵不夠的煩惱
  7. * @author Q-S.T.
  8. *
  9. *
  10. * @help 說明
  11. * <使用方法>在事件腳本或條件分歧的腳本欄使用以下語句:
  12. *  判斷按著(Press):InputEX.isPressed(鍵碼)
  13. *  判斷按下(Trigger):InputEX.isTriggered(鍵碼)
  14. *  判斷長按(Repeat):InputEX.isRepeated(鍵碼)
  15. *  判斷長按2(LongPress):InputEX.isLongPressed(鍵碼)
  16. *
  17. * <使用例>
  18. *  InputEX.isPressed(13)   // 按著Enter
  19. *  InputEX.isTriggered(71)   // 按下G鍵
  20. *
  21. * <其他>
  22. *  1.長按2在預設用來做快轉事件用
  23. *  2.腳本中附的鍵碼表供對照用
  24. *  3.JS中ctrl、alt、shift沒分左右
  25. *  4.判斷數字以外的字會改用預設方法
  26. *  5.print screen(截圖鍵)無效,所以別用
  27. *  6.Num Lock會重置按鍵判定,最好也別用
  28. *  7.MV版本1.1.0後改成和Input關連
  29.   
  30. */
  31.   
  32.   
  33.   
  34. // 舊方法擴充
  35. (function() {   
  36. //
  37. var _Input_initialize = Input.initialize;
  38. Input.initialize = function() {
  39.     _Input_initialize.call(this);
  40.     InputEX.initialize();
  41. };   
  42. //
  43. var _Input_update = Input.update;
  44. Input.update = function() {
  45.     _Input_update.call(this);
  46.     InputEX.update();
  47. };
  48. //



  49. })();
  50.   
  51.   
  52.   
  53.   
  54.   
  55.   
  56.   
  57. /**
  58. * The static class that handles input data from the keyboard and gamepads.
  59. *
  60. * @class Input
  61. */
  62. function InputEX() {
  63.     throw new Error('This is a static class');
  64. }

  65. /**
  66. * Initializes the input system.
  67. *
  68. * @static
  69. * @method initialize
  70. */
  71. InputEX.initialize = function() {
  72.     this.clear();
  73.     this._wrapNwjsAlert();
  74.     this._setupEventHandlers();
  75. };


  76. // 對照表
  77. InputEX.keyMapper = {
  78.     8: 'backspace',      // 倒回
  79.     9: 'tab',        
  80.     12: 'clear',         // 關Num Lock + 數字鍵5   
  81.     13: 'enter',         
  82.     16: 'shift',         
  83.     17: 'control',      
  84.     18: 'alt',           
  85.     19: 'pause',
  86.     20: 'caps lock',
  87.     27: 'esc',           
  88.     32: 'space',         
  89.     33: 'pageup',        
  90.     34: 'pagedown',      
  91.     35: 'end',
  92.     36: 'home',
  93.     37: 'left',           
  94.     38: 'up',            
  95.     39: 'right',         
  96.     40: 'down',           
  97.     44: 'print screen',   // 截圖,這個鍵無效
  98.     45: 'insert',         
  99.     46: 'del',
  100.     48: 'num 0',
  101.     49: 'num 1',
  102.     50: 'num 2',
  103.     51: 'num 3',
  104.     52: 'num 4',
  105.     53: 'num 5',
  106.     54: 'num 6',
  107.     55: 'num 7',
  108.     56: 'num 8',
  109.     57: 'num 9',
  110.     65: 'A',
  111.     66: 'B',
  112.     67: 'C',
  113.     68: 'D',
  114.     69: 'E',
  115.     70: 'F',
  116.     71: 'G',
  117.     72: 'H',
  118.     73: 'I',
  119.     74: 'J',
  120.     75: 'K',
  121.     76: 'L',
  122.     77: 'M',
  123.     78: 'N',
  124.     79: 'O',
  125.     80: 'P',
  126.     81: 'Q',      
  127.     82: 'R',
  128.     83: 'S',
  129.     84: 'T',
  130.     85: 'U',
  131.     86: 'V',
  132.     87: 'W',      
  133.     88: 'X',      
  134.     89: 'Y',
  135.     90: 'Z',      
  136.     91: 'L Win',         // 左Win(會叫出開始選單,慎用)
  137.     92: 'R Win',         // 右Win(會叫出開始選單,慎用)
  138.     93: 'select',       // 選單
  139.     96: 'numpad 0',     
  140.     97: 'numpad 1',     
  141.     98: 'numpad 2',     
  142.     99: 'numpad 3',     
  143.     100: 'numpad 4',   
  144.     101: 'numpad 5',     
  145.     102: 'numpad 6',     
  146.     103: 'numpad 7',     
  147.     104: 'numpad 8',      
  148.     105: 'numpad 9',     
  149.     106: 'numpad *',
  150.     107: 'numpad +',
  151.     109: 'numpad -',
  152.     110: 'numpad .',
  153.     111: 'numpad /',
  154.     112: 'F1',
  155.     113: 'F2',           // 被拿去呼叫FPS視窗,慎用
  156.     114: 'F3',           // 被拿去切換平鋪模式,慎用
  157.     115: 'F4',           // 被拿去視窗縮放,慎用
  158.     116: 'F5',           // 被拿去重新啟動,慎用
  159.     117: 'F6',
  160.     118: 'F7',
  161.     119: 'F8',          // F8
  162.     120: 'F9',          // F9
  163.     121: 'F10',
  164.     122: 'F11',
  165.     123: 'F12',
  166.     144: 'num lock',    // 會重置判定,慎用
  167.     145: 'scroll lock',
  168.     186: ';',
  169.     187: '=',
  170.     188: ',',
  171.     189: '-',
  172.     190: '.',
  173.     191: '/',
  174.     192: '`',
  175.     219: '[',
  176.     220: '\\',        // \鍵,寫兩個是因為會被解讀成正則
  177.     221: ']',
  178.     222: "'",        //  三個'會被誤判,改用""來包
  179. };


  180. /**
  181. * The wait time of the key repeat in frames.
  182. *
  183. * @static
  184. * @property keyRepeatWait
  185. * @type Number
  186. */
  187. InputEX.keyRepeatWait = 24;

  188. /**
  189. * The interval of the key repeat in frames.
  190. *
  191. * @static
  192. * @property keyRepeatInterval
  193. * @type Number
  194. */
  195. InputEX.keyRepeatInterval = 6;


  196. /**
  197. * Clears all the input data.
  198. *
  199. * @static
  200. * @method clear
  201. */
  202. InputEX.clear = function() {
  203.     this._currentState = {};
  204.     this._previousState = {};
  205.     this._latestButton = null;
  206.     this._pressedTime = 0;
  207.     this._dir4 = 0;
  208.     this._dir8 = 0;
  209.     this._preferredAxis = '';
  210.     this._date = 0;
  211. };

  212. /**
  213. * Updates the input data.
  214. *
  215. * @static
  216. * @method update
  217. */
  218. InputEX.update = function() {
  219.     if (this._currentState[this._latestButton]) {
  220.         this._pressedTime++;
  221.     } else {
  222.         this._latestButton = null;
  223.     }
  224.     for (var name in this._currentState) {
  225.         if (this._currentState[name] && !this._previousState[name]) {
  226.             // 轉成數字記錄
  227.             this._latestButton = parseInt(name);
  228.             this._pressedTime = 0;
  229.             this._date = Date.now();
  230.         }
  231.         this._previousState[name] = this._currentState[name];
  232.          
  233.     }
  234.     this._updateDirection();
  235. };

  236. /**
  237. * Checks whether a key is currently pressed down.
  238. *
  239. * @static
  240. * @method isPressed
  241. * @param {String} keyName The mapped name of the key
  242. * @return {Boolean} True if the key is pressed
  243. */
  244. InputEX.isPressed = function(keyName) {
  245.     return !!this._currentState[keyName];
  246. };

  247. /**
  248. * Checks whether a key is just pressed.
  249. *
  250. * @static
  251. * @method isTriggered
  252. * @param {String} keyName The mapped name of the key
  253. * @return {Boolean} True if the key is triggered
  254. */
  255. InputEX.isTriggered = function(keyName) {
  256.     return this._latestButton === keyName && this._pressedTime === 0;
  257. };

  258. /**
  259. * Checks whether a key is just pressed or a key repeat occurred.
  260. *
  261. * @static
  262. * @method isRepeated
  263. * @param {String} keyName The mapped name of the key
  264. * @return {Boolean} True if the key is repeated
  265. */
  266. InputEX.isRepeated = function(keyName) {
  267.     return (this._latestButton === keyName &&
  268.         (this._pressedTime === 0 ||
  269.             (this._pressedTime >= this.keyRepeatWait &&
  270.                 this._pressedTime % this.keyRepeatInterval === 0)));
  271. };

  272. /**
  273. * Checks whether a key is kept depressed.
  274. *
  275. * @static
  276. * @method isLongPressed
  277. * @param {String} keyName The mapped name of the key
  278. * @return {Boolean} True if the key is long-pressed
  279. */
  280. InputEX.isLongPressed = function(keyName) {
  281.     return (this._latestButton === keyName &&
  282.          this._pressedTime >= this.keyRepeatWait);
  283. };

  284. /**
  285. * [read-only] The four direction value as a number of the numpad, or 0 for neutral.
  286. *
  287. * @static
  288. * @property dir4
  289. * @type Number
  290. */
  291. Object.defineProperty(InputEX, 'dir4', {
  292.     get: function() {
  293.         return this._dir4;
  294.     },
  295.     configurable: true
  296. });

  297. /**
  298. * [read-only] The eight direction value as a number of the numpad, or 0 for neutral.
  299. *
  300. * @static
  301. * @property dir8
  302. * @type Number
  303. */
  304. Object.defineProperty(InputEX, 'dir8', {
  305.     get: function() {
  306.         return this._dir8;
  307.     },
  308.     configurable: true
  309. });

  310. /**
  311. * [read-only] The time of the last input in milliseconds.
  312. *
  313. * @static
  314. * @property date
  315. * @type Number
  316. */
  317. Object.defineProperty(InputEX, 'date', {
  318.     get: function() {
  319.         return this._date;
  320.     },
  321.     configurable: true
  322. });

  323. /**
  324. * @static
  325. * @method _wrapNwjsAlert
  326. * @private
  327. */
  328. InputEX._wrapNwjsAlert = function() {
  329.     if (Utils.isNwjs()) {
  330.         var _alert = window.alert;
  331.         window.alert = function() {
  332.             var gui = require('nw.gui');
  333.             var win = gui.Window.get();
  334.             _alert.apply(this, arguments);
  335.             win.focus();
  336.             InputEX.clear();
  337.         };
  338.     }
  339. };

  340. /**
  341. * @static
  342. * @method _setupEventHandlers
  343. * @private
  344. */
  345. InputEX._setupEventHandlers = function() {
  346.     document.addEventListener('keydown', this._onKeyDown.bind(this));
  347.     document.addEventListener('keyup', this._onKeyUp.bind(this));
  348.     window.addEventListener('blur', this._onLostFocus.bind(this));
  349. };

  350. /**
  351. * @static
  352. * @method _onKeyDown
  353. * @param {KeyboardEvent} event
  354. * @private
  355. */
  356. InputEX._onKeyDown = function(event) {
  357.     if (this._shouldPreventDefault(event.keyCode)) {
  358.         event.preventDefault();
  359.     }
  360.     if (event.keyCode === 144) {    // Numlock
  361.         this.clear();
  362.     }
  363.     this._currentState[event.keyCode] = true;
  364.      
  365. };

  366. /**
  367. * @static
  368. * @method _shouldPreventDefault
  369. * @param {Number} keyCode
  370. * @private
  371. */
  372. InputEX._shouldPreventDefault = function(keyCode) {
  373.     switch (keyCode) {
  374.     case 8:     // backspace
  375.     case 33:    // pageup
  376.     case 34:    // pagedown
  377.     case 37:    // left arrow
  378.     case 38:    // up arrow
  379.     case 39:    // right arrow
  380.     case 40:    // down arrow
  381.         return true;
  382.     }
  383.     return false;
  384. };

  385. /**
  386. * @static
  387. * @method _onKeyUp
  388. * @param {KeyboardEvent} event
  389. * @private
  390. */
  391. InputEX._onKeyUp = function(event) {
  392.     this._currentState[event.keyCode] = false;
  393.     if (event.keyCode === 0) {  // For QtWebEngine on OS X
  394.         this.clear();
  395.     }
  396. };

  397. /**
  398. * @static
  399. * @method _onLostFocus
  400. * @private
  401. */
  402. InputEX._onLostFocus = function() {
  403.     this.clear();
  404. };



  405. /**
  406. * @static
  407. * @method _updateDirection
  408. * @private
  409. */
  410. InputEX._updateDirection = function() {
  411.     var x = this._signX();
  412.     var y = this._signY();

  413.     this._dir8 = this._makeNumpadDirection(x, y);

  414.     if (x !== 0 && y !== 0) {
  415.         if (this._preferredAxis === 'x') {
  416.             y = 0;
  417.         } else {
  418.             x = 0;
  419.         }
  420.     } else if (x !== 0) {
  421.         this._preferredAxis = 'y';
  422.     } else if (y !== 0) {
  423.         this._preferredAxis = 'x';
  424.     }

  425.     this._dir4 = this._makeNumpadDirection(x, y);
  426. };

  427. /**
  428. * @static
  429. * @method _signX
  430. * @private
  431. */
  432. InputEX._signX = function() {
  433.     var x = 0;

  434.     if (this.isPressed('left')) {
  435.         x--;
  436.     }
  437.     if (this.isPressed('right')) {
  438.         x++;
  439.     }
  440.     return x;
  441. };

  442. /**
  443. * @static
  444. * @method _signY
  445. * @private
  446. */
  447. InputEX._signY = function() {
  448.     var y = 0;

  449.     if (this.isPressed('up')) {
  450.         y--;
  451.     }
  452.     if (this.isPressed('down')) {
  453.         y++;
  454.     }
  455.     return y;
  456. };

  457. /**
  458. * @static
  459. * @method _makeNumpadDirection
  460. * @param {Number} x
  461. * @param {Number} y
  462. * @return {Number}
  463. * @private
  464. */
  465. InputEX._makeNumpadDirection = function(x, y) {
  466.     if (x !== 0 || y !== 0) {
  467.         return  5 - y * 3 + x;
  468.     }
  469.     return 0;
  470. };
复制代码
回复

使用道具 举报

梦石
0
星屑
141
在线时间
20 小时
注册时间
2015-5-5
回帖
1
 楼主| 发表于 2019-2-26 15:46:32 | 显示全部楼层
soulsaga 发表于 2019-2-26 15:08
//=============================================================================
// MV全按鍵  版本2
/ ...

谢谢大佬
回复

使用道具 举报

梦石
0
星屑
3341
在线时间
469 小时
注册时间
2014-2-6
回帖
217
发表于 2019-9-12 19:20:12 | 显示全部楼层
soulsaga 发表于 2019-2-26 15:08
//=============================================================================
// MV全按鍵  版本2
/ ...

请问大佬,我的游戏打算出售...可以用您这个插件么?
回复

使用道具 举报

梦石
0
星屑
39336
在线时间
11161 小时
注册时间
2009-3-15
回帖
4768
发表于 2019-9-12 19:35:41 | 显示全部楼层
天空娃娃 发表于 2019-9-12 19:20
请问大佬,我的游戏打算出售...可以用您这个插件么?

作者没有提过这方面..我不知道..
回复

使用道具 举报

梦石
0
星屑
3341
在线时间
469 小时
注册时间
2014-2-6
回帖
217
发表于 2019-9-12 19:42:42 | 显示全部楼层
soulsaga 发表于 2019-9-12 19:35
作者没有提过这方面..我不知道..

emmmm,那还是不用了....
回复

使用道具 举报

梦石
0
星屑
3930
在线时间
1198 小时
注册时间
2016-8-9
回帖
2355

开拓者

发表于 2019-9-13 19:50:24 | 显示全部楼层
天空娃娃 发表于 2019-9-12 19:42
emmmm,那还是不用了....

yep系列可商用插件,你值得拥有

按钮公共事件

自定义按键
酸酸甜甜就④哇噢
回复

使用道具 举报

梦石
0
星屑
3341
在线时间
469 小时
注册时间
2014-2-6
回帖
217
发表于 2019-9-13 22:23:01 | 显示全部楼层
白嫩白嫩的 发表于 2019-9-13 19:50
yep系列可商用插件,你值得拥有

按钮公共事件

这个......直接复制么...没找到在哪里付钱

点评

署名 就行 不要钱  发表于 2019-9-13 23:06
回复

使用道具 举报

梦石
0
星屑
2276
在线时间
576 小时
注册时间
2018-9-13
回帖
34
发表于 2019-9-23 14:47:19 | 显示全部楼层
链接:https://pan.baidu.com/s/1GnUtFn270_9C_8crrPXk0g
提取码:jhqu
第四梦境的全键盘插件
回复

使用道具 举报

梦石
0
星屑
253
在线时间
38 小时
注册时间
2019-8-30
回帖
24
发表于 2019-9-27 22:16:40 | 显示全部楼层
这个插件挺好的
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部