MyMouse for developers (Windows)

Thanks for download MyMouse. This guide will help you to get acquainted for languages, process and the necessary variables for you, developer, can find on MyMouse a tool to create cool and innovate aplications.

MyMouse for “Windows OS” use the programming technique called “Named Pipes” that help you share data. This technique makes it possible to relate two processes on a machine or on different connected machines to share messages between processes and communicate.

The principal features of a “Named Pipes” are:

We are not going to delve into the concepts of a "Named Pipes", because we are sure that on the web there is a lot of information about it; This is why we chose this technique, since it provides flexibility to work with different programming languages and different communication procedures. In this guide we suggest some procedures to make it easy for you to develop your applications, but you can feel free to use whatever techniques you like.

Share panel

To show this panel, once linked the connection with the app for Smart phones you have to click right on the icon MyMouse where the connection is set and in the contextual menu click on the “Show Share Panel” option and immediately the panel open out with variable information to interact.

MyMouse

Note: The “Reset Share” option use for reset the connections if there´s a problem. Generally this mistakes are produced when it´s closed or don´t free the connection resources correctly on the client side, be very careful to close all connections used.

MyMouse
Variable description
MyMouse

MyMouse uses four names for each mouse to establish connections, this connections are independent, this means that each one of it can connect independent, but we recommend that always established the connection with ‘mymouse_one_send_state’ and/or ‘mymouse_two_send_state’ to control if there some mistake on the link.

Name for the connections:

mymouse_one_send_state and/or mymouse_two_send_state: It controls the status of the connection, its values are:

mymouse_one_send_x_y and/or mymouse_two_send_x_y: Controls the x, y position of the sensors. These values are concatenated and separated with the character ',' to use them independently a separation function is necessary, their values are:

mymouse_one_send_click and/or mymouse_two_send_click: Control the wheel keys, 'left click' and 'right click' of MyMouse. Its values are:

mymouse_one_send_key and/or mymouse_two_send_key: Control the keys of the keyboard of MyMouse, every key can contain until three values. His values are:

The icons below the table show the condition of the connection in every mouse.

Next, we suggest the next code lines to establish the connection in different programming languages:

    public static void main(String[ ] arg) 
    {
      final String dir = "\\\\.\\pipe\\mymouse_one_send_state";
      String res;

      try {
          // Connect to the named pipe
          RandomAccessFile pipe = new RandomAccessFile(dir, "r");
        
          while (null != (res = pipe.readLine())) 
          {
             System.out.println(res);
          }
          
          // Close the pipe
          pipe.close();
      }
      catch (Exception e) 
      {
        // TODO Auto-generated catch block
        e.printStackTrace(); 
      }      
    }         
              
        #include 'iostream'
        #include 'windows.h'
        
        HANDLE pipe;
        
        int main(int argc, const char **argv)
        {
            cout << "Connecting to pipe..." << endl;
            // Open the named pipe
            // Most of these parameters aren't very relevant for pipes.
            pipe = CreateFileW(
                L"\\\\.\\pipe\\mymouse_one_send_state",
                GENERIC_READ, // only need read access
                FILE_SHARE_READ,
                NULL,
                OPEN_EXISTING,
                FILE_ATTRIBUTE_NORMAL,
                NULL
            );
            if (pipe == INVALID_HANDLE_VALUE) {
                cout << "Failed to connect to pipe." << endl;
                // look up error code here using GetLastError()
                return 1;
            }
            
            cout << "Reading data from pipe..." << endl;
            
            while(true)
            {
              // The read operation will block until there is data to read
              char buffer[128];
              DWORD numBytesRead = 0;
              BOOL result = ReadFile(
                  pipe,
                  buffer, // the data from the pipe will be put here
                  127 * sizeof(char), // number of bytes allocated
                  &numBytesRead, // this will store number of bytes actually read
                  NULL // not using overlapped IO
              );
              if (result) 
              {
                  buffer[numBytesRead / sizeof(char)] = '\0'; // null terminate the string
                  cout << "Number of bytes read: " << numBytesRead << endl;
                  cout << "Message: " << buffer << endl;
              } 
              else 
              {
                  cout << "Failed to read data from the pipe." << endl;
                  break;
              }
            }
          
          // Close our pipe handle
          FlushFileBuffers(pipe);
          CloseHandle(pipe);
          cout << "Done." << endl;
          return 0;
        }
    private void readStateMouseOne()
    {
      pipeState = new NamedPipeClientStream(".", "mymouse_one_send_state", PipeDirection.In, PipeOptions.None);
    
      try
      {
        // Connect to the pipe or wait until the pipe is available.
        pipeState.Connect();
    
        srState = new StreamReader(pipeState);
        
        while (pipeState.IsConnected)
        {
          // Display the read
          String state = srState.ReadLine();
          Debug.WriteLine(state);
        }
        srState.Close();
        pipeState.Dispose();
        pipeState.Close();
        pipeState = null;
      }
      catch (Exception ex)
      {
        Debug.WriteLine("Error: " + ex.ToString());
      }
      finally
      {
        if (pipeState != null)
        {
          pipeState.Dispose();
          pipeState.Close();
          pipeState = null;
        }
      }
    }
