I've done something similar for a USB barcode reader that presents as a HID keyboard.
In recent kernels, there will be an event device for the mouse in /dev/input/event*. If you open that and grab that with the EVIOCGRAB ioctl(), it won't send mouse events to any other app. You can then read events straight off the mouse - see the evdev interface documentation in Documentation/input/input.txt in the linux source code distro.
When you read from the event device, you'll get a whole number of input events, in the following form:
struct input_event {
struct timeval time;
unsigned short type;
unsigned short code;
unsigned int value;
};
(struct input_event and the following macros are all defined in linux/input.h).
The events you're interested in will have input_event.type == EV_REL (relative movement event), the input_event.code member will be something like REL_X (indicating X-axis - see the linux/input.h file for the full list), and input_event.value will be the displacement.
There is no need to implement the HID protocol yourself, as another answer suggests.