Use Tizen To Enable Galaxy Watch Rotary Events
rotary event handling, enabled via the bezel, is supported on the tizen platform. a bezel is a term used to describe the outside frame of a device, and in the case of a galaxy watch, the bezel is the outer ring of the device, which can be rotated. rotary events are triggered from the galaxy watch rotary component when the bezel is rotated clockwise or counterclockwise. the event for each rotation is measured in incremental units called "detents." bezel interactions can be used in a variety of ways, such as controlling the application page, controlling the snap list, changing the progress bar value, scrolling the page, changing the volume, and setting configurations such as date-time on the date-time picker. this blog discusses how to handle rotary events in tizen web and native applications. in the following example, you'll learn how to let a user interact with bezel by using the rotary event to receive or reject a call. the user rotates the bezel clockwise to receive the call and counterclockwise to reject it. note: because galaxy active devices do not have bezels, rotary features will not work on them. prerequisites tizen web in the tizen web application, add the following line in the config.xml file: tizen native in the tizen native application, include the <system_info.h>header file to use the functions and data types of the system information api. #include<system_info.h> you also must add the following line to the manifest file: <feature name="http://tizen.org/feature/input.rotating_bezel">true</feature> check capability tizen web in the tizen web application, use the following line to check if the device supports rotary events or if it uses bezel: var issupport = tizen.systeminfo.getcapability('http://tizen.org/feature/input.rotating_bezel'); console.log(' bezel = ' + issupport); the getcapability() function of the tizen web api returns with information about whether or not the device supports bezel. tizen native in the tizen native application, use the following code to check bezel capability: bool rotaryvalue; int rotaryreturn; rotaryreturn = system_info_get_platform_bool("http://tizen.org/feature/input.rotating_bezel", &rotaryvalue); if (rotaryreturn!= system_info_error_none) { dlog_print(dlog_info, log_tag, "rotary error"); return; } dlog_print(dlog_info, log_tag, "bezel: %s", value ? "supported" : "not supported"); implementation tizen web register the rotarydetent event. after registering an event, ev.detail.direction provides the direction value. if the value is cw, the bezel is rotated clockwise. if the value of direction is ccw, the bezel is rotated counterclockwise. document.addeventlistener('rotarydetent', function(ev) { /* get the direction value from the event */ var direction = ev.detail.direction; var textbox = document.queryselector('.contents'); box = document.queryselector('#textbox'); if (direction == 'cw') { /* add behavior for clockwise rotation */ console.log('clockwise'); box.innerhtml ="clockwise"; } else if (direction == 'ccw') { /* add behavior for counter-clockwise rotation */ console.log('counter-clockwise'); box.innerhtml ="counter-clockwise"; } }); tizen native register the rotary event in the app using the following line: eext_rotary_event_handler_add(_rotary_handler_cb, ad); the handle function is defined using following code: eina_bool _rotary_handler_cb(appdata_s *data, eext_rotary_event_info *ev) { if (ev->direction == eext_rotary_direction_clockwise) { dlog_print(dlog_debug, log_tag, "rotary device rotated in clockwise direction"); } else { dlog_print(dlog_debug, log_tag, "rotary device rotated in counter-clockwise direction"); } return eina_false; } if the rotation direction is equal to eext_rotary_direction_clockwise, the bezel is rotated clockwise. otherwise, the bezel is rotated counterclockwise. demo two sample apps are attached: • rotary native • rotary web web when you run the web sample app and turn the bezel clockwise, the following text appears on the watch face: when you turn the bezel counter counterclockwise, “counterclockwise” appears on the watch face: native when you run the native sample app and turn the bezel clockwise, the following text appears on the watch face: when you turn the bezel counterclockwise, the following text appears: for more information the bezel is the physical controller of some samsung wearable devices. understanding the physical characteristics of the bezel will help you design better interactions. references: https://developer.tizen.org/development/guides/web-application/user-interface/tizen-advanced-ui/applications-circular-ui/handling-rotary-events https://developer.tizen.org/development/guides/native-application/user-interface/efl/hardware-input-handling/managing-rotary-events https://developer.tizen.org/design/wearable/interaction/bezel-interactions?langswitch=en