diff options
author | Bad Diode <bd@badd10de.dev> | 2022-03-03 09:28:22 +0000 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2022-03-03 09:28:22 +0000 |
commit | fd2087225089ccb37a63cbddf786a5efaf5a0377 (patch) | |
tree | 5ecd51fa57feaff12f8dff954c8189cf5643e6c2 /src | |
parent | 1d4759d8c04f18dc2e4f3ce45c4656f85f7301a7 (diff) | |
download | uxnfb-fd2087225089ccb37a63cbddf786a5efaf5a0377.tar.gz uxnfb-fd2087225089ccb37a63cbddf786a5efaf5a0377.zip |
Ensure cursor is not showing when running
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -2,6 +2,7 @@ | |||
2 | #include<stdlib.h> | 2 | #include<stdlib.h> |
3 | #include<stdint.h> | 3 | #include<stdint.h> |
4 | #include<stdbool.h> | 4 | #include<stdbool.h> |
5 | #include<unistd.h> | ||
5 | #include<fcntl.h> | 6 | #include<fcntl.h> |
6 | #include<linux/fb.h> | 7 | #include<linux/fb.h> |
7 | #include<sys/ioctl.h> | 8 | #include<sys/ioctl.h> |
@@ -30,14 +31,31 @@ main(void) { | |||
30 | fprintf(stderr, "couldn't mmap the framebuffer\n"); | 31 | fprintf(stderr, "couldn't mmap the framebuffer\n"); |
31 | exit(EXIT_FAILURE); | 32 | exit(EXIT_FAILURE); |
32 | } | 33 | } |
34 | |||
35 | // Main loop. | ||
33 | uint8_t shade = 0; | 36 | uint8_t shade = 0; |
37 | size_t counter = 0; | ||
38 | size_t direction = 1; | ||
34 | while (true) { | 39 | while (true) { |
35 | for (size_t j = 0; j < height; j++) { | 40 | for (size_t j = 0; j < height; j++) { |
36 | for (size_t i = 0; i < width; i++) { | 41 | for (size_t i = 0; i < width; i++) { |
37 | buf[j * width + i] = shade; | 42 | buf[j * width + i] = shade; |
38 | } | 43 | } |
39 | } | 44 | } |
40 | shade++; | 45 | counter++; |
46 | if (counter > 10) { | ||
47 | shade += direction; | ||
48 | counter = 0; | ||
49 | } | ||
50 | if (shade == 0xFF) { | ||
51 | direction = -1; | ||
52 | } else if (shade == 0x00) { | ||
53 | direction = 1; | ||
54 | } | ||
41 | } | 55 | } |
56 | |||
57 | // Cleanup. | ||
58 | munmap(buf, len); | ||
59 | close(fb); | ||
42 | return 0; | 60 | return 0; |
43 | } | 61 | } |