-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #99, and improves Keyboard MODONLY impl
- Loading branch information
Showing
6 changed files
with
71 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include "kbd.h" | ||
|
||
bool MODONLY(const Uint16 &mod, const Uint16 k) | ||
{ | ||
enum { | ||
CTRL=0, | ||
SHIFT, | ||
ALT, | ||
GUI, | ||
MOD_END | ||
}; | ||
// iteration of each left/right modifier key group | ||
Uint16 modLR[4] = { | ||
KMOD_CTRL, | ||
KMOD_SHIFT, | ||
KMOD_ALT, | ||
KMOD_GUI | ||
}; | ||
|
||
bool match = true; | ||
|
||
// for each modifier key group L/R pair | ||
for (int i=0; i < MOD_END; i++) | ||
{ | ||
if (k & modLR[i]) // if we're supposed to be checking for ANY of these pair | ||
{ | ||
// if the keys pressed do not reflect the keys checked for | ||
// (applies to any specified L / R / LR mod key combo) | ||
if ( ! ( (mod & modLR[i]) & (k & modLR[i]) ) ) | ||
{ | ||
match = false; | ||
break; | ||
} | ||
} | ||
else // if we're not supposed to be checking for this pair | ||
{ | ||
if (mod & modLR[i]) // make sure this pair's keys are not held | ||
{ | ||
match = false; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
return match; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters