ThoNohT / NohBoard

A Keyboard Visualizer
GNU General Public License v2.0
976 stars 168 forks source link

Add Or Mode for KeyboardKeyDefinitions #208

Open Houdini111 opened 3 months ago

Houdini111 commented 3 months ago

This PR adds the ability for KeyboardKeyDefinitions to register as being pressed if any of their key codes are pressed (rather than requiring all of them).

In your review I ask for special attention to the last part of the Keyboard Key Pressed logic but I couldn't quite parse what the point of it was. I removed this whole part:

if(kkDef.KeyCodes.Count == 1
    && allDefs.OfType<KeyboardKeyDefinition>()
        .Any(d => d.KeyCodes.Count > 1
        && d.KeyCodes.All(kbKeys.Contains)
        && d.KeyCodes.ContainsAll(kkDef.KeyCodes))) pressed = false;

From what I can understand of it it says it's NOT pressed if there is any keyboard that exactly contains all the same keycodes and those keycodes are pressed? As in it's not allowing multiple to be triggered at the same time? I don't know why you would want to explicitly disallow that.

I found that in this commit it didn't have that https://github.com/ThoNohT/NohBoard/blob/4e2965a1bbecf6b2f342aa8f5e71ee5f819549b7/NohBoard/Forms/MainForm.cs but in this commit it did https://github.com/ThoNohT/NohBoard/commit/8e20028a717fcba484aa2525e93bba3125ce9588#diff-ddd56594eed44ee72f2d8791249520ccd6802f26bd2a5e7767331930d6598a71 but the commit message implies it was only for edit mode? So I have no idea what the point of it was.