Guest User

Nexie's Single Block Hammer On Keyboard

a guest
Oct 10th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.89 KB | None | 0 0
  1. # THIS SCRIPT SHOULD BE USED WITH FREEPIE
  2. # http://andersmalmgren.github.io/FreePIE/
  3. #------------------------------------------------------------------------------
  4. # Key-Config:
  5. # Use Digital Genesis' Keyscan
  6. # ( ftp://ftp.digitalgenesis.com/pub/keyscan/keyscan09.zip ) to find:
  7. # Five adjactend keys on your keyboard of which:
  8. # Key 1-4 and key 2-5 and any other combo of 4 keys can be pressed simultanously,
  9. # plus an easy to spam strumming bar key, that can also be pressed simultanously
  10. # additionally to the other 4 keys.
  11. #
  12. # The keys also can't be the predefiened keys "1,2,3,4,5" or "a,s,d,f,g" or
  13. # "e,r,space,u,i" because the game already uses those.
  14. # Of course some keys like ESC are also a bad idea to use.
  15. #
  16. # On my keyboard I've found the best result with "RightShift, Slash, Period, Comma, M"
  17. # plus "LeftControl" as Strumbar,  while holding the keyboard away from your body with
  18. # the cable pointing towards your head
  19. # (so your right thumb easily reaches LeftControl).
  20. # It's the default you find below.
  21. # If you have an expensive "N-Key Rollover" keyboard you're in luck and can use
  22. # whatever you want (except predefined keys)!
  23. #
  24. # If you found your keys insert them below. Use Key."XXX" and autocomplete to find the
  25. # correct key name FreePIE wants or look up key names under
  26. # https://github.com/AndersMalmgren/FreePIE/wiki/Reference under the "Key" section.
  27. # For example: Non-Numpad numbers are "D1 - D0". Numpad numbers are "NumberPad0 to
  28. # NumberPad9".
  29. #------------------------------------------------------------------------------------
  30. Key1 = "RightShift"
  31. Key2 = "Slash"
  32. Key3 = "Period"
  33. Key4 = "Comma"
  34. Key5 = "M"
  35. Strumbar = "LeftControl"
  36.  
  37. Test = Key.M
  38.  
  39. # !!!script code starts from here!!!
  40. #-------------------------------------------------
  41. # declare some cycle-persisting variables at start:
  42. #-------------------------------------------------
  43. if starting:
  44.     BarIsPressed = 0
  45.     ButtonIsPressed=[0,0,0,0,0]
  46.     LastHOPOButton = 5
  47. # If LastHOPOButton equals 5, no button has been pressed in a HOPO-mode Session
  48.  
  49. #-------------------------------------------------------------------------
  50. # check for not pressed, pressed and recently pressed stuff
  51. #-------------------------------------------------------------------------
  52. # check for not pressed buttons
  53. if keyboard.getKeyUp(getattr(Key, Key1)):
  54.     ButtonIsPressed[0] = 0
  55. if keyboard.getKeyUp(getattr(Key, Key2)):
  56.     ButtonIsPressed[1] = 0
  57. if keyboard.getKeyUp(getattr(Key, Key3)):
  58.     ButtonIsPressed[2] = 0
  59. if keyboard.getKeyUp(getattr(Key, Key4)):
  60.     ButtonIsPressed[3] = 0
  61. if keyboard.getKeyUp(getattr(Key, Key5)):
  62.     ButtonIsPressed[4] = 0
  63.  
  64. # ButtonJustDown variable
  65. ButtonJustDown=[0,0,0,0,0]
  66.  
  67. # check for currently pressed and possibly just pressed buttons
  68. if keyboard.getKeyDown(getattr(Key, Key1)):
  69.     if ButtonIsPressed[0] == 0:
  70.         ButtonJustDown[0] = 1
  71.     ButtonIsPressed[0] = 1
  72. if keyboard.getKeyDown(getattr(Key, Key2)):
  73.     if ButtonIsPressed[1] == 0:
  74.         ButtonJustDown[1] = 1
  75.     ButtonIsPressed[1] = 1
  76. if keyboard.getKeyDown(getattr(Key, Key3)):
  77.     if ButtonIsPressed[2] == 0:
  78.         ButtonJustDown[2] = 1
  79.     ButtonIsPressed[2] = 1
  80. if keyboard.getKeyDown(getattr(Key, Key4)):
  81.     if ButtonIsPressed[3] == 0:
  82.         ButtonJustDown[3] = 1
  83.     ButtonIsPressed[3] = 1
  84. if keyboard.getKeyDown(getattr(Key, Key5)):
  85.     if ButtonIsPressed[4] == 0:
  86.         ButtonJustDown[4] = 1
  87.     ButtonIsPressed[4] = 1
  88.    
  89. # check for not pressed strum bar and reset HOPO Session if true
  90. if keyboard.getKeyUp(getattr(Key, Strumbar)):
  91.     BarIsPressed = 0
  92.     LastHOPOButton = 5
  93.  
  94. #-------------------------------------------------------------------------------
  95. # HOPO-mode: If the strum bar is pressed, check if a hammered button is different to
  96. # the last one and, if true, do the thing
  97. # No repeated same button Hammer-Ons allowed in this script, because of TRVENESS
  98. # (unless you press 1-5 :-D)
  99. #-------------------------------------------------------------------------------
  100. elif ButtonJustDown[4] and LastHOPOButton != 4:
  101.     keyboard.setPressed(Key.D5)
  102.     LastHOPOButton = 4
  103. elif ButtonJustDown[3] and LastHOPOButton != 3:
  104.     keyboard.setPressed(Key.D4)
  105.     LastHOPOButton = 3
  106. elif ButtonJustDown[2] and LastHOPOButton != 2:
  107.     keyboard.setPressed(Key.D3)
  108.     LastHOPOButton = 2
  109. elif ButtonJustDown[1] and LastHOPOButton != 1:
  110.     keyboard.setPressed(Key.D2)
  111.     LastHOPOButton = 1
  112. elif ButtonJustDown[0] and LastHOPOButton != 0:
  113.     keyboard.setPressed(Key.D1)
  114.     LastHOPOButton = 0
  115.  
  116. #-------------------------------------------
  117. # button handover in case of actual strumming
  118. #-------------------------------------------
  119. if BarIsPressed == 0 and keyboard.getKeyDown(getattr(Key, Strumbar)):
  120.     BarIsPressed = 1
  121.     if ButtonIsPressed[4]:
  122.         keyboard.setPressed(Key.D5)
  123.     elif ButtonIsPressed[3]:
  124.         keyboard.setPressed(Key.D4)
  125.     elif ButtonIsPressed[2]:
  126.         keyboard.setPressed(Key.D3)
  127.     elif ButtonIsPressed[1]:
  128.         keyboard.setPressed(Key.D2)
  129.     elif ButtonIsPressed[0]:
  130.         keyboard.setPressed(Key.D1)
Advertisement
Add Comment
Please, Sign In to add comment