Compare commits

...

4 Commits

Author SHA1 Message Date
d4f47bf9b4 test enhanced_polling_nb_iter 2023-09-03 18:11:51 +02:00
98ba8de780 test enhanced_polling_nb_iter 2023-09-03 18:10:11 +02:00
5eacda584e wip reoptim 2023-09-03 14:24:35 +02:00
2f9d25df05 wip reoptim 2023-09-03 14:23:51 +02:00
2 changed files with 25 additions and 6 deletions

View File

@ -44,6 +44,7 @@ struct popnhax_config {
uint8_t debounce;
bool enhanced_polling_stats;
int8_t enhanced_polling_priority;
uint32_t enhanced_polling_nb_iter;
uint8_t hispeed_auto;
uint16_t hispeed_default_bpm;
uint8_t survival_gauge;

View File

@ -166,6 +166,8 @@ PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, translation_de
"/popnhax/translation_debug")
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, enhanced_polling,
"/popnhax/enhanced_polling")
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_U32, struct popnhax_config, enhanced_polling_nb_iter,
"/popnhax/enhanced_polling_nb_iter")
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_U8, struct popnhax_config, debounce,
"/popnhax/debounce")
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, enhanced_polling_stats,
@ -2202,6 +2204,20 @@ static bool patch_add_to_base_offset(int8_t delta) {
bool g_enhanced_poll_ready = false;
int (*usbPadRead)(uint32_t*);
#pragma GCC push_options
#pragma GCC optimize ("O0")
static uint32_t __inline wait_a_little(uint32_t nb_iter)
{
uint32_t j=0;
for (uint32_t i=0; i<nb_iter; i++)
{
j++;
}
return timeGetTime();
}
#pragma GCC pop_options
uint32_t g_poll_rate_avg = 0;
uint32_t g_last_button_state = 0;
uint8_t g_debounce = 0;
@ -2239,14 +2255,16 @@ static unsigned int __stdcall enhanced_polling_stats_proc(void *ctx)
/* ensure at least 1ms has elapsed between polls
* (beware of SD cab hardware compatibility)
*/
curr_poll_time = timeGetTime();
if (curr_poll_time == prev_poll_time)
{
curr_poll_time++;
Sleep(1);
}
prev_poll_time = curr_poll_time;
{
do {
curr_poll_time = wait_a_little(config.enhanced_polling_nb_iter);
while (curr_poll_time == prev_poll_time);
}
prev_poll_time = curr_poll_time;
if (count == 0)
{
count_time = curr_poll_time;