From 335992a338c2a11a0c3562dc4f7ac3caa126d3ca Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Sat, 5 Mar 2022 03:06:41 +0100 Subject: [PATCH] improved disk --- src/kernel/peripherals/Drive.hx | 23 +++++++++++++++++++++++ src/kernel/peripherals/Peripherals.hx | 1 + 2 files changed, 24 insertions(+) diff --git a/src/kernel/peripherals/Drive.hx b/src/kernel/peripherals/Drive.hx index 79cc7b9..c8c13b9 100644 --- a/src/kernel/peripherals/Drive.hx +++ b/src/kernel/peripherals/Drive.hx @@ -1,13 +1,36 @@ package kernel.peripherals; +import kernel.net.Package; +using tink.CoreApi; + class Drive implements IPeripheral { + public final onDiskInsert:Signal; + public final onDiskEject:Signal; + private final addr:String; private final native:cc.periphs.Disk; + private final onDiskInsertTrigger:SignalTrigger = Signal.trigger(); + private final onDiskEjectTrigger:SignalTrigger = Signal.trigger(); @:allow(kernel.peripherals) private function new(native: cc.periphs.Disk,addr: String) { this.addr = addr; this.native = native; + + this.onDiskInsert = this.onDiskInsertTrigger.asSignal(); + this.onDiskEject = this.onDiskEjectTrigger.asSignal(); + + KernelEvents.instance.onDisk.handle((addr) ->{ + if (addr == this.addr){ + this.onDiskInsertTrigger.trigger(null); + } + }); + + KernelEvents.instance.onDiskEject.handle((addr)->{ + if (addr == this.addr){ + this.onDiskEjectTrigger.trigger(null); + } + }); } public function getAddr():String { diff --git a/src/kernel/peripherals/Peripherals.hx b/src/kernel/peripherals/Peripherals.hx index 7289e35..885dfc2 100644 --- a/src/kernel/peripherals/Peripherals.hx +++ b/src/kernel/peripherals/Peripherals.hx @@ -30,6 +30,7 @@ class Peripheral { private function updatePeripherals() { findScreens(); findModems(); + findDrives(); } /**