|
|
|
@ -18,124 +18,122 @@ class KernelEvents {
|
|
|
|
|
/**
|
|
|
|
|
Depends on: (Nothing)
|
|
|
|
|
**/
|
|
|
|
|
public static var instance:KernelEvents;
|
|
|
|
|
|
|
|
|
|
public final onAlarm:Signal<Int>;
|
|
|
|
|
public final onChar:Signal<String>;
|
|
|
|
|
public final onDisk:Signal<String>;
|
|
|
|
|
public final onDiskEject:Signal<String>;
|
|
|
|
|
public final onHttpCheck:Signal<{url:String, success:Bool, failReason:Any}>;
|
|
|
|
|
public final onHttpFailure:Signal<{url:String, failReason:String, handle:HTTPResponse}>;
|
|
|
|
|
public final onHttpSuccess:Signal<{url:String, handle:HTTPResponse}>;
|
|
|
|
|
public final onKey:Signal<{keyCode:Int, isHeld:Bool}>;
|
|
|
|
|
public final onKeyUp:Signal<Int>;
|
|
|
|
|
public final onModemMessage:Signal<{
|
|
|
|
|
public static var onAlarm(default, null):Signal<Int>;
|
|
|
|
|
public static var onChar(default, null):Signal<String>;
|
|
|
|
|
public static var onDisk(default, null):Signal<String>;
|
|
|
|
|
public static var onDiskEject(default, null):Signal<String>;
|
|
|
|
|
public static var onHttpCheck(default, null):Signal<{url:String, success:Bool, failReason:Any}>;
|
|
|
|
|
public static var onHttpFailure(default, null):Signal<{url:String, failReason:String, handle:HTTPResponse}>;
|
|
|
|
|
public static var onHttpSuccess(default, null):Signal<{url:String, handle:HTTPResponse}>;
|
|
|
|
|
public static var onKey(default, null):Signal<{keyCode:Int, isHeld:Bool}>;
|
|
|
|
|
public static var onKeyUp(default, null):Signal<Int>;
|
|
|
|
|
public static var onModemMessage(default, null):Signal<{
|
|
|
|
|
addr:String,
|
|
|
|
|
channel:Int,
|
|
|
|
|
replyChannel:Int,
|
|
|
|
|
message:Dynamic,
|
|
|
|
|
distance:Null<Float>
|
|
|
|
|
}>;
|
|
|
|
|
public final onMonitorResize:Signal<String>;
|
|
|
|
|
public final onMonitorTouch:Signal<{addr:String, pos:Pos}>;
|
|
|
|
|
public final onMouseClick:Signal<{button:ButtonType, pos:Pos}>;
|
|
|
|
|
public final onMouseDrag:Signal<{button:ButtonType, pos:Pos}>;
|
|
|
|
|
public final onMouseScroll:Signal<{dir:Int, pos:Pos}>;
|
|
|
|
|
public final onMouseUp:Signal<{button:ButtonType, pos:Pos}>;
|
|
|
|
|
public final onPaste:Signal<String>;
|
|
|
|
|
public final onPeripheral:Signal<String>;
|
|
|
|
|
public final onPeripheralDetach:Signal<String>;
|
|
|
|
|
public final onRedstone:Signal<Noise>;
|
|
|
|
|
public final onSpeakerAudioEmpty:Signal<String>;
|
|
|
|
|
public final onTaskComplete:Signal<{id:Int, success:Bool, failedReason:String}>;
|
|
|
|
|
public final onTermResize:Signal<Noise>;
|
|
|
|
|
public final onTerminate:Signal<Noise>;
|
|
|
|
|
public final onTimer:Signal<Int>;
|
|
|
|
|
public final onTurtleInventory:Signal<Noise>;
|
|
|
|
|
public final onWebsocketClose:Signal<String>;
|
|
|
|
|
public final onWebsocketFailure:Signal<{url:String, failReason:String}>;
|
|
|
|
|
public final onWebsocketMessage:Signal<{url:String, message:String, isBinary:Bool}>;
|
|
|
|
|
public final onWebsocketSuccess:Signal<{url:String, handle:Any}>;
|
|
|
|
|
public static var onMonitorResize(default, null):Signal<String>;
|
|
|
|
|
public static var onMonitorTouch(default, null):Signal<{addr:String, pos:Pos}>;
|
|
|
|
|
public static var onMouseClick(default, null):Signal<{button:ButtonType, pos:Pos}>;
|
|
|
|
|
public static var onMouseDrag(default, null):Signal<{button:ButtonType, pos:Pos}>;
|
|
|
|
|
public static var onMouseScroll(default, null):Signal<{dir:Int, pos:Pos}>;
|
|
|
|
|
public static var onMouseUp(default, null):Signal<{button:ButtonType, pos:Pos}>;
|
|
|
|
|
public static var onPaste(default, null):Signal<String>;
|
|
|
|
|
public static var onPeripheral(default, null):Signal<String>;
|
|
|
|
|
public static var onPeripheralDetach(default, null):Signal<String>;
|
|
|
|
|
public static var onRedstone(default, null):Signal<Noise>;
|
|
|
|
|
public static var onSpeakerAudioEmpty(default, null):Signal<String>;
|
|
|
|
|
public static var onTaskComplete(default, null):Signal<{id:Int, success:Bool, failedReason:String}>;
|
|
|
|
|
public static var onTermResize(default, null):Signal<Noise>;
|
|
|
|
|
public static var onTerminate(default, null):Signal<Noise>;
|
|
|
|
|
public static var onTimer(default, null):Signal<Int>;
|
|
|
|
|
public static var onTurtleInventory(default, null):Signal<Noise>;
|
|
|
|
|
public static var onWebsocketClose(default, null):Signal<String>;
|
|
|
|
|
public static var onWebsocketFailure(default, null):Signal<{url:String, failReason:String}>;
|
|
|
|
|
public static var onWebsocketMessage(default, null):Signal<{url:String, message:String, isBinary:Bool}>;
|
|
|
|
|
public static var onWebsocketSuccess(default, null):Signal<{url:String, handle:Any}>;
|
|
|
|
|
|
|
|
|
|
private final onAlarmTrigger:SignalTrigger<Int> = Signal.trigger();
|
|
|
|
|
private final onCharTrigger:SignalTrigger<String> = Signal.trigger();
|
|
|
|
|
private final onDiskTrigger:SignalTrigger<String> = Signal.trigger();
|
|
|
|
|
private final onDiskEjectTrigger:SignalTrigger<String> = Signal.trigger();
|
|
|
|
|
private final onHttpCheckTrigger:SignalTrigger<{url:String, success:Bool, failReason:Any}> = Signal.trigger();
|
|
|
|
|
private final onHttpFailureTrigger:SignalTrigger<{url:String, failReason:String, handle:HTTPResponse}> = Signal.trigger();
|
|
|
|
|
private final onHttpSuccessTrigger:SignalTrigger<{url:String, handle:HTTPResponse}> = Signal.trigger();
|
|
|
|
|
private final onKeyTrigger:SignalTrigger<{keyCode:Int, isHeld:Bool}> = Signal.trigger();
|
|
|
|
|
private final onKeyUpTrigger:SignalTrigger<Int> = Signal.trigger();
|
|
|
|
|
private final onModemMessageTrigger:SignalTrigger<{
|
|
|
|
|
private static final onAlarmTrigger:SignalTrigger<Int> = Signal.trigger();
|
|
|
|
|
private static final onCharTrigger:SignalTrigger<String> = Signal.trigger();
|
|
|
|
|
private static final onDiskTrigger:SignalTrigger<String> = Signal.trigger();
|
|
|
|
|
private static final onDiskEjectTrigger:SignalTrigger<String> = Signal.trigger();
|
|
|
|
|
private static final onHttpCheckTrigger:SignalTrigger<{url:String, success:Bool, failReason:Any}> = Signal.trigger();
|
|
|
|
|
private static final onHttpFailureTrigger:SignalTrigger<{url:String, failReason:String, handle:HTTPResponse}> = Signal.trigger();
|
|
|
|
|
private static final onHttpSuccessTrigger:SignalTrigger<{url:String, handle:HTTPResponse}> = Signal.trigger();
|
|
|
|
|
private static final onKeyTrigger:SignalTrigger<{keyCode:Int, isHeld:Bool}> = Signal.trigger();
|
|
|
|
|
private static final onKeyUpTrigger:SignalTrigger<Int> = Signal.trigger();
|
|
|
|
|
private static final onModemMessageTrigger:SignalTrigger<{
|
|
|
|
|
addr:String,
|
|
|
|
|
channel:Int,
|
|
|
|
|
replyChannel:Int,
|
|
|
|
|
message:Dynamic,
|
|
|
|
|
distance:Null<Float>
|
|
|
|
|
}> = Signal.trigger();
|
|
|
|
|
private final onMonitorResizeTrigger:SignalTrigger<String> = Signal.trigger();
|
|
|
|
|
private final onMonitorTouchTrigger:SignalTrigger<{addr:String, pos:Pos}> = Signal.trigger();
|
|
|
|
|
private final onMouseClickTrigger:SignalTrigger<{button:ButtonType, pos:Pos}> = Signal.trigger();
|
|
|
|
|
private final onMouseDragTrigger:SignalTrigger<{button:ButtonType, pos:Pos}> = Signal.trigger();
|
|
|
|
|
private final onMouseScrollTrigger:SignalTrigger<{dir:Int, pos:Pos}> = Signal.trigger();
|
|
|
|
|
private final onMouseUpTrigger:SignalTrigger<{button:ButtonType, pos:Pos}> = Signal.trigger();
|
|
|
|
|
private final onPasteTrigger:SignalTrigger<String> = Signal.trigger();
|
|
|
|
|
private final onPeripheralTrigger:SignalTrigger<String> = Signal.trigger();
|
|
|
|
|
private final onPeripheralDetachTrigger:SignalTrigger<String> = Signal.trigger();
|
|
|
|
|
private final onRednetMessageTrigger:SignalTrigger<{sender:Int, message:Any, protocol:Any}> = Signal.trigger();
|
|
|
|
|
private final onRedstoneTrigger:SignalTrigger<Noise> = Signal.trigger();
|
|
|
|
|
private final onSpeakerAudioEmptyTrigger:SignalTrigger<String> = Signal.trigger();
|
|
|
|
|
private final onTaskCompleteTrigger:SignalTrigger<{id:Int, success:Bool, failedReason:String}> = Signal.trigger();
|
|
|
|
|
private final onTermResizeTrigger:SignalTrigger<Noise> = Signal.trigger();
|
|
|
|
|
private final onTerminateTrigger:SignalTrigger<Noise> = Signal.trigger();
|
|
|
|
|
private final onTimerTrigger:SignalTrigger<Int> = Signal.trigger();
|
|
|
|
|
private final onTurtleInventoryTrigger:SignalTrigger<Noise> = Signal.trigger();
|
|
|
|
|
private final onWebsocketCloseTrigger:SignalTrigger<String> = Signal.trigger();
|
|
|
|
|
private final onWebsocketFailureTrigger:SignalTrigger<{url:String, failReason:String}> = Signal.trigger();
|
|
|
|
|
private final onWebsocketMessageTrigger:SignalTrigger<{url:String, message:String, isBinary:Bool}> = Signal.trigger();
|
|
|
|
|
private final onWebsocketSuccessTrigger:SignalTrigger<{url:String, handle:Any}> = Signal.trigger();
|
|
|
|
|
private static final onMonitorResizeTrigger:SignalTrigger<String> = Signal.trigger();
|
|
|
|
|
private static final onMonitorTouchTrigger:SignalTrigger<{addr:String, pos:Pos}> = Signal.trigger();
|
|
|
|
|
private static final onMouseClickTrigger:SignalTrigger<{button:ButtonType, pos:Pos}> = Signal.trigger();
|
|
|
|
|
private static final onMouseDragTrigger:SignalTrigger<{button:ButtonType, pos:Pos}> = Signal.trigger();
|
|
|
|
|
private static final onMouseScrollTrigger:SignalTrigger<{dir:Int, pos:Pos}> = Signal.trigger();
|
|
|
|
|
private static final onMouseUpTrigger:SignalTrigger<{button:ButtonType, pos:Pos}> = Signal.trigger();
|
|
|
|
|
private static final onPasteTrigger:SignalTrigger<String> = Signal.trigger();
|
|
|
|
|
private static final onPeripheralTrigger:SignalTrigger<String> = Signal.trigger();
|
|
|
|
|
private static final onPeripheralDetachTrigger:SignalTrigger<String> = Signal.trigger();
|
|
|
|
|
private static final onRednetMessageTrigger:SignalTrigger<{sender:Int, message:Any, protocol:Any}> = Signal.trigger();
|
|
|
|
|
private static final onRedstoneTrigger:SignalTrigger<Noise> = Signal.trigger();
|
|
|
|
|
private static final onSpeakerAudioEmptyTrigger:SignalTrigger<String> = Signal.trigger();
|
|
|
|
|
private static final onTaskCompleteTrigger:SignalTrigger<{id:Int, success:Bool, failedReason:String}> = Signal.trigger();
|
|
|
|
|
private static final onTermResizeTrigger:SignalTrigger<Noise> = Signal.trigger();
|
|
|
|
|
private static final onTerminateTrigger:SignalTrigger<Noise> = Signal.trigger();
|
|
|
|
|
private static final onTimerTrigger:SignalTrigger<Int> = Signal.trigger();
|
|
|
|
|
private static final onTurtleInventoryTrigger:SignalTrigger<Noise> = Signal.trigger();
|
|
|
|
|
private static final onWebsocketCloseTrigger:SignalTrigger<String> = Signal.trigger();
|
|
|
|
|
private static final onWebsocketFailureTrigger:SignalTrigger<{url:String, failReason:String}> = Signal.trigger();
|
|
|
|
|
private static final onWebsocketMessageTrigger:SignalTrigger<{url:String, message:String, isBinary:Bool}> = Signal.trigger();
|
|
|
|
|
private static final onWebsocketSuccessTrigger:SignalTrigger<{url:String, handle:Any}> = Signal.trigger();
|
|
|
|
|
|
|
|
|
|
private var stopLoop:Bool = false;
|
|
|
|
|
private static var stopLoop:Bool = false;
|
|
|
|
|
|
|
|
|
|
@:allow(kernel.Init)
|
|
|
|
|
private function new() {
|
|
|
|
|
this.onAlarm = onAlarmTrigger.asSignal();
|
|
|
|
|
this.onChar = onCharTrigger.asSignal();
|
|
|
|
|
this.onDisk = onDiskTrigger.asSignal();
|
|
|
|
|
this.onDiskEject = onDiskEjectTrigger.asSignal();
|
|
|
|
|
this.onHttpCheck = onHttpCheckTrigger.asSignal();
|
|
|
|
|
this.onHttpFailure = onHttpFailureTrigger.asSignal();
|
|
|
|
|
this.onHttpSuccess = onHttpSuccessTrigger.asSignal();
|
|
|
|
|
this.onKey = onKeyTrigger.asSignal();
|
|
|
|
|
this.onKeyUp = onKeyUpTrigger.asSignal();
|
|
|
|
|
this.onModemMessage = onModemMessageTrigger.asSignal();
|
|
|
|
|
this.onMonitorResize = onMonitorResizeTrigger.asSignal();
|
|
|
|
|
this.onMonitorTouch = onMonitorTouchTrigger.asSignal();
|
|
|
|
|
this.onMouseClick = onMouseClickTrigger.asSignal();
|
|
|
|
|
this.onMouseDrag = onMouseDragTrigger.asSignal();
|
|
|
|
|
this.onMouseScroll = onMouseScrollTrigger.asSignal();
|
|
|
|
|
this.onMouseUp = onMouseUpTrigger.asSignal();
|
|
|
|
|
this.onPaste = onPasteTrigger.asSignal();
|
|
|
|
|
this.onPeripheral = onPeripheralTrigger.asSignal();
|
|
|
|
|
this.onPeripheralDetach = onPeripheralDetachTrigger.asSignal();
|
|
|
|
|
this.onRedstone = onRedstoneTrigger.asSignal();
|
|
|
|
|
this.onSpeakerAudioEmpty = onSpeakerAudioEmptyTrigger.asSignal();
|
|
|
|
|
this.onTaskComplete = onTaskCompleteTrigger.asSignal();
|
|
|
|
|
this.onTermResize = onTermResizeTrigger.asSignal();
|
|
|
|
|
this.onTerminate = onTerminateTrigger.asSignal();
|
|
|
|
|
this.onTimer = onTimerTrigger.asSignal();
|
|
|
|
|
this.onTurtleInventory = onTurtleInventoryTrigger.asSignal();
|
|
|
|
|
this.onWebsocketClose = onWebsocketCloseTrigger.asSignal();
|
|
|
|
|
this.onWebsocketFailure = onWebsocketFailureTrigger.asSignal();
|
|
|
|
|
this.onWebsocketMessage = onWebsocketMessageTrigger.asSignal();
|
|
|
|
|
this.onWebsocketSuccess = onWebsocketSuccessTrigger.asSignal();
|
|
|
|
|
private static function init() {
|
|
|
|
|
onAlarm = onAlarmTrigger.asSignal();
|
|
|
|
|
onChar = onCharTrigger.asSignal();
|
|
|
|
|
onDisk = onDiskTrigger.asSignal();
|
|
|
|
|
onDiskEject = onDiskEjectTrigger.asSignal();
|
|
|
|
|
onHttpCheck = onHttpCheckTrigger.asSignal();
|
|
|
|
|
onHttpFailure = onHttpFailureTrigger.asSignal();
|
|
|
|
|
onHttpSuccess = onHttpSuccessTrigger.asSignal();
|
|
|
|
|
onKey = onKeyTrigger.asSignal();
|
|
|
|
|
onKeyUp = onKeyUpTrigger.asSignal();
|
|
|
|
|
onModemMessage = onModemMessageTrigger.asSignal();
|
|
|
|
|
onMonitorResize = onMonitorResizeTrigger.asSignal();
|
|
|
|
|
onMonitorTouch = onMonitorTouchTrigger.asSignal();
|
|
|
|
|
onMouseClick = onMouseClickTrigger.asSignal();
|
|
|
|
|
onMouseDrag = onMouseDragTrigger.asSignal();
|
|
|
|
|
onMouseScroll = onMouseScrollTrigger.asSignal();
|
|
|
|
|
onMouseUp = onMouseUpTrigger.asSignal();
|
|
|
|
|
onPaste = onPasteTrigger.asSignal();
|
|
|
|
|
onPeripheral = onPeripheralTrigger.asSignal();
|
|
|
|
|
onPeripheralDetach = onPeripheralDetachTrigger.asSignal();
|
|
|
|
|
onRedstone = onRedstoneTrigger.asSignal();
|
|
|
|
|
onSpeakerAudioEmpty = onSpeakerAudioEmptyTrigger.asSignal();
|
|
|
|
|
onTaskComplete = onTaskCompleteTrigger.asSignal();
|
|
|
|
|
onTermResize = onTermResizeTrigger.asSignal();
|
|
|
|
|
onTerminate = onTerminateTrigger.asSignal();
|
|
|
|
|
onTimer = onTimerTrigger.asSignal();
|
|
|
|
|
onTurtleInventory = onTurtleInventoryTrigger.asSignal();
|
|
|
|
|
onWebsocketClose = onWebsocketCloseTrigger.asSignal();
|
|
|
|
|
onWebsocketFailure = onWebsocketFailureTrigger.asSignal();
|
|
|
|
|
onWebsocketMessage = onWebsocketMessageTrigger.asSignal();
|
|
|
|
|
onWebsocketSuccess = onWebsocketSuccessTrigger.asSignal();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Start pulling events. Blocking.
|
|
|
|
|
**/
|
|
|
|
|
@:allow(kernel.Init)
|
|
|
|
|
private function startEventLoop() {
|
|
|
|
|
private static function startEventLoop() {
|
|
|
|
|
while (!stopLoop) {
|
|
|
|
|
var event:Table<Int, Dynamic> = pullEvents();
|
|
|
|
|
|
|
|
|
@ -148,7 +146,7 @@ class KernelEvents {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function shutdown() {
|
|
|
|
|
public static function shutdown() {
|
|
|
|
|
|
|
|
|
|
// clearing screens
|
|
|
|
|
for (screen in Peripheral.instance.getAllScreens()) {
|
|
|
|
@ -156,37 +154,37 @@ class KernelEvents {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Log.info('Shutting down event loop');
|
|
|
|
|
this.stopLoop = true;
|
|
|
|
|
stopLoop = true;
|
|
|
|
|
MainTerm.instance.reset();
|
|
|
|
|
Init.mainEvent.stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function pullEvents():Table<Int, Dynamic> {
|
|
|
|
|
private static function pullEvents():Table<Int, Dynamic> {
|
|
|
|
|
return cast TableTools.pack(Coroutine.yield(null));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function fireSignal(eventName: String,event:Table<Int, Dynamic> ) {
|
|
|
|
|
private static function fireSignal(eventName: String,event:Table<Int, Dynamic> ) {
|
|
|
|
|
switch eventName {
|
|
|
|
|
case "alarm":
|
|
|
|
|
this.onAlarmTrigger.trigger(event[2]);
|
|
|
|
|
onAlarmTrigger.trigger(event[2]);
|
|
|
|
|
case "char":
|
|
|
|
|
this.onCharTrigger.trigger(event[2]);
|
|
|
|
|
onCharTrigger.trigger(event[2]);
|
|
|
|
|
case "disk":
|
|
|
|
|
this.onDiskTrigger.trigger(event[2]);
|
|
|
|
|
onDiskTrigger.trigger(event[2]);
|
|
|
|
|
case "disk_eject":
|
|
|
|
|
this.onDiskEjectTrigger.trigger(event[2]);
|
|
|
|
|
onDiskEjectTrigger.trigger(event[2]);
|
|
|
|
|
case "http_check":
|
|
|
|
|
this.onHttpCheckTrigger.trigger({url: event[2], success: event[3], failReason: event[4]});
|
|
|
|
|
onHttpCheckTrigger.trigger({url: event[2], success: event[3], failReason: event[4]});
|
|
|
|
|
case "http_failure":
|
|
|
|
|
this.onHttpFailureTrigger.trigger({url: event[2], failReason: event[3], handle: event[4]});
|
|
|
|
|
onHttpFailureTrigger.trigger({url: event[2], failReason: event[3], handle: event[4]});
|
|
|
|
|
case "http_success":
|
|
|
|
|
this.onHttpSuccessTrigger.trigger({url: event[2], handle: event[3]});
|
|
|
|
|
onHttpSuccessTrigger.trigger({url: event[2], handle: event[3]});
|
|
|
|
|
case "key":
|
|
|
|
|
this.onKeyTrigger.trigger({keyCode: event[2], isHeld: event[3]});
|
|
|
|
|
onKeyTrigger.trigger({keyCode: event[2], isHeld: event[3]});
|
|
|
|
|
case "key_up":
|
|
|
|
|
this.onKeyUpTrigger.trigger(event[2]);
|
|
|
|
|
onKeyUpTrigger.trigger(event[2]);
|
|
|
|
|
case "modem_message":
|
|
|
|
|
this.onModemMessageTrigger.trigger({
|
|
|
|
|
onModemMessageTrigger.trigger({
|
|
|
|
|
addr: event[2],
|
|
|
|
|
channel: event[3],
|
|
|
|
|
replyChannel: event[4],
|
|
|
|
@ -194,45 +192,45 @@ class KernelEvents {
|
|
|
|
|
distance: event[6]
|
|
|
|
|
});
|
|
|
|
|
case "monitor_resize":
|
|
|
|
|
this.onMonitorResizeTrigger.trigger(event[2]);
|
|
|
|
|
onMonitorResizeTrigger.trigger(event[2]);
|
|
|
|
|
case "monitor_touch":
|
|
|
|
|
this.onMonitorTouchTrigger.trigger({addr: event[2], pos: {x: (event[3] : Int) - 1, y: (event[4] : Int) - 1}});
|
|
|
|
|
onMonitorTouchTrigger.trigger({addr: event[2], pos: {x: (event[3] : Int) - 1, y: (event[4] : Int) - 1}});
|
|
|
|
|
case "mouse_click":
|
|
|
|
|
this.onMouseClickTrigger.trigger({button: ccButtonToEnum(event[2]), pos: {x: (event[3] : Int) - 1, y: (event[4] : Int) - 1}});
|
|
|
|
|
onMouseClickTrigger.trigger({button: ccButtonToEnum(event[2]), pos: {x: (event[3] : Int) - 1, y: (event[4] : Int) - 1}});
|
|
|
|
|
case "mouse_drag":
|
|
|
|
|
this.onMouseDragTrigger.trigger({button: ccButtonToEnum(event[2]), pos: {x: (event[3] : Int) - 1, y: (event[4] : Int) - 1}});
|
|
|
|
|
onMouseDragTrigger.trigger({button: ccButtonToEnum(event[2]), pos: {x: (event[3] : Int) - 1, y: (event[4] : Int) - 1}});
|
|
|
|
|
case "mouse_scroll":
|
|
|
|
|
this.onMouseScrollTrigger.trigger({dir: event[2], pos: {x: (event[3] : Int) - 1, y: (event[4] : Int) - 1}});
|
|
|
|
|
onMouseScrollTrigger.trigger({dir: event[2], pos: {x: (event[3] : Int) - 1, y: (event[4] : Int) - 1}});
|
|
|
|
|
case "mouse_up":
|
|
|
|
|
this.onMouseUpTrigger.trigger({button: ccButtonToEnum(event[2]), pos: {x: (event[3] : Int) - 1, y: (event[4] : Int) - 1}});
|
|
|
|
|
onMouseUpTrigger.trigger({button: ccButtonToEnum(event[2]), pos: {x: (event[3] : Int) - 1, y: (event[4] : Int) - 1}});
|
|
|
|
|
case "paste":
|
|
|
|
|
this.onPasteTrigger.trigger(event[2]);
|
|
|
|
|
onPasteTrigger.trigger(event[2]);
|
|
|
|
|
case "peripheral":
|
|
|
|
|
this.onPeripheralTrigger.trigger(event[2]);
|
|
|
|
|
onPeripheralTrigger.trigger(event[2]);
|
|
|
|
|
case "peripheral_detach":
|
|
|
|
|
this.onPeripheralDetachTrigger.trigger(event[2]);
|
|
|
|
|
onPeripheralDetachTrigger.trigger(event[2]);
|
|
|
|
|
case "redstone":
|
|
|
|
|
this.onRedstoneTrigger.trigger(null);
|
|
|
|
|
onRedstoneTrigger.trigger(null);
|
|
|
|
|
case "speaker_audio_empty":
|
|
|
|
|
this.onSpeakerAudioEmptyTrigger.trigger(event[2]);
|
|
|
|
|
onSpeakerAudioEmptyTrigger.trigger(event[2]);
|
|
|
|
|
case "task_complete":
|
|
|
|
|
this.onTaskCompleteTrigger.trigger({id: event[2], success: event[3], failedReason: event[4]});
|
|
|
|
|
onTaskCompleteTrigger.trigger({id: event[2], success: event[3], failedReason: event[4]});
|
|
|
|
|
case "term_resize":
|
|
|
|
|
this.onTermResizeTrigger.trigger(null);
|
|
|
|
|
onTermResizeTrigger.trigger(null);
|
|
|
|
|
case "terminate":
|
|
|
|
|
this.onTerminateTrigger.trigger(null);
|
|
|
|
|
onTerminateTrigger.trigger(null);
|
|
|
|
|
case "timer":
|
|
|
|
|
this.onTimerTrigger.trigger(event[2]);
|
|
|
|
|
onTimerTrigger.trigger(event[2]);
|
|
|
|
|
case "turtle_inventory":
|
|
|
|
|
this.onTurtleInventoryTrigger.trigger(null);
|
|
|
|
|
onTurtleInventoryTrigger.trigger(null);
|
|
|
|
|
case "websocket_closed":
|
|
|
|
|
this.onWebsocketCloseTrigger.trigger(event[2]);
|
|
|
|
|
onWebsocketCloseTrigger.trigger(event[2]);
|
|
|
|
|
case "websocket_failure":
|
|
|
|
|
this.onWebsocketFailureTrigger.trigger({url: event[2], failReason: event[3]});
|
|
|
|
|
onWebsocketFailureTrigger.trigger({url: event[2], failReason: event[3]});
|
|
|
|
|
case "websocket_message":
|
|
|
|
|
this.onWebsocketMessageTrigger.trigger({url: event[2], message: event[3], isBinary: event[4]});
|
|
|
|
|
onWebsocketMessageTrigger.trigger({url: event[2], message: event[3], isBinary: event[4]});
|
|
|
|
|
case "websocket_success":
|
|
|
|
|
this.onWebsocketSuccessTrigger.trigger({url: event[2], handle: event[3]});
|
|
|
|
|
onWebsocketSuccessTrigger.trigger({url: event[2], handle: event[3]});
|
|
|
|
|
case "endofloop":
|
|
|
|
|
EndOfLoop.run();
|
|
|
|
|
default:
|
|
|
|
@ -254,7 +252,7 @@ class KernelEvents {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@:allow(lib.Debug)
|
|
|
|
|
private function printListenerCount() {
|
|
|
|
|
private static function printListenerCount() {
|
|
|
|
|
if (onAlarmTrigger.getLength() > 0) Log.debug("onAlarm: " + onAlarmTrigger.getLength());
|
|
|
|
|
if (onCharTrigger.getLength() > 0) Log.debug("onChar: " + onCharTrigger.getLength());
|
|
|
|
|
if (onDiskTrigger.getLength() > 0) Log.debug("onDisk: " + onDiskTrigger.getLength());
|
|
|
|
|