~ubuntu-branches/ubuntu/quantal/vice/quantal

« back to all changes in this revision

Viewing changes to src/arch/win32/uijoystick.c

  • Committer: Bazaar Package Importer
  • Author(s): Zed Pobre
  • Date: 2006-07-30 19:15:59 UTC
  • mto: (9.1.1 lenny) (1.1.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20060730191559-g31ymd2mk102kzff
Tags: upstream-1.19
ImportĀ upstreamĀ versionĀ 1.19

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <windows.h>
28
28
#include <tchar.h>
29
29
 
 
30
#include "joy.h"
30
31
#include "res.h"
31
32
#include "resources.h"
32
 
#include "joy.h"
 
33
#include "translate.h"
33
34
#include "winmain.h"
 
35
#include "intl.h"
34
36
 
35
37
/*  These are in joystick.c . */
36
38
extern void joystick_calibrate(HWND hwnd);
47
49
 
48
50
static int keyset[9];
49
51
 
50
 
static TCHAR *keydefine_texts[] = {
51
 
    TEXT("Press key for NorthWest"),
52
 
    TEXT("Press key for North"),
53
 
    TEXT("Press key for NorthEast"),
54
 
    TEXT("Press key for East"),
55
 
    TEXT("Press key for SouthEast"),
56
 
    TEXT("Press key for South"),
57
 
    TEXT("Press key for SouthWest"),
58
 
    TEXT("Press key for West"),
59
 
    TEXT("Press key for Fire")
 
52
static int keydefine_texts[] = {
 
53
    IDS_PRESS_KEY_NORTHWEST,
 
54
    IDS_PRESS_KEY_NORTH,
 
55
    IDS_PRESS_KEY_NORTHEAST,
 
56
    IDS_PRESS_KEY_EAST,
 
57
    IDS_PRESS_KEY_SOUTHEAST,
 
58
    IDS_PRESS_KEY_SOUTH,
 
59
    IDS_PRESS_KEY_SOUTHWEST,
 
60
    IDS_PRESS_KEY_WEST,
 
61
    IDS_PRESS_KEY_FIRE
60
62
};
61
63
 
62
64
static long CALLBACK real_callback(HWND hwnd, UINT msg, WPARAM wparam,
93
95
{
94
96
    switch (msg) {
95
97
      case WM_INITDIALOG:
96
 
        SetWindowText(hwnd, keydefine_texts[current_key_index]);
 
98
        SetWindowText(hwnd, translate_text(keydefine_texts[current_key_index]));
97
99
        SetWindowLong(hwnd, GWL_WNDPROC, (LONG)real_callback);
98
100
        return FALSE;
99
101
    }
113
115
        resources_get_value("KeySet1SouthWest", (void *)&keyset[KEYSET_SW]);
114
116
        resources_get_value("KeySet1West", (void *)&keyset[KEYSET_W]);
115
117
        resources_get_value("KeySet1Fire", (void *)&keyset[KEYSET_FIRE]);
116
 
        SetWindowText(hwnd, TEXT("Configure Keyset A"));
 
118
        SetWindowText(hwnd, translate_text(IDS_CONFIGURE_KEYSET_A));
117
119
    } else {
118
120
        resources_get_value("KeySet2NorthWest", (void *)&keyset[KEYSET_NW]);
119
121
        resources_get_value("KeySet2North", (void *)&keyset[KEYSET_N]);
124
126
        resources_get_value("KeySet2SouthWest", (void *)&keyset[KEYSET_SW]);
125
127
        resources_get_value("KeySet2West", (void *)&keyset[KEYSET_W]);
126
128
        resources_get_value("KeySet2Fire", (void *)&keyset[KEYSET_FIRE]);
127
 
        SetWindowText(hwnd, TEXT("Configure Keyset B"));
 
129
        SetWindowText(hwnd, translate_text(IDS_CONFIGURE_KEYSET_B));
128
130
    }
129
131
    SetDlgItemText(hwnd, IDC_KEY_NW,
130
132
                   kbd_code_to_string((kbd_code_t)keyset[KEYSET_NW]));
282
284
    int device;
283
285
 
284
286
    joy_hwnd = GetDlgItem(hwnd, IDC_JOY_DEV1);
285
 
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)"None");
286
 
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)"Numpad + RCtrl");
287
 
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)"Keyset A");
288
 
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)"Keyset B");
 
