2 #include "ConfigDiag.h"
4 void ConfigDialog::UpdateBitmaps(wxTimerEvent
& WXUNUSED(event
))
7 GamepadPage
* const current_page
= (GamepadPage
*)m_pad_notebook
->GetPage( m_pad_notebook
->GetSelection() );
9 std::vector
< ControlGroupBox
* >::iterator g
= current_page
->control_groups
.begin(),
10 ge
= current_page
->control_groups
.end();
11 for ( ; g
!= ge
; ++g
)
14 if ( (*g
)->static_bitmap
)
17 // don't want game thread updating input when we are using it here
18 if ( false == m_plugin
.interface_crit
.TryEnter() )
21 //if ( false == is_game_running )
23 m_plugin
.controller_interface
.UpdateInput();
25 switch ( (*g
)->control_group
->type
)
27 case GROUP_TYPE_STICK
:
31 ((ControllerEmu::AnalogStick
*)(*g
)->control_group
)->GetState( &x
, &y
, 32.0, 32-1.5 );
33 xx
= ((ControllerEmu::AnalogStick
*)(*g
)->control_group
)->controls
[3]->control_ref
->State();
34 xx
-= ((ControllerEmu::AnalogStick
*)(*g
)->control_group
)->controls
[2]->control_ref
->State();
35 yy
= ((ControllerEmu::AnalogStick
*)(*g
)->control_group
)->controls
[1]->control_ref
->State();
36 yy
-= ((ControllerEmu::AnalogStick
*)(*g
)->control_group
)->controls
[0]->control_ref
->State();
37 xx
*= 32 - 1; xx
+= 32;
38 yy
*= 32 - 1; yy
+= 32;
41 wxBitmap
bitmap(64, 64);
43 dc
.SelectObject(bitmap
);
48 // circle for visual aid for diagonal adjustment
49 dc
.SetPen(*wxLIGHT_GREY_PEN
);
50 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
51 dc
.DrawCircle( 32, 32, 32);
54 dc
.SetBrush(*wxLIGHT_GREY_BRUSH
);
55 dc
.DrawCircle( 32, 32, ((ControllerEmu::AnalogStick
*)(*g
)->control_group
)->settings
[0]->value
* 32 );
58 dc
.SetPen(*wxGREY_PEN
);
59 dc
.SetBrush(*wxGREY_BRUSH
);
60 // i like the dot better than the cross i think
61 dc
.DrawRectangle( xx
- 2, yy
- 2, 4, 4 );
62 //dc.DrawRectangle( xx-1, 64-yy-4, 2, 8 );
63 //dc.DrawRectangle( xx-4, 64-yy-1, 8, 2 );
68 dc
.SetPen(*wxRED_PEN
);
69 dc
.SetBrush(*wxRED_BRUSH
);
70 dc
.DrawRectangle( x
-2, 64-y
-2, 4, 4 );
71 // i like the dot better than the cross i think
72 //dc.DrawRectangle( x-1, 64-y-4, 2, 8 );
73 //dc.DrawRectangle( x-4, 64-y-1, 8, 2 );
78 dc
.SetPen(wxPen(_T("#7f9db9")));
79 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
80 dc
.DrawRectangle(0, 0, 64, 64);
83 dc
.SelectObject(wxNullBitmap
);
86 (*g
)->static_bitmap
->SetBitmap( bitmap
);
89 case GROUP_TYPE_BUTTONS
:
91 const unsigned int button_count
= ((unsigned int)(*g
)->control_group
->controls
.size());
93 wxBitmap
bitmap(12*button_count
+1, 12);
95 dc
.SelectObject(bitmap
);
99 dc
.SetPen(*wxGREY_PEN
);
101 unsigned int * const bitmasks
= new unsigned int[ button_count
];
102 for ( unsigned int n
= 0; n
<button_count
; ++n
)
103 bitmasks
[n
] = ( 1 << n
);
105 unsigned int buttons
= 0;
106 ((ControllerEmu::Buttons
*)(*g
)->control_group
)->GetState( &buttons
, bitmasks
);
108 for ( unsigned int n
= 0; n
<button_count
; ++n
)
110 // TODO: threshold stuff, actually redo this crap with the GetState func
111 if ( buttons
& bitmasks
[n
] )
112 dc
.SetBrush( *wxRED_BRUSH
);
115 unsigned char amt
= 255 - (*g
)->control_group
->controls
[n
]->control_ref
->State() * 128;
116 dc
.SetBrush( wxBrush( wxColor( amt
, amt
, amt
) ) );
118 dc
.DrawRectangle(n
*12, 0, 14, 12);
125 dc
.SetPen(wxPen(_T("#7f9db9")));
126 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
127 dc
.DrawRectangle(0, 0, bitmap
.GetWidth(), bitmap
.GetHeight());
130 dc
.SelectObject(wxNullBitmap
);
133 (*g
)->static_bitmap
->SetBitmap( bitmap
);
137 case GROUP_TYPE_MIXED_TRIGGERS
:
139 const unsigned int trigger_count
= ((unsigned int)((*g
)->control_group
->controls
.size() / 2));
141 wxBitmap
bitmap( 64+12+1, 12*trigger_count
+1);
143 dc
.SelectObject(bitmap
);
147 dc
.SetPen(*wxGREY_PEN
);
148 ControlState thresh
= (*g
)->control_group
->settings
[0]->value
;
150 for ( unsigned int n
= 0; n
< trigger_count
; ++n
)
152 dc
.SetBrush(*wxRED_BRUSH
);
153 ControlState trig_d
= (*g
)->control_group
->controls
[n
]->control_ref
->State();
155 ControlState trig_a
= trig_d
> thresh
? 1
156 : (*g
)->control_group
->controls
[n
+trigger_count
]->control_ref
->State();
158 dc
.DrawRectangle(0, n
*12, 64+20, 14);
159 if ( trig_d
<= thresh
)
160 dc
.SetBrush(*wxWHITE_BRUSH
);
161 dc
.DrawRectangle(trig_a
*64, n
*12, 64+20, 14);
162 dc
.DrawRectangle(64, n
*12, 32, 14);
164 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
165 dc
.DrawRectangle(thresh
*64, 0, 128, trigger_count
*14);
169 dc
.SetPen(wxPen(_T("#7f9db9")));
170 dc
.DrawRectangle(0, 0, bitmap
.GetWidth(), bitmap
.GetHeight());
173 dc
.SelectObject(wxNullBitmap
);
176 (*g
)->static_bitmap
->SetBitmap( bitmap
);
183 m_plugin
.interface_crit
.Leave();