Advertisement
ZoriaRPG

Orithan's Input FLag Function, Revised

Jan 24th, 2019
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.36 KB | None | 0 0
  1. //Button bindings are as follows:
  2. const int BTNFLAG_START     = 1;
  3. const int BTNFLAG_SELECT = 2;
  4. const int BTNFLAG_UP        = 4;
  5. const int BTNFLAG_RIGHT = 32;
  6. const int BTNFLAG_A     = 64;
  7. const int BTNFLAG_B     = 128;
  8. const int BTNFLAG_L     = 256;
  9. const int BTNFLAG_R     = 512;
  10. const int BTNFLAG_EX1   = 1024;
  11. const int BTNFLAG_EX2   = 2048;
  12. const int BTNFLAG_EX3   = 4096;
  13. const int BTNFLAG_EX4   = 8192;
  14.  
  15. const int USE_BUTTON_ONLY = 01b;
  16. const int USE_AXIS_ONLY = 10b;
  17. const int USE_BUTTON_AND_AXIS = 11b;
  18.  
  19.  
  20.  
  21. //Takes an interger to set as many of Link's inputs as you need via a single function.
  22. //val - Number to input. OR (|) the above BTNFLAG_[input] constants together or add their numbers together to get the desired result.
  23. //state - Switch input on or off.
  24. //type - Wherever to set press and/or input. 1 = Input, 2 = Press, 3 = Both. All other values are undefined,
  25. //axis - When modifying directional inputs. 1 = Button only. 2 = Axis only. 11 = both Axis and button.  All other values are undefined,
  26. //axis -
  27. //debug - Set to true to enable traces
  28. void SetInputFlags(int val, bool state, int type, int axis, bool debug){
  29.     if(val&BTNFLAG_START){
  30.         if(type&1){
  31.             Link->InputStart = state;
  32.             if(debug)
  33.                 TraceB(Link->InputStart);
  34.         }
  35.         if(type&2){
  36.             Link->PressStart = state;
  37.             if(debug)
  38.                 TraceB(Link->PressStart);
  39.         }
  40.     }
  41.     if(val&BTNFLAG_SELECT){
  42.         if(type&1){
  43.             Link->InputMap = state;
  44.             if(debug)
  45.                 TraceB(Link->InputMap);
  46.         }
  47.         if(type&2){
  48.             Link->PressMap = state;
  49.             if(debug)
  50.                 TraceB(Link->PressMap);
  51.         }
  52.     }
  53.     if(val&BTNFLAG_UP){
  54.         if(type&1){
  55.             if(axis&1){
  56.                 Link->InputUp = state;
  57.                 if(debug)
  58.                     TraceB(Link->InputUp);
  59.             }
  60.             if(axis&2){
  61.                 Link->InputAxisUp = state;
  62.                 if(debug)
  63.                     TraceB(Link->InputAxisUp);
  64.             }
  65.         }
  66.         if(type&2){
  67.             if(axis&1){
  68.                 Link->PressUp = state;
  69.                 if(debug)
  70.                     TraceB(Link->PressUp);
  71.             }
  72.             if(axis&2){
  73.                 Link->PressAxisUp = state;
  74.                 if(debug)
  75.                     TraceB(Link->PressAxisUp);
  76.             }
  77.         }
  78.     }
  79.     if(val&BTNFLAG_DOWN){
  80.         if(type&1){
  81.             if(axis&1){
  82.                 Link->InputDown = state;
  83.                 if(debug)
  84.                     TraceB(Link->InputDown);
  85.             }
  86.             if(axis&2){
  87.                 Link->InputAxisDown = state;
  88.                 if(debug)
  89.                     TraceB(Link->InputAxisDown);
  90.             }
  91.         }
  92.         if(type&2){
  93.             if(axis&1){
  94.                 Link->PressDown = state;
  95.                 if(debug)
  96.                     TraceB(Link->PressDown);
  97.             }
  98.             if(axis&2){
  99.                 Link->PressAxisDown = state;
  100.                 if(debug)
  101.                     TraceB(Link->PressAxisDown);
  102.             }
  103.         }
  104.     }
  105.     if(val&BTNFLAG_LEFT){
  106.         if(type&1){
  107.             if(axis&1){
  108.                 Link->InputLeft = state;
  109.                 if(debug)
  110.                     TraceB(Link->InputLeft);
  111.             }
  112.             if(axis&2){
  113.                 Link->InputAxisLeft = state;
  114.                 if(debug)
  115.                     TraceB(Link->InputAxisLeft);
  116.             }
  117.         }
  118.         if(type&2){
  119.             if(axis&1){
  120.                 Link->PressLeft = state;
  121.                 if(debug)
  122.                     TraceB(Link->PressLeft);
  123.             }
  124.             if(axis&2){
  125.                 Link->PressAxisLeft = state;
  126.                 if(debug)
  127.                     TraceB(Link->PressAxisLeft);
  128.             }
  129.         }
  130.     }
  131.     if(val&BTNFLAG_RIGHT){
  132.         if(type&1){
  133.             if(axis&1){
  134.                 Link->InputRight = state;
  135.                 if(debug)
  136.                     TraceB(Link->InputRight);
  137.             }
  138.             if(axis&2){
  139.                 Link->InputAxisRight = state;
  140.                 if(debug)
  141.                     TraceB(Link->InputAxisRight);
  142.             }
  143.         }
  144.         if(type&2){
  145.             if(axis&1){
  146.                 Link->PressRight = state;
  147.                 if(debug)
  148.                     TraceB(Link->PressRight);
  149.             }
  150.             if(axis&2){
  151.                 Link->PressAxisRight = state;
  152.                 if(debug)
  153.                     TraceB(Link->PressAxisRight);
  154.             }
  155.         }
  156.     }
  157.     if(val&BTNFLAG_A){
  158.         if(type&1){
  159.             Link->InputA = state;
  160.             if(debug)
  161.                 TraceB(Link->InputA);
  162.         }
  163.         if(type&2){
  164.             Link->PressA = state;
  165.             if(debug)
  166.                 TraceB(Link->PressA);
  167.         }
  168.     }
  169.     if(val&BTNFLAG_B){
  170.         if(type&1){
  171.             Link->InputB = state;
  172.             if(debug)
  173.                 TraceB(Link->InputB);
  174.         }
  175.         if(type&2){
  176.             Link->PressB = state;
  177.             if(debug)
  178.                 TraceB(Link->PressB);
  179.         }
  180.     }
  181.     if(val&BTNFLAG_L){
  182.         if(type&1){
  183.             Link->InputL = state;
  184.             if(debug)
  185.                 TraceB(Link->InputL);
  186.         }
  187.         if(type&2){
  188.             Link->PressL = state;
  189.             if(debug)
  190.                 TraceB(Link->PressL);
  191.         }
  192.     }
  193.     if(val&BTNFLAG_R){
  194.         if(type&1){
  195.             Link->InputR = state;
  196.             if(debug)
  197.                 TraceB(Link->InputR);
  198.         }
  199.         if(type&2){
  200.             Link->PressR = state;
  201.             if(debug)
  202.                 TraceB(Link->PressR);
  203.         }
  204.     }
  205.     if(val&BTNFLAG_R){
  206.         if(type&1){
  207.             Link->InputR = state;
  208.             if(debug)
  209.                 TraceB(Link->InputR);
  210.         }
  211.         if(type&2){
  212.             Link->PressR = state;
  213.             if(debug)
  214.                 TraceB(Link->PressR);
  215.         }
  216.     }
  217. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement