f8526a478c4638ee99eff4be0b6b7f959745e546
[framework/uifw/ise-default.git] / mcf / mcferroradjustment.cpp
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.tizenopensource.org/license
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17
18
19 #include <stdio.h>
20 #include <stdlib.h>
21
22 #include "mcferroradjustment.h"
23 #include "mcfdebug.h"
24 #include "mcfresourcecache.h"
25 #include "mcfutils.h"
26
27 #define OFFSET_MAX                      10
28 #define TWO                             2
29
30 using namespace mcf;
31 CMCFErrorAdjustment* CMCFErrorAdjustment::sInstance; /* For singleton */
32
33 CMCFErrorAdjustment* CMCFErrorAdjustment::get_instance()
34 {
35     if (!sInstance) {
36         sInstance = new CMCFErrorAdjustment();
37     }
38     return (CMCFErrorAdjustment*)sInstance;
39 }
40
41 CMCFErrorAdjustment::CMCFErrorAdjustment()
42 {
43     MCF_DEBUG();
44 }
45
46 CMCFErrorAdjustment::~CMCFErrorAdjustment()
47 {
48     MCF_DEBUG();
49 }
50
51 mcfboolean
52 CMCFErrorAdjustment::apply_touch_offset(MCFTouchOffsetLevel level, mcfint *x, mcfint *y)
53 {
54     MCF_DEBUG();
55     CMCFEvents* events = CMCFEvents::get_instance();
56     CMCFUtils *utils = CMCFUtils::get_instance();
57     McfPoint *pos;
58     pos = events->get_touch_event_offset();
59     if(level == TOUCH_OFFSET_LEVEL_1 ){
60         *x = *x + utils->get_scale_x(pos->x);
61     } else if(level == TOUCH_OFFSET_LEVEL_2) {
62         *x = *x + utils->get_scale_x(pos->x);
63     }   
64     *y = *y + utils->get_scale_y(pos->y);
65     return TRUE;
66 }
67
68