I have a decent level of programming skill, or at least I thought so. I've been getting an error when compiling this Ardulno sketch. I don't really know what this error means or how to fix it. What's wrong with my code that's causing these errors. I was in the middle of making a big change to my code, so a lot of it is commented out because I haven't gotten to those parts.
code:
#include <LinkedList.h>
const uint8_t PinLeft = 2;
const uint8_t PinMiddle = 3;
const uint8_t PinRight = 4;
const uint8_t PinLED = 13;
enum MouseButtons {LEFT, MIDDLE, RIGHT} ;
bool leftPressed = false;
bool middlePressed = false;
bool rightPressed = false;
void sendMouseState() {
if (leftPressed == true && middlePressed == false && rightPressed == false) {
Mouse.set_buttons(1, 0, 0);
} else if (leftPressed == true && middlePressed == true && rightPressed == false) {
Mouse.set_buttons(1, 1, 0);
} else if (leftPressed == true && middlePressed == true && rightPressed == true) {
Mouse.set_buttons(1, 1, 1);
} else if (leftPressed == true && middlePressed == false && rightPressed == true) {
Mouse.set_buttons(1, 0, 1);
} else if (leftPressed == false && middlePressed == true && rightPressed == false) {
Mouse.set_buttons(0, 1, 0);
} else if (leftPressed == false && middlePressed == false && rightPressed == true) {
Mouse.set_buttons(0, 0, 1);
} else if (leftPressed == false && middlePressed == true && rightPressed == true) {
Mouse.set_buttons(0, 1, 1);
} else if (leftPressed == false && middlePressed == false && rightPressed == false) {
Mouse.set_buttons(0, 0, 0);
}
}
void mouseButtonPress(MouseButtons theButton);
void mouseButtonPress(MouseButtons theButton) {
if (theButton == MouseButtons::LEFT) {
leftPressed = true;
} else if(theButton == MouseButtons::MIDDLE) {
middlePressed = true;
} else if (theButton == MouseButtons::RIGHT) {
rightPressed = true;
}
}
void mouseButtonRelease(MouseButtons button);
void mouseButtonRelease(MouseButtons button) {
if (button == LEFT) {
leftPressed = false;
} else if(button == MIDDLE) {
middlePressed = false;
} else if (button == RIGHT) {
rightPressed = false;
}
}
volatile unsigned int nextPressLeft = 0;
volatile unsigned int nextPressCenter = 0;
volatile unsigned int nextPressRight = 0;
const int timeBetween = 150; //milliseconds
enum ActionType {KB, MOU}; //keyboard or mouse
class Action {
public:
uint16_t keyCode;
ActionType actionType;
Action (uint16_t keyCode, ActionType actionType) {
this->keyCode = keyCode;
this->actionType = actionType;
}
};
class ModeAction {
public:
LinkedList<Action> *keys = new LinkedList<Action>();
void addAction(Action action) {
keys->add(action);
}
};
class ActionManager {
private:
uint8_t modeL = 1;
uint8_t modeM = 1;
uint8_t modeR = 1;
LinkedList<ModeAction> *lActions = new LinkedList<ModeAction>();
LinkedList<ModeAction> *mActions=new LinkedList<ModeAction>();
LinkedList<ModeAction> *rActions=new LinkedList<ModeAction>();
bool lActing = false, mActing = false, rActing = false;
public:
ActionManager() {
//actions for left switch
//mode 1
lActions->add(ModeAction());
lActions->get(lActions->size() - 1).addAction(Action(MouseButtons.LEFT, ActionType.MOU));
//mode 2
lActions->add(ModeAction());
lActions->get(lActions->size() - 1).addAction(Action(KEY_F11, ActionType.KB));
//mode 3
lActions->add(ModeAction());
lActions->get(lActions->size() - 1).addAction(Action(KEY_LEFT_CTRL, ActionType.KB));
lActions->get(lActions->size() - 1).addAction(Action(KEY_LEFT_ALT, ActionType.KB));
//mode 4
lActions->add(ModeAction());
lActions->get(lActions->size() - 1).addAction(Action(KEY_W, ActionType.KB));
//actions for middle switch
//mode 1
mActions->add(ModeAction());
mActions->get(lActions->size() - 1).addAction(Action(MouseButtons.MIDDLE, ActionType.MOU));
//actions for right switch
//mode 1
rActions->add(ModeAction());
rActions->get(lActions->size() - 1).addAction(Action(MouseButtons.RIGHT, ActionType.MOU));
}
void cycleModeL() {
this->modeL++;
if(this->modeL >= lActions->size()) {
this->modeL = 1;
}
}
void cycleModeM() {
this->modeM++;
if(this->modeM >= mActions->size()) {
this->modeM = 1;
}
}
void cycleModeR() {
this->modeR++;
if(this->modeR >= rActions->size()) {
this->modeR = 1;
}
}
private:
//void doDownActions(ModeAction modeActions, uint8_t mode) {
//for (int i = 0; i < modeActions.at(mode).keys.length(); i++) {
//if (modeActions[mode][i].keys[i].actionType == ActionType.KB) {
//Keyboard.press(modeActions[mode].keys[i].keyCode)
//} else if (modeActions[mode].keys[i].actionType == ActionType.MOU) {
//mouseButtonPress(modeActions[mode].keys[i].keyCode);
//}
//}
//sendMouseState();
//}
//
//void doUpActions(ModeAction modeActions, uint8_t mode) {
//for (int i = 0; i < modeActions[mode].keys.length(); i++) {
//if (modeActions[mode][i].keys[i].actionType == ActionType.KB) {
//Keyboard.release(modeActions[mode].keys[i].keyCode)
//} else if (modeActions[mode].keys[i].actionType == ActionType.MOU) {
//mouseButtonRelease(modeActions[mode].keys[i].keyCode);
//}
//}
//sendMouseState();
//}
public:
//void leftDown() {
//if (lActing == false) {
//lActing = true;
//doDownActions(lActions, modeL);
//}
//}
//
//void middleDown() {
//if (mActing == false) {
//mActing = true;
//doDownActions(mActions, modeM);
//}
//}
//
//void rightDown() {
//if (rActing == false) {
//rActing = true;
//doDownActions(rActions, modeR);
//}
//}
//
//void leftUp() {
//if (lActing == true) {
//lActing = false;
//doUpActions(lActions, modeL);
//}
//}
//
//void middleUp() {
//if (mActing == true) {
//mActing = false;
//doUpActions(mActions, modeM);
//}
//}
//
//void rightUp() {
//if (rActing == true) {
//rActing = false;
//doUpActions(rActions, modeR);
//}
//}
};
ActionManager actionManager = ActionManager();
void setup() {
Serial.begin(115200);
pinMode(PinLED, OUTPUT);
//pinMode(PinRight, INPUT_PULLUP); // sets the digital pin as output
//attachInterrupt(PinRight, isrChangeR, CHANGE); // interrrupt is data ready
//
//pinMode(PinMiddle, INPUT_PULLUP); // sets the digital pin as output
//attachInterrupt(PinMiddle, isrChangeM, CHANGE); // interrrupt is data ready
//
//pinMode(PinLeft, INPUT_PULLUP); // sets the digital pin as output
//attachInterrupt(PinLeft, isrChangeL, CHANGE); // interrrupt is data ready
}
void loop() {
//if (Serial.available()) {
////change mode
//mode = Serial.parseInt();
//
////release all buttons
//Keyboard.releaseAll();
//Mouse.set_buttons(0, 0, 0);
//
////turn off LED
//digitalWrite(PinLED, LOW);
//
////flush the serial input buffer
//while (Serial.available()) {
//Serial.read();
//}
//
//}
//delay(1000);
//Serial.println("Running");
}
//void isrChangeL() {
//cli();
//if (digitalRead(PinLeft) == LOW && nextPressLeft < millis()) {
////Serial.println("Pressed");
//digitalWrite(PinLED, HIGH); //set the LED on
//
//if (mode == 0) {
//Mouse.set_buttons(1, 0, 0);
//} else if (mode == 1) {
//Keyboard.press(KEY_F11);
//} else if (mode == 2) {
//Keyboard.press(KEY_LEFT_CTRL);
//Keyboard.press(KEY_LEFT_ALT);
//} else if (mode == 3) {
//Keyboard.press(KEY_W);
//}
//
//nextPressLeft = millis() + timeBetween;
//
//} else {
//// Serial.println("Released");
//digitalWrite(PinLED, LOW); // set the LED off
//
//if (mode == 0) {
//Mouse.set_buttons(0, 0, 0);
//} else if (mode == 1) {
//Keyboard.release(KEY_F11);
//} else if (mode == 2) {
//Keyboard.release(KEY_LEFT_CTRL);
//Keyboard.release(KEY_LEFT_ALT);
//} else if (mode == 3) {
//Keyboard.release(KEY_W);
//}
//
//nextPressLeft = millis() + timeBetween * 0.6;
//
//
//}
//sei();
//}
//
//void isrChangeM() {
//cli();
////if (digitalRead(PinMiddle) == LOW && nextPressCenter < millis())
////{
////Keyboard.press(KEY_SPACE);
////delay(250);
////Keyboard.release(KEY_SPACE);
////}
//
//if (digitalRead(PinMiddle) == LOW && nextPressCenter < millis()) {
////Serial.println("Pressed");
//digitalWrite(PinLED, HIGH); //set the LED on
////Mouse.set_buttons(0, 1, 0);
//
//nextPressCenter = millis() + timeBetween;
//
//} else {
//// Serial.println("Released");
//digitalWrite(PinLED, LOW); // set the LED off
////Mouse.set_buttons(0, 0, 0);
//
//nextPressCenter = millis() + timeBetween * 0.6;
//
//
//}
//
//sei();
//}
//
//void isrChangeR() {
//cli();
//if (digitalRead(PinRight) == LOW && nextPressRight < millis()) {
////Serial.println("Pressed");
//digitalWrite(PinLED, HIGH); // set the LED on
//Mouse.set_buttons(0, 0, 1);
////Keyboard.press(KEY_F11);
//nextPressRight = millis() + timeBetween;
//} else {
//// Serial.println("Released");
//digitalWrite(PinLED, LOW); // set the LED off
//Mouse.set_buttons(0, 0, 0);
////Keyboard.release(KEY_F11);
//nextPressRight = millis() + timeBetween * 0.6;
//}
//sei();
//}
compiler log:
Compiling debug version of 'click_switch_5_cycling' for 'Teensy LC'
click_switch_5_cycling.ino: In constructor ActionManager::ActionManager()
click_switch_5_cycling.ino: 106:53: error: expected primary-expression before '(' token
click_switch_5_cycling.ino: 106:66: error: expected primary-expression before '.' token
click_switch_5_cycling.ino: 106:83: error: expected primary-expression before '.' token
click_switch_5_cycling.ino: 109:53: error: expected primary-expression before '(' token
click_switch_5_cycling.ino: 109:73: error: expected primary-expression before '.' token
click_switch_5_cycling.ino: 112:53: error: expected primary-expression before '(' token
click_switch_5_cycling.ino: 112:79: error: expected primary-expression before '.' token
click_switch_5_cycling.ino: 113:53: error: expected primary-expression before '(' token
click_switch_5_cycling.ino: 113:78: error: expected primary-expression before '.' token
click_switch_5_cycling.ino: 116:53: error: expected primary-expression before '(' token
click_switch_5_cycling.ino: 116:71: error: expected primary-expression before '.' token
click_switch_5_cycling.ino: 121:53: error: expected primary-expression before '(' token
click_switch_5_cycling.ino: 121:66: error: expected primary-expression before '.' token
click_switch_5_cycling.ino: 121:85: error: expected primary-expression before '.' token
click_switch_5_cycling.ino: 126:53: error: expected primary-expression before '(' token
click_switch_5_cycling.ino: 126:66: error: expected primary-expression before '.' token
click_switch_5_cycling.ino: 126:84: error: expected primary-expression before '.' token
click_switch_5_cycling.ino:1: In file included from
LinkedList.h: In instantiation of bool LinkedList<T>::add(T) [with T = Action]
click_switch_5_cycling.ino:83: required from here
LinkedList.h: 192:37: error: use of deleted function 'ListNode<Action>::ListNode()
ListNode<T> *tmp = new ListNode<T>()
LinkedList.h:19: note ListNode<Action> ListNode() is implicitly deleted because the default definition would be ill-formed
struct ListNode
LinkedList.h: 19:8: error: no matching function for call to 'Action::Action()
click_switch_5_cycling.ino:70: note candidate Action Action(uint16_t, ActionType)
this->actionType = actionType
click_switch_5_cycling.ino:70: note candidate expects 2 arguments, 0 provided
click_switch_5_cycling.ino:65: note candidate constexpr Action Action(const Action&)
uint16_t keyCode
click_switch_5_cycling.ino:65: note candidate expects 1 argument, 0 provided
click_switch_5_cycling.ino:65: note candidate constexpr Action Action(Action&&)
click_switch_5_cycling.ino:65: note candidate expects 1 argument, 0 provided
click_switch_5_cycling.ino:1: In file included from
LinkedList.h: In instantiation of ListNode<T>* LinkedList<T>::getNode(int) [with T = ModeAction]
LinkedList.h:314: required from T LinkedList<T> get(int) [with T = ModeAction]
click_switch_5_cycling.ino:106: required from here
LinkedList.h: 160:9: warning: converting 'false' to pointer type 'ListNode<ModeAction>*' [-Wconversion-null]
return false
LinkedList.h: In instantiation of bool LinkedList<T>::add(int, T) [with T = Action]
click_switch_5_cycling.ino:262: required from here
LinkedList.h: 177:37: error: use of deleted function 'ListNode<Action>::ListNode()
ListNode<T> *tmp = new ListNode<T>()
LinkedList.h: In instantiation of bool LinkedList<T>::unshift(T) [with T = Action]
click_switch_5_cycling.ino:262: required from here
LinkedList.h: 218:37: error: use of deleted function 'ListNode<Action>::ListNode()
ListNode<T> *tmp = new ListNode<T>()
LinkedList.h: In instantiation of T LinkedList<T>::remove(int) [with T = Action]
click_switch_5_cycling.ino:262: required from here
LinkedList.h: 290:12: error: no matching function for call to 'Action::Action()
return T()
click_switch_5_cycling.ino:70: note candidate Action Action(uint16_t, ActionType)
this->actionType = actionType
click_switch_5_cycling.ino:70: note candidate expects 2 arguments, 0 provided
click_switch_5_cycling.ino:65: note candidate constexpr Action Action(const Action&)
uint16_t keyCode
click_switch_5_cycling.ino:65: note candidate expects 1 argument, 0 provided
click_switch_5_cycling.ino:65: note candidate constexpr Action Action(Action&&)
Error compiling project sources
click_switch_5_cycling.ino:65: note candidate expects 1 argument, 0 provided
Debug build failed for project 'click_switch_5_cycling'
click_switch_5_cycling.ino:1: In file included from
LinkedList.h: In instantiation of T LinkedList<T>::pop() [with T = Action]
click_switch_5_cycling.ino:262: required from here
LinkedList.h: 242:12: error: no matching function for call to 'Action::Action()
return T()
click_switch_5_cycling.ino:70: note candidate Action Action(uint16_t, ActionType)
this->actionType = actionType
click_switch_5_cycling.ino:70: note candidate expects 2 arguments, 0 provided
click_switch_5_cycling.ino:65: note candidate constexpr Action Action(const Action&)
uint16_t keyCode
click_switch_5_cycling.ino:65: note candidate expects 1 argument, 0 provided
click_switch_5_cycling.ino:65: note candidate constexpr Action Action(Action&&)
click_switch_5_cycling.ino:65: note candidate expects 1 argument, 0 provided
click_switch_5_cycling.ino:1: In file included from
LinkedList.h: In instantiation of T LinkedList<T>::shift() [with T = Action]
click_switch_5_cycling.ino:262: required from here
LinkedList.h: 268:12: error: no matching function for call to 'Action::Action()
return T()
click_switch_5_cycling.ino:70: note candidate Action Action(uint16_t, ActionType)
this->actionType = actionType
click_switch_5_cycling.ino:70: note candidate expects 2 arguments, 0 provided
click_switch_5_cycling.ino:65: note candidate constexpr Action Action(const Action&)
uint16_t keyCode
click_switch_5_cycling.ino:65: note candidate expects 1 argument, 0 provided
click_switch_5_cycling.ino:65: note candidate constexpr Action Action(Action&&)
click_switch_5_cycling.ino:65: note candidate expects 1 argument, 0 provided
click_switch_5_cycling.ino:1: In file included from
LinkedList.h: In instantiation of T LinkedList<T>::get(int) [with T = Action]
click_switch_5_cycling.ino:262: required from here
LinkedList.h: 316:14: error: no matching function for call to 'Action::Action()
T())
click_switch_5_cycling.ino:70: note candidate Action Action(uint16_t, ActionType)
this->actionType = actionType
click_switch_5_cycling.ino:70: note candidate expects 2 arguments, 0 provided
click_switch_5_cycling.ino:65: note candidate constexpr Action Action(const Action&)
uint16_t keyCode
click_switch_5_cycling.ino:65: note candidate expects 1 argument, 0 provided
click_switch_5_cycling.ino:65: note candidate constexpr Action Action(Action&&)
click_switch_5_cycling.ino:65: note candidate expects 1 argument, 0 provided
Thanks for any help you can give me about what these errors are and how to fix them.