Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: KeyboardManager/kbd_mgr/KeyboardStateEventServer.h
- Revision:
- 0:1324e7d9d471
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/KeyboardManager/kbd_mgr/KeyboardStateEventServer.h Mon Mar 07 22:51:19 2011 +0000
@@ -0,0 +1,43 @@
+#ifndef KEYBOARD_STATE_EVENT_SERVER_H_
+#define KEYBOARD_STATE_EVENT_SERVER_H_
+
+#include "kbd_mgr/KeyboardEventServer.h"
+#include "kbd_mgr/KeyboardStateHandler.h"
+
+namespace kbd_mgr {
+
+/**
+ * @brief A keyboard state handler that reports only state changes.
+ */
+class KeyboardStateEventServer : public KeyboardEventServer<KeyboardStateHandler> {
+public:
+ /**
+ * @brief Attaches the monitor to a function.
+ * @param fn Event handler called to report keyboard state change.
+ */
+ void attach(FunctionKeyboardStateHandler::HandlerFunction fn) {
+ setHandler(new FunctionKeyboardStateHandler(fn));
+ }
+
+ /**
+ * @brief Attaches the monitor to a method of an object.
+ * @param obj Event handler object
+ * @param fn Event handler method called to report keyboard state after each complete scan.
+ */
+ template <class T>
+ void attach(T *obj, typename MemberKeyboardStateHandler<T>::MemberFunction fn) {
+ setHandler(new MemberKeyboardStateHandler<T>(obj, fn));
+ }
+
+ using KeyboardEventServer<KeyboardStateHandler>::attach;
+
+ void invokeHandler(const KeyboardState &state) {
+ if (this->hasHandler()) {
+ this->handler()->handleState(state);
+ }
+ }
+};
+
+} // kbd_mgr
+
+#endif // KEYBOARD_STATE_EVENT_SERVER_H_