2 * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
4 * This file is a modified version of BSD licensed file and
5 * licensed under the Flora License, Version 1.1 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://floralicense.org/license/
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an AS IS BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * Please, see the LICENSE file for the original copyright owner and
22 #include <atspi/atspi.h>
23 #include "keyboard_tracker.h"
26 static AtspiDeviceListener *listener;
27 static Keyboard_Tracker_Cb user_cb;
28 static void *user_data;
30 static gboolean device_cb(const AtspiDeviceEvent *stroke, void *data)
33 if (!strcmp(stroke->event_string, "KP_Up"))
35 else if (!strcmp(stroke->event_string, "KP_Down"))
37 else if (!strcmp(stroke->event_string, "KP_Left"))
39 else if (!strcmp(stroke->event_string, "KP_Right"))
45 user_cb(user_data, k);
50 void keyboard_tracker_init(void)
53 listener = atspi_device_listener_new(device_cb, NULL, NULL);
54 atspi_register_keystroke_listener(listener, NULL, 0, ATSPI_KEY_PRESSED, ATSPI_KEYLISTENER_SYNCHRONOUS|ATSPI_KEYLISTENER_CANCONSUME, NULL);
55 DEBUG("keyboard tracker init");
58 void keyboard_tracker_register(Keyboard_Tracker_Cb cb, void *data)
64 void keyboard_tracker_shutdown(void)
66 atspi_deregister_keystroke_listener(listener, NULL, 0, ATSPI_KEY_PRESSED, NULL);
67 DEBUG("keyboard tracker shutdown");