Created
November 13, 2016 23:31
-
-
Save Synergyst/6aa179c222c34cb210e7ce415da42fd5 to your computer and use it in GitHub Desktop.
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
#include <DirectIO.h> | |
#include "HID-Project.h" | |
/* | |
* This is the pin that will tie into the mouse. | |
* The button on the mouse MUST tie to ground when pressed, | |
* otherwise this sketch will need to be modified appropriately.. | |
*/ | |
Input<4> my_input(false); | |
/* | |
Benchmark results were determined by using the following projecct-unrelated website: https://cookie.riimu.net/speed/ | |
THESE ARE ABSOLUTE MINIMUMS FOR WINDOWS(Tested on Windows 10 Pro) | |
Refresh rates to MS ratio translations(REL / HLD) | |
10 / 10 = smooth 48Hz | |
9 / 10 = smoothed 48 to 52Hz | |
8 / 10 = semi-smooth 52Hz | |
7 / 10 = smooth 56Hz | |
6 / 10 = semi-smooth 58 to 60Hz | |
*/ | |
/* | |
P90: 30 / 36 with 9 down at each run | |
*/ | |
int delayClickRelAmt = 30; | |
int delayClickHldAmt = 36; | |
//#define maxMoveAmt 4 | |
void setup() { | |
digitalWrite(4, HIGH); | |
//Serial.begin(115200); | |
} | |
void loop() { | |
int currState = my_input; | |
//Serial.println(currState); | |
if (currState == 0) { | |
Mouse.press(1); | |
delay(delayClickHldAmt); | |
Mouse.release(1); | |
//delay(delayClickRelAmt); | |
// P90 anti-coil :D | |
Mouse.move(0, 9); | |
Mouse.move(-1, 0); | |
Mouse.move(1, 0); | |
Mouse.move(0, -1); | |
Mouse.move(0, 1); | |
Mouse.release(1); | |
} | |
delay(delayClickRelAmt); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a basic sketch to allow limited recoil and rapid fire with the P90 on Battlefield 4 in or out of semi-auto fire(there shouldn't really be a difference in fire rate, although I haven't tweaked these values enough to verify).
This does require an Arduino Leonardo or other ATMega32U4-based MCU mouse!
Other mice are untested!
You should be able to easily expand the amount of macro assignments using this sketch.