Hi,
I just re-worded the subject to be a question instead of a statement.
I would like to have add a second function to each of the 4 Dpad buttons, perhaps by using the slider as a mode switch:
ie: slider is to the left, Dpad buttons send keystrokes 1,2,3,4 then slider to the right and Dpad buttons send keystrokes 5,6,7,8.
I got the Esplora for Christmas and so am a new user. Can you show me how to go about this?
Thank you. Here is what I have so far, which since it is a modification to the Tux controller, works for the 1,2,3,4, functions:
/*
8 buttons - add 4 more functions to Dpad by using slider as mode switch
Based on Keyboard emulation By Enrico Gueli
*/
#include <Esplora.h>
boolean buttonStates[8];
const byte buttons[] = {
JOYSTICK_DOWN, // down arrow
JOYSTICK_LEFT, // left arrow
JOYSTICK_UP, // up arrow
JOYSTICK_RIGHT, // right arrow
SWITCH_DOWN, // press 1
SWITCH_LEFT, // press 2
SWITCH_UP, // press 3
SWITCH_RIGHT, // press 4
};
const char keystrokes[] = {
KEY_UP_ARROW,
KEY_UP_ARROW,
KEY_DOWN_ARROW,
KEY_DOWN_ARROW,
'1',
'2',
'3',
'4'
};
void setup() {
Keyboard.begin();
}
void loop() {
// Iterate through all the buttons:
for (byte thisButton = 0; thisButton < 8; thisButton++) {
boolean lastState = buttonStates[thisButton];
boolean newState = Esplora.readButton(buttons[thisButton]);
if (lastState != newState) { // Something changed!
if (newState == PRESSED) {
Keyboard.press(keystrokes[thisButton]);
}
else if (newState == RELEASED) {
Keyboard.release(keystrokes[thisButton]);
}
}
// Store the new button state, so you can sense a difference later:
buttonStates[thisButton] = newState;
int slider = Esplora.readSlider();
byte mode2 = map(slider, 0, 1023, 0, 13);
delay(5);
}}
Thank you for your time.