#include <stdlib.h>
#include <unistd.h>
-#include <sensor.h>
+#include <sensor_internal_deprecated.h>
+//#include <sensor_auto_rotation.h>
+
#include <vconf.h>
#include <Ecore_X.h>
#include <Ecore.h>
} while(0)
#define STR_ATOM_ROTATION_LOCK "_E_ROTATION_LOCK"
+#define MAX_LOCAL_BUFSZ 128
static Ecore_X_Atom ATOM_ROTATION_LOCK = 0;
static Ecore_X_Window root;
struct rot_s {
int handle;
- int (*callback) (enum appcore_rm, void *);
+ int (*callback) (void *event_info, enum appcore_rm, void *);
enum appcore_rm mode;
int lock;
void *cbdata;
static struct rot_s rot;
struct rot_evt {
- enum accelerometer_rotate_state re;
+ int re;
enum appcore_rm rm;
};
static struct rot_evt re_to_rm[] = {
{
- ROTATION_EVENT_0,
- APPCORE_RM_PORTRAIT_NORMAL,
+ AUTO_ROTATION_DEGREE_0,
+ APPCORE_RM_PORTRAIT_NORMAL,
},
{
- ROTATION_EVENT_90,
- APPCORE_RM_LANDSCAPE_NORMAL,
+ AUTO_ROTATION_DEGREE_90,
+ APPCORE_RM_LANDSCAPE_NORMAL,
},
{
- ROTATION_EVENT_180,
- APPCORE_RM_PORTRAIT_REVERSE,
+ AUTO_ROTATION_DEGREE_180,
+ APPCORE_RM_PORTRAIT_REVERSE,
},
{
- ROTATION_EVENT_270,
- APPCORE_RM_LANDSCAPE_REVERSE,
+ AUTO_ROTATION_DEGREE_270,
+ APPCORE_RM_LANDSCAPE_REVERSE,
},
};
if (rot.lock)
return;
- if (event_type != ACCELEROMETER_EVENT_ROTATION_CHECK) {
+ if (event_type != AUTO_ROTATION_EVENT_CHANGE_STATE) {
errno = EINVAL;
return;
}
m = __get_mode(*cb_event_data);
_DBG("[APP %d] Rotation: %d -> %d", getpid(), rot.mode, m);
-
if (rot.callback) {
if (rot.cb_set && rot.mode != m) {
_DBG("[APP %d] Rotation: %d -> %d", getpid(), rot.mode, m);
- rot.callback(m, data);
+ rot.callback((void *)&m, m, data);
rot.mode = m;
}
}
+
}
static void __lock_cb(keynode_t *node, void *data)
{
int r;
enum appcore_rm m;
- int ret;
rot.lock = !vconf_keynode_get_bool(node);
if (rot.lock) {
m = APPCORE_RM_PORTRAIT_NORMAL;
if (rot.mode != m) {
- rot.callback(m, data);
+ rot.callback((void *)&m, m, data);
rot.mode = m;
}
_DBG("[APP %d] Rotation locked", getpid());
_DBG("[APP %d] Rotmode prev %d -> curr %d", getpid(),
rot.mode, m);
if (!r && rot.mode != m) {
- rot.callback(m, data);
+ rot.callback((void *)&m, m, data);
rot.mode = m;
}
}
rot.lock = 0;
}
-EXPORT_API int appcore_set_rotation_cb(int (*cb) (enum appcore_rm, void *),
+EXPORT_API int appcore_set_rotation_cb(int (*cb) (void *event_info, enum appcore_rm, void *),
void *data)
{
if (rot.wm_rotate) {
return rot.wm_rotate->set_rotation_cb(cb, data);
- }
- else {
+ } else {
int r;
int handle;
return -1;
}
- handle = sf_connect(ACCELEROMETER_SENSOR);
+ handle = sf_connect(AUTO_ROTATION_SENSOR);
if (handle < 0) {
_ERR("sf_connect failed: %d", handle);
return -1;
}
- r = sf_register_event(handle, ACCELEROMETER_EVENT_ROTATION_CHECK,
+ r = sf_register_event(handle, AUTO_ROTATION_EVENT_CHANGE_STATE,
NULL, __changed_cb, data);
if (r < 0) {
_ERR("sf_register_event failed: %d", r);
r = sf_start(handle, 0);
if (r < 0) {
_ERR("sf_start failed: %d", r);
- r = sf_unregister_event(handle, ACCELEROMETER_EVENT_ROTATION_CHECK);
+ r = sf_unregister_event(handle, AUTO_ROTATION_EVENT_CHANGE_STATE);
if (r < 0) {
_ERR("sf_unregister_event failed: %d", r);
}
if (rot.cb_set) {
r = sf_unregister_event(rot.handle,
- ACCELEROMETER_EVENT_ROTATION_CHECK);
+ AUTO_ROTATION_EVENT_CHANGE_STATE);
if (r < 0) {
_ERR("sf_unregister_event failed: %d", r);
return -1;
else {
int r;
unsigned long event;
+ sensor_data_t data;
if (curr == NULL) {
errno = EINVAL;
return -1;
}
- r = sf_check_rotation(&event);
- if (r < 0) {
- _ERR("sf_check_rotation failed: %d", r);
+ r = sf_get_data(rot.handle, AUTO_ROTATION_BASE_DATA_SET, &data);
+ if (r == 1 && data.value_count > 0) {
+ event = data.values[0];
+ } else {
+ _ERR("sf_get_data for AUTO_ROTATION_BASE_DATA_SET failed: %d", r);
*curr = APPCORE_RM_UNKNOWN;
return -1;
}
if (rot.cb_set) {
r = sf_unregister_event(rot.handle,
- ACCELEROMETER_EVENT_ROTATION_CHECK);
+ AUTO_ROTATION_EVENT_CHANGE_STATE);
if (r < 0) {
_ERR("sf_unregister_event in appcore_internal_sf_stop failed: %d", r);
return -1;
return rot.wm_rotate->resume_rotation_cb();
}
else {
- int r;
+ int r,ret;
enum appcore_rm m;
_retv_if(rot.callback == NULL, 0);
if (rot.cb_set == 0) {
r = sf_register_event(rot.handle,
- ACCELEROMETER_EVENT_ROTATION_CHECK, NULL,
+ AUTO_ROTATION_EVENT_CHANGE_STATE, NULL,
__changed_cb, rot.cbdata);
if (r < 0) {
_ERR("sf_register_event in appcore_internal_sf_start failed: %d", r);
if (r < 0) {
_ERR("sf_start in appcore_internal_sf_start failed: %d",
r);
- r = sf_unregister_event(rot.handle,
- ACCELEROMETER_EVENT_ROTATION_CHECK);
- if (r < 0) {
- _ERR("sf_unregister_event failed: %d", r);
- }
+ ret = sf_unregister_event(rot.handle,
+ AUTO_ROTATION_EVENT_CHANGE_STATE);
+ if (ret < 0)
+ _ERR("sf_unregister_event failed: %d", ret);
rot.cb_set = 0;
return -1;
}
r = appcore_get_rotation_state(&m);
_DBG("[APP %d] Rotmode prev %d -> curr %d", getpid(), rot.mode, m);
if (!r && rot.mode != m && rot.lock == 0) {
- rot.callback(m, rot.cbdata);
+ rot.callback((void *)&m, m, rot.cbdata);
rot.mode = m;
}
}