mirror of https://github.com/stella-emu/stella.git
improve JoyMap hashing
This commit is contained in:
parent
22b4f36bbc
commit
e3c97c3725
|
@ -130,12 +130,13 @@ class JoyMap
|
|||
|
||||
struct JoyHash {
|
||||
size_t operator()(const JoyMapping& m)const {
|
||||
return std::hash<uInt64>()((uInt64(m.mode)) // 3 bit
|
||||
^ ((uInt64(m.button)) << 2) // 2 bits
|
||||
^ ((uInt64(m.axis)) << 4) // 1 bit
|
||||
^ ((uInt64(m.adir)) << 5) // 1 bit
|
||||
^ ((uInt64(m.hat)) << 6) // 1 bit
|
||||
^ ((uInt64(m.hdir)) << 7) // 2 bits
|
||||
return std::hash<uInt64>()((uInt64(m.mode)) // 3 bits
|
||||
+ ((uInt64(m.button)) * 7) // 3 bits
|
||||
+ (((uInt64(m.axis)) << 0) // 2 bits
|
||||
| ((uInt64(m.adir)) << 2) // 2 bits
|
||||
| ((uInt64(m.hat )) << 4) // 1 bit
|
||||
| ((uInt64(m.hdir)) << 5) // 2 bits
|
||||
) * 61
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -109,7 +109,9 @@ class KeyMap
|
|||
+ (((uInt64((m.mod & KBDM_SHIFT) != 0) << 0)) // 1 bit
|
||||
| ((uInt64((m.mod & KBDM_ALT ) != 0) << 1)) // 1 bit
|
||||
| ((uInt64((m.mod & KBDM_GUI ) != 0) << 2)) // 1 bit
|
||||
| ((uInt64((m.mod & KBDM_CTRL ) != 0) << 3))) * 2047); // 1 bit
|
||||
| ((uInt64((m.mod & KBDM_CTRL ) != 0) << 3)) // 1 bit
|
||||
) * 2047
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue