Skip to content

Commit 9ae7b0a

Browse files
committed
use USB_SUPPORT_ENABLED
1 parent 9a96f71 commit 9ae7b0a

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

examples/example_xinput.c

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919

2020
#include "mdt/drivers/usb_input.h"
2121

22+
#ifdef USB_SUPPORT_ENABLED
2223

23-
void DrawPointer(MDT_BITMAP *bmp, int x, int y, uint8_t color);
24+
static void DrawPointer(MDT_BITMAP *bmp, int x, int y, uint8_t color);
2425

2526
void MDT_EXAMPLE_xinput(void) {
2627

@@ -73,7 +74,7 @@ void MDT_EXAMPLE_xinput(void) {
7374

7475
REPORT_F("%s", usb_state, 5, 190, 0xFF);
7576

76-
HID_MOUSE_Info_TypeDef* mouseInfo = MDT_USB_INPUT_GetMouseInfo();
77+
MDT_USB_INPUT_MouseInfo* mouseInfo = MDT_USB_INPUT_GetMouseInfo();
7778
if (mouseInfo != NULL) {
7879

7980
REPORT(mouseInfo->x, 140, 5 , 0xBF);
@@ -94,7 +95,7 @@ void MDT_EXAMPLE_xinput(void) {
9495

9596
}
9697

97-
HID_KEYBD_Info_TypeDef* kbdInfo = MDT_USB_INPUT_GetKbdInfo();
98+
MDT_USB_INPUT_KeybdInfo* kbdInfo = MDT_USB_INPUT_GetKeybdInfo();
9899
if (kbdInfo != NULL) {
99100
for (uint8_t i = 0; i < 6; i++) {
100101
REPORT(kbdInfo->keys[i], 140, 65 + 10 * i, 0xF8);
@@ -127,7 +128,7 @@ void MDT_EXAMPLE_xinput(void) {
127128

128129
}
129130

130-
void DrawPointer(MDT_BITMAP *bmp, int x, int y, uint8_t color) {
131+
static void DrawPointer(MDT_BITMAP *bmp, int x, int y, uint8_t color) {
131132

132133
#define PX(_x_, _y_) MDT_GRAPHICS_PutPixel(bmp, x + (_x_), y + (_y_), color);
133134

@@ -139,4 +140,33 @@ void DrawPointer(MDT_BITMAP *bmp, int x, int y, uint8_t color) {
139140

140141
}
141142

143+
#else
142144

145+
void MDT_EXAMPLE_xinput(void) {
146+
147+
MDT_GRAPHICS_InitTypeDef graphicsCfg = {
148+
.useHardwareAcceleration = true,
149+
.useSDRAM = false,
150+
.mainCtxHeight = 200,
151+
.mainCtxWidth = 320,
152+
.videoDriver = VIDEO_DRIVER_VGA,
153+
};
154+
MDT_GRAPHICS_Init(&graphicsCfg);
155+
156+
uint8_t bgcolor = 0b00100100;
157+
158+
while (1) {
159+
160+
//Draw frame:
161+
MDT_Clear(bgcolor);
162+
163+
MDT_DrawText("USB SUPPORT IS NOT ENABLED", 10, 10, 0XFF);
164+
165+
MDT_WaitForVSync();
166+
MDT_SwapBuffers();
167+
168+
}
169+
170+
}
171+
172+
#endif

0 commit comments

Comments
 (0)