Raspberry Pi Official Mouse (White-Red)
Raspberry Pi Official Mouse (White-Red)
The Raspberry Pi Official Mouse (White-Red) is a compact, high-quality computer mouse designed specifically for use with Raspberry Pi single-board computers. This official mouse is a perfect accessory for Raspberry Pi enthusiasts, providing a reliable and efficient way to interact with their projects.
The Raspberry Pi Official Mouse (White-Red) is a standard optical mouse that allows users to navigate and interact with their Raspberry Pi device graphically. The mouse connects to the Raspberry Pi via a USB port and provides a plug-and-play experience, requiring no additional drivers or setup.
USB
Optical
1000 DPI
Three-button design (left, right, and scroll wheel)
1.5m
Raspberry Pi models (all)
The Raspberry Pi Official Mouse (White-Red) is a high-quality, reliable, and compact mouse designed specifically for use with Raspberry Pi devices. Its optical sensor, three-button design, and ergonomic shape provide an excellent user experience, making it an ideal accessory for Raspberry Pi enthusiasts and project builders.
Raspberry Pi Official Mouse (White-Red) Documentation
The Raspberry Pi Official Mouse (White-Red) is a high-quality, optical mouse designed specifically for use with the Raspberry Pi series of single-board computers. This mouse is a Plug-and-Play device, making it easy to use with your Raspberry Pi projects.
Technical Specifications:
Interface: USB
Resolution: 1000 dpi optical sensor
Buttons: 3 (left, right, and middle)
Power Consumption: Bus-powered
Compatibility: Raspberry Pi 1, 2, 3, 4, and Zero series
Using the Raspberry Pi Official Mouse with Raspberry Pi OS
To use the Raspberry Pi Official Mouse with Raspberry Pi OS, simply plug it into one of the available USB ports on your Raspberry Pi. The mouse will be automatically recognized by the operating system, and you can start using it immediately.
Code Example 1: Using the Mouse with Python in Raspberry Pi OS
In this example, we will use the `python-uinput` library to read mouse events in Python. First, install the required library by running the following command:
```
sudo pip install python-uinput
```
Then, create a new Python script with the following code:
```python
import uinput
# Create a new uinput device
device = uinput.Device()
# Read mouse events
while True:
event = device.read()
if event:
if event.ev_type == uinput.EV_REL:
print(f"Mouse moved: {event.code} {event.value}")
elif event.ev_type == uinput.EV_KEY:
if event.code == uinput.BTN_LEFT:
print("Left button pressed")
elif event.code == uinput.BTN_RIGHT:
print("Right button pressed")
elif event.code == uinput.BTN_MIDDLE:
print("Middle button pressed")
```
Run the script, and you will see mouse events printed to the console as you move the mouse and press the buttons.
Code Example 2: Using the Mouse with Scratch in Raspberry Pi OS
In this example, we will use Scratch to create a simple program that responds to mouse events.
Create a new Scratch project and add the following blocks:
`When space key pressed` block to initialize the program
`Forever` block to continuously read mouse events
`Mouse x` and `Mouse y` blocks to get the current mouse position
`If-Then` block to check for button presses
`Say` block to print a message to the console when a button is pressed
Here's an example Scratch program:

Run the program, and you will see the mouse position printed to the console as you move the mouse and press the buttons.
Code Example 3: Using the Mouse with RetroPie
In this example, we will configure RetroPie to use the Raspberry Pi Official Mouse as a controller for emulated games.
First, install RetroPie on your Raspberry Pi by following the official installation guide. Then, edit the RetroPie configuration file by running the following command:
```
sudo nano /etc/retropie/configs/all/retroarch.cfg
```
Add the following lines to the end of the file:
```
input_player1_mouse_enable = "true"
input_player1_mouse_btn_1 = "1"
input_player1_mouse_btn_2 = "2"
input_player1_mouse_btn_3 = "3"
```
Save and exit the editor. Restart RetroPie, and you can now use the Raspberry Pi Official Mouse as a controller in your emulated games.
These examples demonstrate the ease of use and flexibility of the Raspberry Pi Official Mouse (White-Red) in various contexts. Whether you're developing with Python, creating interactive projects with Scratch, or playing classic games with RetroPie, this mouse is an excellent addition to your Raspberry Pi projects.