diff options
author | Mike Blumenkrantz <zmike@osg.samsung.com> | 2017-05-26 16:34:10 -0400 |
---|---|---|
committer | Mike Blumenkrantz <zmike@osg.samsung.com> | 2017-05-26 16:27:42 -0400 |
commit | 03e23322d59c697ebc8b36f82693eddfc753d07d (patch) | |
tree | 46471f7b856502d357edc0d7f166293532ea548f /src/lib/elput | |
parent | 7cc52ef27bfdf28064e5877df172e04bb32d4132 (diff) |
elput: send axis events for tablet tools
Diffstat (limited to 'src/lib/elput')
-rw-r--r-- | src/lib/elput/elput_evdev.c | 96 |
1 files changed, 94 insertions, 2 deletions
diff --git a/src/lib/elput/elput_evdev.c b/src/lib/elput/elput_evdev.c index 3b41db896f..98f8c472a9 100644 --- a/src/lib/elput/elput_evdev.c +++ b/src/lib/elput/elput_evdev.c | |||
@@ -1188,11 +1188,23 @@ cont: | |||
1188 | } | 1188 | } |
1189 | 1189 | ||
1190 | static void | 1190 | static void |
1191 | _axis_event_free(void *d EINA_UNUSED, void *event) | ||
1192 | { | ||
1193 | Ecore_Event_Axis_Update *ev = event; | ||
1194 | |||
1195 | free(ev->axis); | ||
1196 | free(ev); | ||
1197 | } | ||
1198 | |||
1199 | static void | ||
1191 | _tablet_tool_axis(struct libinput_device *idev, struct libinput_event_tablet_tool *event) | 1200 | _tablet_tool_axis(struct libinput_device *idev, struct libinput_event_tablet_tool *event) |
1192 | { | 1201 | { |
1193 | Elput_Pointer *ptr; | 1202 | Elput_Pointer *ptr; |
1194 | struct libinput_tablet_tool *tool; | 1203 | struct libinput_tablet_tool *tool; |
1195 | Elput_Device *dev = libinput_device_get_user_data(idev); | 1204 | Elput_Device *dev = libinput_device_get_user_data(idev); |
1205 | Ecore_Event_Axis_Update *ev; | ||
1206 | Ecore_Axis ax[8] = {0}, *axis = NULL; | ||
1207 | int i, num = 0; | ||
1196 | 1208 | ||
1197 | ptr = _evdev_pointer_get(dev->seat); | 1209 | ptr = _evdev_pointer_get(dev->seat); |
1198 | EINA_SAFETY_ON_NULL_RETURN(ptr); | 1210 | EINA_SAFETY_ON_NULL_RETURN(ptr); |
@@ -1201,11 +1213,91 @@ _tablet_tool_axis(struct libinput_device *idev, struct libinput_event_tablet_too | |||
1201 | ptr->x = libinput_event_tablet_tool_get_x_transformed(event, dev->ow); | 1213 | ptr->x = libinput_event_tablet_tool_get_x_transformed(event, dev->ow); |
1202 | ptr->y = libinput_event_tablet_tool_get_y_transformed(event, dev->oh); | 1214 | ptr->y = libinput_event_tablet_tool_get_y_transformed(event, dev->oh); |
1203 | 1215 | ||
1216 | if (libinput_event_tablet_tool_x_has_changed(event)) | ||
1217 | { | ||
1218 | ax[num].label = ECORE_AXIS_LABEL_X; | ||
1219 | ax[num].value = ptr->x; | ||
1220 | num++; | ||
1221 | } | ||
1222 | if (libinput_event_tablet_tool_y_has_changed(event)) | ||
1223 | { | ||
1224 | ax[num].label = ECORE_AXIS_LABEL_Y; | ||
1225 | ax[num].value = ptr->y; | ||
1226 | num++; | ||
1227 | } | ||
1204 | if (libinput_tablet_tool_has_pressure(tool)) | 1228 | if (libinput_tablet_tool_has_pressure(tool)) |
1205 | ptr->pressure = libinput_event_tablet_tool_get_pressure(event); | 1229 | { |
1230 | if (libinput_event_tablet_tool_pressure_has_changed(event)) | ||
1231 | { | ||
1232 | ax[num].label = ECORE_AXIS_LABEL_PRESSURE; | ||
1233 | ax[num].value = ptr->pressure = libinput_event_tablet_tool_get_pressure(event); | ||
1234 | num++; | ||
1235 | } | ||
1236 | } | ||
1237 | if (libinput_tablet_tool_has_distance(tool)) | ||
1238 | { | ||
1239 | if (libinput_event_tablet_tool_distance_has_changed(event)) | ||
1240 | { | ||
1241 | ax[num].label = ECORE_AXIS_LABEL_DISTANCE; | ||
1242 | ax[num].value = libinput_event_tablet_tool_get_distance(event); | ||
1243 | num++; | ||
1244 | } | ||
1245 | } | ||
1246 | if (libinput_tablet_tool_has_tilt(tool)) | ||
1247 | { | ||
1248 | if (libinput_event_tablet_tool_tilt_x_has_changed(event) || | ||
1249 | libinput_event_tablet_tool_tilt_y_has_changed(event)) | ||
1250 | { | ||
1251 | double x = sin(libinput_event_tablet_tool_get_tilt_x(event)); | ||
1252 | double y = sin(-libinput_event_tablet_tool_get_tilt_y(event)); | ||
1253 | |||
1254 | ax[num].label = ECORE_AXIS_LABEL_TILT; | ||
1255 | ax[num].value = asin(sqrt((x * x) + (y * y))); | ||
1256 | num++; | ||
1257 | |||
1258 | /* note: the value of atan2(0,0) is implementation-defined */ | ||
1259 | ax[num].label = ECORE_AXIS_LABEL_AZIMUTH; | ||
1260 | ax[num].value = atan2(y, x); | ||
1261 | num++; | ||
1262 | } | ||
1263 | } | ||
1264 | if (libinput_tablet_tool_has_rotation(tool)) | ||
1265 | { | ||
1266 | if (libinput_event_tablet_tool_rotation_has_changed(event)) | ||
1267 | { | ||
1268 | ax[num].label = ECORE_AXIS_LABEL_TWIST; | ||
1269 | ax[num].value = libinput_event_tablet_tool_get_rotation(event); | ||
1270 | ax[num].value *= M_PI / 180; | ||
1271 | num++; | ||
1272 | } | ||
1273 | } | ||
1206 | 1274 | ||
1207 | ptr->timestamp = libinput_event_tablet_tool_get_time(event); | 1275 | ptr->timestamp = libinput_event_tablet_tool_get_time(event); |
1208 | _pointer_motion_send(dev); | 1276 | /* FIXME: other properties which efl event structs don't support: |
1277 | * slider_position | ||
1278 | * wheel_delta | ||
1279 | */ | ||
1280 | |||
1281 | |||
1282 | if (libinput_event_tablet_tool_x_has_changed(event) || | ||
1283 | libinput_event_tablet_tool_y_has_changed(event)) | ||
1284 | _pointer_motion_send(dev); | ||
1285 | |||
1286 | if (!num) return; | ||
1287 | ev = calloc(1, sizeof(Ecore_Event_Axis_Update)); | ||
1288 | |||
1289 | ev->window = dev->seat->manager->window; | ||
1290 | ev->event_window = dev->seat->manager->window; | ||
1291 | ev->root_window = dev->seat->manager->window; | ||
1292 | ev->timestamp = ptr->timestamp; | ||
1293 | ev->naxis = num; | ||
1294 | ev->axis = axis = calloc(num, sizeof(Ecore_Axis)); | ||
1295 | for (i = 0; i < num; i++) | ||
1296 | { | ||
1297 | axis[i].label = ax[i].label; | ||
1298 | axis[i].value = ax[i].value; | ||
1299 | } | ||
1300 | ecore_event_add(ECORE_EVENT_AXIS_UPDATE, ev, _axis_event_free, NULL); | ||
1209 | } | 1301 | } |
1210 | 1302 | ||
1211 | static void | 1303 | static void |