Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
larsbrinkhoff committed Oct 27, 2024
1 parent 4775a5b commit be16836
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
14 changes: 9 additions & 5 deletions vt100/flowers.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
#include <sys/ioctl.h>
#include "vt100.h"

int flowers = 0; // Trevor Flowers' mini VT100.
int flowersi = 0; // Trevor Flowers' mini VT100.
int flowerso = 0;

void flowers_leds(u8 data)
{
char command[100];
int n;
if (!flowers)
if (!flowerso)
return;
n = snprintf(command, sizeof command, "SET_ALL_LEDS %c%c%c%c%c%c%c\n",
(data & 0x20) ? '0' : '1',
Expand All @@ -18,7 +19,7 @@ void flowers_leds(u8 data)
(data & 0x04) ? '1' : '0',
(data & 0x02) ? '1' : '0',
(data & 0x01) ? '1' : '0');
write(flowers, command, n);
write(flowerso, command, n);
}

static const char *const prefix = "\nSPECIAL_KEY: ";
Expand All @@ -29,11 +30,14 @@ int flowers_key(void)
char data;
int n;

if (ioctl(flowers, FIONREAD, &n) != 0)
if (!flowersi)
return -1;

if (ioctl(flowersi, FIONREAD, &n) != 0)
return -1;
if (n < 1)
return -1;
if (read(flowers, &data, 1) != 1)
if (read(flowersi, &data, 1) != 1)
return -1;

if (*pointer == 0) {
Expand Down
2 changes: 1 addition & 1 deletion vt100/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,6 @@ void reset_keyboard (void)
down[0x7F] = 1;
scan = 0x80;
flowers_leds(0);
if (flowers)
if (flowersi)
add_event (1000, &flowers_event);
}
11 changes: 9 additions & 2 deletions vt100/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,16 @@ int main (int argc, char **argv)
curvature = atof (optarg);
break;
case 'F':
flowers = open(optarg, O_RDONLY);
if (flowers == -1)
#if 1
flowersi = open(optarg, O_RDONLY);
if (flowersi == -1)
panic("Couldn't open %s: %s", optarg, strerror (errno));
#endif
#if 0
flowerso = open(optarg, O_WRONLY);
if (flowerso == -1)
panic("Couldn't open %s: %s", optarg, strerror (errno));
#endif
break;
default:
usage();
Expand Down
3 changes: 2 additions & 1 deletion vt100/vt100.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ extern u8 vt100_flags;
extern int pty;
extern int sound_scope;
extern int field_rate;
extern int flowers;

extern int quick;
extern int pixcolor;
Expand Down Expand Up @@ -64,5 +63,7 @@ extern void nvr_clock (void);
extern void key_down (u8 code);
extern void key_up (u8 code);

extern int flowersi;
extern int flowerso;
extern void flowers_leds(u8 data);
extern int flowers_key(void);

0 comments on commit be16836

Please sign in to comment.