-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-merit/mtouchxl.cpp: Added touch-enabled layout.
-ui/tapectrl.cpp: Ensure device monitored for media change is up-to-date. -osd/windows: Changed a pointer to a const reference in an API.
- Loading branch information
Showing
8 changed files
with
132 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
license:CC0-1.0 | ||
--> | ||
<mamelayout version="2"> | ||
<view name="Touch-Enabled" showpointers="yes"> | ||
<screen id="screen" index="0"> | ||
<bounds left="0" top="0" right="4" bottom="3" /> | ||
</screen> | ||
</view> | ||
|
||
<script><![CDATA[ | ||
file:set_resolve_tags_callback( | ||
function () | ||
-- get the touchscreen I/O port fields | ||
local tsdev = file.device:subdevice('microtouch') | ||
local btn_field = tsdev:ioport('TOUCH'):field(0x01) | ||
local x_field = tsdev:ioport('TOUCH_X'):field(0x3fff) | ||
local y_field = tsdev:ioport('TOUCH_Y'):field(0x3fff) | ||
-- for mapping coordinates | ||
local view = file.views['Touch-Enabled'] | ||
local scr_item = view.items['screen'] | ||
local floor = math.floor | ||
local l, r, t, b | ||
local x_scale, y_scale | ||
-- pointer state | ||
local ptr_id = nil | ||
local inside = false | ||
local function release_touch() | ||
btn_field:clear_value() | ||
x_field:clear_value() | ||
y_field:clear_value() | ||
end | ||
local function recomputed() | ||
local bounds = scr_item.bounds | ||
l = bounds.x0 | ||
r = bounds.x1 | ||
t = bounds.y0 | ||
b = bounds.y1 | ||
x_scale = 0x3fff / bounds.width | ||
y_scale = 0x3fff / bounds.height | ||
end | ||
local function check_pointer(x, y) | ||
if (x >= l) and (x < r) and (y >= t) and (y < b) then | ||
inside = true | ||
btn_field:set_value(1) | ||
x_field:set_value(floor((x - l) * x_scale)) | ||
y_field:set_value(floor((y - t) * y_scale)) | ||
elseif inside then | ||
inside = false | ||
release_touch() | ||
end | ||
end | ||
local function forget_pointer() | ||
if inside then | ||
release_touch() | ||
end | ||
ptr_id = nil | ||
inside = false | ||
end | ||
local function pointer_updated(type, id, dev, x, y, btn, dn, up, cnt) | ||
if ptr_id == id then | ||
if (btn & 0x01) == 0 then | ||
forget_pointer() | ||
else | ||
check_pointer(x, y) | ||
end | ||
elseif (not ptr_id) and ((dn & 0x01) ~= 0) then | ||
ptr_id = id | ||
check_pointer(x, y) | ||
end | ||
end | ||
local function pointer_lost(type, id, dev, x, y, up, cnt) | ||
if ptr_id == id then | ||
forget_pointer() | ||
end | ||
end | ||
-- attach callbacks to view | ||
view:set_recomputed_callback(recomputed) | ||
view:set_pointer_updated_callback(pointer_updated) | ||
view:set_pointer_left_callback(pointer_lost) | ||
view:set_pointer_aborted_callback(pointer_lost) | ||
view:set_forget_pointers_callback(forget_pointer) | ||
end) | ||
]]></script> | ||
</mamelayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e22aae6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This lets you just click/touch the screen in Megatouch XL games, and it will be converted to the units the fake “lightgun” uses automatically, without needing
-mouse
or-lightgun
. I successfully played a game of Photo Hunt purely for QA purposes.