287
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)intl_translate_text_new(IDS_NONE));
 
288
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)translate_text(IDS_NUMPAD_AND_RCTRL));
 
289
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)translate_text(IDS_KEYSET_A));
 
290
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)translate_text(IDS_KEYSET_B));
289
291
    joystick_ui_get_device_list(joy_hwnd);
290
292
    resources_get_value("JoyDevice1", (void *)&res_value);
291
293
    SendMessage(joy_hwnd, CB_SETCURSEL, (WPARAM)res_value,0);
292
294
    joy1 = device = res_value;
293
295
 
294
296
    joy_hwnd = GetDlgItem(hwnd, IDC_JOY_FIRE1_BUTTON);
295
 
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)"All buttons used as fire");
 
297
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)translate_text(IDS_ALL_BUTTONS_AS_FIRE));
296
298
    joystick_ui_get_autofire_buttons(joy_hwnd, device);
297
299
    resources_get_value("JoyFire1Button", (void *)&res_value);
298
300
    SendMessage(joy_hwnd, CB_SETCURSEL, (WPARAM)res_value, 0);
300
302
    resources_get_value("JoyAutofire1Speed", (void *)&res_value);
301
303
    SetDlgItemInt(hwnd, IDC_JOY_FIRE1_SPEED, res_value, FALSE);
302
304
    joy_hwnd = GetDlgItem(hwnd, IDC_JOY_FIRE1_AXIS);
303
 
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)"numeric (see above)");
 
305
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)translate_text(IDS_NUMERIC_SEE_ABOVE));
304
306
    joystick_ui_get_autofire_axes(joy_hwnd, device);
305
307
    resources_get_value("JoyAutofire1Axis", (void *)&res_value);
306
308
    SendMessage(joy_hwnd, CB_SETCURSEL, (WPARAM)res_value, 0);
307
309
    joy_hwnd = GetDlgItem(hwnd, IDC_JOY_AUTOFIRE1_BUTTON);
308
 
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)"No button - Autofire disabled");
 
310
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)translate_text(IDS_NO_BUTTON_NO_AUTOFIRE));
309
311
    joystick_ui_get_autofire_buttons(joy_hwnd, device);
310
312
    resources_get_value("JoyAutofire1Button", (void *)&res_value);
311
313
    SendMessage(joy_hwnd, CB_SETCURSEL, (WPARAM)res_value, 0);
319
321
                            (device >= JOYDEV_HW1));
320
322
 
321
323
    joy_hwnd = GetDlgItem(hwnd,IDC_JOY_DEV2);
322
 
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)"None");
323
 
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)"Numpad + RCtrl");
324
 
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)"Keyset A");
325
 
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)"Keyset B");
 
324
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)intl_translate_text_new(IDS_NONE));
 
325
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)translate_text(IDS_NUMPAD_AND_RCTRL));
 
326
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)translate_text(IDS_KEYSET_A));
 
327
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)translate_text(IDS_KEYSET_B));
326
328
    joystick_ui_get_device_list(joy_hwnd);
327
329
    resources_get_value("JoyDevice2", (void *)&res_value);
328
330
    SendMessage(joy_hwnd, CB_SETCURSEL, (WPARAM)res_value,0);
329
331
    joy2 = device = res_value;
330
332
 
331
333
    joy_hwnd = GetDlgItem(hwnd, IDC_JOY_FIRE2_BUTTON);
332
 
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)"All buttons used as fire");
 
334
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)translate_text(IDS_ALL_BUTTONS_AS_FIRE));
333
335
    joystick_ui_get_autofire_buttons(joy_hwnd, device);
334
336
    resources_get_value("JoyFire2Button", (void *)&res_value);
