rpcsx/rpcsx-os/iodev/stdin.cpp

29 lines
856 B
C++
Raw Normal View History

2023-06-23 02:28:14 +02:00
#include "io-device.hpp"
2023-07-04 18:19:17 +02:00
#include "orbis/KernelAllocator.hpp"
2023-06-23 02:28:14 +02:00
2023-07-06 18:16:25 +02:00
struct StdinDevice : public IoDevice {};
2023-06-23 02:28:14 +02:00
2023-07-06 18:16:25 +02:00
struct StdinInstance : public IoDeviceInstance {};
2023-06-23 02:28:14 +02:00
static std::int64_t stdin_instance_read(IoDeviceInstance *instance, void *data,
2023-07-06 18:16:25 +02:00
std::uint64_t size) {
2023-06-23 02:28:14 +02:00
return -1;
}
2023-07-06 18:16:25 +02:00
static std::int32_t open(IoDevice *device,
orbis::Ref<IoDeviceInstance> *instance,
2023-06-23 02:28:14 +02:00
const char *path, std::uint32_t flags,
std::uint32_t mode) {
2023-07-04 18:19:17 +02:00
auto *newInstance = orbis::knew<StdinInstance>();
2023-06-23 02:28:14 +02:00
newInstance->read = stdin_instance_read;
io_device_instance_init(device, newInstance);
*instance = newInstance;
return 0;
}
IoDevice *createStdinCharacterDevice() {
2023-07-04 18:19:17 +02:00
auto *newDevice = orbis::knew<StdinDevice>();
2023-06-23 02:28:14 +02:00
newDevice->open = open;
return newDevice;
}