![]() |
Wireless-X
|
This includes the code for the server-side of Wireless-X. More...
Functions | |
def | Wireless-X_server.bind_sockets () |
This function establishes two sockets for receiving camera frames as well as mouse and keyboard actions. More... | |
def | Wireless-X_server.mouse_keyboard_connections () |
This function decodes the received mouse and keyboard actions and acts accordingly. More... | |
def | Wireless-X_server.camera_stream_connections () |
This function is responsible for handling the camera frames. More... | |
def | Wireless-X_server.listening_connections () |
This function is responsible for listening to connections. More... | |
Variables | |
Wireless-X_server.virtualCamera = subprocess.run(["sudo", "modprobe", "v4l2loopback", "devices=1", "video_nr=20", "card_label='Wireless-X Camera'", "exclusive_caps=1"]) | |
Creates a virtual camera on the laptop/PC. | |
Wireless-X_server.width | |
Stores the width of the screen. | |
Wireless-X_server.height | |
Stores the height of the screen. | |
Wireless-X_server.curr_x | |
Stores the x-coordinate of the current mouse location. | |
Wireless-X_server.curr_y | |
Stores the y-coordinate of the current mouse location. | |
def | Wireless-X_server.remote_x = curr_x/2 |
Stores the mid of x-coordinate of current mouse location. | |
def | Wireless-X_server.remote_y = curr_y/2 |
Stores the mid of y-coordinate of current mouse location. | |
string | Wireless-X_server.s = '' |
Socket used for receiving keyboard and mouse related actions. | |
string | Wireless-X_server.cameraSocket = '' |
Socket used for receiving the camera frames of user's smartphone. | |
int | Wireless-X_server.img_width = 720 |
Width of the camera frame. | |
int | Wireless-X_server.img_height = 480 |
Height of the camera frame. | |
Wireless-X_server.camera = pyfakewebcam.FakeWebcam('/dev/video20', img_width, img_height) | |
Virtual webcam device. | |
bool | Wireless-X_server.thread_run = True |
The camera and keyboard-mouse sockets receive user requests until this variable is set to 'True'. | |
Wireless-X_server.keyboard = KeyboardController() | |
Initializing the KeyboardController object. | |
Wireless-X_server.mouse = MouseController() | |
Initializing the MouseController object. | |
int | Wireless-X_server.mouse_speed = 2 |
Speed of mouse movement. | |
int | Wireless-X_server.screenshot_count = 0 |
Screenshot counter to keep track of screenshots. | |
dictionary | Wireless-X_server.special_key_android_dictionary = {"F1": "F1", "F2":"F2", "F3":"F3", "F4":"F4", "F5":"F5", "F6":"F6", "F7":"F7", "F8":"F8", "F9":"F9", "F10":"F10", "F11":"F11", "F12":"F12", "Alt":"ALT", "Backspace":"BACKSPACE", "Caps\nLock":"CAPS_LOCK", "Ctrl":"CONTROL", "Delete":"DELETE", "↓":"DOWN_ARROW", "End":"END", "Esc":"ESCAPE", "Home":"HOME", "←":"LEFT_ARROW", "META":"META", "Page Down":"PAGE_DOWN", "Page Up":"PAGE_UP", "Enter":"RETURN", "→":"RIGHT_ARROW", "Shift":"SHIFT", "Space":"SPACE", "↑":"UP_ARROW", "Tab":"Tab"} |
Maps the keys in keyboard layout to the actual keyboard keys. | |
This includes the code for the server-side of Wireless-X.
The server running on laptop or PC is responsible for receiving the actions performed by user on the Wireless-X android app as well as receiving the camera frames of the user's smartphone (if the user has turned) on the camera). Such actions are transmitted to the server in encoded form, the server decodes the received message and instructs the laptop or PC to perform the action described in that message.
def Wireless-X_server.bind_sockets | ( | ) |
This function establishes two sockets for receiving camera frames as well as mouse and keyboard actions.
This function creates a camera socket which is responsible for receiving the camera frames, and it also creates another socket which is responsible for receiving the keyboard and mouse frames.
def Wireless-X_server.camera_stream_connections | ( | ) |
This function is responsible for handling the camera frames.
This function uses the 'OpenCV' library to decode and resize the camera frame. Then, this frame is scheduled on the virtual webcam device created using 'pyfakewebcam' library.
def Wireless-X_server.listening_connections | ( | ) |
This function is responsible for listening to connections.
This function creates two threads corresponding to the two sockets, one for handling mouse and keyboard events and the other for handling camera frames received from the user's smartphone.
def Wireless-X_server.mouse_keyboard_connections | ( | ) |
This function decodes the received mouse and keyboard actions and acts accordingly.
This function checks if the message received corresponds to a mouse action (left-click, scroll, etc.) or a keyboard action (such as keypress). It then instructs the laptop to perform these actions, using the 'autopy' and 'pynput' libraries. Some special characters in keyboard are not supported by 'autopy' library, so the actions corresponding to these special characters are performed by the 'pynput' library, other key actions are handled by the 'autopy' library. In case of mouse, the 'autopy' library was not that efficient, so we used the 'pynput' library.