335
337
    SendMessage(joy_hwnd, CB_SETCURSEL, (WPARAM)res_value, 0);
337
339
    resources_get_value("JoyAutofire2Speed", (void *)&res_value);
338
340
    SetDlgItemInt(hwnd, IDC_JOY_FIRE2_SPEED, res_value, FALSE);
339
341
    joy_hwnd = GetDlgItem(hwnd, IDC_JOY_FIRE2_AXIS);
340
 
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)"numeric (see above)");
 
342
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)translate_text(IDS_NUMERIC_SEE_ABOVE));
341
343
    joystick_ui_get_autofire_axes(joy_hwnd, device);
342
344
    resources_get_value("JoyAutofire2Axis", (void *)&res_value);
343
345
    SendMessage(joy_hwnd, CB_SETCURSEL, (WPARAM)res_value, 0);
344
346
    joy_hwnd = GetDlgItem(hwnd, IDC_JOY_AUTOFIRE2_BUTTON);
345
 
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)"No button - Autofire disabled");
 
347
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)translate_text(IDS_NO_BUTTON_NO_AUTOFIRE));
346
348
    joystick_ui_get_autofire_buttons(joy_hwnd, device);
347
349
    resources_get_value("JoyAutofire2Button", (void *)&res_value);
348
350
    SendMessage(joy_hwnd, CB_SETCURSEL, (WPARAM)res_value, 0);
365
367
 
366
368
    SendDlgItemMessage(hwnd, IDC_JOY_FIRE1_AXIS, CB_RESETCONTENT, 0, 0);
367
369
    joy_hwnd = GetDlgItem(hwnd, IDC_JOY_FIRE1_AXIS);
368
 
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)"numeric (see above)");
 
370
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)translate_text(IDS_NUMERIC_SEE_ABOVE));
369
371
    joystick_ui_get_autofire_axes(joy_hwnd, device);
370
372
    resources_get_value("JoyAutofire1Axis", (void *)&res_value);
371
373
    SendMessage(joy_hwnd, CB_SETCURSEL, (WPARAM)res_value, 0);
378
380
 
379
381
    SendDlgItemMessage(hwnd, IDC_JOY_FIRE2_AXIS, CB_RESETCONTENT, 0, 0);
380
382
    joy_hwnd = GetDlgItem(hwnd, IDC_JOY_FIRE2_AXIS);
381
 
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)"numeric (see above)");
 
383
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)translate_text(IDS_NUMERIC_SEE_ABOVE));
382
384
    joystick_ui_get_autofire_axes(joy_hwnd, device);
383
385
    resources_get_value("JoyAutofire2Axis", (void *)&res_value);
384
386
    SendMessage(joy_hwnd, CB_SETCURSEL, (WPARAM)res_value, 0);
391
393
 
392
394
    SendDlgItemMessage(hwnd, IDC_JOY_FIRE1_BUTTON, CB_RESETCONTENT, 0, 0);
393
395
    joy_hwnd = GetDlgItem(hwnd, IDC_JOY_FIRE1_BUTTON);
394
 
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)"All buttons used as fire");
 
396
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)translate_text(IDS_ALL_BUTTONS_AS_FIRE));
395
397
    joystick_ui_get_autofire_buttons(joy_hwnd, device);
396
398
    resources_get_value("JoyFire1Button", (void *)&res_value);
397
399
    SendMessage(joy_hwnd, CB_SETCURSEL, (WPARAM)res_value, 0);
398
400
 
399
401
    SendDlgItemMessage(hwnd, IDC_JOY_AUTOFIRE1_BUTTON, CB_RESETCONTENT, 0, 0);
400
402
    joy_hwnd = GetDlgItem(hwnd, IDC_JOY_AUTOFIRE1_BUTTON);
401
 
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)"No button - Autofire disabled");
 
403
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)translate_text(IDS_NO_BUTTON_NO_AUTOFIRE));
402
404
    joystick_ui_get_autofire_buttons(joy_hwnd, device);
403
405
    resources_get_value("JoyAutofire1Button", (void *)&res_value);
