Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8111223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:02:08+00:00 2026-06-06T02:02:08+00:00

I’ve been trying several things to emulate a serial mouse for the DoxBox emulator

  • 0

I’ve been trying several things to emulate a serial mouse for the DoxBox emulator (in order to play a 2-player game in Settlers 2).

I haven’t found any working solution yet, so I tried making my own. It seems that dosbox can use any /dev/ttyS* as a serial input. So I thought directly writing some bits to a FIFO to mascarade as a serial mouse should do the thing! Unfortunately it doesn’t really work, as I’m obviously missing some steps (in particular initialisation, telling the driver that it is a mouse?), and I feel like I don’t really understand the workings of serial ports.

I haven’t found much on mouse protocol except the Microsoft serial mouse protocol. I tried outputting reasonable bytes. But nothing seems to really happen, and dosbox says it can’t open the serial port.

Here’s what I implemented:

def bits(byte):                                                                                                                                         
    b = []                                                                               
    for i in xrange(8):                                                                                                                                 
        b.append((byte >> i) & 1)                                                                                                                       
    return b                                                                                                                                            
def pack(*args):
    # packs the bits into a string                                                                                                                                        
    s = ""                                                                                                                                              
    for i in args:                                                                                                                                      
        v = 0                                                                                                                                           
        for bit in i:                                                                                                                                   
            v = v<<1                                                                                                                                    
            v+=bit                                                                                                                                      
        s+=chr(v)                                                                                                                                       
    return s                                                                                                                                            
def makebytes(ld,rd,dx,dy): 
    # left down, right down, delta x, delta y                                                                                   
    # create 3 byte message for mouse
    dx = bits(dx)                                                                                                                                       
    dy = bits(dy)                                                                                                                                       
    A = [0,1,                                                                                                                                           
         1 if ld else 0,                                                                                                                                
         1 if rd else 0,                                                                                                                                
         dx[7],dx[6],                                                                                                                                   
         dy[7],dy[6]]                                                                                                                                   
    B = [0,0]+dx[::-1][2:]                                                                                                                              
    C = [0,0]+dy[::-1][2:]                                                                                                                              
    return pack(A,B,C)                                                                                                                                  
# this is the FIFO I created with go+rw                                                                                                                                              
f = file("/dev/ttyS42",'w')                                                                                                                             
print "Got"                                                                                                                                          
import time                                                                                                                                             
while 1:                                                                                                                                                
    # send some mouse movement                                                                                                                                                    
    f.write(makebytes(0,0,10,10))                                                                                                                         
    print "sent 1"                                                                                                                                        
    time.sleep(0.5)                                                                                                                                     
    f.write(makebytes(0,0,-10,-10))                                                                                                                       
    print "sent 2"

So, I don’t know where to look now, and any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T02:02:11+00:00Added an answer on June 6, 2026 at 2:02 am

    Looking at the DosBox source it seems you’ll have trouble to use a FIFO because of how dosbox handles the serial port.

    In src/hardware/serialport/libserial.cpp, line 295 you see how the serial device is opened in unices :

    cp->porthandle = open (extended_portname, O_RDWR | O_NOCTTY | O_NONBLOCK);
    

    In any way, using O_RDWR with a FIFO leads to an unspecified behavior (see open(3) about O_RDWR).

    Moreover, even if the open() call succeeds, you will be blocked when the DosBox serial lib tries to get the terminal attributes of your device (line 298 of the same file)

    result = tcgetattr(cp->porthandle,&cp->backup);
    

    tcgetattr() will fail because it cannot retrieve termios data from a FIFO.

    I guess a FIFO is not the way to go to emulate your device, you should either try to roll your own kernel module, modify dosbox or use an external adaptater to connect a physical second mouse on a serial port.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.