|
27 | 27 | #include "options.h" |
28 | 28 | #include "keyboard.h" |
29 | 29 | #include "inputdevice.h" |
| 30 | + |
| 31 | +#include <algorithm> |
30 | 32 | #include "inputrecord.h" |
31 | 33 | #include "keybuf.h" |
32 | 34 | #include "custom.h" |
@@ -210,6 +212,42 @@ extern int draco_keyboard_get_rate(void); |
210 | 212 | static int draco_keybord_repeat_cnt, draco_keybord_repeat_code; |
211 | 213 | #endif |
212 | 214 |
|
| 215 | +static void osk_control(int x, int y, int button, int buttonstate) |
| 216 | +{ |
| 217 | + if (vkbd_allowed(0) && vkbd_is_active()) |
| 218 | + { |
| 219 | + int vkbd_state = 0; |
| 220 | + if (button && buttonstate) |
| 221 | + { |
| 222 | + vkbd_state |= VKBD_BUTTON; |
| 223 | + } |
| 224 | + x = std::min(x, 1); |
| 225 | + x = std::max(x, -1); |
| 226 | + y = std::min(y, 1); |
| 227 | + y = std::max(y, -1); |
| 228 | + if (x < 0) { |
| 229 | + vkbd_state |= VKBD_LEFT; |
| 230 | + } |
| 231 | + if (x > 0) { |
| 232 | + vkbd_state |= VKBD_RIGHT; |
| 233 | + } |
| 234 | + if (y < 0) { |
| 235 | + vkbd_state |= VKBD_UP; |
| 236 | + } |
| 237 | + if (y > 0) { |
| 238 | + vkbd_state |= VKBD_DOWN; |
| 239 | + } |
| 240 | + |
| 241 | + int code; |
| 242 | + int pressed; |
| 243 | + if (vkbd_process(vkbd_state, &code, &pressed)) |
| 244 | + { |
| 245 | + inputdevice_do_keyboard(code, pressed); |
| 246 | + } |
| 247 | + vkbd_process(0, &code, &pressed); |
| 248 | + } |
| 249 | +} |
| 250 | + |
213 | 251 | static int isdevice (struct uae_input_device *id) |
214 | 252 | { |
215 | 253 | int i, j; |
@@ -5252,64 +5290,6 @@ static uae_u64 isqual (int evt) |
5252 | 5290 | return ID_FLAG_QUALIFIER1 << (num * 2); |
5253 | 5291 | } |
5254 | 5292 |
|
5255 | | -#ifdef AMIBERRY |
5256 | | -// Pass the joystick state (joybutton and joydir) to vkbd subsystem and clear them for the emulator. |
5257 | | -static void handle_vkbd() |
5258 | | -{ |
5259 | | - if (!vkbd_is_active()) return; |
5260 | | - |
5261 | | - int vkbd_state = 0; |
5262 | | - for (int joy = 0; joy < 2; ++joy) |
5263 | | - { |
5264 | | - oleft[joy] = 0; |
5265 | | - oright[joy] = 0; |
5266 | | - otop[joy] = 0; |
5267 | | - obot[joy] = 0; |
5268 | | - horizclear[joy] = 0; |
5269 | | - vertclear[joy] = 0; |
5270 | | - |
5271 | | - int mask_button; |
5272 | | - if (cd32_pad_enabled[joy]) |
5273 | | - mask_button = 1 << JOYBUTTON_CD32_RED; |
5274 | | - else |
5275 | | - mask_button = 1 << JOYBUTTON_1; |
5276 | | - |
5277 | | - if (joybutton[joy] & mask_button) |
5278 | | - { |
5279 | | - vkbd_state |= VKBD_BUTTON; |
5280 | | - joybutton[joy] &= ~mask_button; |
5281 | | - } |
5282 | | - if (joydir[joy] & DIR_LEFT) |
5283 | | - { |
5284 | | - vkbd_state |= VKBD_LEFT; |
5285 | | - joydir[joy] &= ~DIR_LEFT; |
5286 | | - } |
5287 | | - if (joydir[joy] & DIR_RIGHT) |
5288 | | - { |
5289 | | - vkbd_state |= VKBD_RIGHT; |
5290 | | - joydir[joy] &= ~DIR_RIGHT; |
5291 | | - } |
5292 | | - if (joydir[joy] & DIR_UP) |
5293 | | - { |
5294 | | - vkbd_state |= VKBD_UP; |
5295 | | - joydir[joy] &= ~DIR_UP; |
5296 | | - } |
5297 | | - if (joydir[joy] & DIR_DOWN) |
5298 | | - { |
5299 | | - vkbd_state |= VKBD_DOWN; |
5300 | | - joydir[joy] &= ~DIR_DOWN; |
5301 | | - } |
5302 | | - } |
5303 | | - |
5304 | | - int code; |
5305 | | - int pressed; |
5306 | | - if (vkbd_process(vkbd_state, &code, &pressed)) |
5307 | | - { |
5308 | | - inputdevice_do_keyboard(code, pressed); |
5309 | | - } |
5310 | | -} |
5311 | | -#endif |
5312 | | - |
5313 | 5293 | static int handle_input_event2(int nr, int state, int max, int flags, int extra) |
5314 | 5294 | { |
5315 | 5295 | struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo; |
@@ -5474,21 +5454,26 @@ static int handle_input_event2(int nr, int state, int max, int flags, int extra) |
5474 | 5454 | case 4: /* ->Parallel port joystick adapter port #2 */ |
5475 | 5455 | joy = ie->unit - 1; |
5476 | 5456 | if (ie->type & 4) { |
5477 | | - int old = joybutton[joy] & (1 << ie->data); |
5478 | | - |
5479 | | - if (state) { |
5480 | | - joybutton[joy] |= 1 << ie->data; |
5481 | | - //gui_gameport_button_change (joy, ie->data, 1); |
5482 | | - } else { |
5483 | | - joybutton[joy] &= ~(1 << ie->data); |
5484 | | - //gui_gameport_button_change (joy, ie->data, 0); |
| 5457 | + if (vkbd_allowed(0) && vkbd_is_active()) { |
| 5458 | + osk_control(0, 0, 1 << ie->data, state); |
5485 | 5459 | } |
| 5460 | + else { |
| 5461 | + int old = joybutton[joy] & (1 << ie->data); |
| 5462 | + if (state) { |
| 5463 | + joybutton[joy] |= 1 << ie->data; |
| 5464 | + //gui_gameport_button_change(joy, ie->data, 1); |
| 5465 | + } |
| 5466 | + else { |
| 5467 | + joybutton[joy] &= ~(1 << ie->data); |
| 5468 | + //gui_gameport_button_change(joy, ie->data, 0); |
| 5469 | + } |
5486 | 5470 |
|
5487 | | - if (ie->data == 0 && old != (joybutton[joy] & (1 << ie->data)) && currprefs.cpu_cycle_exact) { |
5488 | | - if (!input_record && !input_play && currprefs.input_contact_bounce) { |
5489 | | - // emulate contact bounce, 1st button only, others have capacitors |
5490 | | - bouncy = 1; |
5491 | | - bouncy_cycles = get_cycles () + CYCLE_UNIT * currprefs.input_contact_bounce; |
| 5471 | + if (ie->data == 0 && old != (joybutton[joy] & (1 << ie->data)) && currprefs.cpu_cycle_exact) { |
| 5472 | + if (!input_record && !input_play && currprefs.input_contact_bounce) { |
| 5473 | + // emulate contact bounce, 1st button only, others have capacitors |
| 5474 | + bouncy = 1; |
| 5475 | + bouncy_cycles = get_cycles() + CYCLE_UNIT * currprefs.input_contact_bounce; |
| 5476 | + } |
5492 | 5477 | } |
5493 | 5478 | } |
5494 | 5479 |
|
@@ -5720,48 +5705,61 @@ static int handle_input_event2(int nr, int state, int max, int flags, int extra) |
5720 | 5705 | } |
5721 | 5706 | mouse_deltanoreset[joy][0] = 1; |
5722 | 5707 | mouse_deltanoreset[joy][1] = 1; |
5723 | | - joydir[joy] = 0; |
5724 | | - if (left) { |
5725 | | - if (!allowoppositestick) { |
5726 | | - joydir[joy] &= ~DIR_RIGHT; |
| 5708 | + if (vkbd_allowed(0) && vkbd_is_active()) { |
| 5709 | + if (left) { |
| 5710 | + osk_control(-1, 0, 0, 0); |
5727 | 5711 | } |
5728 | | - joydir[joy] |= DIR_LEFT; |
5729 | | - } |
5730 | | - if (right) { |
5731 | | - if (!allowoppositestick) { |
5732 | | - joydir[joy] &= ~DIR_LEFT; |
| 5712 | + if (right) { |
| 5713 | + osk_control(1, 0, 0, 0); |
5733 | 5714 | } |
5734 | | - joydir[joy] |= DIR_RIGHT; |
5735 | | - } |
5736 | | - if (top) { |
5737 | | - if (!allowoppositestick) { |
5738 | | - joydir[joy] &= ~DIR_DOWN; |
| 5715 | + if (top) { |
| 5716 | + osk_control(0, -1, 0, 0); |
5739 | 5717 | } |
5740 | | - joydir[joy] |= DIR_UP; |
5741 | | - } |
5742 | | - if (bot) { |
5743 | | - if (!allowoppositestick) { |
5744 | | - joydir[joy] &= ~DIR_UP; |
| 5718 | + if (bot) { |
| 5719 | + osk_control(0, 1, 0, 0); |
5745 | 5720 | } |
5746 | | - joydir[joy] |= DIR_DOWN; |
5747 | 5721 | } |
5748 | | - if (joy == 0 || joy == 1) |
5749 | | - joymousecounter (joy); |
| 5722 | + else { |
| 5723 | + joydir[joy] = 0; |
| 5724 | + if (left) { |
| 5725 | + if (!allowoppositestick) { |
| 5726 | + joydir[joy] &= ~DIR_RIGHT; |
| 5727 | + } |
| 5728 | + joydir[joy] |= DIR_LEFT; |
| 5729 | + } |
| 5730 | + if (right) { |
| 5731 | + if (!allowoppositestick) { |
| 5732 | + joydir[joy] &= ~DIR_LEFT; |
| 5733 | + } |
| 5734 | + joydir[joy] |= DIR_RIGHT; |
| 5735 | + } |
| 5736 | + if (top) { |
| 5737 | + if (!allowoppositestick) { |
| 5738 | + joydir[joy] &= ~DIR_DOWN; |
| 5739 | + } |
| 5740 | + joydir[joy] |= DIR_UP; |
| 5741 | + } |
| 5742 | + if (bot) { |
| 5743 | + if (!allowoppositestick) { |
| 5744 | + joydir[joy] &= ~DIR_UP; |
| 5745 | + } |
| 5746 | + joydir[joy] |= DIR_DOWN; |
| 5747 | + } |
| 5748 | + if (joy == 0 || joy == 1) |
| 5749 | + joymousecounter(joy); |
5750 | 5750 |
|
5751 | | - //gui_gameport_axis_change (joy, DIR_LEFT_BIT, left, 0); |
5752 | | - //gui_gameport_axis_change (joy, DIR_RIGHT_BIT, right, 0); |
5753 | | - //gui_gameport_axis_change (joy, DIR_UP_BIT, top, 0); |
5754 | | - //gui_gameport_axis_change (joy, DIR_DOWN_BIT, bot, 0); |
| 5751 | + //gui_gameport_axis_change(joy, DIR_LEFT_BIT, left, 0); |
| 5752 | + //gui_gameport_axis_change(joy, DIR_RIGHT_BIT, right, 0); |
| 5753 | + //gui_gameport_axis_change(joy, DIR_UP_BIT, top, 0); |
| 5754 | + //gui_gameport_axis_change(joy, DIR_DOWN_BIT, bot, 0); |
| 5755 | + } |
5755 | 5756 | } |
5756 | 5757 | break; |
5757 | 5758 | case 0: /* ->KEY */ |
5758 | 5759 | inputdevice_do_keyboard (ie->data, state); |
5759 | 5760 | break; |
5760 | 5761 | } |
5761 | | -#ifdef AMIBERRY |
5762 | | - if (vkbd_allowed(0) && vkbd_is_active()) |
5763 | | - handle_vkbd(); |
5764 | | -#endif |
| 5762 | + |
5765 | 5763 | return 1; |
5766 | 5764 | } |
5767 | 5765 |
|
|
0 commit comments