404
406
    SendMessage(joy_hwnd, CB_SETCURSEL, (WPARAM)res_value, 0);
411
413
 
412
414
    SendDlgItemMessage(hwnd, IDC_JOY_FIRE2_BUTTON, CB_RESETCONTENT, 0, 0);
413
415
    joy_hwnd = GetDlgItem(hwnd, IDC_JOY_FIRE2_BUTTON);
414
 
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)"All buttons used as fire");
 
416
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)translate_text(IDS_ALL_BUTTONS_AS_FIRE));
415
417
    joystick_ui_get_autofire_buttons(joy_hwnd, device);
416
418
    resources_get_value("JoyFire2Button", (void *)&res_value);
417
419
    SendMessage(joy_hwnd, CB_SETCURSEL, (WPARAM)res_value, 0);
418
420
 
419
421
    SendDlgItemMessage(hwnd, IDC_JOY_AUTOFIRE2_BUTTON, CB_RESETCONTENT, 0, 0);
420
422
    joy_hwnd = GetDlgItem(hwnd, IDC_JOY_AUTOFIRE2_BUTTON);
421
 
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)"No button - Autofire disabled");
 
423
    SendMessage(joy_hwnd, CB_ADDSTRING, 0, (LPARAM)translate_text(IDS_NO_BUTTON_NO_AUTOFIRE));
422
424
    joystick_ui_get_autofire_buttons(joy_hwnd, device);
423
425
    resources_get_value("JoyAutofire2Button", (void *)&res_value);
424
426
    SendMessage(joy_hwnd, CB_SETCURSEL, (WPARAM)res_value, 0);
443
445
            return TRUE;
444
446
          case IDC_JOY_CONFIG_A:
445
447
            current_keyset_index = 0;
446
 
            DialogBox(winmain_instance, (LPCTSTR)IDD_CONFIG_KEYSET_DIALOG,
 
448
            DialogBox(winmain_instance, (LPCTSTR)translate_res(IDD_CONFIG_KEYSET_DIALOG),
447
449
                      hwnd, keyset_dialog);
448
450
            return TRUE;
449
451
          case IDC_JOY_CONFIG_B:
450
452
            current_keyset_index = 1;
451
 
            DialogBox(winmain_instance, (LPCTSTR)IDD_CONFIG_KEYSET_DIALOG,
 
453
            DialogBox(winmain_instance, (LPCTSTR)translate_res(IDD_CONFIG_KEYSET_DIALOG),
452
454
                      hwnd, keyset_dialog);
453
455
            return TRUE;
454
456
          case IDC_JOY_DEV1:
579
581
 
580
582
void ui_joystick_settings_dialog(HWND hwnd)
581
583
{
582
 
    DialogBox(winmain_instance, (LPCTSTR)IDD_JOY_SETTINGS_DIALOG,
 
584
    DialogBox(winmain_instance, (LPCTSTR)translate_res(IDD_JOY_SETTINGS_DIALOG),
583
585
              hwnd,dialog_proc);
584
586
}
585
587
 
609
611
    resources_set_value("JoyAutofire1Button",(resource_value_t)device2);
610
612
    resources_set_value("JoyAutofire2Button",(resource_value_t)device1);
611
613
 
 
614
/* swapping the keyset definitions when swapping the joysticks is
 
615
   improper bahaviour in my opinion, if needed a swap keyset can be
 
616
   made later, for now the keyset swapping is commented out. */
 
617
 
 
618
#if 0
612
619
    resources_get_value("KeySet1NorthWest",(void *)&device1);
613
620
    resources_get_value("KeySet2NorthWest",(void *)&device2);
614
621
    resources_set_value("KeySet1NorthWest",(resource_value_t)device2);
645
652
    resources_get_value("KeySet2Fire",(void *)&device2);
646
653
    resources_set_value("KeySet1Fire",(resource_value_t)device2);
647
654
    resources_set_value("KeySet2Fire",(resource_value_t)device1);
 
655
#endif
648
656
}