diff options
author | 2017-07-11 02:31:42 +1000 | |
---|---|---|
committer | 2017-07-11 02:31:42 +1000 | |
commit | c5c3012634f76a15b30637cc687519cb5989667d (patch) | |
tree | ca0b98d7a40cbe4c93eb2c8f6f082ad7c242d42f /src/devices/bus/rs232/ser_mouse.cpp | |
parent | 7d980227979c30aac9eb527f15c5b893aebea5c6 (diff) |
Cleaned up serial, matrix keyboard and TI-8x link protocol interfaces:
* Switched to delegate timers
- Frees implementations from having to call timer method
- Eliminates risk of ID conflicts with implementations/other interfaces
* Moved save state registration to interface post start
- Plays nicely with device_missing_dependencies exceptions
- Frees implementation from having to call save state registration method
- Improves save state support in devices that neglected to call method
Diffstat (limited to 'src/devices/bus/rs232/ser_mouse.cpp')
-rw-r--r-- | src/devices/bus/rs232/ser_mouse.cpp | 72 |
1 files changed, 34 insertions, 38 deletions
diff --git a/src/devices/bus/rs232/ser_mouse.cpp b/src/devices/bus/rs232/ser_mouse.cpp index d84f9a4d5f3..2c80fc43ef5 100644 --- a/src/devices/bus/rs232/ser_mouse.cpp +++ b/src/devices/bus/rs232/ser_mouse.cpp @@ -86,46 +86,42 @@ void serial_mouse_device::tra_callback() **************************************************************************/ void serial_mouse_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { - if (id) + if (!id) { - device_serial_interface::device_timer(timer, id, param, ptr); - return; + static int ox = 0, oy = 0; + int nx,ny; + int dx, dy, nb; + int mbc; + + /* Do not get deltas or send packets if queue is not empty (Prevents drifting) */ + if (m_head==m_tail) + { + nx = m_x->read(); + + dx = nx - ox; + if (dx<=-0x800) dx = nx + 0x1000 - ox; /* Prevent jumping */ + if (dx>=0x800) dx = nx - 0x1000 - ox; + ox = nx; + + ny = m_y->read(); + + dy = ny - oy; + if (dy<=-0x800) dy = ny + 0x1000 - oy; + if (dy>=0x800) dy = ny - 0x1000 - oy; + oy = ny; + + nb = m_btn->read(); + mbc = nb^m_mb; + m_mb = nb; + + /* check if there is any delta or mouse buttons changed */ + if ( (dx!=0) || (dy!=0) || (mbc!=0) ) + mouse_trans(dx, dy, nb, mbc); + } + + if(m_tail != m_head && is_transmit_register_empty()) + transmit_register_setup(unqueue_data()); } - - static int ox = 0, oy = 0; - int nx,ny; - int dx, dy, nb; - int mbc; - - /* Do not get deltas or send packets if queue is not empty (Prevents drifting) */ - if (m_head==m_tail) - { - nx = m_x->read(); - - dx = nx - ox; - if (dx<=-0x800) dx = nx + 0x1000 - ox; /* Prevent jumping */ - if (dx>=0x800) dx = nx - 0x1000 - ox; - ox = nx; - - ny = m_y->read(); - - dy = ny - oy; - if (dy<=-0x800) dy = ny + 0x1000 - oy; - if (dy>=0x800) dy = ny - 0x1000 - oy; - oy = ny; - - nb = m_btn->read(); - mbc = nb^m_mb; - m_mb = nb; - - /* check if there is any delta or mouse buttons changed */ - if ( (dx!=0) || (dy!=0) || (mbc!=0) ) - mouse_trans(dx, dy, nb, mbc); - } - - - if(m_tail != m_head && is_transmit_register_empty()) - transmit_register_setup(unqueue_data()); } void microsoft_mouse_device::mouse_trans(int dx, int dy, int nb, int mbc) |