input: Controller unique mapping (preliminary)

Add ini option `unique_mapping` which makes controller mappings unique to the physical port the controller is connected to.
Calculates a uint32_t unique_hash for each device during enumeration.

Co-authored-by: Martin Donlon <github-martin@donlons.com>
This commit is contained in:
Alexey Melnikov
2023-05-21 02:14:27 +08:00
committed by GitHub
parent 9307e54f1d
commit 0ebf137532
5 changed files with 36 additions and 3 deletions

View File

@@ -31,4 +31,17 @@ char *strncpyz(char *dest, size_t dest_size, const char *src, size_t num)
char *strcpyz(char *dest, size_t dest_size, const char *src)
{
return strncpyz(dest, dest_size, src, dest_size - 1);
}
unsigned int str_hash(const char *s, unsigned int initial)
{
unsigned int hash = initial;
int c;
while( c = *s++ )
{
hash = ((hash << 5) + hash) + c;
}
return hash;
}