2007-03-21 21:54:41 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2011-02-25 01:05:47 +03:00
|
|
|
// $Id$
|
2007-03-21 21:54:41 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2012-08-31 16:08:19 +04:00
|
|
|
// USB HID emulation support (mouse and tablet) ported from QEMU
|
|
|
|
// USB keypad emulation based on code by Benjamin D Lunt (fys at frontiernet net)
|
2007-03-21 21:54:41 +03:00
|
|
|
//
|
2012-08-31 16:08:19 +04:00
|
|
|
// Copyright (c) 2005 Fabrice Bellard
|
|
|
|
// Copyright (c) 2007 OpenMoko, Inc. (andrew@openedhand.com)
|
|
|
|
// Copyright (C) 2009-2012 The Bochs Project
|
2007-03-21 21:54:41 +03:00
|
|
|
//
|
2012-08-31 16:08:19 +04:00
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
// furnished to do so, subject to the following conditions:
|
2007-03-21 21:54:41 +03:00
|
|
|
//
|
2012-08-31 16:08:19 +04:00
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
// THE SOFTWARE.
|
2009-02-08 00:05:31 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2007-03-21 21:54:41 +03:00
|
|
|
|
|
|
|
#ifndef BX_IODEV_USB_HID_H
|
|
|
|
#define BX_IODEV_USB_HID_H
|
|
|
|
|
|
|
|
|
2009-01-19 12:48:12 +03:00
|
|
|
class usb_hid_device_c : public usb_device_c {
|
2007-03-21 21:54:41 +03:00
|
|
|
public:
|
2009-01-19 12:48:12 +03:00
|
|
|
usb_hid_device_c(usbdev_type type);
|
|
|
|
virtual ~usb_hid_device_c(void);
|
2007-03-21 21:54:41 +03:00
|
|
|
|
|
|
|
virtual void handle_reset();
|
|
|
|
virtual int handle_control(int request, int value, int index, int length, Bit8u *data);
|
|
|
|
virtual int handle_data(USBPacket *p);
|
2007-04-01 15:15:48 +04:00
|
|
|
virtual void register_state_specific(bx_list_c *parent);
|
2007-03-21 21:54:41 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
struct {
|
|
|
|
int mouse_delayed_dx;
|
|
|
|
int mouse_delayed_dy;
|
|
|
|
int mouse_delayed_dz;
|
2007-03-24 14:43:41 +03:00
|
|
|
Bit16s mouse_x;
|
|
|
|
Bit16s mouse_y;
|
2007-03-21 21:54:41 +03:00
|
|
|
Bit8s mouse_z;
|
|
|
|
Bit8u b_state;
|
2007-03-25 21:37:59 +04:00
|
|
|
Bit8u saved_key[8];
|
|
|
|
Bit8u key_pad_packet[8];
|
2007-03-21 21:54:41 +03:00
|
|
|
} s;
|
2009-03-03 00:21:16 +03:00
|
|
|
|
2009-03-03 21:29:51 +03:00
|
|
|
static bx_bool key_enq_static(void *dev, Bit8u *scan_code);
|
|
|
|
bx_bool key_enq(Bit8u *scan_code);
|
2009-03-03 00:21:16 +03:00
|
|
|
static void mouse_enabled_changed(void *dev, bx_bool enabled);
|
2012-06-21 21:33:37 +04:00
|
|
|
static void mouse_enq_static(void *dev, int delta_x, int delta_y, int delta_z, unsigned button_state, bx_bool absxy);
|
|
|
|
void mouse_enq(int delta_x, int delta_y, int delta_z, unsigned button_state, bx_bool absxy);
|
2009-03-03 00:21:16 +03:00
|
|
|
int mouse_poll(Bit8u *buf, int len);
|
|
|
|
int keypad_poll(Bit8u *buf, int len);
|
2007-03-21 21:54:41 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|