-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce HID, add documentation, clean chuck code
- Loading branch information
1 parent
82cbb45
commit be90a1c
Showing
13 changed files
with
306 additions
and
561 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
declare const HidMsg_ck = "\nglobal Event _msg;\n \nglobal Event _hid;\nglobal int _hidMultiple;\n0 => global int _cursorX;\n0 => global int _cursorY;\n\n0 => global float _deltaX;\n0 => global float _deltaY;\n\nglobal string _key;\nglobal int _isDown;\nglobal int _isUp;\nglobal int _isMouseDown;\nglobal int _isMouseUp;\nglobal int _isScroll;\nglobal int _ascii;\nglobal int _which;\nglobal int _mouseActive;\nglobal int _kbdActive;\nglobal int _mouseMotion;\nglobal float _scaledCursorX;\nglobal float _scaledCursorY;\n\npublic class HidMsg {\n int type;\n int deviceType;\n int cursorX;\n int cursorY;\n float deltaX;\n float deltaY;\n float scaledCursorX;\n float scaledCursorY;\n int which;\n int ascii;\n string key;\n\n // type 1 message\n function int isButtonDown() {\n if (type == 1) { return 1; }\n return 0;\n }\n\n // type 2 message\n function int isButtonUp() {\n if (type == 2) { return 1; }\n return 0;\n }\n\n // type 5 message\n function int isMouseMotion(){\n if (type == 5) { return 1; }\n return 0;\n }\n\n // type 6 message\n function int isWheelMotion(){\n if (type == 6) { return 1; }\n return 0;\n }\n\n function void _copy(HidMsg localMsg) {\n localMsg.type => type;\n localMsg.deviceType => deviceType;\n localMsg.cursorX => cursorX;\n localMsg.cursorY => cursorY;\n localMsg.deltaX => deltaX;\n localMsg.deltaY => deltaY;\n localMsg.scaledCursorX => scaledCursorX;\n localMsg.scaledCursorY => scaledCursorY;\n localMsg.which => which;\n localMsg.ascii => ascii;\n localMsg.key => key;\n }\n}\n"; | ||
declare const Hid_ck = "\nglobal Event _msg;\n\nglobal Event _hid;\nglobal int _cursorX;\nglobal int _cursorY;\n\nglobal float _deltaX;\nglobal float _deltaY;\n\nglobal int _type;\nglobal string _key;\nglobal int _isDown;\nglobal int _isUp;\nglobal int _isMouseDown;\nglobal int _isMouseUp;\nglobal int _isScroll;\nglobal int _ascii;\nglobal int _which;\nglobal int _mouseActive;\nglobal int _kbdActive;\nglobal int _mouseMotion;\nglobal float _scaledCursorX;\nglobal float _scaledCursorY;\n\npublic class Hid extends Event {\n\n 0 => int isMouseOpen;\n 0 => int isKBDOpen;\n 0 => int active;\n\n string deviceName; \n int deviceType; // mouse = 2, keyboard = 3\n\n // HidMsg Queue\n HidMsg _hidMsgQueue[0];\n\n function string name() {\n return deviceName;\n }\n\n function int openMouse(int num) {\n if (num < 0) {\n false => active;\n } else {\n \"virtualJS mouse/trackpad\" => deviceName;\n 2 => deviceType;\n true => active;\n }\n active => isMouseOpen => _mouseActive;\n return active;\n }\n\n function int openKeyboard(int num) {\n if (num < 0) {\n false => active;\n } else {\n \"virtualJS keyboard\" => deviceName;\n 3 => deviceType;\n true => active;\n }\n active => isKBDOpen => _kbdActive;\n return active;\n }\n\n // Pop the first HidMsg from the queue\n // Write it to msg and return 1\n function int recv(HidMsg msg) {\n // is empty\n if (_hidMsgQueue.size() <= 0) {\n return 0;\n }\n\n // pop the first HidMsg to msg, return true\n _hidMsgQueue[0] @=> HidMsg localMsg;\n msg._copy(localMsg); \n _hidMsgQueue.popFront();\n return 1;\n }\n\n // Hid Listener\n // Get variables from JS and write to the HidMsg \n function void _HidListener() {\n HidMsg @ msg;\n while(true){\n new HidMsg @=> msg;\n deviceType => msg.deviceType;\n _hid => now;\n\n _type => msg.type;\n _cursorX => msg.cursorX;\n _cursorY => msg.cursorY;\n _deltaX => msg.deltaX;\n _deltaY => msg.deltaY;\n _scaledCursorX => msg.scaledCursorX;\n _scaledCursorY => msg.scaledCursorY;\n _which => msg.which;\n _ascii => msg.ascii;\n _key => msg.key;\n\n _hidMsgQueue << msg;\n this.broadcast();\n }\n }\n spork ~ _HidListener();\n}\n"; | ||
declare const HidMsg_ck = "\npublic class HidMsg {\n int type;\n int deviceType;\n int cursorX;\n int cursorY;\n float deltaX;\n float deltaY;\n float scaledCursorX;\n float scaledCursorY;\n int which;\n int ascii;\n string key;\n\n // type 1 message\n function int isButtonDown() {\n return type == 1;\n }\n\n // type 2 message\n function int isButtonUp() {\n return type == 2;\n }\n\n // type 5 message\n function int isMouseMotion(){\n return type == 5;\n }\n\n // type 6 message\n function int isWheelMotion(){\n return type == 6;\n }\n\n function void _copy(HidMsg localMsg) {\n localMsg.type => type;\n localMsg.deviceType => deviceType;\n localMsg.cursorX => cursorX;\n localMsg.cursorY => cursorY;\n localMsg.deltaX => deltaX;\n localMsg.deltaY => deltaY;\n localMsg.scaledCursorX => scaledCursorX;\n localMsg.scaledCursorY => scaledCursorY;\n localMsg.which => which;\n localMsg.ascii => ascii;\n localMsg.key => key;\n }\n}\n"; | ||
declare const Hid_ck = "\nglobal Event _hid;\nglobal int _type;\nglobal int _mouseActive;\nglobal int _kbdActive;\n\nglobal int _cursorX;\nglobal int _cursorY;\nglobal float _deltaX;\nglobal float _deltaY;\nglobal float _scaledCursorX;\nglobal float _scaledCursorY;\n\nglobal int _ascii;\nglobal int _which;\nglobal string _key;\n\npublic class Hid extends Event {\n\n 0 => int isMouseOpen;\n 0 => int isKBDOpen;\n 0 => int active;\n\n string deviceName; \n int deviceType; // mouse = 2, keyboard = 3\n\n // HidMsg Queue\n HidMsg _hidMsgQueue[0];\n\n function string name() {\n return deviceName;\n }\n\n function int openMouse(int num) {\n if (num < 0) {\n false => active;\n } else {\n \"virtualJS mouse/trackpad\" => deviceName;\n 2 => deviceType;\n true => active;\n }\n active => isMouseOpen => _mouseActive;\n return active;\n }\n\n function int openKeyboard(int num) {\n if (num < 0) {\n false => active;\n } else {\n \"virtualJS keyboard\" => deviceName;\n 3 => deviceType;\n true => active;\n }\n active => isKBDOpen => _kbdActive;\n return active;\n }\n\n // Pop the first HidMsg from the queue\n // Write it to msg and return 1\n function int recv(HidMsg msg) {\n // is empty\n if (_hidMsgQueue.size() <= 0) {\n return 0;\n }\n\n // pop the first HidMsg to msg, return true\n _hidMsgQueue[0] @=> HidMsg localMsg;\n msg._copy(localMsg); \n _hidMsgQueue.popFront();\n return 1;\n }\n\n // Hid Listener\n // Get variables from JS and write to the HidMsg \n function void _HidListener() {\n HidMsg @ msg;\n while(true){\n new HidMsg @=> msg;\n deviceType => msg.deviceType;\n _hid => now;\n\n _type => msg.type;\n _cursorX => msg.cursorX;\n _cursorY => msg.cursorY;\n _deltaX => msg.deltaX;\n _deltaY => msg.deltaY;\n _scaledCursorX => msg.scaledCursorX;\n _scaledCursorY => msg.scaledCursorY;\n _which => msg.which;\n _ascii => msg.ascii;\n _key => msg.key;\n\n _hidMsgQueue << msg;\n this.broadcast();\n\n // Clear message type\n 0 => _type;\n }\n }\n spork ~ _HidListener();\n}\n"; | ||
export { HidMsg_ck, Hid_ck }; |
Oops, something went wrong.