Search
lxdream.org :: lxdream/src/maple/kbd.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/maple/kbd.c
changeset 736:a02d1475ccfd
prev614:a2d239d4438a
next770:429ff505c450
author nkeynes
date Mon Jul 14 07:44:42 2008 +0000 (15 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/kbd.c Mon Jan 28 02:38:09 2008 +0000
1.2 +++ b/src/maple/kbd.c Mon Jul 14 07:44:42 2008 +0000
1.3 @@ -24,27 +24,27 @@
1.4 #include "maple.h"
1.5
1.6 #define KEYBOARD_IDENT { 0x00, 0x00, 0x00, 0x40, 0x02, 0x05, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, \
1.7 - 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x4b, 0x65, 0x79, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x20, 0x20, \
1.8 - 0x20, 0x20, 0x20, 0x20, 0x20, 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 - 0x2c, 0x01, 0x90, 0x01 }
1.14 + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x4b, 0x65, 0x79, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x20, 0x20, \
1.15 + 0x20, 0x20, 0x20, 0x20, 0x20, 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 + 0x2c, 0x01, 0x90, 0x01 }
1.21
1.22 #define KEYBOARD_VERSION {0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x31, 0x2e, 0x30, 0x31, \
1.23 - 0x30, 0x2c, 0x31, 0x39, 0x39, 0x39, 0x2f, 0x30, 0x34, 0x2f, 0x32, 0x37, 0x2c, 0x33, 0x31, 0x35, \
1.24 - 0x2d, 0x36, 0x32, 0x31, 0x31, 0x2d, 0x41, 0x4d, 0x20, 0x20, 0x20, 0x2c, 0x4b, 0x65, 0x79, 0x20, \
1.25 - 0x53, 0x63, 0x61, 0x6e, 0x20, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x20, 0x3a, 0x20, 0x54, 0x68, \
1.26 - 0x65, 0x20, 0x32, 0x6e, 0x64, 0x20, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x20, 0x30, \
1.27 - 0x34, 0x2f, 0x32, 0x35 }
1.28 + 0x30, 0x2c, 0x31, 0x39, 0x39, 0x39, 0x2f, 0x30, 0x34, 0x2f, 0x32, 0x37, 0x2c, 0x33, 0x31, 0x35, \
1.29 + 0x2d, 0x36, 0x32, 0x31, 0x31, 0x2d, 0x41, 0x4d, 0x20, 0x20, 0x20, 0x2c, 0x4b, 0x65, 0x79, 0x20, \
1.30 + 0x53, 0x63, 0x61, 0x6e, 0x20, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x20, 0x3a, 0x20, 0x54, 0x68, \
1.31 + 0x65, 0x20, 0x32, 0x6e, 0x64, 0x20, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x20, 0x30, \
1.32 + 0x34, 0x2f, 0x32, 0x35 }
1.33
1.34 void keyboard_attach( maple_device_t dev );
1.35 void keyboard_detach( maple_device_t dev );
1.36 maple_device_t keyboard_clone( maple_device_t dev );
1.37 maple_device_t keyboard_new();
1.38 int keyboard_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 keyboard_device {
1.43 struct maple_device dev;
1.44 @@ -54,10 +54,10 @@
1.45 struct maple_device_class keyboard_class = { "Sega Keyboard", keyboard_new };
1.46
1.47 static struct keyboard_device base_keyboard = {
1.48 - { MAPLE_DEVICE_TAG, &keyboard_class, KEYBOARD_IDENT, KEYBOARD_VERSION,
1.49 - NULL, keyboard_attach, keyboard_detach, maple_default_destroy,
1.50 - keyboard_clone, NULL, NULL, keyboard_get_cond, NULL, NULL, NULL },
1.51 - {0,0,0,0,0,0,0,0},
1.52 + { MAPLE_DEVICE_TAG, &keyboard_class, KEYBOARD_IDENT, KEYBOARD_VERSION,
1.53 + NULL, keyboard_attach, keyboard_detach, maple_default_destroy,
1.54 + keyboard_clone, NULL, NULL, keyboard_get_cond, NULL, NULL, NULL },
1.55 + {0,0,0,0,0,0,0,0},
1.56 };
1.57
1.58 #define KEYBOARD(x) ((keyboard_device_t)(x))
1.59 @@ -81,12 +81,12 @@
1.60 {
1.61 int i;
1.62 for( i=2; i<8; i++ ) {
1.63 - if( dev->condition[i] == key ) {
1.64 - return; // key already down, missed event or repeat
1.65 - } else if( dev->condition[i] == 0 ) {
1.66 - dev->condition[i] = key;
1.67 - return;
1.68 - }
1.69 + if( dev->condition[i] == key ) {
1.70 + return; // key already down, missed event or repeat
1.71 + } else if( dev->condition[i] == 0 ) {
1.72 + dev->condition[i] = key;
1.73 + return;
1.74 + }
1.75 }
1.76 /* Key array is full - skip for the moment */
1.77 }
1.78 @@ -95,13 +95,13 @@
1.79 {
1.80 int i;
1.81 for( i=2; i<8; i++ ) {
1.82 - if( dev->condition[i] == key ) {
1.83 - for( ; i<7; i++ ) {
1.84 - dev->condition[i] = dev->condition[i+1];
1.85 - }
1.86 - dev->condition[7] = 0;
1.87 - break;
1.88 - }
1.89 + if( dev->condition[i] == key ) {
1.90 + for( ; i<7; i++ ) {
1.91 + dev->condition[i] = dev->condition[i+1];
1.92 + }
1.93 + dev->condition[7] = 0;
1.94 + break;
1.95 + }
1.96 }
1.97 }
1.98
1.99 @@ -110,26 +110,26 @@
1.100 keyboard_device_t dev = (keyboard_device_t)mdev;
1.101 uint16_t key = input_keycode_to_dckeysym( keycode );
1.102 if( key != 0 ) {
1.103 - if( key >> 8 == 0xFF ) { // shift
1.104 - if( isKeyDown ) {
1.105 - dev->condition[0] |= (key&0xFF);
1.106 - } else {
1.107 - dev->condition[0] &= ~(key&0xFF);
1.108 - }
1.109 - } else {
1.110 - if( isKeyDown ) {
1.111 - keyboard_key_down( dev, (uint8_t)key );
1.112 - } else {
1.113 - keyboard_key_up( dev, (uint8_t)key );
1.114 - }
1.115 - }
1.116 + if( key >> 8 == 0xFF ) { // shift
1.117 + if( isKeyDown ) {
1.118 + dev->condition[0] |= (key&0xFF);
1.119 + } else {
1.120 + dev->condition[0] &= ~(key&0xFF);
1.121 + }
1.122 + } else {
1.123 + if( isKeyDown ) {
1.124 + keyboard_key_down( dev, (uint8_t)key );
1.125 + } else {
1.126 + keyboard_key_up( dev, (uint8_t)key );
1.127 + }
1.128 + }
1.129 }
1.130 /*
1.131 fprintf( stderr, "Key cond: %02X %02X %02X %02X %02X %02X %02X %02X\n",
1.132 dev->condition[0], dev->condition[1], dev->condition[2],
1.133 dev->condition[3], dev->condition[4], dev->condition[5],
1.134 dev->condition[6], dev->condition[7] );
1.135 - */
1.136 + */
1.137 }
1.138
1.139 /**
1.140 @@ -148,7 +148,7 @@
1.141
1.142
1.143 int keyboard_get_cond( maple_device_t mdev, int function, unsigned char *outbuf,
1.144 - unsigned int *outlen )
1.145 + unsigned int *outlen )
1.146 {
1.147 keyboard_device_t dev = (keyboard_device_t)mdev;
1.148 if( function == MAPLE_FUNC_KEYBOARD ) {
.