Search
lxdream.org :: lxdream/src/maple/mouse.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/maple/mouse.c
changeset 736:a02d1475ccfd
prev669:ab344e42bca9
next770:429ff505c450
author nkeynes
date Mon Jul 14 07:44:42 2008 +0000 (11 years ago)
permissions -rw-r--r--
last change Re-indent everything consistently
Fix include guards for consistency as well
file annotate diff log raw
1.1 --- a/src/maple/mouse.c Mon May 12 10:00:13 2008 +0000
1.2 +++ b/src/maple/mouse.c Mon Jul 14 07:44:42 2008 +0000
1.3 @@ -22,19 +22,19 @@
1.4 #include "maple/maple.h"
1.5
1.6 #define MOUSE_IDENT { 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,\
1.7 - 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x44, 0x72, 0x65, 0x61, 0x6d, 0x63, 0x61, 0x73, 0x74, 0x20,\
1.8 - 0x4d, 0x6f, 0x75, 0x73, 0x65, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\
1.9 - 0x20, 0x20, 0x20, 0x20, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x64, 0x20, 0x42, 0x79, 0x20,\
1.10 - 0x6f, 0x72, 0x20, 0x55, 0x6e, 0x64, 0x65, 0x72, 0x20, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65,\
1.11 - 0x20, 0x46, 0x72, 0x6f, 0x6d, 0x20, 0x53, 0x45, 0x47, 0x41, 0x20, 0x45, 0x4e, 0x54, 0x45, 0x52,\
1.12 - 0x50, 0x52, 0x49, 0x53, 0x45, 0x53, 0x2c, 0x4c, 0x54, 0x44, 0x2e, 0x20, 0x20, 0x20, 0x20, 0x20,\
1.13 - 0x90, 0x01, 0xf4, 0x01 }
1.14 + 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x44, 0x72, 0x65, 0x61, 0x6d, 0x63, 0x61, 0x73, 0x74, 0x20,\
1.15 + 0x4d, 0x6f, 0x75, 0x73, 0x65, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\
1.16 + 0x20, 0x20, 0x20, 0x20, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x64, 0x20, 0x42, 0x79, 0x20,\
1.17 + 0x6f, 0x72, 0x20, 0x55, 0x6e, 0x64, 0x65, 0x72, 0x20, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65,\
1.18 + 0x20, 0x46, 0x72, 0x6f, 0x6d, 0x20, 0x53, 0x45, 0x47, 0x41, 0x20, 0x45, 0x4e, 0x54, 0x45, 0x52,\
1.19 + 0x50, 0x52, 0x49, 0x53, 0x45, 0x53, 0x2c, 0x4c, 0x54, 0x44, 0x2e, 0x20, 0x20, 0x20, 0x20, 0x20,\
1.20 + 0x90, 0x01, 0xf4, 0x01 }
1.21 #define MOUSE_VERSION { 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x31, 0x2e, 0x30, 0x30,\
1.22 - 0x30, 0x2c, 0x32, 0x30, 0x30, 0x30, 0x2f, 0x30, 0x32, 0x2f, 0x32, 0x35, 0x2c, 0x33, 0x31, 0x35,\
1.23 - 0x2d, 0x36, 0x32, 0x31, 0x31, 0x2d, 0x41, 0x54, 0x20, 0x20, 0x20, 0x2c, 0x33, 0x20, 0x42, 0x75,\
1.24 - 0x74, 0x74, 0x6f, 0x6e, 0x20, 0x26, 0x20, 0x58, 0x2d, 0x59, 0x20, 0x42, 0x61, 0x6c, 0x6c, 0x20,\
1.25 - 0x26, 0x20, 0x5a, 0x20, 0x57, 0x68, 0x65, 0x65, 0x6c, 0x20, 0x2c, 0x34, 0x30, 0x30, 0x64, 0x70,\
1.26 - 0x69, 0x20, 0x20, 0x20 }
1.27 + 0x30, 0x2c, 0x32, 0x30, 0x30, 0x30, 0x2f, 0x30, 0x32, 0x2f, 0x32, 0x35, 0x2c, 0x33, 0x31, 0x35,\
1.28 + 0x2d, 0x36, 0x32, 0x31, 0x31, 0x2d, 0x41, 0x54, 0x20, 0x20, 0x20, 0x2c, 0x33, 0x20, 0x42, 0x75,\
1.29 + 0x74, 0x74, 0x6f, 0x6e, 0x20, 0x26, 0x20, 0x58, 0x2d, 0x59, 0x20, 0x42, 0x61, 0x6c, 0x6c, 0x20,\
1.30 + 0x26, 0x20, 0x5a, 0x20, 0x57, 0x68, 0x65, 0x65, 0x6c, 0x20, 0x2c, 0x34, 0x30, 0x30, 0x64, 0x70,\
1.31 + 0x69, 0x20, 0x20, 0x20 }
1.32
1.33 #define BUTTON_MIDDLE 0x01
1.34 #define BUTTON_RIGHT 0x02
1.35 @@ -46,7 +46,7 @@
1.36 maple_device_t mouse_clone( maple_device_t dev );
1.37 maple_device_t mouse_new();
1.38 int mouse_get_cond( maple_device_t dev, int function, unsigned char *outbuf,
1.39 - unsigned int *outlen );
1.40 + unsigned int *outlen );
1.41
1.42 typedef struct mouse_device {
1.43 struct maple_device dev;
1.44 @@ -57,10 +57,10 @@
1.45 struct maple_device_class mouse_class = { "Sega Mouse", mouse_new };
1.46
1.47 static struct mouse_device base_mouse = {
1.48 - { MAPLE_DEVICE_TAG, &mouse_class, MOUSE_IDENT, MOUSE_VERSION,
1.49 - NULL, mouse_attach, mouse_detach, maple_default_destroy,
1.50 - mouse_clone, NULL, NULL, mouse_get_cond, NULL, NULL, NULL },
1.51 - 0, {0,0,0,0,0,0,0,0},
1.52 + { MAPLE_DEVICE_TAG, &mouse_class, MOUSE_IDENT, MOUSE_VERSION,
1.53 + NULL, mouse_attach, mouse_detach, maple_default_destroy,
1.54 + mouse_clone, NULL, NULL, mouse_get_cond, NULL, NULL, NULL },
1.55 + 0, {0,0,0,0,0,0,0,0},
1.56 };
1.57
1.58 static int32_t mouse_axis_scale_factors[8] = { 10, 10, 1, 1, 1, 1, 1, 1 };
1.59 @@ -88,16 +88,16 @@
1.60 mouse_device_t dev = (mouse_device_t)mdev;
1.61 dev->buttons = 0xFF;
1.62 if( buttons & 0x01 ) {
1.63 - dev->buttons &= ~BUTTON_LEFT;
1.64 + dev->buttons &= ~BUTTON_LEFT;
1.65 }
1.66 if( buttons & 0x02 ) {
1.67 - dev->buttons &= ~BUTTON_MIDDLE;
1.68 + dev->buttons &= ~BUTTON_MIDDLE;
1.69 }
1.70 if( buttons & 0x04 ) {
1.71 - dev->buttons &= ~BUTTON_RIGHT;
1.72 + dev->buttons &= ~BUTTON_RIGHT;
1.73 }
1.74 if( buttons & 0x08 ) {
1.75 - dev->buttons &= ~BUTTON_THUMB;
1.76 + dev->buttons &= ~BUTTON_THUMB;
1.77 }
1.78 dev->axis[0] += x;
1.79 dev->axis[1] += y;
1.80 @@ -114,26 +114,26 @@
1.81 }
1.82
1.83 int mouse_get_cond( maple_device_t mdev, int function, unsigned char *outbuf,
1.84 - unsigned int *outlen )
1.85 + unsigned int *outlen )
1.86 {
1.87 mouse_device_t dev = (mouse_device_t)mdev;
1.88 if( function == MAPLE_FUNC_MOUSE ) {
1.89 *outlen = 5;
1.90 - *(uint32_t *)outbuf = dev->buttons;
1.91 - uint16_t *p = (uint16_t *)(outbuf+4);
1.92 - int i;
1.93 - // Axis values are in the range 0..0x3FF, where 0x200 is zero movement
1.94 - for( i=0; i<8; i++ ) {
1.95 - int32_t value = dev->axis[i] / mouse_axis_scale_factors[i];
1.96 - if( value < -0x200 ) {
1.97 - p[i] = 0;
1.98 - } else if( value > 0x1FF ) {
1.99 - p[i] = 0x3FF;
1.100 - } else {
1.101 - p[i] = 0x200 + value;
1.102 - }
1.103 - dev->axis[i] = 0; // clear after returning.
1.104 - }
1.105 + *(uint32_t *)outbuf = dev->buttons;
1.106 + uint16_t *p = (uint16_t *)(outbuf+4);
1.107 + int i;
1.108 + // Axis values are in the range 0..0x3FF, where 0x200 is zero movement
1.109 + for( i=0; i<8; i++ ) {
1.110 + int32_t value = dev->axis[i] / mouse_axis_scale_factors[i];
1.111 + if( value < -0x200 ) {
1.112 + p[i] = 0;
1.113 + } else if( value > 0x1FF ) {
1.114 + p[i] = 0x3FF;
1.115 + } else {
1.116 + p[i] = 0x200 + value;
1.117 + }
1.118 + dev->axis[i] = 0; // clear after returning.
1.119 + }
1.120 return 0;
1.121 } else {
1.122 return MAPLE_ERR_FUNC_UNSUP;
.