35 #include <QMapIterator> |
35 #include <QMapIterator> |
36 #include <QDebug> |
36 #include <QDebug> |
37 |
37 |
38 #include "hbinstantfeedback.h" |
38 #include "hbinstantfeedback.h" |
39 #include "hbcontinuousfeedback.h" |
39 #include "hbcontinuousfeedback.h" |
40 #include "hbtacticonfeedback.h" |
40 |
41 #include "hbhitareafeedback.h" |
41 /* |
42 |
|
43 /*! |
|
44 Symbian-specific feedback class that wraps Symbian feedback APIs. |
42 Symbian-specific feedback class that wraps Symbian feedback APIs. |
45 */ |
43 */ |
46 |
44 |
47 class HbFeedbackBasePlayerPrivate |
45 class HbFeedbackBasePlayerPrivate |
48 { |
46 { |
56 inline int getNewIdentifier(); |
54 inline int getNewIdentifier(); |
57 inline TRect convertToSymbian(const QRect& rect); |
55 inline TRect convertToSymbian(const QRect& rect); |
58 inline CCoeControl* convertToSymbian(QWidget* window); |
56 inline CCoeControl* convertToSymbian(QWidget* window); |
59 inline TTouchLogicalFeedback convertToSymbian(HbFeedback::InstantEffect effect); |
57 inline TTouchLogicalFeedback convertToSymbian(HbFeedback::InstantEffect effect); |
60 inline TTacticonType convertTacticonToSymbian(HbFeedback::InstantEffect effect); |
58 inline TTacticonType convertTacticonToSymbian(HbFeedback::InstantEffect effect); |
61 inline TTacticonType convertTacticonToSymbian(HbFeedback::TacticonEffect effect); |
|
62 inline TTouchContinuousFeedback convertToSymbian(HbFeedback::ContinuousEffect effect); |
59 inline TTouchContinuousFeedback convertToSymbian(HbFeedback::ContinuousEffect effect); |
63 inline TTouchEventType convertToSymbian(HbFeedback::HitAreaType hitAreaType); |
|
64 inline TTouchFeedbackType convertToSymbian(HbFeedback::Modalities modalities); |
60 inline TTouchFeedbackType convertToSymbian(HbFeedback::Modalities modalities); |
65 |
61 |
66 public: |
62 public: |
67 MTouchFeedback *iFeedback; |
63 MTouchFeedback *iFeedback; |
68 RTacticon iTacticon; |
64 RTacticon iTacticon; |
69 TBool iTacticonReady; |
65 TBool iTacticonReady; |
70 QMap <int, QWidget*> registeredHitAreas; |
|
71 QMap <int, QWidget*> ongoingContinuousFeedbacks; |
66 QMap <int, QWidget*> ongoingContinuousFeedbacks; |
72 int slidingValue; |
67 int slidingValue; |
73 }; |
68 }; |
74 |
69 |
75 HbFeedbackBasePlayerPrivate::HbFeedbackBasePlayerPrivate() : slidingValue(0) |
70 HbFeedbackBasePlayerPrivate::HbFeedbackBasePlayerPrivate() : slidingValue(0) |
238 break; |
233 break; |
239 } |
234 } |
240 return type; |
235 return type; |
241 } |
236 } |
242 |
237 |
243 TTacticonType HbFeedbackBasePlayerPrivate::convertTacticonToSymbian(HbFeedback::TacticonEffect effect) { |
|
244 |
|
245 TTacticonType type = ENoTacticon; |
|
246 |
|
247 switch (effect) { |
|
248 |
|
249 case HbFeedback::TacticonPositive: |
|
250 type = EPositiveTacticon; |
|
251 break; |
|
252 case HbFeedback::TacticonNeutral: |
|
253 type = ENeutralTacticon; |
|
254 break; |
|
255 case HbFeedback::TacticonNegative: |
|
256 type = ENegativeTacticon; |
|
257 break; |
|
258 default: |
|
259 break; |
|
260 } |
|
261 return type; |
|
262 } |
|
263 |
|
264 TTouchContinuousFeedback HbFeedbackBasePlayerPrivate::convertToSymbian(HbFeedback::ContinuousEffect effect) { |
238 TTouchContinuousFeedback HbFeedbackBasePlayerPrivate::convertToSymbian(HbFeedback::ContinuousEffect effect) { |
265 |
239 |
266 TTouchContinuousFeedback continuousFeedbackSymbian = ETouchContinuousSmooth; |
240 TTouchContinuousFeedback continuousFeedbackSymbian = ETouchContinuousSmooth; |
267 |
241 |
268 switch (effect) { |
242 switch (effect) { |
287 break; |
261 break; |
288 } |
262 } |
289 return continuousFeedbackSymbian; |
263 return continuousFeedbackSymbian; |
290 } |
264 } |
291 |
265 |
292 TTouchEventType HbFeedbackBasePlayerPrivate::convertToSymbian(HbFeedback::HitAreaType hitAreaType) { |
|
293 |
|
294 TTouchEventType touchEventType = ETouchEventStylusDown; |
|
295 |
|
296 if ( hitAreaType == HbFeedback::MouseButtonPress ) { |
|
297 touchEventType = ETouchEventStylusDown; |
|
298 } else if (hitAreaType == HbFeedback::MouseButtonRelease ) { |
|
299 // ETouchEventStylusUp not yet supported |
|
300 touchEventType = ETouchEventStylusDown; |
|
301 } |
|
302 return touchEventType; |
|
303 } |
|
304 |
266 |
305 TTouchFeedbackType HbFeedbackBasePlayerPrivate::convertToSymbian(HbFeedback::Modalities modalities) |
267 TTouchFeedbackType HbFeedbackBasePlayerPrivate::convertToSymbian(HbFeedback::Modalities modalities) |
306 { |
268 { |
307 int symbianFeedbackType = 0; |
269 int symbianFeedbackType = 0; |
308 |
270 |
333 d->init(); |
295 d->init(); |
334 } |
296 } |
335 |
297 |
336 HbFeedbackBasePlayer::~HbFeedbackBasePlayer() { |
298 HbFeedbackBasePlayer::~HbFeedbackBasePlayer() { |
337 |
299 |
338 removeHitAreas(); |
|
339 cancelContinuousFeedbacks(); |
300 cancelContinuousFeedbacks(); |
340 delete d; |
301 delete d; |
341 } |
302 } |
342 |
303 |
343 void HbFeedbackBasePlayer::removeHitAreas() { |
304 |
344 |
|
345 // remove hit areas |
|
346 QMapIterator<int, QWidget*> i(d->registeredHitAreas); |
|
347 |
|
348 while (i.hasNext()) { |
|
349 i.next(); |
|
350 removeHitArea( i.key()); |
|
351 } |
|
352 |
|
353 d->registeredHitAreas.clear(); |
|
354 } |
|
355 |
305 |
356 void HbFeedbackBasePlayer::cancelContinuousFeedbacks() { |
306 void HbFeedbackBasePlayer::cancelContinuousFeedbacks() { |
357 |
307 |
358 // stop ongoing continuous feedbacks |
308 // stop ongoing continuous feedbacks |
359 QMapIterator<int, QWidget*> i(d->ongoingContinuousFeedbacks); |
309 QMapIterator<int, QWidget*> i(d->ongoingContinuousFeedbacks); |
451 feedbackOngoing = true; |
394 feedbackOngoing = true; |
452 } |
395 } |
453 return feedbackOngoing; |
396 return feedbackOngoing; |
454 } |
397 } |
455 |
398 |
456 int HbFeedbackBasePlayer::insertHitArea(const HbHitAreaFeedback& feedback) { |
399 |
457 |
|
458 int identifier = -1; |
|
459 CCoeControl* control = d->convertToSymbian(feedback.window()); |
|
460 if (d->iFeedback && control) { |
|
461 identifier = d->getNewIdentifier(); |
|
462 TTouchLogicalFeedback logicalFeedback = d->convertToSymbian(feedback.instantEffect()); |
|
463 // current hit area implementation below does not yet support new logical feedbacks |
|
464 if (logicalFeedback > ETouchFeedbackSensitive) { |
|
465 logicalFeedback = ETouchFeedbackSensitive; |
|
466 } |
|
467 |
|
468 int errorValue = d->iFeedback->SetFeedbackArea(control, identifier, |
|
469 d->convertToSymbian(feedback.rect()), |
|
470 logicalFeedback, |
|
471 d->convertToSymbian(feedback.hitAreaType())); |
|
472 if (errorValue >= 0) { |
|
473 // no error |
|
474 d->registeredHitAreas.insert(identifier, feedback.window()); |
|
475 } |
|
476 } |
|
477 return identifier; |
|
478 } |
|
479 |
|
480 void HbFeedbackBasePlayer::updateHitArea(int identifier, const HbHitAreaFeedback& feedback) { |
|
481 |
|
482 CCoeControl* control = d->convertToSymbian(feedback.window()); |
|
483 |
|
484 if (d->iFeedback && control && d->registeredHitAreas.contains(identifier)) { |
|
485 CCoeControl* storedControl = d->convertToSymbian(d->registeredHitAreas[identifier]); |
|
486 if (storedControl == control) { |
|
487 d->iFeedback->ChangeFeedbackArea(storedControl, identifier, d->convertToSymbian(feedback.rect())); |
|
488 } |
|
489 } |
|
490 } |
|
491 |
|
492 void HbFeedbackBasePlayer::removeHitArea(int identifier) { |
|
493 |
|
494 if (d->iFeedback && d->registeredHitAreas.contains(identifier)) { |
|
495 CCoeControl* storedControl = d->convertToSymbian(d->registeredHitAreas[identifier]); |
|
496 d->iFeedback->RemoveFeedbackArea(storedControl, identifier); |
|
497 d->registeredHitAreas.remove(identifier); |
|
498 } |
|
499 } |
|
500 |
|
501 bool HbFeedbackBasePlayer::hitAreaExists(int identifier) { |
|
502 |
|
503 return d->registeredHitAreas.contains(identifier); |
|
504 } |
|