MyMouse for developers (Android)

MyMouse for androidTV uses the programming technique called “Broadcast Receiver”. A “Broadcast Receiver” can be seen as a listener that attends to system events, these can be launched by the operating system, or in events launched by applications, as well as including additional information in an Intent. We are therefore faced with a mechanism that will allow us to integrate applications with each other and / or with Android, but also to establish an internal communication channel between components of the same app.

We are not going to delve into the concepts of a "Broadcast Receiver", because we are sure that on the web there is a lot of information about it; This is why we chose this technique in Android, since it afford flexibility for achievement of communications between Intens. In this guide we suggest some procedures to make it easy for you to develop your applications, but you can feel free to use whatever techniques you like.

Share Panel

To display this panel, once the connection with the application for smart phones has been made, the "SHARE" option must be selected from the icon menu in which the connection was established. The panel will immediately be displayed with the information of the variables with which it must interact.

MyMouse
Variables description

MyMouse uses four names for each mouse to establish connections, this connections are independent, this means that each one of it can connect independent, but we recommend that always established the connection with ‘mymouse_one_send_state’ and/or ‘mymouse_two_send_state’ to control if there some mistake on the link.

Unlike the application for “Windows OS”, the names of the variables of its procedures must be identical to those described in the panel.

Name for connections:

mymouse_one_send_state and/or mymouse_two_send_state: It controls the status of the connection, its values are:

mymouse_one_send_x_y and/or mymouse_two_send_x_y: Controls the x, y position of the sensors. These values are concatenated and separated with the character ',' to use them independently a separation function is necessary, their values are:

mymouse_one_send_click and/or mymouse_two_send_click: Control the wheel keys, 'left click' and 'right click' of MyMouse. Its values are:

mymouse_one_send_key and/or mymouse_two_send_key: Control the keys of the keyboard of MyMouse, every key can contain until three values. His values are:

Next, we suggest the next code lines to establish the connection with the “Boradcast Receiver” technique:

    //create IntentFilter and register the receiver
    IntentFilter filterState = new IntentFilter();
    filterState.addAction("mymouse_one_send_state");
    getApplicationContext().registerReceiver(new SampleReceiverMyMouseOneState(), filterState);


    //create SampleReceiverMyMouseOneState.java
    public class SampleReceiverMyMouseOneState extends BroadcastReceiver 
    {
      @Override
      public void onReceive(Context context, Intent intent) 
      {
          if ("mymouse_one_send_state".equals(intent.getAction())) 
          {
              String state = intent.getStringExtra("state");
              Log.i("stateMyMouseOne", state);
          }
      }
    }

We are happy to work with you, our commitment is to always stay updated so that you enjoy the development with the MyMouse features.

Thanks a lot.