summaryrefslogtreecommitdiff
path: root/wacom_pointer.e
diff options
context:
space:
mode:
authorribet2009-06-25 14:43:50 +0000
committerribet2009-06-25 14:43:50 +0000
commit1171c3c7b6ff7632959493dd3dc234d7f6011f88 (patch)
tree4733d7642af58bbf1d108f3a0376893a304c4c0b /wacom_pointer.e
parentc90578dee067bcdc267edf7dc4457948e6df61f3 (diff)
downloadxinput-ivy-1171c3c7b6ff7632959493dd3dc234d7f6011f88.zip
xinput-ivy-1171c3c7b6ff7632959493dd3dc234d7f6011f88.tar.gz
xinput-ivy-1171c3c7b6ff7632959493dd3dc234d7f6011f88.tar.bz2
xinput-ivy-1171c3c7b6ff7632959493dd3dc234d7f6011f88.tar.xz
Version 1.2
Diffstat (limited to 'wacom_pointer.e')
-rw-r--r--wacom_pointer.e67
1 files changed, 62 insertions, 5 deletions
diff --git a/wacom_pointer.e b/wacom_pointer.e
index 1325625..8bfd40c 100644
--- a/wacom_pointer.e
+++ b/wacom_pointer.e
@@ -54,6 +54,10 @@ feature {}
x_offset, y_offset: INTEGER
+ cropping: BOOLEAN
+
+ x_min_crop, y_min_crop, x_max_crop, y_max_crop, crop_width, crop_height: INTEGER
+
prediction_time: REAL
ignore_rate, ignored_counter: INTEGER
@@ -107,6 +111,46 @@ feature {XINPUT_IVY}
y_offset := offset
end
+ is_valid_crop(description: STRING): BOOLEAN is
+ require
+ description /= Void
+ local
+ tmp: STRING
+ values: ARRAY[STRING]
+ do
+ Result := description.occurrences(',') = 3
+ if Result then
+ tmp := description.twin
+ tmp.replace_all(',', ' ')
+ from
+ values := tmp.split
+ Result := values.count = 4
+ until
+ not Result or else values.is_empty
+ loop
+ Result := values.last.is_integer
+ values.remove_last
+ end
+ end
+ end
+
+ set_crop(description: STRING) is
+ require
+ is_valid_crop(description)
+ local
+ values: ARRAY[STRING]
+ do
+ description.replace_all(',', ' ')
+ values := description.split
+ x_min_crop := values.item(1).to_integer
+ y_min_crop := values.item(2).to_integer
+ x_max_crop := values.item(3).to_integer
+ y_max_crop := values.item(4).to_integer
+ cropping := True
+ crop_width := x_max_crop - x_min_crop
+ crop_height := y_max_crop - y_min_crop
+ end
+
set_prediction(milliseconds: REAL) is
do
prediction_time := milliseconds
@@ -133,12 +177,12 @@ feature {XINPUT_IVY}
device_to_screen_x(x: INTEGER): INTEGER is
do
- Result := (x / 86400 * 1600 + x_offset).force_to_integer_32 -- **** geometrie paramétrable
+ Result := ((x - 150) / 86650 * 1600 + x_offset).force_to_integer_32 -- **** geometrie paramétrable
end
device_to_screen_y(y: INTEGER): INTEGER is
do
- Result := (y / 65000 * 1200 + y_offset).force_to_integer_32 -- **** geometrie paramétrable
+ Result := ((y - 300) / 64700 * 1200 + y_offset).force_to_integer_32 -- **** geometrie paramétrable
end
x_history, y_history, time_history: RING_ARRAY[INTEGER]
@@ -161,7 +205,7 @@ feature {XINPUT_IVY}
Result := sum / history.count
end
- move(pointer: X_INPUT_DEVICE) is
+ move (pointer: X_INPUT_DEVICE) is
local
x, y, presure: INTEGER
t3: REAL_64
@@ -181,6 +225,11 @@ feature {XINPUT_IVY}
update_predicted_position(mean(x_history), mean(y_history), t3)
end
presure := pointer.motion_axis_data(3)
+ if cropping then
+ if x < x_min_crop or else y < y_min_crop or else x > x_max_crop or else y > y_max_crop then
+ ignored_counter := -1
+ end
+ end
if ignored_counter < ignore_rate and then ((old_presure = 0) = (presure = 0)) then
ignored_counter := ignored_counter + 1
else
@@ -222,9 +271,17 @@ feature {XINPUT_IVY}
message.append(once " time=")
time.append_in(message)
message.append(once " hires_x=")
- (x/86400).append_in(message) -- **** geometrie paramétrable
+ if not cropping then
+ (x/86400).append_in(message) -- **** geometrie paramétrable
+ else
+ ((x - x_min_crop) / crop_width).append_in(message)
+ end
message.append(once " hires_y=")
- (y/65000).append_in(message) -- **** geometrie paramétrable
+ if not cropping then
+ (y/65000).append_in(message) -- **** geometrie paramétrable
+ else
+ ((y - y_min_crop) / crop_height).append_in(message)
+ end
message.append(once " proximity=")
message.append(proximity_description)
end