Advertisement
Guest User

chords

a guest
Oct 22nd, 2013
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. typedef bool (*InputFunc)(Input const*);
  2.  
  3. template<InputFunc Function1, InputFunc... Functions>
  4. struct Logic {
  5.     static inline bool conjunction(Input const* input) {
  6.         return Function1(input) && Logic<Functions...>::conjunction(input);
  7.     }
  8.     static inline bool disjunction(Input const* input) {
  9.         return Function1(input) || Logic<Functions...>::disjunction(input);
  10.     }
  11. };
  12.  
  13. template<InputFunc Function1>
  14. struct Logic<Function1> {
  15.     static inline bool conjunction(Input const* input) {
  16.         return Function1(input);
  17.     }
  18.     static inline bool disjunction(Input const* input) {
  19.         return Function1(input);
  20.     }
  21. };
  22.  
  23. if (
  24.     Logic<
  25.         Logic<
  26.             Key::pressed<Key::LEFT_CONTROL>,
  27.             Key::wentDown<Key::C>
  28.         >::conjunction,
  29.         Mouse::wentDown<Mouse::RIGHT>
  30.     >::disjunction(&input)
  31.     ) {
  32.     printf("LCtrl + C or right mouse pressed.\n");
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement