Browse Source

Initial commit

main
fluffy 5 months ago
commit
91dd90c38e
3 changed files with 81 additions and 0 deletions
  1. +43
    -0
      DDRuino.ino
  2. +21
    -0
      LICENSE
  3. +17
    -0
      README.md

+ 43
- 0
DDRuino.ino View File

@@ -0,0 +1,43 @@
#include <Keyboard.h>

struct Input {
int pin;
int keyCode;
bool state;
};

Input mapping[] = {
{ 1, KEY_RETURN },
{ 2, KEY_ESC },
{ 3, KEY_UP_ARROW },
{ 4, KEY_DOWN_ARROW },
{ 5, KEY_RIGHT_ARROW },
{ 6, KEY_LEFT_ARROW },
};

void setup()
{
for (auto i : mapping) {
pinMode(i.pin, INPUT_PULLUP);
i.state = false;
}

Keyboard.begin();
}

void loop()
{
for (auto& i : mapping) {
bool val = digitalRead(i.pin);
if (val != i.state) {
if (val) {
// TODO debounce
Keyboard.press(i.keyCode);
} else {
Keyboard.release(i.keyCode);
}

i.state = val;
}
}
}

+ 21
- 0
LICENSE View File

@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 j "fluffy" shagam

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

+ 17
- 0
README.md View File

@@ -0,0 +1,17 @@
# DDRuino

A simple DDR controller implementation for Arduino devices

(c)2021 j "fluffy" shagam, fluffy@beesbuzz.biz

## About

I was pretty dissatisfied with the code quality of all of the Arduino-based DDR controller sketches I could find, so I decided to write my own using more-modern C++ with an easier means of configuring things.

This only needs Arduino's default keyboard library, and is intended to let you customize the mapping on a per-pin basis.

## Usage

Modify the `mapping` array to include all of your active pins and their respective buttons. The mapping provided is just how my pad happens to be wired up; yours will probably vary.

If you have two pads in a doubles set, you'll want to set the pads' arrow buttons to be different keys (for example, `wasd` for the left pad and `ijkl` for the right pad).

Loading…
Cancel
Save