55 |
55 |
56 // Capture keys for primary camera |
56 // Capture keys for primary camera |
57 mPrimaryCameraCaptureKeys.append(CXUI_CAPTURE_KEY_CODE1); |
57 mPrimaryCameraCaptureKeys.append(CXUI_CAPTURE_KEY_CODE1); |
58 mPrimaryCameraCaptureKeys.append(CXUI_CAPTURE_KEY_CODE2); |
58 mPrimaryCameraCaptureKeys.append(CXUI_CAPTURE_KEY_CODE2); |
59 |
59 |
60 listenKeys(true); |
60 startListeningKeys(); |
61 CX_DEBUG_EXIT_FUNCTION(); |
61 CX_DEBUG_EXIT_FUNCTION(); |
62 } |
62 } |
63 |
63 |
64 CxuiCaptureKeyHandlerPrivate::~CxuiCaptureKeyHandlerPrivate() |
64 CxuiCaptureKeyHandlerPrivate::~CxuiCaptureKeyHandlerPrivate() |
65 { |
65 { |
66 CX_DEBUG_ENTER_FUNCTION(); |
66 CX_DEBUG_ENTER_FUNCTION(); |
67 listenKeys(false); |
67 stopListeningKeys(); |
68 CX_DEBUG_EXIT_FUNCTION(); |
68 CX_DEBUG_EXIT_FUNCTION(); |
69 } |
69 } |
70 |
70 |
71 /*! |
71 /*! |
72 * Start or stop listening key events. |
72 * Starts listening key events. |
73 * @param listen Should we start (true) or stop (false) listening key events. |
|
74 */ |
73 */ |
75 void CxuiCaptureKeyHandlerPrivate::listenKeys(bool listen) |
74 void CxuiCaptureKeyHandlerPrivate::startListeningKeys() |
76 { |
75 { |
77 CX_DEBUG_ENTER_FUNCTION(); |
76 CX_DEBUG_ENTER_FUNCTION(); |
|
77 // Protect from multiple calls |
|
78 if (mCapturedKeyUpDownHandles.empty() && mCapturedKeyHandles.empty()) { |
78 |
79 |
79 if (listen) { |
80 int key(0); |
80 // Protect from multiple calls |
81 foreach (key, mPrimaryCameraAutofocusKeys) { |
81 if (mCapturedKeyUpDownHandles.empty() && mCapturedKeyHandles.empty()) { |
82 CX_DEBUG(("CxuiCaptureKeyHandlerPrivate - hooking autofocus key with scan / key code: %d", key)); |
|
83 listenKey(key); |
|
84 } |
|
85 foreach (key, mPrimaryCameraCaptureKeys) { |
|
86 CX_DEBUG(("CxuiCaptureKeyHandlerPrivate - hooking capture key with scan / key code: %d", key)); |
|
87 listenKey(key); |
|
88 } |
|
89 } |
|
90 CX_DEBUG_EXIT_FUNCTION(); |
|
91 } |
82 |
92 |
83 int key(0); |
93 /*! |
84 foreach (key, mPrimaryCameraAutofocusKeys) { |
94 * Stops listening key events. |
85 CX_DEBUG(("CxuiCaptureKeyHandlerPrivate - hooking autofocus key with scan / key code: %d", key)); |
95 */ |
86 listenKey(key); |
96 void CxuiCaptureKeyHandlerPrivate::stopListeningKeys() |
87 } |
97 { |
88 foreach (key, mPrimaryCameraCaptureKeys) { |
98 CX_DEBUG_ENTER_FUNCTION(); |
89 CX_DEBUG(("CxuiCaptureKeyHandlerPrivate - hooking capture key with scan / key code: %d", key)); |
99 int handle(0); |
90 listenKey(key); |
100 foreach (handle, mCapturedKeyUpDownHandles) { |
91 } |
101 mWindowGroup.CancelCaptureKeyUpAndDowns(handle); |
92 } |
102 } |
93 } else { |
103 mCapturedKeyUpDownHandles.clear(); |
94 |
104 |
95 int handle(0); |
105 foreach (handle, mCapturedKeyHandles) { |
96 foreach (handle, mCapturedKeyUpDownHandles) { |
106 mWindowGroup.CancelCaptureKey(handle); |
97 mWindowGroup.CancelCaptureKeyUpAndDowns(handle); |
|
98 } |
|
99 mCapturedKeyUpDownHandles.clear(); |
|
100 |
|
101 foreach (handle, mCapturedKeyHandles) { |
|
102 mWindowGroup.CancelCaptureKey(handle); |
|
103 } |
|
104 mCapturedKeyHandles.clear(); |
|
105 } |
107 } |
|
108 mCapturedKeyHandles.clear(); |
106 CX_DEBUG_EXIT_FUNCTION(); |
109 CX_DEBUG_EXIT_FUNCTION(); |
107 } |
110 } |
108 |
111 |
109 bool CxuiCaptureKeyHandlerPrivate::isAutofocusKeyPressed() |
112 bool CxuiCaptureKeyHandlerPrivate::isAutofocusKeyPressed() |
110 { |
113 { |