{"action":"created","issue":{"url":"https://api.github.com/repos/openMSX/openMSX/issues/892","labels_url":"https://api.github.com/repos/openMSX/openMSX/issues/892/labels{/name}","comments_url":"https://api.github.com/repos/openMSX/openMSX/issues/892/comments","events_url":"https://api.github.com/repos/openMSX/openMSX/issues/892/events","html_url":"https://github.com/openMSX/openMSX/issues/892","id":90630264,"number":892,"title":"[Bug] Mouse emulation lacks arithmetic saturation [sf#498]","user":{"login":"openMSX-import","id":12987176,"avatar_url":"https://avatars.githubusercontent.com/u/12987176?v=3","gravatar_id":"","url":"https://api.github.com/users/openMSX-import","html_url":"https://github.com/openMSX-import","followers_url":"https://api.github.com/users/openMSX-import/followers","following_url":"https://api.github.com/users/openMSX-import/following{/other_user}","gists_url":"https://api.github.com/users/openMSX-import/gists{/gist_id}","starred_url":"https://api.github.com/users/openMSX-import/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openMSX-import/subscriptions","organizations_url":"https://api.github.com/users/openMSX-import/orgs","repos_url":"https://api.github.com/users/openMSX-import/repos","events_url":"https://api.github.com/users/openMSX-import/events{/privacy}","received_events_url":"https://api.github.com/users/openMSX-import/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/openMSX/openMSX/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/openMSX/openMSX/labels/mouse","name":"mouse","color":"ededed"},{"url":"https://api.github.com/repos/openMSX/openMSX/labels/saturation%20arithmetics","name":"saturation arithmetics","color":"ededed"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-06-24T10:02:09Z","updated_at":"2015-06-24T10:18:46Z","closed_at":"2015-06-24T10:18:29Z","body":"**Reported by sd-snatcher on 2013-08-31 17:03 UTC**\nThis bug is related to the #477.\r\n\r\n\r\nInteresting enough, just like what happened on Trackball.cc, the mouse emulation also fails arithmetic saturation tests. This means that the same overflow bug happens with the mouse, albeit they're much rarer because the offsets are 8-bit.\r\n\r\n\r\nBut it seems that there was already an attempt to implement the arithmetic saturation on Mouse.cc, but the code is bugged and end up imposing limits to the actual X/Y coordinates instead of the offsets.\r\n\r\nThe fixed code for the lines 240-243 of Mouse.cc seems to be:\r\n\r\nint newX = curxrel - mev.getX();\r\nint newY = curyrel - mev.getY();\r\nint deltaX = max(127, min(-128, newX - curxrel));\r\nint deltaY = max(127, min(-128, newY - curyrel));\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/openMSX/openMSX/issues/comments/114815805","html_url":"https://github.com/openMSX/openMSX/issues/892#issuecomment-114815805","issue_url":"https://api.github.com/repos/openMSX/openMSX/issues/892","id":114815805,"user":{"login":"openMSX-import","id":12987176,"avatar_url":"https://avatars.githubusercontent.com/u/12987176?v=3","gravatar_id":"","url":"https://api.github.com/users/openMSX-import","html_url":"https://github.com/openMSX-import","followers_url":"https://api.github.com/users/openMSX-import/followers","following_url":"https://api.github.com/users/openMSX-import/following{/other_user}","gists_url":"https://api.github.com/users/openMSX-import/gists{/gist_id}","starred_url":"https://api.github.com/users/openMSX-import/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openMSX-import/subscriptions","organizations_url":"https://api.github.com/users/openMSX-import/orgs","repos_url":"https://api.github.com/users/openMSX-import/repos","events_url":"https://api.github.com/users/openMSX-import/events{/privacy}","received_events_url":"https://api.github.com/users/openMSX-import/received_events","type":"User","site_admin":false},"created_at":"2015-06-24T10:18:46Z","updated_at":"2015-06-24T10:18:46Z","body":"**Commented by sd-snatcher on 2013-09-02 02:16 UTC**\n\r\nThe Philips mouse may not have clipping, but I have a MK-Mouse II here and it clearly has.\r\n\r\nThe clipping seems to be implementation dependent. Some mice have, others don't. This happens because the MSX mice are implemented by software on a small microcontroller, so each mouse has a unique algorithm.\r\n\r\nIf you want to, I may record a video of my MK-Mouse II, similar to the one Werner recorded for the trackball. \r\n\r\n\r\n"}}