arduino help?

General GBZ-related chat goes here. Share ideas, tips and tricks, or ask questions that don't fit into the hardware/software help forums.
Post Reply
User avatar
jostie94
Posts: 51
Joined: Sat Apr 01, 2017 3:34 am
Location: the netherlands
Has thanked: 5 times
Been thanked: 28 times

arduino help?

Post by jostie94 » Sat Apr 29, 2017 7:44 am

hi,
I added an extra tact switch on my GBZ. I want to set this switch as an alt key and change my A, B, X, Y input to f2, f1, esc, f9.
i changed the hotkey behaviour in retroarch. when the alt key is pressed the A, B, X, Y buttons need to change to hotkeys, like save state and exit emulator.

how do i change the key input in arduino to esc, f1, f2, f9 and ALT? (Using a teensy Lc)
Or does anyone have an arduino code for me that contains the alt, esc, f1, etc?
and how do i add an Thirteenth button to the arduino code?
my GBZ builds:
1) http://www.sudomod.com/forum/viewtopic.php?f=9&t=3197
------------------------------------------------------------------------------------------

User avatar
jostie94
Posts: 51
Joined: Sat Apr 01, 2017 3:34 am
Location: the netherlands
Has thanked: 5 times
Been thanked: 28 times

Re: arduino help?

Post by jostie94 » Mon May 01, 2017 1:03 pm

got it! I have rewrite the arduino code:

Code: Select all

#include <Bounce.h>

#define NUM_KEYS 13

struct Key {
  int keycode;
  Bounce* bounce;
};

Key keys[NUM_KEYS];

Key key(int keycode, int pin) {
  Key *ret = new Key;
  ret->keycode = keycode;
  ret->bounce = new Bounce(pin, 100);
  pinMode(pin, INPUT_PULLUP);
  return *ret;
}

void setupKeys() {
  keys[0] = key(KEY_RETURN, 0);
  keys[1] = key('b', 1);
  keys[2] = key(KEY_F3, 2);
  keys[3] = key(KEY_F2, 3);
  keys[4] = key(KEY_ESC, 4);
  keys[5] = key(KEY_F1, 5);
  keys[6] = key(KEY_RIGHT_ARROW, 6);
  keys[7] = key(KEY_DOWN_ARROW, 7);
  keys[8] = key(KEY_UP_ARROW, 8);
  keys[9] = key(KEY_LEFT_ARROW, 9);
  keys[10] = key('l',10);
  keys[11] = key('r',11);
  keys[12] = key(KEY_LEFT_ALT, 12);
  }

void setup() {
  setupKeys();
  Keyboard.begin();
  //  pinMode(0, INPUT_PULLUP);
}

void loop() {
  for (int i = 0; i < NUM_KEYS; i++) {
    keys[i].bounce->update();
    if (keys[i].bounce->fallingEdge()) {
      Keyboard.press(keys[i].keycode);
    } else if (keys[i].bounce->risingEdge()) {
      Keyboard.release(keys[i].keycode);
    }
  }
}
my GBZ builds:
1) http://www.sudomod.com/forum/viewtopic.php?f=9&t=3197
------------------------------------------------------------------------------------------

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest