]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Dual lightgun support, improved lightpen emulation.
authorToni Wilen <twilen@winuae.net>
Sat, 1 Apr 2017 17:10:57 +0000 (20:10 +0300)
committerToni Wilen <twilen@winuae.net>
Sat, 1 Apr 2017 17:10:57 +0000 (20:10 +0300)
cfgfile.cpp
custom.cpp
drawing.cpp
include/custom.h
include/inputdevice.h
include/options.h
inputdevice.cpp
inputevents.def

index 6739153e54588cc22df50f435579208a329a323e..52f5baa47d936ca72ba7c2786d0c7ff809992bc1 100644 (file)
@@ -737,6 +737,10 @@ end:
        xfree (tmp2);
        xfree (tmp1);
 }
+static void cfgfile_dwrite_coords(struct zfile *f, const TCHAR *option, int x, int y)
+{
+       cfgfile_dwrite(f, option, _T("%d,%d"), x, y);
+}
 static void cfg_dowrite (struct zfile *f, const TCHAR *option, const TCHAR *value, int d, int target)
 {
        cfg_dowrite (f, option, NULL, value, d, target);
@@ -1923,6 +1927,7 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
        cfgfile_dwrite(f, _T("genlock_mix"), _T("%d"), p->genlock_mix);
        cfgfile_dwrite(f, _T("genlock_scale"), _T("%d"), p->genlock_scale);
        cfgfile_dwrite_str(f, _T("monitoremu"), specialmonitors[p->monitoremu]);
+       cfgfile_dwrite_coords(f, _T("lightpen_offset"), p->lightpen_offset[0], p->lightpen_offset[1]);
        cfgfile_dwrite_bool(f, _T("lightpen_crosshair"), p->lightpen_crosshair);
 
        cfgfile_dwrite_bool (f, _T("show_leds"), !!(p->leds_on_screen & STATUSLINE_CHIPSET));
@@ -2267,6 +2272,21 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
        write_inputdevice_config (p, f);
 }
 
+static int cfgfile_coords(const TCHAR *option, const TCHAR *value, const TCHAR *name, int *x, int *y)
+{
+       if (name != NULL && _tcscmp (option, name) != 0)
+               return 0;
+       TCHAR tmp[MAX_DPATH];
+       _tcscpy(tmp, value);
+       TCHAR *p = _tcschr(tmp, ',');
+       if (!p)
+               return 0;
+       *p++ = 0;
+       *x = _tstol(tmp);
+       *y = _tstol(p);
+       return 1;
+}
+
 static int cfgfile_yesno (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, bool numbercheck)
 {
        if (name != NULL && _tcscmp (option, name) != 0)
@@ -4799,6 +4819,7 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, const TCHAR *option, TCH
                || cfgfile_yesno(option, value, _T("gfxcard_hardware_sprite"), &p->rtg_hardwaresprite)
                || cfgfile_yesno(option, value, _T("synchronize_clock"), &p->tod_hack)
                || cfgfile_yesno(option, value, _T("keyboard_connected"), &p->keyboard_connected)
+               || cfgfile_coords(option, value, _T("lightpen_offset"), &p->lightpen_offset[0], &p->lightpen_offset[1])
                || cfgfile_yesno(option, value, _T("lightpen_crosshair"), &p->lightpen_crosshair)
 
                || cfgfile_yesno (option, value, _T("kickshifter"), &p->kickshifter)
index 30e726fccebda8f10e3f20aefa462237ac46871c..84b379a8d4fdaf72a141332704ec155fb78fb025 100644 (file)
@@ -159,7 +159,7 @@ static int lof_togglecnt_lace, lof_togglecnt_nlace; //, nlace_cnt;
 static int vpos_previous, hpos_previous;
 static int vpos_lpen, hpos_lpen, lightpen_triggered;
 int lightpen_x[2], lightpen_y[2];
-int lightpen_cx, lightpen_cy, lightpen_active, lightpen_enabled;
+int lightpen_cx[2], lightpen_cy[2], lightpen_active, lightpen_enabled, lightpen_enabled2;
 
 static uae_u32 sprtaba[256],sprtabb[256];
 static uae_u32 sprite_ab_merge[256];
@@ -4620,7 +4620,7 @@ STATIC_INLINE int islightpentriggered (void)
 {
        if (beamcon0 & 0x2000) // LPENDIS
                return 0;
-       return lightpen_triggered > 0;
+       return lightpen_triggered != 0;
 }
 STATIC_INLINE int issyncstopped (void)
 {
@@ -5462,8 +5462,20 @@ static void BPLCON0 (int hpos, uae_u16 v)
                hpos_previous = hpos;
        }
 
-       if (bplcon0 & 4)
+       if (v & 4) {
                bplcon0_interlace_seen = true;
+       }
+
+       if ((v & 8) && !lightpen_triggered && vpos < sprite_vblank_endline) {
+               // setting lightpen bit immediately freezes VPOSR if inside vblank and not already frozen
+               lightpen_triggered = 1;
+               vpos_lpen = vpos;
+               hpos_lpen = hpos;
+       } 
+       if (!(v & 8)) {
+               // clearing lightpen bit immediately returns VPOSR back to normal
+               lightpen_triggered = 0;
+       }
        
        bplcon0 = v;
 
@@ -8078,6 +8090,13 @@ static void events_dmal_hsync (void)
        events_dmal (7);
 }
 
+static void lightpen_trigger_func(uae_u32 v)
+{
+       vpos_lpen = vpos;
+       hpos_lpen = v;
+       lightpen_triggered = 1;
+}
+
 static bool is_custom_vsync (void)
 {
        int vp = vpos + 1;
@@ -8125,15 +8144,27 @@ static void hsync_handler_pre (bool onvsync)
                                do_playfield_collisions ();
                }
                hsync_record_line_state (next_lineno, nextline_how, thisline_changed);
+
                /* reset light pen latch */
                if (vpos == sprite_vblank_endline) {
                        lightpen_triggered = 0;
                        sprite_0 = 0;
                }
-               if (lightpen_enabled && lightpen_cx > 0 && (bplcon0 & 8) && !lightpen_triggered && lightpen_cy == vpos) {
-                       vpos_lpen = vpos;
-                       hpos_lpen = lightpen_cx;
-                       lightpen_triggered = 1;
+
+               if (!lightpen_triggered && vpos >= sprite_vblank_endline && (bplcon0 & 8)) {
+                       // lightpen always triggers at the beginning of the last line
+                       if (vpos + 1 == maxvpos + lof_store) {
+                               vpos_lpen = vpos;
+                               hpos_lpen = 1;
+                               lightpen_triggered = 1;
+                       } else if (lightpen_enabled) {
+                               int lpnum = inputdevice_get_lightpen_id();
+                               if (lpnum < 0)
+                                       lpnum = 0;
+                               if (lightpen_cx[lpnum] > 0 && lightpen_cy[lpnum] == vpos) {
+                                       event2_newevent_xx (-1, lightpen_cx[lpnum] * CYCLE_UNIT, lightpen_cx[lpnum], lightpen_trigger_func);
+                               }
+                       }
                }
                hardware_line_completed (next_lineno);
                if (doflickerfix () && interlace_seen > 0)
@@ -8264,11 +8295,6 @@ static void hsync_handler_post (bool onvsync)
 
        if (onvsync) {
                // vpos_count >= MAXVPOS just to not crash if VPOSW writes prevent vsync completely
-               if ((bplcon0 & 8) && !lightpen_triggered) {
-                       vpos_lpen = vpos - 1;
-                       hpos_lpen = maxhpos;
-                       lightpen_triggered = 1;
-               }
                vpos = 0;
                vsync_handler_post ();
                vpos_count = 0;
@@ -8611,7 +8637,8 @@ void custom_reset (bool hardreset, bool keyboardreset)
 
        lightpen_active = -1;
        lightpen_triggered = 0;
-       lightpen_cx = lightpen_cy = -1;
+       lightpen_cx[0] = lightpen_cy[0] = -1;
+       lightpen_cx[1] = lightpen_cy[1] = -1;
        lightpen_x[0] = -1;
        lightpen_y[0] = -1;
        lightpen_x[1] = -1;
index 734a4aceb58bfb89dbf1c298b2bc277b2a1e3361..7dbb836be736f0f53ef46b99a5c9dde462422006 100644 (file)
@@ -3420,7 +3420,7 @@ static void init_drawing_frame (void)
        drawing_color_matches = -1;
 }
 
-static int lightpen_y1, lightpen_y2;
+static int lightpen_y1[2], lightpen_y2[2];
 static int statusbar_y1, statusbar_y2;
 
 void putpixel(uae_u8 *buf, uae_u8 *genlockbuf, int bpp, int x, xcolnr c8, int opaq)
@@ -3515,23 +3515,19 @@ static const char *lightpen_cursor = {
        "------.....------"
 };
 
-static void draw_lightpen_cursor (int x, int y, int line, int onscreen)
+static void draw_lightpen_cursor (int x, int y, int line, int onscreen, int lpnum)
 {
-       int i;
        const char *p;
-       int color1 = onscreen ? 0xff0 : 0xf00;
+       int color1 = onscreen ? (lpnum ? 0x0ff : 0xff0) : (lpnum ? 0x0f0 : 0xf00);
        int color2 = 0x000;
 
-       if (!currprefs.lightpen_crosshair)
-               return;
-
        xlinebuffer = gfxvidinfo.drawbuffer.linemem;
        if (xlinebuffer == 0)
                xlinebuffer = row_map[line];
        xlinebuffer_genlock = row_map_genlock[line];
 
        p = lightpen_cursor + y * LIGHTPEN_WIDTH;
-       for (i = 0; i < LIGHTPEN_WIDTH; i++) {
+       for (int i = 0; i < LIGHTPEN_WIDTH; i++) {
                int xx = x + i - LIGHTPEN_WIDTH / 2;
                if (*p != '-' && xx >= 0 && xx < gfxvidinfo.drawbuffer.outwidth) {
                        putpixel (xlinebuffer, xlinebuffer_genlock, gfxvidinfo.drawbuffer.pixbytes, xx, *p == 'x' ? xcolors[color1] : xcolors[color2], 1);
@@ -3542,6 +3538,9 @@ static void draw_lightpen_cursor (int x, int y, int line, int onscreen)
 
 static void lightpen_update (struct vidbuffer *vb, int lpnum)
 {
+       if (lightpen_x[lpnum] < 0 || lightpen_y[lpnum] < 0)
+               return;
+
        if (lightpen_x[lpnum] < LIGHTPEN_WIDTH + 1)
                lightpen_x[lpnum] = LIGHTPEN_WIDTH + 1;
        if (lightpen_x[lpnum] >= gfxvidinfo.drawbuffer.inwidth - LIGHTPEN_WIDTH - 1)
@@ -3553,31 +3552,39 @@ static void lightpen_update (struct vidbuffer *vb, int lpnum)
        if (lightpen_y[lpnum] >= max_ypos_thisframe - LIGHTPEN_HEIGHT - 1)
                lightpen_y[lpnum] = max_ypos_thisframe - LIGHTPEN_HEIGHT - 2;
 
-       lightpen_cx = (((lightpen_x[lpnum] + visible_left_border) >> lores_shift) >> 1) + DISPLAY_LEFT_SHIFT - DIW_DDF_OFFSET;
+       int cx = (((lightpen_x[lpnum] + visible_left_border) >> lores_shift) >> 1) + DISPLAY_LEFT_SHIFT - DIW_DDF_OFFSET - 2;
 
-       lightpen_cy = lightpen_y[lpnum];
-       lightpen_cy >>= linedbl;
-       lightpen_cy += minfirstline;
+       int cy = lightpen_y[lpnum];
+       cy >>= linedbl;
+       cy += minfirstline;
 
-       if (lightpen_cx < 0x18)
-               lightpen_cx = 0x18;
-       if (lightpen_cx >= maxhpos)
-               lightpen_cx -= maxhpos;
-       if (lightpen_cy < minfirstline)
-               lightpen_cy = minfirstline;
-       if (lightpen_cy >= maxvpos)
-               lightpen_cy = maxvpos - 1;
+       cx += currprefs.lightpen_offset[0];
+       cy += currprefs.lightpen_offset[1];
+
+       if (cx < 0x18)
+               cx = 0x18;
+       if (cx >= maxhpos)
+               cx -= maxhpos;
+       if (cy < minfirstline)
+               cy = minfirstline;
+       if (cy >= maxvpos)
+               cy = maxvpos - 1;
 
        for (int i = 0; i < LIGHTPEN_HEIGHT; i++) {
                int line = lightpen_y[lpnum] + i - LIGHTPEN_HEIGHT / 2;
                if (line >= 0 || line < max_ypos_thisframe) {
-                       if (lightpen_active > 0)
-                               draw_lightpen_cursor (lightpen_x[lpnum], i, line, lightpen_cx > 0);
-                       flush_line (vb, line);
+                       if (lightpen_active > 0 && currprefs.lightpen_crosshair) {
+                               draw_lightpen_cursor (lightpen_x[lpnum], i, line, cx > 0, lpnum);
+                               flush_line (vb, line);
+                       }
                }
        }
-       lightpen_y1 = lightpen_y[lpnum] - LIGHTPEN_HEIGHT / 2 - 1 + min_ypos_for_screen;
-       lightpen_y2 = lightpen_y1 + LIGHTPEN_HEIGHT + 2;
+
+       lightpen_y1[lpnum] = lightpen_y[lpnum] - LIGHTPEN_HEIGHT / 2 - 1 + min_ypos_for_screen;
+       lightpen_y2[lpnum] = lightpen_y1[lpnum] + LIGHTPEN_HEIGHT + 2;
+
+       lightpen_cx[lpnum] = cx;
+       lightpen_cy[lpnum] = cy;
 
        if (lightpen_active < 0)
                lightpen_active = 0;
@@ -3782,8 +3789,11 @@ static void finish_drawing_frame (void)
                }
        }
 
-       if (lightpen_active)
-               lightpen_update (vb, inputdevice_get_lightpen());
+       if (lightpen_active) {
+               lightpen_update (vb, 0);
+               if (inputdevice_get_lightpen_id() >= 0)
+                       lightpen_update (vb, 1);
+       }
        if (refresh_indicator_buffer)
                refresh_indicator_update(vb);
 
@@ -4001,7 +4011,8 @@ void hsync_record_line_state (int lineno, enum nln_how how, int changed)
 
        state = linestate + lineno;
        changed |= frame_redraw_necessary != 0 || refresh_indicator_buffer != NULL ||
-               ((lineno >= lightpen_y1 && lineno < lightpen_y2) ||
+               ((lineno >= lightpen_y1[0] && lineno < lightpen_y2[0]) ||
+               (lineno >= lightpen_y1[1] && lineno < lightpen_y2[1]) ||
                (lineno >= statusbar_y1 && lineno < statusbar_y2));
 
        switch (how) {
@@ -4180,7 +4191,8 @@ void reset_drawing (void)
 
        notice_screen_contents_lost ();
        frame_res_cnt = currprefs.gfx_autoresolution_delay;
-       lightpen_y1 = lightpen_y2 = -1;
+       lightpen_y1[0] = lightpen_y2[0] = -1;
+       lightpen_y1[1] = lightpen_y2[1] = -1;
 
        reset_custom_limits ();
 
index 5b64ed280b9baca9fbaba20879f05e3c619c1b4c..98c377f03441796f30dc38bdf87205eaa68460d7 100644 (file)
@@ -225,7 +225,7 @@ STATIC_INLINE int GET_PLANES(uae_u16 bplcon0)
 extern void fpscounter_reset (void);
 extern unsigned long idletime;
 extern int lightpen_x[2], lightpen_y[2];
-extern int lightpen_cx, lightpen_cy, lightpen_active, lightpen_enabled;
+extern int lightpen_cx[2], lightpen_cy[2], lightpen_active, lightpen_enabled, lightpen_enabled2;
 
 struct customhack {
        uae_u16 v;
index 95c826d761ce861ebb5a31f4393985bc7e50d036..80c5e0f2971b6ce5b7c57407c830d3c8549c9ab8 100644 (file)
@@ -32,6 +32,8 @@
 #define JOYBUTTON_CD32_RED 8
 #define JOYBUTTON_CD32_BLUE 9
 
+#define JOYBUTTON_LIGHTPEN2 10
+
 #define IDTYPE_JOYSTICK 0
 #define IDTYPE_MOUSE 1
 #define IDTYPE_KEYBOARD 2
@@ -318,7 +320,7 @@ extern void inputdevice_tablet (int x, int y, int z,
 extern void inputdevice_tablet_info (int maxx, int maxy, int maxz, int maxax, int maxay, int maxaz, int xres, int yres);
 extern void inputdevice_tablet_strobe (void);
 extern void tablet_lightpen(int x, int y, int maxx, int maxy, int touch, int buttonmask, bool touchmode, int devid, int lpnum);
-extern int inputdevice_get_lightpen(void);
+extern int inputdevice_get_lightpen_id(void);
 
 extern uae_u64 input_getqualifiers (void);
 
index b249620dd61f6a0cbfee25ee71cc86a3abe4fa7a..b6051a3ac404588f156f542966f4626d2895bbcd 100644 (file)
@@ -504,6 +504,7 @@ struct uae_prefs {
        int lightboost_strobo_ratio;
        bool gfx_grayscale;
        bool lightpen_crosshair;
+       int lightpen_offset[2];
 
        struct gfx_filterdata gf[2];
 
index cd14b88ddfc021245c40cebbd8fcde066aa25750..f75a9104c100b5caecfdf34f516dbcc8fd4ea259 100644 (file)
@@ -327,6 +327,7 @@ static uae_s16 mouse_delta[MAX_JPORTS][MOUSE_AXIS_TOTAL];
 static uae_s16 mouse_deltanoreset[MAX_JPORTS][MOUSE_AXIS_TOTAL];
 static uae_s16 lightpen_delta[2][2];
 static uae_s16 lightpen_deltanoreset[2][2];
+static int lightpen_trigger2;
 static int joybutton[MAX_JPORTS];
 static int joydir[MAX_JPORTS];
 static int joydirpot[MAX_JPORTS][2];
@@ -346,6 +347,7 @@ static uae_u8 pot_dat[NORMAL_JPORTS][2];
 static int pot_dat_act[NORMAL_JPORTS][2];
 static int analog_port[NORMAL_JPORTS][2];
 static int digital_port[NORMAL_JPORTS][2];
+static int lightpen_port[NORMAL_JPORTS];
 #define POTDAT_DELAY_PAL 8
 #define POTDAT_DELAY_NTSC 7
 
@@ -2263,11 +2265,15 @@ void inputdevice_tablet_strobe (void)
                put_byte_host(mousehack_address + MH_CNT, get_byte_host(mousehack_address + MH_CNT) + 1);
 }
 
-int inputdevice_get_lightpen(void)
+int inputdevice_get_lightpen_id(void)
 {
-       if (!alg_flag)
-               return 0;
-       return alg_get_player(potgo_value);
+       if (!alg_flag) {
+               if (lightpen_enabled2) 
+                       return alg_get_player(potgo_value);
+               return -1;
+       } else {
+               return alg_get_player(potgo_value);
+       }
 }
 
 void tablet_lightpen(int tx, int ty, int tmaxx, int tmaxy, int touch, int buttonmask, bool touchmode, int devid, int lpnum)
@@ -3244,6 +3250,11 @@ static bool is_mouse_pullup (int joy)
        return mouse_pullup;
 }
 
+static int lightpen_port_number(void)
+{
+       return currprefs.cs_dipagnus ? 0 : 1;
+}
+
 static void charge_cap (int joy, int idx, int charge)
 {
        if (charge < -1 || charge > 1)
@@ -3278,6 +3289,10 @@ static void cap_check (void)
                                        continue;
                        }
 
+                       // two lightpens use multiplexer chip
+                       if (lightpen_enabled2 && lightpen_port_number() == joy)
+                               continue;
+
                        dong = dongle_analogjoy (joy, i);
                        if (dong >= 0) {
                                isbutton = 0;
@@ -3334,17 +3349,23 @@ static void cap_check (void)
                        if (cd32_pad_enabled[joy] && i == 1 && charge == 0)
                                charge = 2;
                
-                       /* official Commodore mouse has pull-up resistors in button lines
-                       * NOTE: 3rd party mice may not have pullups! */
-                       if (dong < 0 && (is_mouse_pullup (joy) && mouse_port[joy] && digital_port[joy][i]) && charge == 0)
-                               charge = 2;
+                       if (dong < 0 && charge == 0) {
 
-                       /* emulate pullup resistor if button mapped because there too many broken
-                       * programs that read second button in input-mode (and most 2+ button pads have
-                       * pullups)
-                       */
-                       if (dong < 0 && (is_joystick_pullup (joy) && digital_port[joy][i]) && charge == 0)
-                               charge = 2;
+                               if (lightpen_port[joy])
+                                       charge = 2;
+
+                               /* official Commodore mouse has pull-up resistors in button lines
+                               * NOTE: 3rd party mice may not have pullups! */
+                               if (is_mouse_pullup (joy) && mouse_port[joy] && digital_port[joy][i])
+                                       charge = 2;
+
+                               /* emulate pullup resistor if button mapped because there too many broken
+                               * programs that read second button in input-mode (and most 2+ button pads have
+                               * pullups)
+                               */
+                               if (is_joystick_pullup (joy) && digital_port[joy][i])
+                                       charge = 2;
+                       }
 
                        charge_cap (joy, i, charge);
                }
@@ -3453,6 +3474,19 @@ static uae_u16 handle_joystick_potgor (uae_u16 potgor)
 
                        potgor = alg_potgor(potgo_value);
 
+               } else if (lightpen_enabled2 && lightpen_port_number() == i) {
+
+                       int button;
+
+                       if (inputdevice_get_lightpen_id() == 1)
+                               button = lightpen_trigger2;
+                       else
+                               button = getbuttonstate(i, JOYBUTTON_3);
+
+                       potgor |= 0x1000;
+                       if (button)
+                               potgor &= ~0x1000;
+
                } else {
 
                        potgor &= ~p5dat;
@@ -4494,14 +4528,15 @@ static int handle_input_event2 (int nr, int state, int max, int flags, int extra
        switch (ie->unit)
        {
        case 5: /* lightpen/gun */
+       case 6: /* lightpen/gun #2 */
                {
                        int unit = (ie->data & 1) ? 1 : 0;
-                       int lpnum = (ie->data & 2) ? 1 : 0;
-                       if (!lightpen_active) {
-                               for (int i = 0; i < 2; i++) {
-                                       lightpen_x[i] = gfxvidinfo.outbuffer->outwidth / 2;
-                                       lightpen_y[i] = gfxvidinfo.outbuffer->outheight / 2;
-                               }
+                       int lpnum = ie->unit - 5;
+                       if (lightpen_active <= 0) {
+                               lightpen_x[0] = gfxvidinfo.outbuffer->outwidth / 2;
+                               lightpen_y[0] = gfxvidinfo.outbuffer->outheight / 2;
+                               lightpen_x[1] = -1;
+                               lightpen_y[1] = -1;
                        }
                        lightpen_active = true;
                        lightpen_enabled = true;
@@ -4542,16 +4577,20 @@ static int handle_input_event2 (int nr, int state, int max, int flags, int extra
                                        lightpen_delta[lpnum][unit] = delta;
                                else
                                        lightpen_delta[lpnum][unit] += delta;
+                       } else if (ie->type == 2) {
+                               lightpen_trigger2 = state;
                        } else {
-                               int delta = currprefs.input_joymouse_speed;
-                               if (ie->data & DIR_LEFT)
-                                       lightpen_x[lpnum] -= delta;
-                               if (ie->data & DIR_RIGHT)
-                                       lightpen_x[lpnum] += delta;
-                               if (ie->data & DIR_UP)
-                                       lightpen_y[lpnum] -= delta;
-                               if (ie->data & DIR_DOWN)
-                                       lightpen_y[lpnum] += delta;
+                               if (state) {
+                                       int delta = currprefs.input_joymouse_speed;
+                                       if (ie->data & DIR_LEFT)
+                                               lightpen_x[lpnum] -= delta;
+                                       if (ie->data & DIR_RIGHT)
+                                               lightpen_x[lpnum] += delta;
+                                       if (ie->data & DIR_UP)
+                                               lightpen_y[lpnum] -= delta;
+                                       if (ie->data & DIR_DOWN)
+                                               lightpen_y[lpnum] += delta;
+                               }
                        }
                }
                break;
@@ -4946,6 +4985,7 @@ void inputdevice_reset (void)
                lastmxy_abs[i][0] = 0;
                lastmxy_abs[i][1] = 0;
        }
+       lightpen_trigger2 = 0;
 }
 
 static int getoldport (struct uae_input_device *id)
@@ -5661,8 +5701,12 @@ static int isdigitalbutton (int ei)
 
 static int islightpen (int ei)
 {
+       if (ei >= INPUTEVENT_LIGHTPEN_HORIZ2 && ei < INPUTEVENT_LIGHTPEN_DOWN2) {
+               lightpen_enabled2 = true;
+       }
        if (ei >= INPUTEVENT_LIGHTPEN_FIRST && ei < INPUTEVENT_LIGHTPEN_LAST) {
                lightpen_enabled = true;
+               lightpen_port[lightpen_port_number()] = 1;
                return 1;
        }
        return 0;
@@ -5702,6 +5746,7 @@ static void scanevents (struct uae_prefs *p)
                }
        }
        lightpen_enabled = false;
+       lightpen_enabled2 = false;
        if (lightpen_active > 0)
                lightpen_active = -1;
 
index ad427ea3770c5d4fa563d12c7d238e219ea49eb8..fd007769c29ab7fa8dc00152ed2745cfeb9222e1 100644 (file)
@@ -102,6 +102,13 @@ DEFEVENT(LIGHTPEN_LEFT,_T("Lightpen Left"),AM_K,1,5,DIR_LEFT)
 DEFEVENT(LIGHTPEN_RIGHT,_T("Lightpen Right"),AM_K,1,5,DIR_RIGHT)
 DEFEVENT(LIGHTPEN_UP,_T("Lightpen Up"),AM_K,1,5,DIR_UP)
 DEFEVENT(LIGHTPEN_DOWN,_T("Lightpen Down"),AM_K,1,5,DIR_DOWN)
+DEFEVENT(LIGHTPEN_HORIZ2,_T("Dual Lightpen Horizontal #2"),AM_MOUSE_AXIS|AM_JOY_AXIS,0,6,0)
+DEFEVENT(LIGHTPEN_VERT2,_T("Dual Lightpen Vertical #2"),AM_MOUSE_AXIS|AM_JOY_AXIS,0,6,1)
+DEFEVENT(LIGHTPEN_LEFT2,_T("Dual Lightpen Left #2"),AM_K,1,6,DIR_LEFT)
+DEFEVENT(LIGHTPEN_RIGHT2,_T("Dual Lightpen Right #2"),AM_K,1,6,DIR_RIGHT)
+DEFEVENT(LIGHTPEN_UP2,_T("Dual Lightpen Up #2"),AM_K,1,6,DIR_UP)
+DEFEVENT(LIGHTPEN_DOWN2,_T("Dual Lightpen Down #2"),AM_K,1,6,DIR_DOWN)
+DEFEVENT(LIGHTPEN_TRIGGER2,_T("Dual Lightpen Trigger"),AM_K,2,6,JOYBUTTON_LIGHTPEN2)
 
 DEFEVENT(LIGHTPEN_LAST, _T(""), AM_DUMMY, 0,0,0)
 
@@ -415,8 +422,6 @@ DEFEVENT(SPC_ALG_LTRIGGER,_T("American Laser Games Left Trigger"),AM_K,0,0,AKS_A
 DEFEVENT(SPC_ALG_RTRIGGER,_T("American Laser Games Right Trigger"),AM_K,0,0,AKS_ALGRTRIGGER)
 DEFEVENT(SPC_ALG_LHOLSTER,_T("American Laser Games Left Holster"),AM_K,0,0,AKS_ALGLHOLSTER)
 DEFEVENT(SPC_ALG_RHOLSTER,_T("American Laser Games Right Holster"),AM_K,0,0,AKS_ALGRHOLSTER)
-DEFEVENT(SPC_ALG_LIGHTPEN_HORIZ2,_T("American Laser Games Lightpen Horizontal #2"),AM_MOUSE_AXIS|AM_JOY_AXIS,0,5,2)
-DEFEVENT(SPC_ALG_LIGHTPEN_VERT2,_T("American Laser Games Lightpen Vertical #2"),AM_MOUSE_AXIS|AM_JOY_AXIS,0,5,3)
 
 DEFEVENT(SPC_CDTV_FRONT_PANEL_STOP,_T("CDTV Front Panel Stop"),AM_K,0,0,AKS_CDTV_FRONT_PANEL_STOP)
 DEFEVENT(SPC_CDTV_FRONT_PANEL_PLAYPAUSE,_T("CDTV Front Panel Play/Pause"),AM_K,0,0,AKS_CDTV_FRONT_PANEL_PLAYPAUSE)