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:
13
str_util.cpp
13
str_util.cpp
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user