The rapper class to move it like MotionEvent in Android.
MotionEventConverter.h@1:5bfc165e8f08, 2016-06-29 (annotated)
- Committer:
- dkato
- Date:
- Wed Jun 29 05:33:35 2016 +0000
- Revision:
- 1:5bfc165e8f08
- Parent:
- 0:c41d29f1e0fb
update
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dkato | 0:c41d29f1e0fb | 1 | /* mbed Microcontroller Library |
dkato | 0:c41d29f1e0fb | 2 | * Copyright (C) 2016 Renesas Electronics Corporation. All rights reserved. |
dkato | 0:c41d29f1e0fb | 3 | * |
dkato | 0:c41d29f1e0fb | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
dkato | 0:c41d29f1e0fb | 5 | * you may not use this file except in compliance with the License. |
dkato | 0:c41d29f1e0fb | 6 | * You may obtain a copy of the License at |
dkato | 0:c41d29f1e0fb | 7 | * |
dkato | 0:c41d29f1e0fb | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
dkato | 0:c41d29f1e0fb | 9 | * |
dkato | 0:c41d29f1e0fb | 10 | * Unless required by applicable law or agreed to in writing, software |
dkato | 0:c41d29f1e0fb | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
dkato | 0:c41d29f1e0fb | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
dkato | 0:c41d29f1e0fb | 13 | * See the License for the specific language governing permissions and |
dkato | 0:c41d29f1e0fb | 14 | * limitations under the License. |
dkato | 0:c41d29f1e0fb | 15 | */ |
dkato | 0:c41d29f1e0fb | 16 | /**************************************************************************//** |
dkato | 0:c41d29f1e0fb | 17 | * @file MotionEventConverter.h |
dkato | 0:c41d29f1e0fb | 18 | * @brief MotionEventConverter API |
dkato | 0:c41d29f1e0fb | 19 | ******************************************************************************/ |
dkato | 0:c41d29f1e0fb | 20 | |
dkato | 0:c41d29f1e0fb | 21 | #ifndef MOTION_EVENT_CONVERTER_H |
dkato | 0:c41d29f1e0fb | 22 | #define MOTION_EVENT_CONVERTER_H |
dkato | 0:c41d29f1e0fb | 23 | |
dkato | 0:c41d29f1e0fb | 24 | #include "mbed.h" |
dkato | 0:c41d29f1e0fb | 25 | #include "rtos.h" |
dkato | 0:c41d29f1e0fb | 26 | #include "MotionEvent.h" |
dkato | 0:c41d29f1e0fb | 27 | #include "TouchKey.h" |
dkato | 0:c41d29f1e0fb | 28 | |
dkato | 0:c41d29f1e0fb | 29 | /** |
dkato | 0:c41d29f1e0fb | 30 | * A class to communicate a MotionEventConverter |
dkato | 0:c41d29f1e0fb | 31 | */ |
dkato | 0:c41d29f1e0fb | 32 | class MotionEventConverter { |
dkato | 0:c41d29f1e0fb | 33 | |
dkato | 0:c41d29f1e0fb | 34 | public: |
dkato | 1:5bfc165e8f08 | 35 | /** Constructor |
dkato | 1:5bfc165e8f08 | 36 | * |
dkato | 1:5bfc165e8f08 | 37 | */ |
dkato | 1:5bfc165e8f08 | 38 | MotionEventConverter(); |
dkato | 1:5bfc165e8f08 | 39 | |
dkato | 0:c41d29f1e0fb | 40 | /** Run the touch panel process. |
dkato | 0:c41d29f1e0fb | 41 | * |
dkato | 1:5bfc165e8f08 | 42 | * @param fptr A pointer to a void function |
dkato | 1:5bfc165e8f08 | 43 | * @param p_touch pointer of TouchKey class |
dkato | 1:5bfc165e8f08 | 44 | */ |
dkato | 1:5bfc165e8f08 | 45 | void Process(int (*fptr)(MotionEvent event), TouchKey * p_touch) { |
dkato | 1:5bfc165e8f08 | 46 | _callback.attach(fptr); |
dkato | 1:5bfc165e8f08 | 47 | touch_process(p_touch); |
dkato | 1:5bfc165e8f08 | 48 | } |
dkato | 1:5bfc165e8f08 | 49 | |
dkato | 1:5bfc165e8f08 | 50 | /** Run the touch panel process. |
dkato | 0:c41d29f1e0fb | 51 | * |
dkato | 1:5bfc165e8f08 | 52 | * @param tptr pointer to the object to call the member function on |
dkato | 1:5bfc165e8f08 | 53 | * @param mptr pointer to the member function to be called |
dkato | 1:5bfc165e8f08 | 54 | * @param p_touch pointer of TouchKey class |
dkato | 0:c41d29f1e0fb | 55 | */ |
dkato | 1:5bfc165e8f08 | 56 | template<typename T> |
dkato | 1:5bfc165e8f08 | 57 | void Process(T* tptr, int (T::*mptr)(MotionEvent event), TouchKey * p_touch) { |
dkato | 1:5bfc165e8f08 | 58 | _callback.attach(tptr, mptr); |
dkato | 1:5bfc165e8f08 | 59 | touch_process(p_touch); |
dkato | 1:5bfc165e8f08 | 60 | } |
dkato | 0:c41d29f1e0fb | 61 | |
dkato | 0:c41d29f1e0fb | 62 | private: |
dkato | 1:5bfc165e8f08 | 63 | TouchKey * p_touch; |
dkato | 0:c41d29f1e0fb | 64 | MotionEventCtl event; |
dkato | 0:c41d29f1e0fb | 65 | Timer t; |
dkato | 1:5bfc165e8f08 | 66 | Semaphore sem_touch_int; |
dkato | 0:c41d29f1e0fb | 67 | TouchKey::touch_pos_t touch_pos[MotionEvent::TOUCH_NUM_MAX]; |
dkato | 0:c41d29f1e0fb | 68 | TouchKey::touch_pos_t touch_pos_last[MotionEvent::TOUCH_NUM_MAX]; |
dkato | 0:c41d29f1e0fb | 69 | uint32_t time_cnt; |
dkato | 0:c41d29f1e0fb | 70 | int pidx; |
dkato | 0:c41d29f1e0fb | 71 | uint8_t touch_num; |
dkato | 0:c41d29f1e0fb | 72 | uint8_t touch_num_last; |
dkato | 1:5bfc165e8f08 | 73 | FunctionPointerArg1<int, MotionEvent> _callback; |
dkato | 1:5bfc165e8f08 | 74 | |
dkato | 1:5bfc165e8f08 | 75 | void touch_process(TouchKey * p_touch); |
dkato | 1:5bfc165e8f08 | 76 | void touch_int_callback(void); |
dkato | 0:c41d29f1e0fb | 77 | }; |
dkato | 0:c41d29f1e0fb | 78 | |
dkato | 0:c41d29f1e0fb | 79 | #endif |