diff options
author | 2013-01-11 07:32:46 +0000 | |
---|---|---|
committer | 2013-01-11 07:32:46 +0000 | |
commit | 0e19f641d3186cdbf51f8ca857e2b07ab95779c2 (patch) | |
tree | 234109de1123b13f217494af4b3f8efad346d5cc /src/osd/sdl/input.c | |
parent | 111157ca09a9ff60fe4a9ba49173c315e94314fa (diff) |
Cleanups and version bumpmame0148
Diffstat (limited to 'src/osd/sdl/input.c')
-rw-r--r-- | src/osd/sdl/input.c | 1242 |
1 files changed, 621 insertions, 621 deletions
diff --git a/src/osd/sdl/input.c b/src/osd/sdl/input.c index 75aa92fcdd6..933c2799f0b 100644 --- a/src/osd/sdl/input.c +++ b/src/osd/sdl/input.c @@ -53,12 +53,12 @@ enum POVDIR_DOWN }; -#define MAX_KEYS 256 -#define MAX_AXES 32 -#define MAX_BUTTONS 32 -#define MAX_HATS 8 -#define MAX_POV 4 -#define MAX_DEVMAP_ENTRIES 16 +#define MAX_KEYS 256 +#define MAX_AXES 32 +#define MAX_BUTTONS 32 +#define MAX_HATS 8 +#define MAX_POV 4 +#define MAX_DEVMAP_ENTRIES 16 #if (USE_XINPUT) //For xinput @@ -79,7 +79,7 @@ static int proximity_out_type = INVALID_EVENT_TYPE; // introduced in 1.3 #ifndef SDLK_INDEX -#define SDLK_INDEX(x) (x) +#define SDLK_INDEX(x) (x) #endif @@ -90,9 +90,9 @@ static int proximity_out_type = INVALID_EVENT_TYPE; // state information for a keyboard struct keyboard_state { - INT32 state[0x3ff]; // must be INT32! - INT8 oldkey[MAX_KEYS]; - INT8 currkey[MAX_KEYS]; + INT32 state[0x3ff]; // must be INT32! + INT8 oldkey[MAX_KEYS]; + INT8 currkey[MAX_KEYS]; }; @@ -118,11 +118,11 @@ struct joystick_state // state information for a lightgun struct lightgun_state { - INT32 lX, lY; - INT32 buttons[MAX_BUTTONS]; - XID deviceid; //Xinput device id - INT32 maxx,maxy; - INT32 minx,miny; + INT32 lX, lY; + INT32 buttons[MAX_BUTTONS]; + XID deviceid; //Xinput device id + INT32 maxx,maxy; + INT32 minx,miny; }; #endif @@ -130,21 +130,21 @@ struct lightgun_state struct device_info { // device information - device_info ** head; - device_info * next; - char * name; + device_info ** head; + device_info * next; + char * name; // MAME information - input_device * device; + input_device * device; // device state union { - keyboard_state keyboard; - mouse_state mouse; - joystick_state joystick; + keyboard_state keyboard; + mouse_state mouse; + joystick_state joystick; #if (USE_XINPUT) - lightgun_state lightgun; + lightgun_state lightgun; #endif }; }; @@ -155,40 +155,40 @@ struct device_info //============================================================ // global states -static osd_lock * input_lock; -static UINT8 input_paused; +static osd_lock * input_lock; +static UINT8 input_paused; -static sdl_window_info * focus_window = NULL; +static sdl_window_info * focus_window = NULL; // input buffer - only for SDLMAME_EVENTS_IN_WORKER_THREAD -#define MAX_BUF_EVENTS (500) /* 100 not enough for SDL 1.3 */ -static SDL_Event event_buf[MAX_BUF_EVENTS]; -static int event_buf_count; +#define MAX_BUF_EVENTS (500) /* 100 not enough for SDL 1.3 */ +static SDL_Event event_buf[MAX_BUF_EVENTS]; +static int event_buf_count; // keyboard states -static device_info * keyboard_list; +static device_info * keyboard_list; // mouse states -static UINT8 app_has_mouse_focus; -static UINT8 mouse_enabled; -static device_info * mouse_list; +static UINT8 app_has_mouse_focus; +static UINT8 mouse_enabled; +static device_info * mouse_list; // lightgun states -static UINT8 lightgun_enabled; -static device_info * lightgun_list; +static UINT8 lightgun_enabled; +static device_info * lightgun_list; // joystick states -static device_info * joystick_list; +static device_info * joystick_list; // joystick mapper struct device_map_t { struct { - char *name; - int physical; + char *name; + int physical; } map[MAX_DEVMAP_ENTRIES]; - int logical[MAX_DEVMAP_ENTRIES]; + int logical[MAX_DEVMAP_ENTRIES]; int initialized; }; @@ -231,12 +231,12 @@ static device_info *generic_device_find_index(device_info *devlist_head, int ind // master keyboard translation table struct kt_table { - input_item_id mame_key; - INT32 sdl_key; + input_item_id mame_key; + INT32 sdl_key; //const char * vkey; //const char * ascii; - const char * mame_key_name; - char * ui_name; + const char * mame_key_name; + char * ui_name; }; #if (SDLMAME_SDL2) @@ -260,113 +260,113 @@ struct kt_table { static kt_table sdl_key_trans_table[] = { // MAME key SDL key vkey ascii - KTT_ENTRY0( ESC, ESCAPE, 0x1b, 0x1b, "ESC" ), // 0 - KTT_ENTRY1( 1, 1 ), // 1 - KTT_ENTRY1( 2, 2 ), // 2 - KTT_ENTRY1( 3, 3 ), // 3 - KTT_ENTRY1( 4, 4 ), // 4 - KTT_ENTRY1( 5, 5 ), // 5 - KTT_ENTRY1( 6, 6 ), // 6 - KTT_ENTRY1( 7, 7 ), // 7 - KTT_ENTRY1( 8, 8 ), // 8 - KTT_ENTRY1( 9, 9 ), // 9 - KTT_ENTRY1( 0, 0 ), // 10 - KTT_ENTRY0( MINUS, MINUS, 0xbd, '-', "MINUS" ), // 11 - KTT_ENTRY0( EQUALS, EQUALS, 0xbb, '=', "EQUALS" ), // 12 - KTT_ENTRY0( BACKSPACE, BACKSPACE, 0x08, 0x08, "BACKSPACE" ), // 13 - KTT_ENTRY0( TAB, TAB, 0x09, 0x09, "TAB" ), // 14 - KTT_ENTRY1( Q, Q ), // 15 - KTT_ENTRY1( W, W ), // 16 - KTT_ENTRY1( E, E ), // 17 - KTT_ENTRY1( R, R ), // 18 - KTT_ENTRY1( T, T ), // 19 - KTT_ENTRY1( Y, Y ), // 20 - KTT_ENTRY1( U, U ), // 21 - KTT_ENTRY1( I, I ), // 22 - KTT_ENTRY1( O, O ), // 23 - KTT_ENTRY1( P, P ), // 24 - KTT_ENTRY0( OPENBRACE, LEFTBRACKET, 0xdb, '[', "OPENBRACE" ), // 25 - KTT_ENTRY0( CLOSEBRACE,RIGHTBRACKET, 0xdd, ']', "CLOSEBRACE" ), // 26 - KTT_ENTRY0( ENTER, RETURN, 0x0d, 0x0d, "RETURN" ), // 27 - KTT_ENTRY2( LCONTROL, LCTRL ), // 28 - KTT_ENTRY1( A, A ), // 29 - KTT_ENTRY1( S, S ), // 30 - KTT_ENTRY1( D, D ), // 31 - KTT_ENTRY1( F, F ), // 32 - KTT_ENTRY1( G, G ), // 33 - KTT_ENTRY1( H, H ), // 34 - KTT_ENTRY1( J, J ), // 35 - KTT_ENTRY1( K, K ), // 36 - KTT_ENTRY1( L, L ), // 37 - KTT_ENTRY0( COLON, SEMICOLON, 0xba, ';', "COLON" ), // 38 - KTT_ENTRY0( QUOTE, APOSTROPHE, 0xde, '\'', "QUOTE" ), // 39 - KTT_ENTRY2( LSHIFT, LSHIFT ), // 40 - KTT_ENTRY0( BACKSLASH, BACKSLASH, 0xdc, '\\', "BACKSLASH" ), // 41 - KTT_ENTRY1( Z, Z ), // 42 - KTT_ENTRY1( X, X ), // 43 - KTT_ENTRY1( C, C ), // 44 - KTT_ENTRY1( V, V ), // 45 - KTT_ENTRY1( B, B ), // 46 - KTT_ENTRY1( N, N ), // 47 - KTT_ENTRY1( M, M ), // 48 - KTT_ENTRY0( COMMA, COMMA, 0xbc, ',', "COMMA" ), // 49 - KTT_ENTRY0( STOP, PERIOD, 0xbe, '.', "STOP" ), // 50 - KTT_ENTRY0( SLASH, SLASH, 0xbf, '/', "SLASH" ), // 51 - KTT_ENTRY2( RSHIFT, RSHIFT ), // 52 - KTT_ENTRY0( ASTERISK, KP_MULTIPLY, '*', '*', "ASTERIX" ), // 53 - KTT_ENTRY2( LALT, LALT ), // 54 - KTT_ENTRY0( SPACE, SPACE, ' ', ' ', "SPACE" ), // 55 - KTT_ENTRY2( CAPSLOCK, CAPSLOCK ), // 56 - KTT_ENTRY2( F1, F1 ), // 57 - KTT_ENTRY2( F2, F2 ), // 58 - KTT_ENTRY2( F3, F3 ), // 59 - KTT_ENTRY2( F4, F4 ), // 60 - KTT_ENTRY2( F5, F5 ), // 61 - KTT_ENTRY2( F6, F6 ), // 62 - KTT_ENTRY2( F7, F7 ), // 63 - KTT_ENTRY2( F8, F8 ), // 64 - KTT_ENTRY2( F9, F9 ), // 65 - KTT_ENTRY2( F10, F10 ), // 66 - KTT_ENTRY2( NUMLOCK, NUMLOCKCLEAR ), // 67 - KTT_ENTRY2( SCRLOCK, SCROLLLOCK ), // 68 - KTT_ENTRY2( 7_PAD, KP_7 ), // 69 - KTT_ENTRY2( 8_PAD, KP_8 ), - KTT_ENTRY2( 9_PAD, KP_9 ), - KTT_ENTRY2( MINUS_PAD, KP_MINUS ), - KTT_ENTRY2( 4_PAD, KP_4 ), - KTT_ENTRY2( 5_PAD, KP_5 ), - KTT_ENTRY2( 6_PAD, KP_6 ), - KTT_ENTRY2( PLUS_PAD, KP_PLUS ), - KTT_ENTRY2( 1_PAD, KP_1 ), - KTT_ENTRY2( 2_PAD, KP_2 ), - KTT_ENTRY2( 3_PAD, KP_3 ), - KTT_ENTRY2( 0_PAD, KP_0 ), - KTT_ENTRY2( DEL_PAD, KP_PERIOD ), - KTT_ENTRY2( F11, F11 ), - KTT_ENTRY2( F12, F12 ), - KTT_ENTRY2( F13, F13 ), - KTT_ENTRY2( F14, F14 ), - KTT_ENTRY2( F15, F15 ), - KTT_ENTRY2( ENTER_PAD, KP_ENTER ), - KTT_ENTRY2( RCONTROL, RCTRL ), - KTT_ENTRY2( SLASH_PAD, KP_DIVIDE ), - KTT_ENTRY2( PRTSCR, PRINTSCREEN ), - KTT_ENTRY2( RALT, RALT ), - KTT_ENTRY2( HOME, HOME ), - KTT_ENTRY2( UP, UP ), - KTT_ENTRY2( PGUP, PAGEUP ), - KTT_ENTRY2( LEFT, LEFT ), - KTT_ENTRY2( RIGHT, RIGHT ), - KTT_ENTRY2( END, END ), - KTT_ENTRY2( DOWN, DOWN ), - KTT_ENTRY2( PGDN, PAGEDOWN ), - KTT_ENTRY2( INSERT, INSERT ), + KTT_ENTRY0( ESC, ESCAPE, 0x1b, 0x1b, "ESC" ), // 0 + KTT_ENTRY1( 1, 1 ), // 1 + KTT_ENTRY1( 2, 2 ), // 2 + KTT_ENTRY1( 3, 3 ), // 3 + KTT_ENTRY1( 4, 4 ), // 4 + KTT_ENTRY1( 5, 5 ), // 5 + KTT_ENTRY1( 6, 6 ), // 6 + KTT_ENTRY1( 7, 7 ), // 7 + KTT_ENTRY1( 8, 8 ), // 8 + KTT_ENTRY1( 9, 9 ), // 9 + KTT_ENTRY1( 0, 0 ), // 10 + KTT_ENTRY0( MINUS, MINUS, 0xbd, '-', "MINUS" ), // 11 + KTT_ENTRY0( EQUALS, EQUALS, 0xbb, '=', "EQUALS" ), // 12 + KTT_ENTRY0( BACKSPACE, BACKSPACE, 0x08, 0x08, "BACKSPACE" ), // 13 + KTT_ENTRY0( TAB, TAB, 0x09, 0x09, "TAB" ), // 14 + KTT_ENTRY1( Q, Q ), // 15 + KTT_ENTRY1( W, W ), // 16 + KTT_ENTRY1( E, E ), // 17 + KTT_ENTRY1( R, R ), // 18 + KTT_ENTRY1( T, T ), // 19 + KTT_ENTRY1( Y, Y ), // 20 + KTT_ENTRY1( U, U ), // 21 + KTT_ENTRY1( I, I ), // 22 + KTT_ENTRY1( O, O ), // 23 + KTT_ENTRY1( P, P ), // 24 + KTT_ENTRY0( OPENBRACE, LEFTBRACKET, 0xdb, '[', "OPENBRACE" ), // 25 + KTT_ENTRY0( CLOSEBRACE,RIGHTBRACKET, 0xdd, ']', "CLOSEBRACE" ), // 26 + KTT_ENTRY0( ENTER, RETURN, 0x0d, 0x0d, "RETURN" ), // 27 + KTT_ENTRY2( LCONTROL, LCTRL ), // 28 + KTT_ENTRY1( A, A ), // 29 + KTT_ENTRY1( S, S ), // 30 + KTT_ENTRY1( D, D ), // 31 + KTT_ENTRY1( F, F ), // 32 + KTT_ENTRY1( G, G ), // 33 + KTT_ENTRY1( H, H ), // 34 + KTT_ENTRY1( J, J ), // 35 + KTT_ENTRY1( K, K ), // 36 + KTT_ENTRY1( L, L ), // 37 + KTT_ENTRY0( COLON, SEMICOLON, 0xba, ';', "COLON" ), // 38 + KTT_ENTRY0( QUOTE, APOSTROPHE, 0xde, '\'', "QUOTE" ), // 39 + KTT_ENTRY2( LSHIFT, LSHIFT ), // 40 + KTT_ENTRY0( BACKSLASH, BACKSLASH, 0xdc, '\\', "BACKSLASH" ), // 41 + KTT_ENTRY1( Z, Z ), // 42 + KTT_ENTRY1( X, X ), // 43 + KTT_ENTRY1( C, C ), // 44 + KTT_ENTRY1( V, V ), // 45 + KTT_ENTRY1( B, B ), // 46 + KTT_ENTRY1( N, N ), // 47 + KTT_ENTRY1( M, M ), // 48 + KTT_ENTRY0( COMMA, COMMA, 0xbc, ',', "COMMA" ), // 49 + KTT_ENTRY0( STOP, PERIOD, 0xbe, '.', "STOP" ), // 50 + KTT_ENTRY0( SLASH, SLASH, 0xbf, '/', "SLASH" ), // 51 + KTT_ENTRY2( RSHIFT, RSHIFT ), // 52 + KTT_ENTRY0( ASTERISK, KP_MULTIPLY, '*', '*', "ASTERIX" ), // 53 + KTT_ENTRY2( LALT, LALT ), // 54 + KTT_ENTRY0( SPACE, SPACE, ' ', ' ', "SPACE" ), // 55 + KTT_ENTRY2( CAPSLOCK, CAPSLOCK ), // 56 + KTT_ENTRY2( F1, F1 ), // 57 + KTT_ENTRY2( F2, F2 ), // 58 + KTT_ENTRY2( F3, F3 ), // 59 + KTT_ENTRY2( F4, F4 ), // 60 + KTT_ENTRY2( F5, F5 ), // 61 + KTT_ENTRY2( F6, F6 ), // 62 + KTT_ENTRY2( F7, F7 ), // 63 + KTT_ENTRY2( F8, F8 ), // 64 + KTT_ENTRY2( F9, F9 ), // 65 + KTT_ENTRY2( F10, F10 ), // 66 + KTT_ENTRY2( NUMLOCK, NUMLOCKCLEAR ), // 67 + KTT_ENTRY2( SCRLOCK, SCROLLLOCK ), // 68 + KTT_ENTRY2( 7_PAD, KP_7 ), // 69 + KTT_ENTRY2( 8_PAD, KP_8 ), + KTT_ENTRY2( 9_PAD, KP_9 ), + KTT_ENTRY2( MINUS_PAD, KP_MINUS ), + KTT_ENTRY2( 4_PAD, KP_4 ), + KTT_ENTRY2( 5_PAD, KP_5 ), + KTT_ENTRY2( 6_PAD, KP_6 ), + KTT_ENTRY2( PLUS_PAD, KP_PLUS ), + KTT_ENTRY2( 1_PAD, KP_1 ), + KTT_ENTRY2( 2_PAD, KP_2 ), + KTT_ENTRY2( 3_PAD, KP_3 ), + KTT_ENTRY2( 0_PAD, KP_0 ), + KTT_ENTRY2( DEL_PAD, KP_PERIOD ), + KTT_ENTRY2( F11, F11 ), + KTT_ENTRY2( F12, F12 ), + KTT_ENTRY2( F13, F13 ), + KTT_ENTRY2( F14, F14 ), + KTT_ENTRY2( F15, F15 ), + KTT_ENTRY2( ENTER_PAD, KP_ENTER ), + KTT_ENTRY2( RCONTROL, RCTRL ), + KTT_ENTRY2( SLASH_PAD, KP_DIVIDE ), + KTT_ENTRY2( PRTSCR, PRINTSCREEN ), + KTT_ENTRY2( RALT, RALT ), + KTT_ENTRY2( HOME, HOME ), + KTT_ENTRY2( UP, UP ), + KTT_ENTRY2( PGUP, PAGEUP ), + KTT_ENTRY2( LEFT, LEFT ), + KTT_ENTRY2( RIGHT, RIGHT ), + KTT_ENTRY2( END, END ), + KTT_ENTRY2( DOWN, DOWN ), + KTT_ENTRY2( PGDN, PAGEDOWN ), + KTT_ENTRY2( INSERT, INSERT ), { ITEM_ID_DEL, SDL_SCANCODE_DELETE, "ITEM_ID_DEL", (char *)"DELETE" }, - KTT_ENTRY2( LWIN, LGUI ), - KTT_ENTRY2( RWIN, RGUI ), - KTT_ENTRY2( MENU, MENU ), - KTT_ENTRY0( TILDE, GRAVE, 0xc0, '`', "TILDE" ), - KTT_ENTRY0( BACKSLASH2, NONUSBACKSLASH, 0xdc, '\\', "BACKSLASH2" ), + KTT_ENTRY2( LWIN, LGUI ), + KTT_ENTRY2( RWIN, RGUI ), + KTT_ENTRY2( MENU, MENU ), + KTT_ENTRY0( TILDE, GRAVE, 0xc0, '`', "TILDE" ), + KTT_ENTRY0( BACKSLASH2, NONUSBACKSLASH, 0xdc, '\\', "BACKSLASH2" ), { ITEM_ID_INVALID } }; #else @@ -385,113 +385,113 @@ static kt_table sdl_key_trans_table[] = static kt_table sdl_key_trans_table[] = { // MAME key SDL key vkey ascii - KTT_ENTRY0( ESC, ESCAPE, 0x1b, 0x1b, "ESC" ), - KTT_ENTRY1( 1, 1 ), - KTT_ENTRY1( 2, 2 ), - KTT_ENTRY1( 3, 3 ), - KTT_ENTRY1( 4, 4 ), - KTT_ENTRY1( 5, 5 ), - KTT_ENTRY1( 6, 6 ), - KTT_ENTRY1( 7, 7 ), - KTT_ENTRY1( 8, 8 ), - KTT_ENTRY1( 9, 9 ), - KTT_ENTRY1( 0, 0 ), - KTT_ENTRY0( MINUS, MINUS, 0xbd, '-', "MINUS" ), - KTT_ENTRY0( EQUALS, EQUALS, 0xbb, '=', "EQUALS" ), - KTT_ENTRY0( BACKSPACE, BACKSPACE, 0x08, 0x08, "BACKSPACE" ), - KTT_ENTRY0( TAB, TAB, 0x09, 0x09, "TAB" ), - KTT_ENTRY1( Q, q ), - KTT_ENTRY1( W, w ), - KTT_ENTRY1( E, e ), - KTT_ENTRY1( R, r ), - KTT_ENTRY1( T, t ), - KTT_ENTRY1( Y, y ), - KTT_ENTRY1( U, u ), - KTT_ENTRY1( I, i ), - KTT_ENTRY1( O, o ), - KTT_ENTRY1( P, p ), - KTT_ENTRY0( OPENBRACE, LEFTBRACKET, 0xdb, '[', "OPENBRACE" ), - KTT_ENTRY0( CLOSEBRACE,RIGHTBRACKET, 0xdd, ']', "CLOSEBRACE" ), - KTT_ENTRY0( ENTER, RETURN, 0x0d, 0x0d, "RETURN" ), - KTT_ENTRY2( LCONTROL, LCTRL ), - KTT_ENTRY1( A, a ), - KTT_ENTRY1( S, s ), - KTT_ENTRY1( D, d ), - KTT_ENTRY1( F, f ), - KTT_ENTRY1( G, g ), - KTT_ENTRY1( H, h ), - KTT_ENTRY1( J, j ), - KTT_ENTRY1( K, k ), - KTT_ENTRY1( L, l ), - KTT_ENTRY0( COLON, SEMICOLON, 0xba, ';', "COLON" ), - KTT_ENTRY0( QUOTE, QUOTE, 0xde, '\'', "QUOTE" ), - KTT_ENTRY2( LSHIFT, LSHIFT ), - KTT_ENTRY0( BACKSLASH, BACKSLASH, 0xdc, '\\', "BACKSLASH" ), - KTT_ENTRY1( Z, z ), - KTT_ENTRY1( X, x ), - KTT_ENTRY1( C, c ), - KTT_ENTRY1( V, v ), - KTT_ENTRY1( B, b ), - KTT_ENTRY1( N, n ), - KTT_ENTRY1( M, m ), - KTT_ENTRY0( COMMA, COMMA, 0xbc, ',', "COMMA" ), - KTT_ENTRY0( STOP, PERIOD, 0xbe, '.', "STOP" ), - KTT_ENTRY0( SLASH, SLASH, 0xbf, '/', "SLASH" ), - KTT_ENTRY2( RSHIFT, RSHIFT ), - KTT_ENTRY0( ASTERISK, KP_MULTIPLY, '*', '*', "ASTERIX" ), - KTT_ENTRY2( LALT, LALT ), - KTT_ENTRY0( SPACE, SPACE, ' ', ' ', "SPACE" ), - KTT_ENTRY2( CAPSLOCK, CAPSLOCK ), - KTT_ENTRY2( F1, F1 ), - KTT_ENTRY2( F2, F2 ), - KTT_ENTRY2( F3, F3 ), - KTT_ENTRY2( F4, F4 ), - KTT_ENTRY2( F5, F5 ), - KTT_ENTRY2( F6, F6 ), - KTT_ENTRY2( F7, F7 ), - KTT_ENTRY2( F8, F8 ), - KTT_ENTRY2( F9, F9 ), - KTT_ENTRY2( F10, F10 ), - KTT_ENTRY2( NUMLOCK, NUMLOCK ), - KTT_ENTRY2( SCRLOCK, SCROLLOCK ), - KTT_ENTRY2( 7_PAD, KP7 ), - KTT_ENTRY2( 8_PAD, KP8 ), - KTT_ENTRY2( 9_PAD, KP9 ), - KTT_ENTRY2( MINUS_PAD, KP_MINUS ), - KTT_ENTRY2( 4_PAD, KP4 ), - KTT_ENTRY2( 5_PAD, KP5 ), - KTT_ENTRY2( 6_PAD, KP6 ), - KTT_ENTRY2( PLUS_PAD, KP_PLUS ), - KTT_ENTRY2( 1_PAD, KP1 ), - KTT_ENTRY2( 2_PAD, KP2 ), - KTT_ENTRY2( 3_PAD, KP3 ), - KTT_ENTRY2( 0_PAD, KP0 ), - KTT_ENTRY2( DEL_PAD, KP_PERIOD ), - KTT_ENTRY2( F11, F11 ), - KTT_ENTRY2( F12, F12 ), - KTT_ENTRY2( F13, F13 ), - KTT_ENTRY2( F14, F14 ), - KTT_ENTRY2( F15, F15 ), - KTT_ENTRY2( ENTER_PAD, KP_ENTER ), - KTT_ENTRY2( RCONTROL, RCTRL ), - KTT_ENTRY2( SLASH_PAD, KP_DIVIDE ), - KTT_ENTRY2( PRTSCR, PRINT ), - KTT_ENTRY2( RALT, RALT ), - KTT_ENTRY2( HOME, HOME ), - KTT_ENTRY2( UP, UP ), - KTT_ENTRY2( PGUP, PAGEUP ), - KTT_ENTRY2( LEFT, LEFT ), - KTT_ENTRY2( RIGHT, RIGHT ), - KTT_ENTRY2( END, END ), - KTT_ENTRY2( DOWN, DOWN ), - KTT_ENTRY2( PGDN, PAGEDOWN ), - KTT_ENTRY2( INSERT, INSERT ), + KTT_ENTRY0( ESC, ESCAPE, 0x1b, 0x1b, "ESC" ), + KTT_ENTRY1( 1, 1 ), + KTT_ENTRY1( 2, 2 ), + KTT_ENTRY1( 3, 3 ), + KTT_ENTRY1( 4, 4 ), + KTT_ENTRY1( 5, 5 ), + KTT_ENTRY1( 6, 6 ), + KTT_ENTRY1( 7, 7 ), + KTT_ENTRY1( 8, 8 ), + KTT_ENTRY1( 9, 9 ), + KTT_ENTRY1( 0, 0 ), + KTT_ENTRY0( MINUS, MINUS, 0xbd, '-', "MINUS" ), + KTT_ENTRY0( EQUALS, EQUALS, 0xbb, '=', "EQUALS" ), + KTT_ENTRY0( BACKSPACE, BACKSPACE, 0x08, 0x08, "BACKSPACE" ), + KTT_ENTRY0( TAB, TAB, 0x09, 0x09, "TAB" ), + KTT_ENTRY1( Q, q ), + KTT_ENTRY1( W, w ), + KTT_ENTRY1( E, e ), + KTT_ENTRY1( R, r ), + KTT_ENTRY1( T, t ), + KTT_ENTRY1( Y, y ), + KTT_ENTRY1( U, u ), + KTT_ENTRY1( I, i ), + KTT_ENTRY1( O, o ), + KTT_ENTRY1( P, p ), + KTT_ENTRY0( OPENBRACE, LEFTBRACKET, 0xdb, '[', "OPENBRACE" ), + KTT_ENTRY0( CLOSEBRACE,RIGHTBRACKET, 0xdd, ']', "CLOSEBRACE" ), + KTT_ENTRY0( ENTER, RETURN, 0x0d, 0x0d, "RETURN" ), + KTT_ENTRY2( LCONTROL, LCTRL ), + KTT_ENTRY1( A, a ), + KTT_ENTRY1( S, s ), + KTT_ENTRY1( D, d ), + KTT_ENTRY1( F, f ), + KTT_ENTRY1( G, g ), + KTT_ENTRY1( H, h ), + KTT_ENTRY1( J, j ), + KTT_ENTRY1( K, k ), + KTT_ENTRY1( L, l ), + KTT_ENTRY0( COLON, SEMICOLON, 0xba, ';', "COLON" ), + KTT_ENTRY0( QUOTE, QUOTE, 0xde, '\'', "QUOTE" ), + KTT_ENTRY2( LSHIFT, LSHIFT ), + KTT_ENTRY0( BACKSLASH, BACKSLASH, 0xdc, '\\', "BACKSLASH" ), + KTT_ENTRY1( Z, z ), + KTT_ENTRY1( X, x ), + KTT_ENTRY1( C, c ), + KTT_ENTRY1( V, v ), + KTT_ENTRY1( B, b ), + KTT_ENTRY1( N, n ), + KTT_ENTRY1( M, m ), + KTT_ENTRY0( COMMA, COMMA, 0xbc, ',', "COMMA" ), + KTT_ENTRY0( STOP, PERIOD, 0xbe, '.', "STOP" ), + KTT_ENTRY0( SLASH, SLASH, 0xbf, '/', "SLASH" ), + KTT_ENTRY2( RSHIFT, RSHIFT ), + KTT_ENTRY0( ASTERISK, KP_MULTIPLY, '*', '*', "ASTERIX" ), + KTT_ENTRY2( LALT, LALT ), + KTT_ENTRY0( SPACE, SPACE, ' ', ' ', "SPACE" ), + KTT_ENTRY2( CAPSLOCK, CAPSLOCK ), + KTT_ENTRY2( F1, F1 ), + KTT_ENTRY2( F2, F2 ), + KTT_ENTRY2( F3, F3 ), + KTT_ENTRY2( F4, F4 ), + KTT_ENTRY2( F5, F5 ), + KTT_ENTRY2( F6, F6 ), + KTT_ENTRY2( F7, F7 ), + KTT_ENTRY2( F8, F8 ), + KTT_ENTRY2( F9, F9 ), + KTT_ENTRY2( F10, F10 ), + KTT_ENTRY2( NUMLOCK, NUMLOCK ), + KTT_ENTRY2( SCRLOCK, SCROLLOCK ), + KTT_ENTRY2( 7_PAD, KP7 ), + KTT_ENTRY2( 8_PAD, KP8 ), + KTT_ENTRY2( 9_PAD, KP9 ), + KTT_ENTRY2( MINUS_PAD, KP_MINUS ), + KTT_ENTRY2( 4_PAD, KP4 ), + KTT_ENTRY2( 5_PAD, KP5 ), + KTT_ENTRY2( 6_PAD, KP6 ), + KTT_ENTRY2( PLUS_PAD, KP_PLUS ), + KTT_ENTRY2( 1_PAD, KP1 ), + KTT_ENTRY2( 2_PAD, KP2 ), + KTT_ENTRY2( 3_PAD, KP3 ), + KTT_ENTRY2( 0_PAD, KP0 ), + KTT_ENTRY2( DEL_PAD, KP_PERIOD ), + KTT_ENTRY2( F11, F11 ), + KTT_ENTRY2( F12, F12 ), + KTT_ENTRY2( F13, F13 ), + KTT_ENTRY2( F14, F14 ), + KTT_ENTRY2( F15, F15 ), + KTT_ENTRY2( ENTER_PAD, KP_ENTER ), + KTT_ENTRY2( RCONTROL, RCTRL ), + KTT_ENTRY2( SLASH_PAD, KP_DIVIDE ), + KTT_ENTRY2( PRTSCR, PRINT ), + KTT_ENTRY2( RALT, RALT ), + KTT_ENTRY2( HOME, HOME ), + KTT_ENTRY2( UP, UP ), + KTT_ENTRY2( PGUP, PAGEUP ), + KTT_ENTRY2( LEFT, LEFT ), + KTT_ENTRY2( RIGHT, RIGHT ), + KTT_ENTRY2( END, END ), + KTT_ENTRY2( DOWN, DOWN ), + KTT_ENTRY2( PGDN, PAGEDOWN ), + KTT_ENTRY2( INSERT, INSERT ), { ITEM_ID_DEL, SDLK_DELETE, "ITEM_ID_DEL", (char *)"DELETE" }, - KTT_ENTRY2( LWIN, LSUPER ), - KTT_ENTRY2( RWIN, RSUPER ), - KTT_ENTRY2( MENU, MENU ), - KTT_ENTRY0( TILDE, BACKQUOTE, 0xc0, '`', "TILDE" ), - KTT_ENTRY0( BACKSLASH2, HASH, 0xdc, '\\', "BACKSLASH2" ), + KTT_ENTRY2( LWIN, LSUPER ), + KTT_ENTRY2( RWIN, RSUPER ), + KTT_ENTRY2( MENU, MENU ), + KTT_ENTRY0( TILDE, BACKQUOTE, 0xc0, '`', "TILDE" ), + KTT_ENTRY0( BACKSLASH2, HASH, 0xdc, '\\', "BACKSLASH2" ), { ITEM_ID_INVALID } }; #endif @@ -511,23 +511,23 @@ struct key_lookup_table static key_lookup_table sdl_lookup_table[] = { - KE7(UNKNOWN, BACKSPACE, TAB, CLEAR, RETURN, PAUSE, ESCAPE ) + KE7(UNKNOWN, BACKSPACE, TAB, CLEAR, RETURN, PAUSE, ESCAPE ) KE(SPACE) - KE5(COMMA, MINUS, PERIOD, SLASH, 0 ) - KE8(1, 2, 3, 4, 5, 6, 7, 8 ) - KE3(9, SEMICOLON, EQUALS) - KE5(LEFTBRACKET,BACKSLASH, RIGHTBRACKET, A, B ) - KE8(C, D, E, F, G, H, I, J ) - KE8(K, L, M, N, O, P, Q, R ) - KE8(S, T, U, V, W, X, Y, Z ) - KE8(DELETE, KP_0, KP_1, KP_2, KP_3, KP_4, KP_5, KP_6 ) - KE8(KP_7, KP_8, KP_9, KP_PERIOD, KP_DIVIDE, KP_MULTIPLY,KP_MINUS, KP_PLUS ) - KE8(KP_ENTER, KP_EQUALS, UP, DOWN, RIGHT, LEFT, INSERT, HOME ) - KE8(END, PAGEUP, PAGEDOWN, F1, F2, F3, F4, F5 ) - KE8(F6, F7, F8, F9, F10, F11, F12, F13 ) - KE8(F14, F15, NUMLOCKCLEAR, CAPSLOCK, SCROLLLOCK, RSHIFT, LSHIFT, RCTRL ) - KE5(LCTRL, RALT, LALT, LGUI, RGUI) - KE8(GRAVE, LEFTBRACKET,RIGHTBRACKET, SEMICOLON, APOSTROPHE, BACKSLASH, PRINTSCREEN,MENU ) + KE5(COMMA, MINUS, PERIOD, SLASH, 0 ) + KE8(1, 2, 3, 4, 5, 6, 7, 8 ) + KE3(9, SEMICOLON, EQUALS) + KE5(LEFTBRACKET,BACKSLASH, RIGHTBRACKET, A, B ) + KE8(C, D, E, F, G, H, I, J ) + KE8(K, L, M, N, O, P, Q, R ) + KE8(S, T, U, V, W, X, Y, Z ) + KE8(DELETE, KP_0, KP_1, KP_2, KP_3, KP_4, KP_5, KP_6 ) + KE8(KP_7, KP_8, KP_9, KP_PERIOD, KP_DIVIDE, KP_MULTIPLY,KP_MINUS, KP_PLUS ) + KE8(KP_ENTER, KP_EQUALS, UP, DOWN, RIGHT, LEFT, INSERT, HOME ) + KE8(END, PAGEUP, PAGEDOWN, F1, F2, F3, F4, F5 ) + KE8(F6, F7, F8, F9, F10, F11, F12, F13 ) + KE8(F14, F15, NUMLOCKCLEAR, CAPSLOCK, SCROLLLOCK, RSHIFT, LSHIFT, RCTRL ) + KE5(LCTRL, RALT, LALT, LGUI, RGUI) + KE8(GRAVE, LEFTBRACKET,RIGHTBRACKET, SEMICOLON, APOSTROPHE, BACKSLASH, PRINTSCREEN,MENU ) KE(UNDO) {-1, ""} }; @@ -537,35 +537,35 @@ static key_lookup_table sdl_lookup_table[] = static key_lookup_table sdl_lookup_table[] = { - KE8(UNKNOWN, FIRST, BACKSPACE, TAB, CLEAR, RETURN, PAUSE, ESCAPE ) - KE8(SPACE, EXCLAIM, QUOTEDBL, HASH, DOLLAR, AMPERSAND, QUOTE, LEFTPAREN ) - KE8(RIGHTPAREN, ASTERISK, PLUS, COMMA, MINUS, PERIOD, SLASH, 0 ) - KE8(1, 2, 3, 4, 5, 6, 7, 8 ) - KE8(9, COLON, SEMICOLON, LESS, EQUALS, GREATER, QUESTION, AT ) - KE8(LEFTBRACKET,BACKSLASH, RIGHTBRACKET, CARET, UNDERSCORE, BACKQUOTE, a, b ) - KE8(c, d, e, f, g, h, i, j ) - KE8(k, l, m, n, o, p, q, r ) - KE8(s, t, u, v, w, x, y, z ) - KE8(DELETE, WORLD_0, WORLD_1, WORLD_2, WORLD_3, WORLD_4, WORLD_5, WORLD_6 ) - KE8(WORLD_7, WORLD_8, WORLD_9, WORLD_10, WORLD_11, WORLD_12, WORLD_13, WORLD_14 ) - KE8(WORLD_15, WORLD_16, WORLD_17, WORLD_18, WORLD_19, WORLD_20, WORLD_21, WORLD_22 ) - KE8(WORLD_23, WORLD_24, WORLD_25, WORLD_26, WORLD_27, WORLD_28, WORLD_29, WORLD_30 ) - KE8(WORLD_31, WORLD_32, WORLD_33, WORLD_34, WORLD_35, WORLD_36, WORLD_37, WORLD_38 ) - KE8(WORLD_39, WORLD_40, WORLD_41, WORLD_42, WORLD_43, WORLD_44, WORLD_45, WORLD_46 ) - KE8(WORLD_47, WORLD_48, WORLD_49, WORLD_50, WORLD_51, WORLD_52, WORLD_53, WORLD_54 ) - KE8(WORLD_55, WORLD_56, WORLD_57, WORLD_58, WORLD_59, WORLD_60, WORLD_61, WORLD_62 ) - KE8(WORLD_63, WORLD_64, WORLD_65, WORLD_66, WORLD_67, WORLD_68, WORLD_69, WORLD_70 ) - KE8(WORLD_71, WORLD_72, WORLD_73, WORLD_74, WORLD_75, WORLD_76, WORLD_77, WORLD_78 ) - KE8(WORLD_79, WORLD_80, WORLD_81, WORLD_82, WORLD_83, WORLD_84, WORLD_85, WORLD_86 ) - KE8(WORLD_87, WORLD_88, WORLD_89, WORLD_90, WORLD_91, WORLD_92, WORLD_93, WORLD_94 ) - KE8(WORLD_95, KP0, KP1, KP2, KP3, KP4, KP5, KP6 ) - KE8(KP7, KP8, KP9, KP_PERIOD, KP_DIVIDE, KP_MULTIPLY,KP_MINUS, KP_PLUS ) - KE8(KP_ENTER, KP_EQUALS, UP, DOWN, RIGHT, LEFT, INSERT, HOME ) - KE8(END, PAGEUP, PAGEDOWN, F1, F2, F3, F4, F5 ) - KE8(F6, F7, F8, F9, F10, F11, F12, F13 ) - KE8(F14, F15, NUMLOCK, CAPSLOCK, SCROLLOCK, RSHIFT, LSHIFT, RCTRL ) - KE8(LCTRL, RALT, LALT, RMETA, LMETA, LSUPER, RSUPER, MODE ) - KE8(COMPOSE, HELP, PRINT, SYSREQ, BREAK, MENU, POWER, EURO ) + KE8(UNKNOWN, FIRST, BACKSPACE, TAB, CLEAR, RETURN, PAUSE, ESCAPE ) + KE8(SPACE, EXCLAIM, QUOTEDBL, HASH, DOLLAR, AMPERSAND, QUOTE, LEFTPAREN ) + KE8(RIGHTPAREN, ASTERISK, PLUS, COMMA, MINUS, PERIOD, SLASH, 0 ) + KE8(1, 2, 3, 4, 5, 6, 7, 8 ) + KE8(9, COLON, SEMICOLON, LESS, EQUALS, GREATER, QUESTION, AT ) + KE8(LEFTBRACKET,BACKSLASH, RIGHTBRACKET, CARET, UNDERSCORE, BACKQUOTE, a, b ) + KE8(c, d, e, f, g, h, i, j ) + KE8(k, l, m, n, o, p, q, r ) + KE8(s, t, u, v, w, x, y, z ) + KE8(DELETE, WORLD_0, WORLD_1, WORLD_2, WORLD_3, WORLD_4, WORLD_5, WORLD_6 ) + KE8(WORLD_7, WORLD_8, WORLD_9, WORLD_10, WORLD_11, WORLD_12, WORLD_13, WORLD_14 ) + KE8(WORLD_15, WORLD_16, WORLD_17, WORLD_18, WORLD_19, WORLD_20, WORLD_21, WORLD_22 ) + KE8(WORLD_23, WORLD_24, WORLD_25, WORLD_26, WORLD_27, WORLD_28, WORLD_29, WORLD_30 ) + KE8(WORLD_31, WORLD_32, WORLD_33, WORLD_34, WORLD_35, WORLD_36, WORLD_37, WORLD_38 ) + KE8(WORLD_39, WORLD_40, WORLD_41, WORLD_42, WORLD_43, WORLD_44, WORLD_45, WORLD_46 ) + KE8(WORLD_47, WORLD_48, WORLD_49, WORLD_50, WORLD_51, WORLD_52, WORLD_53, WORLD_54 ) + KE8(WORLD_55, WORLD_56, WORLD_57, WORLD_58, WORLD_59, WORLD_60, WORLD_61, WORLD_62 ) + KE8(WORLD_63, WORLD_64, WORLD_65, WORLD_66, WORLD_67, WORLD_68, WORLD_69, WORLD_70 ) + KE8(WORLD_71, WORLD_72, WORLD_73, WORLD_74, WORLD_75, WORLD_76, WORLD_77, WORLD_78 ) + KE8(WORLD_79, WORLD_80, WORLD_81, WORLD_82, WORLD_83, WORLD_84, WORLD_85, WORLD_86 ) + KE8(WORLD_87, WORLD_88, WORLD_89, WORLD_90, WORLD_91, WORLD_92, WORLD_93, WORLD_94 ) + KE8(WORLD_95, KP0, KP1, KP2, KP3, KP4, KP5, KP6 ) + KE8(KP7, KP8, KP9, KP_PERIOD, KP_DIVIDE, KP_MULTIPLY,KP_MINUS, KP_PLUS ) + KE8(KP_ENTER, KP_EQUALS, UP, DOWN, RIGHT, LEFT, INSERT, HOME ) + KE8(END, PAGEUP, PAGEDOWN, F1, F2, F3, F4, F5 ) + KE8(F6, F7, F8, F9, F10, F11, F12, F13 ) + KE8(F14, F15, NUMLOCK, CAPSLOCK, SCROLLOCK, RSHIFT, LSHIFT, RCTRL ) + KE8(LCTRL, RALT, LALT, RMETA, LMETA, LSUPER, RSUPER, MODE ) + KE8(COMPOSE, HELP, PRINT, SYSREQ, BREAK, MENU, POWER, EURO ) KE(UNDO) KE(LAST) {-1, ""} @@ -792,7 +792,7 @@ static void sdlinput_register_joysticks(running_machine &machine) devinfo->device->add_item(tempname, itemid, generic_button_get_state, &devinfo->joystick.hatsL[hat]); sprintf(tempname, "hat %d Right", hat); itemid = (input_item_id) ((hat < INPUT_MAX_HATS) ? ITEM_ID_HAT1RIGHT + 4 * hat : ITEM_ID_OTHER_SWITCH); - devinfo->device->add_item(tempname, itemid, generic_button_get_state, &devinfo->joystick.hatsR[hat]); + devinfo->device->add_item(tempname, itemid, generic_button_get_state, &devinfo->joystick.hatsR[hat]); } // loop over all (track)balls @@ -927,106 +927,106 @@ static void sdlinput_register_mice(running_machine &machine) XDeviceInfo* find_device_info(Display *display, - char *name, - Bool only_extended) + char *name, + Bool only_extended) { - XDeviceInfo *devices; - XDeviceInfo *found = NULL; - int loop; - int num_devices; - int len = strlen(name); - Bool is_id = True; - XID id = (XID)-1; - - for(loop=0; loop<len; loop++) { - if (!isdigit(name[loop])) { - is_id = False; - break; - } - } - - if (is_id) { - id = atoi(name); - } - - devices = XListInputDevices(display, &num_devices); - - for(loop=0; loop<num_devices; loop++) { - if ((!only_extended || (devices[loop].use >= IsXExtensionDevice)) && - ((!is_id && strcmp(devices[loop].name, name) == 0) || - (is_id && devices[loop].id == id))) { - if (found) { - fprintf(stderr, - "Warning: There are multiple devices named \"%s\".\n" - "To ensure the correct one is selected, please use " - "the device ID instead.\n\n", name); - } else { - found = &devices[loop]; - } - } - } - return found; + XDeviceInfo *devices; + XDeviceInfo *found = NULL; + int loop; + int num_devices; + int len = strlen(name); + Bool is_id = True; + XID id = (XID)-1; + + for(loop=0; loop<len; loop++) { + if (!isdigit(name[loop])) { + is_id = False; + break; + } + } + + if (is_id) { + id = atoi(name); + } + + devices = XListInputDevices(display, &num_devices); + + for(loop=0; loop<num_devices; loop++) { + if ((!only_extended || (devices[loop].use >= IsXExtensionDevice)) && + ((!is_id && strcmp(devices[loop].name, name) == 0) || + (is_id && devices[loop].id == id))) { + if (found) { + fprintf(stderr, + "Warning: There are multiple devices named \"%s\".\n" + "To ensure the correct one is selected, please use " + "the device ID instead.\n\n", name); + } else { + found = &devices[loop]; + } + } + } + return found; } //Copypasted from xinfo static int register_events(Display *dpy, - XDeviceInfo *info, - char *dev_name, - Bool handle_proximity) + XDeviceInfo *info, + char *dev_name, + Bool handle_proximity) { - int number = 0; /* number of events registered */ - XEventClass event_list[7]; - int i; - XDevice *device; - Window root_win; - unsigned long screen; - XInputClassInfo *ip; - - screen = DefaultScreen(dpy); - root_win = RootWindow(dpy, screen); - - device = XOpenDevice(dpy, info->id); - - if (!device) { - fprintf(stderr, "unable to open device %s\n", dev_name); - return 0; - } - - if (device->num_classes > 0) { - for (ip = device->classes, i=0; i<info->num_classes; ip++, i++) { - switch (ip->input_class) { - case KeyClass: - DeviceKeyPress(device, key_press_type, event_list[number]); number++; - DeviceKeyRelease(device, key_release_type, event_list[number]); number++; - break; - - case ButtonClass: - DeviceButtonPress(device, button_press_type, event_list[number]); number++; - DeviceButtonRelease(device, button_release_type, event_list[number]); number++; - break; - - case ValuatorClass: - DeviceMotionNotify(device, motion_type, event_list[number]); number++; - fprintf(stderr, "Motion = %i\n",motion_type); - if (handle_proximity) { - ProximityIn(device, proximity_in_type, event_list[number]); number++; - ProximityOut(device, proximity_out_type, event_list[number]); number++; - } - break; - - default: - fprintf(stderr, "unknown class\n"); - break; - } - } - - if (XSelectExtensionEvent(dpy, root_win, event_list, number)) { - fprintf(stderr, "error selecting extended events\n"); - return 0; - } - } - return number; + int number = 0; /* number of events registered */ + XEventClass event_list[7]; + int i; + XDevice *device; + Window root_win; + unsigned long screen; + XInputClassInfo *ip; + + screen = DefaultScreen(dpy); + root_win = RootWindow(dpy, screen); + + device = XOpenDevice(dpy, info->id); + + if (!device) { + fprintf(stderr, "unable to open device %s\n", dev_name); + return 0; + } + + if (device->num_classes > 0) { + for (ip = device->classes, i=0; i<info->num_classes; ip++, i++) { + switch (ip->input_class) { + case KeyClass: + DeviceKeyPress(device, key_press_type, event_list[number]); number++; + DeviceKeyRelease(device, key_release_type, event_list[number]); number++; + break; + + case ButtonClass: + DeviceButtonPress(device, button_press_type, event_list[number]); number++; + DeviceButtonRelease(device, button_release_type, event_list[number]); number++; + break; + + case ValuatorClass: + DeviceMotionNotify(device, motion_type, event_list[number]); number++; + fprintf(stderr, "Motion = %i\n",motion_type); + if (handle_proximity) { + ProximityIn(device, proximity_in_type, event_list[number]); number++; + ProximityOut(device, proximity_out_type, event_list[number]); number++; + } + break; + + default: + fprintf(stderr, "unknown class\n"); + break; + } + } + + if (XSelectExtensionEvent(dpy, root_win, event_list, number)) { + fprintf(stderr, "error selecting extended events\n"); + return 0; + } + } + return number; } //============================================================ @@ -1035,108 +1035,108 @@ register_events(Display *dpy, static void sdlinput_register_lightguns(running_machine &machine) { - int index; - XExtensionVersion *version; - - lightgun_enabled = machine.options().lightgun(); - devmap_init(machine, &lightgun_map, SDLOPTION_LIGHTGUNINDEX, 8, "Lightgun mapping"); - - XDisplay = XOpenDisplay(NULL); - - if (XDisplay == NULL) { - fprintf(stderr, "Unable to connect to X server\n"); - return; - } - - version = XGetExtensionVersion(XDisplay, INAME); - - if (!version || (version == (XExtensionVersion*) NoSuchExtension)) { - fprintf(stderr, "xinput extension not available!\n"); - return; - } - - - for (index=0; index<8; index++) { - XDeviceInfo *info; - if (strlen(lightgun_map.map[index].name)!=0) { - device_info *devinfo; - char *name=lightgun_map.map[index].name; - char defname[512]; - devinfo = devmap_class_register(machine, &lightgun_map, index, &lightgun_list, DEVICE_CLASS_LIGHTGUN); - fprintf(stderr, "%i: %s\n",index, name); - info=find_device_info(XDisplay, name, 0); - if (!info) continue; - - //Grab device info and translate to stuff mame can use - if (info->num_classes > 0) { - XAnyClassPtr any = (XAnyClassPtr) (info->inputclassinfo); - int i; - for (i=0; i<info->num_classes; i++) { - int button; - XValuatorInfoPtr v; - XAxisInfoPtr a; - int j; - XButtonInfoPtr b; + int index; + XExtensionVersion *version; + + lightgun_enabled = machine.options().lightgun(); + devmap_init(machine, &lightgun_map, SDLOPTION_LIGHTGUNINDEX, 8, "Lightgun mapping"); + + XDisplay = XOpenDisplay(NULL); + + if (XDisplay == NULL) { + fprintf(stderr, "Unable to connect to X server\n"); + return; + } + + version = XGetExtensionVersion(XDisplay, INAME); + + if (!version || (version == (XExtensionVersion*) NoSuchExtension)) { + fprintf(stderr, "xinput extension not available!\n"); + return; + } + + + for (index=0; index<8; index++) { + XDeviceInfo *info; + if (strlen(lightgun_map.map[index].name)!=0) { + device_info *devinfo; + char *name=lightgun_map.map[index].name; + char defname[512]; + devinfo = devmap_class_register(machine, &lightgun_map, index, &lightgun_list, DEVICE_CLASS_LIGHTGUN); + fprintf(stderr, "%i: %s\n",index, name); + info=find_device_info(XDisplay, name, 0); + if (!info) continue; + + //Grab device info and translate to stuff mame can use + if (info->num_classes > 0) { + XAnyClassPtr any = (XAnyClassPtr) (info->inputclassinfo); + int i; + for (i=0; i<info->num_classes; i++) { + int button; + XValuatorInfoPtr v; + XAxisInfoPtr a; + int j; + XButtonInfoPtr b; #if defined(__cplusplus) || defined(c_plusplus) - switch (any->c_class) { + switch (any->c_class) { #else - switch (any->class) { + switch (any->class) { #endif - case ButtonClass: - b = (XButtonInfoPtr) any; - for (button = 0; button < b->num_buttons; button++) - { - input_item_id itemid; - itemid = (input_item_id) (ITEM_ID_BUTTON1 + button); - sprintf(defname, "B%d", button + 1); - devinfo->device->add_item(defname, itemid, generic_button_get_state, &devinfo->lightgun.buttons[button]); - } - break; - case ValuatorClass: - v = (XValuatorInfoPtr) any; - a = (XAxisInfoPtr) ((char *) v + sizeof (XValuatorInfo)); - for (j=0; j<v->num_axes; j++, a++) { - if (j==0) { + case ButtonClass: + b = (XButtonInfoPtr) any; + for (button = 0; button < b->num_buttons; button++) + { + input_item_id itemid; + itemid = (input_item_id) (ITEM_ID_BUTTON1 + button); + sprintf(defname, "B%d", button + 1); + devinfo->device->add_item(defname, itemid, generic_button_get_state, &devinfo->lightgun.buttons[button]); + } + break; + case ValuatorClass: + v = (XValuatorInfoPtr) any; + a = (XAxisInfoPtr) ((char *) v + sizeof (XValuatorInfo)); + for (j=0; j<v->num_axes; j++, a++) { + if (j==0) { #if (USE_XINPUT_DEBUG) - fprintf(stderr, "For index %d: Set minx=%d, maxx=%d\n", - index, - a->min_value, a->max_value); + fprintf(stderr, "For index %d: Set minx=%d, maxx=%d\n", + index, + a->min_value, a->max_value); #endif - devinfo->lightgun.maxx=a->max_value; - devinfo->lightgun.minx=a->min_value; - } - if (j==1) { + devinfo->lightgun.maxx=a->max_value; + devinfo->lightgun.minx=a->min_value; + } + if (j==1) { #if (USE_XINPUT_DEBUG) - fprintf(stderr, "For index %d: Set miny=%d, maxy=%d\n", - index, - a->min_value, a->max_value); + fprintf(stderr, "For index %d: Set miny=%d, maxy=%d\n", + index, + a->min_value, a->max_value); #endif - devinfo->lightgun.maxy=a->max_value; - devinfo->lightgun.miny=a->min_value; - } - } - break; - } - any = (XAnyClassPtr) ((char *) any + any->length); - } - } - - - sprintf(defname, "X %s", devinfo->name); - devinfo->device->add_item(defname, ITEM_ID_XAXIS, generic_axis_get_state, &devinfo->lightgun.lX); - sprintf(defname, "Y %s", devinfo->name); - devinfo->device->add_item(defname, ITEM_ID_YAXIS, generic_axis_get_state, &devinfo->lightgun.lY); - - - devinfo->lightgun.deviceid=info->id; - if (!info) { - fprintf(stderr, "Can't find device %s!\n", lightgun_map.map[index].name); - } else { - fprintf(stderr, "Device %i: Registered %i events.\n",(int)info->id, register_events(XDisplay, info, lightgun_map.map[index].name, 0)); - } - } - } - mame_printf_verbose("Lightgun: End initialization\n"); + devinfo->lightgun.maxy=a->max_value; + devinfo->lightgun.miny=a->min_value; + } + } + break; + } + any = (XAnyClassPtr) ((char *) any + any->length); + } + } + + + sprintf(defname, "X %s", devinfo->name); + devinfo->device->add_item(defname, ITEM_ID_XAXIS, generic_axis_get_state, &devinfo->lightgun.lX); + sprintf(defname, "Y %s", devinfo->name); + devinfo->device->add_item(defname, ITEM_ID_YAXIS, generic_axis_get_state, &devinfo->lightgun.lY); + + + devinfo->lightgun.deviceid=info->id; + if (!info) { + fprintf(stderr, "Can't find device %s!\n", lightgun_map.map[index].name); + } else { + fprintf(stderr, "Device %i: Registered %i events.\n",(int)info->id, register_events(XDisplay, info, lightgun_map.map[index].name, 0)); + } + } + } + mame_printf_verbose("Lightgun: End initialization\n"); } #endif @@ -1470,54 +1470,54 @@ sdl_window_info *sdlinput_get_focus_window(running_machine &machine) #if (USE_XINPUT) device_info *get_lightgun_info_for_deviceid(XID deviceid) { - device_info *devinfo; - int index; - //Find lightgun according to device id - for (index=0; ; index++) { - devinfo = generic_device_find_index(lightgun_list, index); - if (devinfo==NULL) break; - if (devinfo->lightgun.deviceid==deviceid) break; - } - return devinfo; + device_info *devinfo; + int index; + //Find lightgun according to device id + for (index=0; ; index++) { + devinfo = generic_device_find_index(lightgun_list, index); + if (devinfo==NULL) break; + if (devinfo->lightgun.deviceid==deviceid) break; + } + return devinfo; } INT32 normalize_absolute_axis(INT32 raw, INT32 rawmin, INT32 rawmax) { - INT32 rv; - - INT32 center = ((INT64)rawmax + (INT64)rawmin) / 2; - - // make sure we have valid data - if (rawmin >= rawmax) - { - rv = raw; - goto out; - } - - // above center - if (raw >= center) - { - INT32 result = (INT64)(raw - center) * (INT64)INPUT_ABSOLUTE_MAX / (INT64)(rawmax - center); - rv = MIN(result, INPUT_ABSOLUTE_MAX); - goto out; - } - - // below center - else - { - INT32 result = -((INT64)(center - raw) * (INT64)-INPUT_ABSOLUTE_MIN / (INT64)(center - rawmin)); - rv = MAX(result, INPUT_ABSOLUTE_MIN); - goto out; - } - - out: + INT32 rv; + + INT32 center = ((INT64)rawmax + (INT64)rawmin) / 2; + + // make sure we have valid data + if (rawmin >= rawmax) + { + rv = raw; + goto out; + } + + // above center + if (raw >= center) + { + INT32 result = (INT64)(raw - center) * (INT64)INPUT_ABSOLUTE_MAX / (INT64)(rawmax - center); + rv = MIN(result, INPUT_ABSOLUTE_MAX); + goto out; + } + + // below center + else + { + INT32 result = -((INT64)(center - raw) * (INT64)-INPUT_ABSOLUTE_MIN / (INT64)(center - rawmin)); + rv = MAX(result, INPUT_ABSOLUTE_MIN); + goto out; + } + + out: #if (USE_XINPUT_DEBUG) - fprintf(stderr, "raw: %d, rawmin: %d, rawmax: %d, center: %d, rv: %d, ABS_MIN: %d, ABS_MAX: %d\n", - raw, rawmin, rawmax, center, rv, INPUT_ABSOLUTE_MIN, INPUT_ABSOLUTE_MAX); + fprintf(stderr, "raw: %d, rawmin: %d, rawmax: %d, center: %d, rv: %d, ABS_MIN: %d, ABS_MAX: %d\n", + raw, rawmin, rawmax, center, rv, INPUT_ABSOLUTE_MIN, INPUT_ABSOLUTE_MAX); #endif - return rv; + return rv; } #endif @@ -1593,8 +1593,8 @@ void sdlinput_poll(running_machine &machine) int index; // only for SDLMAME_EVENTS_IN_WORKER_THREAD - SDL_Event loc_event_buf[MAX_BUF_EVENTS]; - int loc_event_buf_count; + SDL_Event loc_event_buf[MAX_BUF_EVENTS]; + int loc_event_buf_count; int bufp; #if (USE_XINPUT) @@ -1611,99 +1611,99 @@ void sdlinput_poll(running_machine &machine) } #if (USE_XINPUT) - //Get XInput events - while (XPending(XDisplay)!=0) - { - XNextEvent(XDisplay, &xevent); - if (xevent.type==motion_type) - { - XDeviceMotionEvent *motion = (XDeviceMotionEvent *) &xevent; + //Get XInput events + while (XPending(XDisplay)!=0) + { + XNextEvent(XDisplay, &xevent); + if (xevent.type==motion_type) + { + XDeviceMotionEvent *motion = (XDeviceMotionEvent *) &xevent; #if (USE_XINPUT_DEBUG) - /* - * print a lot of debug informations of the motion event(s). - */ - fprintf(stderr, - "XDeviceMotionEvent:\n" - " type: %d\n" - " serial: %lu\n" - " send_event: %d\n" - " display: %p\n" - " window: --\n" - " deviceid: %lu\n" - " root: --\n" - " subwindow: --\n" - " time: --\n" - " x: %d, y: %d\n" - " x_root: %d, y_root: %d\n" - " state: %u\n" - " is_hint: %2.2X\n" - " same_screen: %d\n" - " device_state: %u\n" - " axes_count: %2.2X\n" - " first_axis: %2.2X\n" - " axis_data[6]: {%d,%d,%d,%d,%d,%d}\n", - motion->type, - motion->serial, - motion->send_event, - motion->display, - /* motion->window, */ - motion->deviceid, - /* motion->root */ - /* motion->subwindow */ - /* motion->time, */ - motion->x, motion->y, - motion->x_root, motion->y_root, - motion->state, - motion->is_hint, - motion->same_screen, - motion->device_state, - motion->axes_count, - motion->first_axis, - motion->axis_data[0], motion->axis_data[1], motion->axis_data[2], motion->axis_data[3], motion->axis_data[4], motion->axis_data[5] - ); + /* + * print a lot of debug informations of the motion event(s). + */ + fprintf(stderr, + "XDeviceMotionEvent:\n" + " type: %d\n" + " serial: %lu\n" + " send_event: %d\n" + " display: %p\n" + " window: --\n" + " deviceid: %lu\n" + " root: --\n" + " subwindow: --\n" + " time: --\n" + " x: %d, y: %d\n" + " x_root: %d, y_root: %d\n" + " state: %u\n" + " is_hint: %2.2X\n" + " same_screen: %d\n" + " device_state: %u\n" + " axes_count: %2.2X\n" + " first_axis: %2.2X\n" + " axis_data[6]: {%d,%d,%d,%d,%d,%d}\n", + motion->type, + motion->serial, + motion->send_event, + motion->display, + /* motion->window, */ + motion->deviceid, + /* motion->root */ + /* motion->subwindow */ + /* motion->time, */ + motion->x, motion->y, + motion->x_root, motion->y_root, + motion->state, + motion->is_hint, + motion->same_screen, + motion->device_state, + motion->axes_count, + motion->first_axis, + motion->axis_data[0], motion->axis_data[1], motion->axis_data[2], motion->axis_data[3], motion->axis_data[4], motion->axis_data[5] + ); #endif - devinfo=get_lightgun_info_for_deviceid(motion->deviceid); - - /* - * We have to check with axis will start on array index 0. - * We have also to check the number of axes that are stored in the array. - */ - switch (motion->first_axis) - { - /* - * Starting with x, check number of axis, if there is also the y axis stored. - */ - case 0: - if (motion->axes_count >= 1) - { - devinfo->lightgun.lX=normalize_absolute_axis(motion->axis_data[0], devinfo->lightgun.minx, devinfo->lightgun.maxx); - if (motion->axes_count >= 2) - { - devinfo->lightgun.lY=normalize_absolute_axis(motion->axis_data[1], devinfo->lightgun.miny, devinfo->lightgun.maxy); - } - } - break; - - /* - * Starting with y, ... - */ - case 1: - if (motion->axes_count >= 1) - { - devinfo->lightgun.lY=normalize_absolute_axis(motion->axis_data[0], devinfo->lightgun.miny, devinfo->lightgun.maxy); - } - break; - } - } - else if (xevent.type==button_press_type || xevent.type==button_release_type) - { - XDeviceButtonEvent *button = (XDeviceButtonEvent *) &xevent; - devinfo=get_lightgun_info_for_deviceid(button->deviceid); - devinfo->lightgun.buttons[button->button]=(xevent.type==button_press_type)?0x80:0; - } - } + devinfo=get_lightgun_info_for_deviceid(motion->deviceid); + + /* + * We have to check with axis will start on array index 0. + * We have also to check the number of axes that are stored in the array. + */ + switch (motion->first_axis) + { + /* + * Starting with x, check number of axis, if there is also the y axis stored. + */ + case 0: + if (motion->axes_count >= 1) + { + devinfo->lightgun.lX=normalize_absolute_axis(motion->axis_data[0], devinfo->lightgun.minx, devinfo->lightgun.maxx); + if (motion->axes_count >= 2) + { + devinfo->lightgun.lY=normalize_absolute_axis(motion->axis_data[1], devinfo->lightgun.miny, devinfo->lightgun.maxy); + } + } + break; + + /* + * Starting with y, ... + */ + case 1: + if (motion->axes_count >= 1) + { + devinfo->lightgun.lY=normalize_absolute_axis(motion->axis_data[0], devinfo->lightgun.miny, devinfo->lightgun.maxy); + } + break; + } + } + else if (xevent.type==button_press_type || xevent.type==button_release_type) + { + XDeviceButtonEvent *button = (XDeviceButtonEvent *) &xevent; + devinfo=get_lightgun_info_for_deviceid(button->deviceid); + devinfo->lightgun.buttons[button->button]=(xevent.type==button_press_type)?0x80:0; + } + } #endif if (SDLMAME_EVENTS_IN_WORKER_THREAD) @@ -1731,7 +1731,7 @@ void sdlinput_poll(running_machine &machine) } if (event.type == SDL_KEYUP && - event.key.keysym.sym == SDLK_CAPSLOCK) + event.key.keysym.sym == SDLK_CAPSLOCK) { /* more caps-lock hack */ event.type = SDL_KEYDOWN; |