static int brl_readCommand(BrailleDisplay *brl, KeyTableCommandContext context) { vbButtons buttons; BrButtons(&buttons); if (!buttons.keypressed) { return EOF; } else { vbButtons b; do { BrButtons(&b); buttons.bigbuttons |= b.bigbuttons; { const TimeValue duration = { .seconds = 0, .nanoseconds = 1 * NSECS_PER_USEC }; accurateDelay(&duration); } } while (b.keypressed); /* Test which buttons has been pressed */ if (buttons.bigbuttons==KEY_UP) return BRL_CMD_LNUP; else if (buttons.bigbuttons==KEY_LEFT) return BRL_CMD_FWINLT; else if (buttons.bigbuttons==KEY_RIGHT) return BRL_CMD_FWINRT; else if (buttons.bigbuttons==KEY_DOWN) return BRL_CMD_LNDN; else if (buttons.bigbuttons==KEY_ATTRIBUTES) return BRL_CMD_ATTRVIS; else if (buttons.bigbuttons==KEY_CURSOR) return BRL_CMD_CSRVIS; else if (buttons.bigbuttons==KEY_HOME) { /* If a routing key has been pressed, then mark the beginning of a block; go to cursor position otherwise */ return (buttons.routingkey>0) ? BRL_CMD_BLK(CLIP_NEW)+buttons.routingkey-1 : BRL_CMD_HOME; } else if (buttons.bigbuttons==KEY_MENU) { /* If a routing key has been pressed, then mark the end of a block; go to preferences menu otherwise */ return (buttons.routingkey>0) ? BRL_CMD_BLK(COPY_RECT)+buttons.routingkey-1 : BRL_CMD_PREFMENU; } else if (buttons.bigbuttons==(KEY_ATTRIBUTES | KEY_MENU)) return BRL_CMD_PASTE; else if (buttons.bigbuttons==(KEY_CURSOR | KEY_LEFT)) return BRL_CMD_CHRLT; else if (buttons.bigbuttons==(KEY_HOME | KEY_RIGHT)) return BRL_CMD_CHRRT; else if (buttons.bigbuttons==(KEY_UP | KEY_LEFT)) return BRL_CMD_TOP_LEFT; else if (buttons.bigbuttons==(KEY_RIGHT | KEY_DOWN)) return BRL_CMD_BOT_LEFT; else if (buttons.bigbuttons==(KEY_ATTRIBUTES | KEY_DOWN)) return BRL_CMD_HELP; else if (buttons.bigbuttons==(KEY_MENU | KEY_CURSOR)) return BRL_CMD_INFO; else if (buttons.bigbuttons==0) { /* A cursor routing key has been pressed */ if (buttons.routingkey>0) { const TimeValue duration = { .seconds = 0, .nanoseconds = 5 * NSECS_PER_USEC }; accurateDelay(&duration); return BRL_CMD_BLK(ROUTE)+buttons.routingkey-1; } else return EOF; } else return EOF;
int fmTestCard (int errorLevel) { const unsigned char mask = AL_STAT_EXP | AL_STAT_EXP1 | AL_STAT_EXP2; AL_resetTimers(); if (!(AL_readStatus() & mask)) { unsigned char status; AL_writeRegister(ALR_T1DATA, 0xFF); AL_writeRegister(ALR_TCTL, AL_TCTL_T1START|AL_TCTL_T2MASK); { const TimeValue duration = { .seconds = 0, .nanoseconds = 80 * NSECS_PER_USEC }; accurateDelay(&duration); } status = AL_readStatus(); AL_resetTimers(); if ((status & mask) == (AL_STAT_EXP | AL_STAT_EXP1)) return 1; }
int playBeep (unsigned short frequency, unsigned int duration) { if (asynchronousBeep(frequency, duration*4)) { accurateDelay(duration); stopBeep(); return 1; } if (startBeep(frequency)) { accurateDelay(duration); stopBeep(); return 1; } return synchronousBeep(frequency, duration); }
static int beepPlay (NoteDevice *device, unsigned char note, unsigned int duration) { logMessage(LOG_DEBUG, "tone: msec=%d note=%d", duration, note); if (!note) { accurateDelay(duration); return 1; } return playBeep(getIntegerNoteFrequency(note), duration); }
static int fmPlay (NoteDevice *device, unsigned char note, unsigned int duration) { logMessage(LOG_DEBUG, "tone: msec=%d note=%d", duration, note); if (note) { fmPlayTone(device->channelNumber, getIntegerNoteFrequency(note), duration, prefs.fmVolume); } else { accurateDelay(duration); } return 1; }
static int beeperPlay (NoteDevice *device, unsigned char note, unsigned int duration) { logMessage(LOG_DEBUG, "tone: msec=%d note=%d", duration, note); if (!note) { accurateDelay(duration); return 1; } if (asynchronousBeep(getIntegerNoteFrequency(note), duration*4)) { accurateDelay(duration); stopBeep(); return 1; } if (startBeep(getIntegerNoteFrequency(note))) { accurateDelay(duration); stopBeep(); return 1; } return synchronousBeep(getIntegerNoteFrequency(note), duration); }
static int brl_writeWindow(BrailleDisplay *brl, const wchar_t *text) { const size_t cells = 40; unsigned char outbuff[cells]; /* Only display something if the data actually differs, this * could most likely cause some problems in redraw situations etc * but since the darn thing wants to redraw quite frequently otherwise * this still makes a better lookin result */ if (cellsHaveChanged(lastbuff, brl->buffer, cells, NULL, NULL, NULL)) { translateOutputCells(outbuff, brl->buffer, cells); vbdisplay(outbuff); vbdisplay(outbuff); accurateDelay(VBREFRESHDELAY); } return 1; }