I am attempting to reprogram a MakeyMakey board based on Arduino. I got as far as finding the lines of code that need to be changed, but I have a fairly atypical change to make.
Basically, the board has several inputs that can act as buttons on a keyboard or mouse. I need to change those buttons to act as Shift+1
So for example this is the current line of code:
KEY_DOWN_ARROW, // down arrow pad
I need to know how to change that to give me shift and a number. I know changing it to KEY_LEFT_SHIFT will turn the input into a left shift key, but I'm unsure how to add the 1.
Those have the look of #define constants. You should look in the library you included to get them to find the actual values and if you can, work out the one you want and make a #define for that.
I'm not really sure what other information I can give you. I just need to change one line of code, I even know how, but am unsure as to what to change it to. I already tried the forums for this specific device, but they are quite the ghost town.
You need to post the whole sketch. A single line with a comma at the end (meaning that it's just a part of a statement) is not enough to give a useful answer.
#include "Arduino.h"
/*
/////////////////////////////////////////////////////////////////////////
// KEY MAPPINGS: WHICH KEY MAPS TO WHICH PIN ON THE MAKEY MAKEY BOARD? //
/////////////////////////////////////////////////////////////////////////
- edit the keyCodes array below to change the keys sent by the MaKey MaKey for each input
- the comments tell you which input sends that key (for example, by default 'w' is sent by pin D5)
- change the keys by replacing them. for example, you can replace 'w' with any other individual letter,
number, or symbol on your keyboard
- you can also use codes for other keys such as modifier and function keys (see the
the list of additional key codes at the bottom of this file)
*/
int keyCodes[NUM_INPUTS] = {
// top side of the makey makey board
KEY_UP_ARROW, // up arrow pad
KEY_DOWN_ARROW, // down arrow pad
KEY_LEFT_ARROW, // left arrow pad
KEY_RIGHT_ARROW, // right arrow pad
' ', // space button pad
MOUSE_LEFT, // click button pad
// female header on the back left side
'w', // pin D5
'a', // pin D4
's', // pin D3
'd', // pin D2
'f', // pin D1
'g', // pin D0
// female header on the back right side
MOUSE_MOVE_UP, // pin A5
MOUSE_MOVE_DOWN, // pin A4
MOUSE_MOVE_LEFT, // pin A3
MOUSE_MOVE_RIGHT, // pin A2
MOUSE_LEFT, // pin A1
MOUSE_RIGHT // pin A0
};
///////////////////////////
// NOISE CANCELLATION /////
///////////////////////////
#define SWITCH_THRESHOLD_OFFSET_PERC 5 // number between 1 and 49
// larger value protects better against noise oscillations, but makes it harder to press and release
// recommended values are between 2 and 20
// default value is 5
#define SWITCH_THRESHOLD_CENTER_BIAS 55 // number between 1 and 99
// larger value makes it easier to "release" keys, but harder to "press"
// smaller value makes it easier to "press" keys, but harder to "release"
// recommended values are between 30 and 70
// 50 is "middle" 2.5 volt center
// default value is 55
// 100 = 5V (never use this high)
// 0 = 0 V (never use this low
/////////////////////////
// MOUSE MOTION /////////
/////////////////////////
#define MOUSE_MOTION_UPDATE_INTERVAL 35 // how many loops to wait between
// sending mouse motion updates
#define PIXELS_PER_MOUSE_STEP 4 // a larger number will make the mouse
// move faster
#define MOUSE_RAMP_SCALE 150 // Scaling factor for mouse movement ramping
// Lower = more sensitive mouse movement
// Higher = slower ramping of speed
// 0 = Ramping off
#define MOUSE_MAX_PIXELS 10 // Max pixels per step for mouse movement
/*
///////////////////////////
// ADDITIONAL KEY CODES ///
///////////////////////////
- you can use these codes in the keyCodes array above
- to get modifier keys, function keys, etc
KEY_LEFT_CTRL
KEY_LEFT_SHIFT
KEY_LEFT_ALT
KEY_LEFT_GUI
KEY_RIGHT_CTRL
KEY_RIGHT_SHIFT
KEY_RIGHT_ALT
KEY_RIGHT_GUI
KEY_BACKSPACE
KEY_TAB
KEY_RETURN
KEY_ESC
KEY_INSERT
KEY_DELETE
KEY_PAGE_UP
KEY_PAGE_DOWN
KEY_HOME
KEY_END
KEY_CAPS_LOCK
KEY_F1
KEY_F2
KEY_F3
KEY_F4
KEY_F5
KEY_F6
KEY_F7
KEY_F8
KEY_F9
KEY_F10
KEY_F11
KEY_F12
*/
hunterjwizzard:
I just need to change one line of code
In that case you have the advantage over the rest of us, because we have no idea what that line of code does or what effect changing it would have, so no idea what change would produce the effect you are hoping for. I suggest you post your whole code, describe what it does currently and what you want it to do instead.
I think that in order to answer this question, it would be necessary to understand how shifted characters are sent using this library. Unfortunately I'm not familiar with it and don't know. If the library is sending scan codes, you might need to send key down & key up events for the shift key. If it's sending virtual keys there might be a way to include a modifier in the event to indicate what other modifier keys are down. Unless you can find documentation that explains this, or somebody else who already knows, I suspect your best bet would be to track down the definitions of those constant values mentioned in the header file and see whether there are any recognisable definitions for modifiers such as shift, or for the symbol that you are trying to send. If not, follow down into the code that sends the keyboard event and see whether it has any support for modifiers to be associated with the event.