mirror of
https://github.com/dekuNukem/USB4VC.git
synced 2025-10-31 11:26:46 -07:00
uploaded new IBM PC firmware
This commit is contained in:
@@ -8,13 +8,13 @@ void kb_buf_reset(kb_buf *lb)
|
||||
{
|
||||
lb->head = 0;
|
||||
lb->tail = 0;
|
||||
memset(lb->keycode_buf, 0, lb->size);
|
||||
memset(lb->keyvalue_buf, 0, lb->size);
|
||||
memset(lb->keycode_buf, 0, KEYBOARD_EVENT_BUFFER_SIZE);
|
||||
memset(lb->keyvalue_buf, 0, KEYBOARD_EVENT_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
uint8_t kb_buf_is_full(kb_buf *lb)
|
||||
{
|
||||
return lb->tail == (lb->head + 1) % lb->size;
|
||||
return lb->tail == (lb->head + 1) % KEYBOARD_EVENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
uint8_t kb_buf_is_empty(kb_buf *lb)
|
||||
@@ -30,7 +30,7 @@ uint8_t kb_buf_add(kb_buf *lb, uint8_t code, uint8_t value)
|
||||
return 1;
|
||||
lb->keycode_buf[lb->head] = code;
|
||||
lb->keyvalue_buf[lb->head] = value;
|
||||
lb->head = (lb->head + 1) % lb->size;
|
||||
lb->head = (lb->head + 1) % KEYBOARD_EVENT_BUFFER_SIZE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -46,14 +46,13 @@ uint8_t kb_buf_peek(kb_buf *lb, uint8_t* code, uint8_t* value)
|
||||
void kb_buf_pop(kb_buf *lb)
|
||||
{
|
||||
if(!kb_buf_is_empty(lb))
|
||||
lb->tail = (lb->tail + 1) % lb->size;;
|
||||
lb->tail = (lb->tail + 1) % KEYBOARD_EVENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
void kb_buf_init(kb_buf *lb, uint8_t size)
|
||||
void kb_buf_init(kb_buf *lb)
|
||||
{
|
||||
lb->size = size;
|
||||
lb->keycode_buf = malloc(size);
|
||||
lb->keyvalue_buf = malloc(size);
|
||||
lb->keycode_buf = malloc(KEYBOARD_EVENT_BUFFER_SIZE);
|
||||
lb->keyvalue_buf = malloc(KEYBOARD_EVENT_BUFFER_SIZE);
|
||||
kb_buf_reset(lb);
|
||||
}
|
||||
|
||||
@@ -61,7 +60,7 @@ void kb_buf_init(kb_buf *lb, uint8_t size)
|
||||
|
||||
uint8_t mouse_buf_is_full(mouse_buf *lb)
|
||||
{
|
||||
return lb->tail == (lb->head + 1) % lb->size;
|
||||
return lb->tail == (lb->head + 1) % MOUSE_EVENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
uint8_t mouse_buf_is_empty(mouse_buf *lb)
|
||||
@@ -74,7 +73,7 @@ uint8_t mouse_buf_add(mouse_buf *lb, mouse_event* event)
|
||||
if(mouse_buf_is_full(lb))
|
||||
return 1;
|
||||
memcpy(&lb->mouse_events[lb->head], event, sizeof(mouse_event));
|
||||
lb->head = (lb->head + 1) % lb->size;
|
||||
lb->head = (lb->head + 1) % MOUSE_EVENT_BUFFER_SIZE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -88,20 +87,19 @@ mouse_event* mouse_buf_peek(mouse_buf *lb)
|
||||
void mouse_buf_pop(mouse_buf *lb)
|
||||
{
|
||||
if(!mouse_buf_is_empty(lb))
|
||||
lb->tail = (lb->tail + 1) % lb->size;
|
||||
lb->tail = (lb->tail + 1) % MOUSE_EVENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
void mouse_buf_reset(mouse_buf *lb)
|
||||
{
|
||||
lb->head = 0;
|
||||
lb->tail = 0;
|
||||
memset(lb->mouse_events, 0, lb->size * sizeof(mouse_event));
|
||||
memset(lb->mouse_events, 0, MOUSE_EVENT_BUFFER_SIZE * sizeof(mouse_event));
|
||||
}
|
||||
|
||||
void mouse_buf_init(mouse_buf *lb, uint8_t size)
|
||||
void mouse_buf_init(mouse_buf *lb)
|
||||
{
|
||||
lb->size = size;
|
||||
lb->mouse_events = malloc(size * sizeof(mouse_event));
|
||||
lb->mouse_events = malloc(MOUSE_EVENT_BUFFER_SIZE * sizeof(mouse_event));
|
||||
mouse_buf_reset(lb);
|
||||
}
|
||||
|
||||
@@ -109,7 +107,7 @@ void mouse_buf_init(mouse_buf *lb, uint8_t size)
|
||||
|
||||
uint8_t gamepad_buf_is_full(gamepad_buf *lb)
|
||||
{
|
||||
return lb->tail == (lb->head + 1) % lb->size;
|
||||
return lb->tail == (lb->head + 1) % GAMEPAD_EVENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
uint8_t gamepad_buf_is_empty(gamepad_buf *lb)
|
||||
@@ -122,7 +120,7 @@ uint8_t gamepad_buf_add(gamepad_buf *lb, gamepad_event* event)
|
||||
if(gamepad_buf_is_full(lb))
|
||||
return 1;
|
||||
memcpy(&lb->gamepad_events[lb->head], event, sizeof(gamepad_event));
|
||||
lb->head = (lb->head + 1) % lb->size;
|
||||
lb->head = (lb->head + 1) % GAMEPAD_EVENT_BUFFER_SIZE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -136,20 +134,19 @@ gamepad_event* gamepad_buf_peek(gamepad_buf *lb)
|
||||
void gamepad_buf_pop(gamepad_buf *lb)
|
||||
{
|
||||
if(!gamepad_buf_is_empty(lb))
|
||||
lb->tail = (lb->tail + 1) % lb->size;
|
||||
lb->tail = (lb->tail + 1) % GAMEPAD_EVENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
void gamepad_buf_reset(gamepad_buf *lb)
|
||||
{
|
||||
lb->head = 0;
|
||||
lb->tail = 0;
|
||||
memset(lb->gamepad_events, 0, lb->size * sizeof(gamepad_event));
|
||||
memset(lb->gamepad_events, 0, GAMEPAD_EVENT_BUFFER_SIZE * sizeof(gamepad_event));
|
||||
}
|
||||
|
||||
void gamepad_buf_init(gamepad_buf *lb, uint8_t size)
|
||||
void gamepad_buf_init(gamepad_buf *lb)
|
||||
{
|
||||
lb->size = size;
|
||||
lb->gamepad_events = malloc(size * sizeof(gamepad_event));
|
||||
lb->gamepad_events = malloc(GAMEPAD_EVENT_BUFFER_SIZE * sizeof(gamepad_event));
|
||||
gamepad_buf_reset(lb);
|
||||
}
|
||||
|
||||
|
||||
@@ -662,9 +662,9 @@ int main(void)
|
||||
if(is_protocol_enabled(PROTOCOL_XT_KB))
|
||||
xtkb_enable();
|
||||
|
||||
kb_buf_init(&my_kb_buf, KEYBOARD_EVENT_BUFFER_SIZE);
|
||||
mouse_buf_init(&my_mouse_buf, MOUSE_EVENT_BUFFER_SIZE);
|
||||
gamepad_buf_init(&my_gamepad_buf, GAMEPAD_EVENT_BUFFER_SIZE);
|
||||
kb_buf_init(&my_kb_buf);
|
||||
mouse_buf_init(&my_mouse_buf);
|
||||
gamepad_buf_init(&my_gamepad_buf);
|
||||
|
||||
mcp4451_reset();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user