http://ep.lgb.hu/jsep/demo.new/enterprise.jsIn this file there are several important parts of the emulator, we can say the "glue" and "init" code or such. It also registers the JS events browser will call in case of mouse events, eg this line:
document.addEventListener("mousemove", mouseMoveCallback, false);
The event handlers themselves are in mouse.js, see later. Also, the I/O port emulation is in this file, check functions readport and writeport out. Maybe it's the best to search for words mouse and Mouse in enterprise.js to find important places.
http://ep.lgb.hu/jsep/demo.new/mouse.jsIn this file, you can find the mouse specific stuffs, incuding the handlers registered in enterprise.js:
mouseMoveCallback
mouseClickCallback
mouseGrabbingCallback
Also the routines called by the I/O port reading in enterprise.js, function readport, see at port 0xB6, mouseRead(). Also writeport() function uses mouseCheckDataShift() function.
Important to note: in readport() you can see odd port numbers 0x40, 0x41, 0x42. There are for test purposes I used for my initial test, it's nothing to do with the boxsoft compatibilty, honestly I only forget to remove them
![Smiley :)](/Smileys/phpbb/smiley.gif)
It defines a simple interface without bit shifting etc, so it was easier to test the mouse handling itself. Btw, an interface like this would be very comfortable and simple in real too, but of course it wouldn't be compatible with anything existing software and would require a card in the expansion bay, or such.
One important part is mouseCheckDataShift() in mouse.js keySel is a quite important variable in many places, it's the value written by port 0xB5 and used by keyboard and joystick emulation as well, again see writeport() in enterprise.js
It was JSep, Xep128 is somewhat different by nature (not JS events, etc, but the SDL even loop, and of course C, not JS), but the idea is very similar, in fact, I used my own code in JSep, the create something similar, without thinking too much about the re-implementation from zero. In Xep128, many input related stuffs (even kbd) are in this file:
https://github.com/lgblgblgb/xep128/blob/master/input.cCheck functions out with "mouse" in their name. Quite similar as they're in JSep. As with readport and writeport in JSep, you can find functions _pread and _pwrite here:
https://github.com/lgblgblgb/xep128/blob/master/cpu.cAnd the heart of the emulation loop is here:
https://github.com/lgblgblgb/xep128/blob/master/main.cemu_one_frame() is called after each frame, which calls the present frame function first to show it, and then it looks for pending SDL events (it's not like JS events browser call for you, you must check events and process here). They include key events (used to emulate keyboard) and also mouse events.
I am not sure if my post helped
![Smiley :)](/Smileys/phpbb/smiley.gif)