static int midooss_init(void *arg) { char *name = "/dev/sequencer"; seq_fd = RPT_SYSCALL(open(name, O_WRONLY)); if (seq_fd == -1) { S_printf("%s: unable to open %s for writing: %s\n", midooss_name, name, strerror(errno)); return 0; } return 1; }
static int midipipe_init(void *arg) { char *name = DOSEMU_MIDI_IN_PATH; pipe_fd = RPT_SYSCALL(open(name, O_RDONLY | O_NONBLOCK)); if (pipe_fd == -1) { S_printf("%s: unable to open %s for reading: %s\n", midipipe_name, name, strerror(errno)); return 0; } add_to_io_select(pipe_fd, midipipe_io, NULL); return 1; }
static void midopipe_write(unsigned char val) { /* Try again to open FIFO on each write in case some readers showed up. */ if (pipe_fd == -1) { pipe_fd = RPT_SYSCALL(open(DOSEMU_MIDI_PATH, O_WRONLY | O_CREAT | O_NONBLOCK, 0666)); if (pipe_fd == -1) { return; } } if (write(pipe_fd, &val, 1) == -1) { error("MIDI: Error writing to %s, resetting: %s\n", midopipe_name, strerror(errno)); close(pipe_fd); pipe_fd = -1; } }
static int midopipe_init(void *arg) { char *name = DOSEMU_MIDI_PATH; mkfifo(name, 0666); pipe_fd = RPT_SYSCALL(open(name, O_WRONLY | O_NONBLOCK)); if (pipe_fd == -1) { int err = errno; S_printf("%s: unable to open %s for writing (%s)%s\n", midopipe_name, name, strerror(errno), errno == ENXIO ? ", will continue trying" : ""); if (err == ENXIO) { /* no FIFO readers */ return 1; } else { /* some other problem */ return 0; } } /* open ok */ return 1; }
static void do_raw_getkeys(void) { int i,count; Bit8u buf[KBBUF_SIZE]; count = RPT_SYSCALL(read(kbd_fd, &buf, KBBUF_SIZE - 1)); k_printf("KBD(raw): do_raw_getkeys() found %d characters (Raw)\n", count); if (count == -1) { k_printf("KBD(raw): do_raw_getkeys(): keyboard read failed!\n"); return; } for (i = 0; i < count; i++) { k_printf("KBD(raw): readcode: %02x \n", buf[i]); put_rawkey(buf[i]); #if 0 set_kbd_leds(get_shiftstate()); #endif } }
static void do_raw_getkeys(void *arg) { int i,count; char buf[KBBUF_SIZE]; count = RPT_SYSCALL(read(kbd_fd, buf, KBBUF_SIZE - 1)); k_printf("KBD(raw): do_raw_getkeys() found %d characters (Raw)\n", count); if (count == -1) { k_printf("KBD(raw): do_raw_getkeys(): keyboard read failed!\n"); return; } if (config.console_keyb == KEYB_RAW) { for (i = 0; i < count; i++) { k_printf("KBD(raw): readcode: %02x \n", buf[i]); put_rawkey(buf[i]); } } else { paste_text(buf, count, "utf8"); } }
/* load <msize> bytes of file <name> starting at offset <foffset> * into memory at <mstart> */ int load_file(char *name, int foffset, unsigned char *mstart, int msize) { int fd; if (strcmp(name, "/dev/mem") == 0) { v_printf("kmem used for loadfile\n"); open_kmem(); fd = mem_fd; } else fd = open(name, O_RDONLY); (void)DOS_SYSCALL(lseek(fd, foffset, SEEK_SET)); (void)RPT_SYSCALL(read(fd, mstart, msize)); if (strcmp(name, "/dev/mem") == 0) close_kmem(); else close(fd); return 0; }
static void midipipe_io(void *arg) { unsigned char buf[1024]; int n, selret; fd_set rfds; struct timeval tv; FD_ZERO(&rfds); FD_SET(pipe_fd, &rfds); tv.tv_sec = 0; tv.tv_usec = 0; while ((selret = select(pipe_fd + 1, &rfds, NULL, NULL, &tv)) > 0) { n = RPT_SYSCALL(read(pipe_fd, buf, sizeof(buf))); if (n > 0) { midi_put_data(buf, n); } else { break; } FD_ZERO(&rfds); FD_SET(pipe_fd, &rfds); tv.tv_sec = 0; tv.tv_usec = 0; } }
static void midotmdty_io(void) { char buf[16384]; int n, selret; fd_set rfds; struct timeval tv; FD_ZERO(&rfds); FD_SET(data_sock, &rfds); tv.tv_sec = 0; tv.tv_usec = 0; while ((selret = select(data_sock + 1, &rfds, NULL, NULL, &tv)) > 0) { n = RPT_SYSCALL(read(data_sock, buf, sizeof(buf))); if (n > 0) { pcm_write_samples(buf, n, 44100, PCM_FORMAT_S16_LE, pcm_stream); } else { break; } FD_ZERO(&rfds); FD_SET(data_sock, &rfds); tv.tv_sec = 0; tv.tv_usec = 0; } }