mirror of
https://github.com/dekuNukem/USB4VC.git
synced 2025-10-31 11:26:46 -07:00
adjusted ps2 mouse inhibit detection
This commit is contained in:
@@ -298,8 +298,20 @@ void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi)
|
||||
HAL_GPIO_WritePin(ACT_LED_GPIO_Port, ACT_LED_Pin, GPIO_PIN_RESET);
|
||||
}
|
||||
|
||||
uint8_t is_ps2_mouse_connected_prev;
|
||||
|
||||
void ps2mouse_update(void)
|
||||
{
|
||||
uint8_t is_ps2_mouse_connected = IS_PS2MOUSE_PRESENT();
|
||||
uint8_t send_bat = 0;
|
||||
if(is_ps2_mouse_connected == 1 && is_ps2_mouse_connected_prev == 0)
|
||||
{
|
||||
send_bat = 1;
|
||||
HAL_Delay(50);
|
||||
ps2mouse_restore_defaults();
|
||||
}
|
||||
is_ps2_mouse_connected_prev = is_ps2_mouse_connected;
|
||||
|
||||
ps2mouse_bus_status = ps2mouse_get_bus_status();
|
||||
if(ps2mouse_bus_status == PS2_BUS_INHIBIT)
|
||||
{
|
||||
@@ -312,6 +324,11 @@ void ps2mouse_update(void)
|
||||
ps2mouse_host_req_reply(ps2mouse_host_cmd, &latest_mouse_event);
|
||||
return;
|
||||
}
|
||||
else if(send_bat)
|
||||
{
|
||||
ps2mouse_write(0xaa, 100);
|
||||
ps2mouse_write(0, 100);
|
||||
}
|
||||
|
||||
mouse_event* this_mouse_event = mouse_buf_peek(&my_mouse_buf);
|
||||
if(this_mouse_event == NULL)
|
||||
@@ -331,7 +348,7 @@ void ps2mouse_update(void)
|
||||
;
|
||||
HAL_GPIO_WritePin(ERR_LED_GPIO_Port, ERR_LED_Pin, GPIO_PIN_RESET);
|
||||
}
|
||||
mouse_buf_reset(&my_mouse_buf);
|
||||
mouse_buf_reset(&my_mouse_buf); // don't change this!
|
||||
}
|
||||
|
||||
void ps2kb_update(void)
|
||||
@@ -584,7 +601,8 @@ int main(void)
|
||||
}
|
||||
HAL_GPIO_WritePin(ERR_LED_GPIO_Port, ERR_LED_Pin, GPIO_PIN_SET);
|
||||
}
|
||||
|
||||
ps2mouse_write(0xaa, 100);
|
||||
ps2mouse_write(0, 100);
|
||||
while (1)
|
||||
{
|
||||
// HAL_IWDG_Refresh(&hiwdg);
|
||||
|
||||
Reference in New Issue
Block a user