![overwatch activation mccree overwatch activation mccree](https://static.wikia.nocookie.net/overwatch_gamepedia/images/3/38/AsheMcCree-rebels.jpg)
A small inconvenience, but an inconvenience nonetheless.Īs an aside, the wires for the capacitive sensor’s antenna run through the hand grip, which means that I can detect whether someone is holding the controller or not.
![overwatch activation mccree overwatch activation mccree](https://www.dexerto.com/wp-content/uploads/2020/01/Overwatch-McCree-Deadeye-Ultimate-Havana.png)
Running the auto-calibration this way means I need to pull the trigger after the gun starts up before the capacitive sensor will work properly. A nice perk of the autocalibration is that it works off of the lowest-sensed value, so if I do accidentally set the calibration when I’m “pressing” the capacitive button it will re-calibrate as soon as I let go and its value drifts below the zero’d level. The trigger is something that shouldn’t be getting pulled when aim inputs are disabled, and the rotary encoder seems to interfere with the sensor (induction on the PCB?). The solution I came up with was to activate the library’s auto-calibrate feature manually every time the trigger was pulled or the cylinder was spun. The timer-based autocalibration was unreliable because would reset the calibration when I was holding the button. When I set static values it worked fine but occasionally I would pick it up and the baseline level would be different, so I had to find a way to set the threshold values on the fly. The other thing I noticed is that because the sensor picks up stray capacitance, everything from the weather to the time of day and the cycle of the moon will influence it. The sample count and timeout values were mostly trial-and-error, trying to keep the polling time low while still keeping a clear distinction between a “pressed” and “unpressed” state (thumb on top of the sensor or clear from it). One thing I noticed while testing is that when using my left hand to pull the hammer back it would trigger the capacitive sensor, so the function is configured to not return a ‘true’ value if the hammer button is currently active. If this variable is greater than 75 (arbitrary limit) the sensor is seen as “active”. The handleIMU function calls capRead, which reads the capacitive sensor with 15 samples and returns a unit-less variable representing the relative capacitance. The only exception to this is the rotary encoder, but since I only care about whether it’s turned and not how far it’s turned (within reason) this is not a concern. Everything is at a human time scale so I shouldn’t need to worry about missing updates. Translated to English, that means that so long as polling works it’s acceptable.
Overwatch activation mccree code#
Although even if it was, both the capacitive sensor and the LED code disable interrupts and I’m not sure if the keyboard / mouse libraries would process their outputs enough to allow the I 2C interrupts to work as designed. I have a few reasons for this, not least of which is that due to my routing limitations the PCB was not made with inputs mapped to interrupt-capable pins. But I’m going to use polling for this controller. This is a classic question with a fairly definitive answer: when possible, interrupts will always be preferred over polling. If I wanted to create classes for different parts of the code I would need to include separate header and implementation files, which seems excessive for something relatively simple like this. Because of how the IDE is set up, I can’t create classes or structs for each part of the controller inside of main. I’m going to be programming the controller using the back-to-basics Arduino IDE. Programming Principlesīefore talking about the code itself, I need to cover two overall things about how the program is going to be written.
Overwatch activation mccree series#
This post is part of a series on creating a custom controller for Overwatch using a Nerf revolver. The hardware is done and the Nerf gun is assembled, so all that’s left is to write the code to drive the controller!