Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Keyboard and Mouse object instantiation into a function to reduce user-part binary size #1224

Merged
merged 1 commit into from Jan 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion wiring/inc/spark_wiring_usbkeyboard.h
Expand Up @@ -61,7 +61,9 @@ class USBKeyboard : public Print
void sendReport();
};

extern USBKeyboard Keyboard;
extern USBKeyboard& _fetch_usbkeyboard();
#define Keyboard _fetch_usbkeyboard()

#endif

#endif
4 changes: 3 additions & 1 deletion wiring/inc/spark_wiring_usbmouse.h
Expand Up @@ -98,7 +98,9 @@ class USBMouse
bool isPressed(uint8_t button = MOUSE_LEFT); // check LEFT by default
};

extern USBMouse Mouse;
extern USBMouse& _fetch_usbmouse();
#define Mouse _fetch_usbmouse()

#endif

#endif
8 changes: 6 additions & 2 deletions wiring/src/spark_wiring_usbkeyboard.cpp
Expand Up @@ -354,6 +354,10 @@ void USBKeyboard::sendReport()
}
}

//Preinstantiate Object
USBKeyboard Keyboard;
USBKeyboard& _fetch_usbkeyboard()
{
static USBKeyboard _usbkeyboard;
return _usbkeyboard;
}

#endif
8 changes: 6 additions & 2 deletions wiring/src/spark_wiring_usbmouse.cpp
Expand Up @@ -187,6 +187,10 @@ void USBMouse::enableMoveTo(bool state)
HAL_USB_HID_Set_State(0x03, (uint8_t)state, nullptr);
}

//Preinstantiate Object
USBMouse Mouse;
USBMouse& _fetch_usbmouse()
{
static USBMouse _usbmouse;
return _usbmouse;
}

#endif