preparing to add event consolidation

This commit is contained in:
dekunukem
2022-05-13 12:13:31 +01:00
parent 27defa1617
commit ade56b8aaa
68 changed files with 3359 additions and 3366 deletions

View File

@@ -45,6 +45,10 @@
#define PROTOCOL_GENERIC_GAMEPORT_GAMEPAD 7
#define PROTOCOL_MOUSESYSTEMS_SERIAL_MOUSE 8
#define MOUSE_EVENT_BUFFER_SIZE 8
#define KEYBOARD_EVENT_BUFFER_SIZE 8
#define GAMEPAD_EVENT_BUFFER_SIZE 8
typedef struct
{
uint8_t head;
@@ -56,8 +60,8 @@ typedef struct
typedef struct
{
int16_t movement_x;
int16_t movement_y;
int32_t movement_x;
int32_t movement_y;
int8_t scroll_vertical;
int8_t scroll_horizontal;
uint8_t button_left;
@@ -65,7 +69,6 @@ typedef struct
uint8_t button_right;
uint8_t button_side;
uint8_t button_extra;
uint8_t has_button_transition;
} mouse_event;
typedef struct

View File

File diff suppressed because one or more lines are too long

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

@@ -22,25 +22,57 @@ Dialog DLL: TARMCM1.DLL V1.14.1.0
<h2>Project:</h2>
C:\Users\allen\Desktop\repos\usb2ps2\firmware\ibmpc\MDK-ARM\ibmpc.uvprojx
Project File Date: 03/28/2022
Project File Date: 05/13/2022
<h2>Output:</h2>
*** Using Compiler 'V5.06 update 6 (build 750)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
Build target 'ibmpc'
assembling startup_stm32f072xb.s...
compiling xt_kb.c...
compiling stm32f0xx_hal_i2c_ex.c...
compiling mcp4451.c...
compiling ps2kb.c...
compiling stm32f0xx_it.c...
compiling delay_us.c...
compiling helpers.c...
compiling stm32f0xx_hal_msp.c...
compiling ps2mouse.c...
..\Src\ps2mouse.c(157): warning: #1182-D: a declaration cannot have a label
uint32_t ps2mouse_wait_start = HAL_GetTick();
..\Src\ps2mouse.c: 1 warning, 0 errors
compiling main.c...
../Src/main.c(526): warning: #188-D: enumerated type mixed with another type
../Src/main.c(518): warning: #188-D: enumerated type mixed with another type
HAL_GPIO_WritePin(GAMEPAD_B1_GPIO_Port, GAMEPAD_B1_Pin, !(this_gamepad_event->button_1));
../Src/main.c(527): warning: #188-D: enumerated type mixed with another type
../Src/main.c(519): warning: #188-D: enumerated type mixed with another type
HAL_GPIO_WritePin(GAMEPAD_B2_GPIO_Port, GAMEPAD_B2_Pin, !(this_gamepad_event->button_2));
../Src/main.c(528): warning: #188-D: enumerated type mixed with another type
../Src/main.c(520): warning: #188-D: enumerated type mixed with another type
HAL_GPIO_WritePin(GAMEPAD_B3_GPIO_Port, GAMEPAD_B3_Pin, !(this_gamepad_event->button_3));
../Src/main.c(529): warning: #188-D: enumerated type mixed with another type
../Src/main.c(521): warning: #188-D: enumerated type mixed with another type
HAL_GPIO_WritePin(GAMEPAD_B4_GPIO_Port, GAMEPAD_B4_Pin, !(this_gamepad_event->button_4));
../Src/main.c: 4 warnings, 0 errors
compiling stm32f0xx_hal_i2c.c...
compiling stm32f0xx_hal_iwdg.c...
compiling stm32f0xx_hal_uart_ex.c...
compiling stm32f0xx_hal.c...
compiling stm32f0xx_hal_spi_ex.c...
compiling stm32f0xx_hal_tim_ex.c...
compiling stm32f0xx_hal_uart.c...
compiling stm32f0xx_hal_gpio.c...
compiling stm32f0xx_hal_rcc_ex.c...
compiling stm32f0xx_hal_spi.c...
compiling stm32f0xx_hal_dma.c...
compiling stm32f0xx_hal_rcc.c...
compiling stm32f0xx_hal_tim.c...
compiling stm32f0xx_hal_cortex.c...
compiling stm32f0xx_hal_flash.c...
compiling system_stm32f0xx.c...
compiling stm32f0xx_hal_pwr.c...
compiling stm32f0xx_hal_flash_ex.c...
compiling stm32f0xx_hal_pwr_ex.c...
linking...
Program Size: Code=17244 RO-data=768 RW-data=144 ZI-data=2320
Program Size: Code=17144 RO-data=768 RW-data=140 ZI-data=2324
FromELF: creating hex file...
"ibmpc\ibmpc.axf" - 0 Error(s), 4 Warning(s).
"ibmpc\ibmpc.axf" - 0 Error(s), 5 Warning(s).
<h2>Software Packages used:</h2>
@@ -63,7 +95,7 @@ Package Vendor: Keil
<h2>Collection of Component Files used:</h2>
* Component: ARM::CMSIS:CORE:5.3.0
Build Time Elapsed: 00:00:01
Build Time Elapsed: 00:00:10
</pre>
</body>
</html>

View File

File diff suppressed because it is too large Load Diff

View File

File diff suppressed because it is too large Load Diff

View File

File diff suppressed because it is too large Load Diff

View File

File diff suppressed because it is too large Load Diff

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

@@ -236,9 +236,6 @@ void handle_protocol_switch(uint8_t spi_byte)
}
}
#define MOUSE_BUTTON_HISTORY_SIZE 5
uint8_t mouse_button_history[MOUSE_BUTTON_HISTORY_SIZE];
/*
This is called when a new SPI packet is received
This is part of an ISR, so keep it short!
@@ -267,10 +264,6 @@ void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi)
latest_mouse_event.button_middle = backup_spi1_recv_buf[15];
latest_mouse_event.button_side = backup_spi1_recv_buf[16];
latest_mouse_event.button_extra = backup_spi1_recv_buf[17];
latest_mouse_event.has_button_transition = 0;
if(memcmp(mouse_button_history, &backup_spi1_recv_buf[13], MOUSE_BUTTON_HISTORY_SIZE))
latest_mouse_event.has_button_transition = 1;
memcpy(mouse_button_history, &backup_spi1_recv_buf[13], MOUSE_BUTTON_HISTORY_SIZE);
mouse_buf_add(&my_mouse_buf, &latest_mouse_event);
}
else if(backup_spi1_recv_buf[SPI_BUF_INDEX_MSG_TYPE] == SPI_MOSI_MSG_TYPE_GAMEPAD_EVENT_MAPPED_IBMPC)
@@ -374,7 +367,14 @@ void ps2mouse_update(void)
// HAL_GPIO_WritePin(ERR_LED_GPIO_Port, ERR_LED_Pin, GPIO_PIN_RESET);
}
last_mouse_send = micros();
mouse_buf_reset(&my_mouse_buf); // don't change this!
int i;
for (i = 0; i < 100; ++i)
{
if(mouse_buf_peek(&my_mouse_buf) == NULL)
break;
mouse_buf_pop(&my_mouse_buf);
}
printf("%d", i);
}
void ps2kb_update(void)
@@ -448,11 +448,7 @@ void microsoft_serial_mouse_update(void)
return;
if(serial_mouse_is_tx_in_progress)
{
if(this_mouse_event->has_button_transition == 0) // dont throw away events that have button transitions
mouse_buf_pop(&my_mouse_buf);
return;
}
memset(microsoft_serial_mouse_output_buf, 0, MICROSOFT_SERIAL_MOUSE_BUF_SIZE);
microsoft_serial_mouse_output_buf[0] = 0xc0;
@@ -478,8 +474,6 @@ void microsoft_serial_mouse_update(void)
mouse_buf_pop(&my_mouse_buf);
HAL_UART_Transmit_IT(&huart3, microsoft_serial_mouse_output_buf, MICROSOFT_SERIAL_MOUSE_BUF_SIZE);
serial_mouse_is_tx_in_progress = 1;
if(this_mouse_event->has_button_transition)
HAL_Delay(10);
}
void spi_error_dump_reboot(void)
@@ -569,11 +563,7 @@ void mousesystems_serial_mouse_update(void)
return;
if(serial_mouse_is_tx_in_progress)
{
if(this_mouse_event->has_button_transition == 0) // don't throw away mouse events that has button transitions
mouse_buf_pop(&my_mouse_buf);
return;
}
memset(mousesystems_serial_mouse_output_buf, 0, MOUSESYSTEMS_SERIAL_MOUSE_BUF_SIZE);
mousesystems_serial_mouse_output_buf[0] = 0x87;
@@ -590,8 +580,6 @@ void mousesystems_serial_mouse_update(void)
mouse_buf_pop(&my_mouse_buf);
HAL_UART_Transmit_IT(&huart3, mousesystems_serial_mouse_output_buf, MOUSESYSTEMS_SERIAL_MOUSE_BUF_SIZE);
serial_mouse_is_tx_in_progress = 1;
if(this_mouse_event->has_button_transition)
HAL_Delay(10); // wait a bit for the computer to register button press
}
/* USER CODE END 0 */
@@ -644,9 +632,9 @@ int main(void)
if(is_protocol_enabled(PROTOCOL_XT_KB))
xtkb_enable();
kb_buf_init(&my_kb_buf, 16);
mouse_buf_init(&my_mouse_buf, 16);
gamepad_buf_init(&my_gamepad_buf, 16);
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);
mcp4451_reset();

View File

@@ -61,7 +61,7 @@ void ps2mouse_restore_defaults(void)
ps2mouse_sampling_rate = 100;
ps2mouse_resolution = 2;
ps2mouse_scale = 1;
ps2mouse_data_reporting_enabled = 0;
ps2mouse_data_reporting_enabled = 1;
ps2mouse_current_mode = PS2MOUSE_MODE_STREAM;
}